{"record":{"id":"27988ce21e4377c5","repo":"sgl-project/sglang","slug":"trace-file-is-empty","errorCode":null,"errorMessage":"Trace file is empty.","messagePattern":"Trace file is empty\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/utils/rpd_utils.py","lineNumber":72,"sourceCode":"                    ',{\"name\":\"thread_name\",\"ph\":\"M\",\"pid\":\"%s\",\"tid\":\"%s\",\"args\":{\"name\":\"%s\"}}\\n'\n                    % (row[0], row[1], \"HSA \" + str(row[1]))\n                )\n                outfile.write(\n                    ',{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"pid\":\"%s\",\"tid\":\"%s\",\"args\":{\"sort_index\":\"%s\"}}\\n'\n                    % (row[0], row[1], row[1] * 2 - 1)\n                )\n            except ValueError:\n                outfile.write(\"\")\n    except:\n        pass\n\n    rangeStringApi = \"\"\n    rangeStringOp = \"\"\n    rangeStringMonitor = \"\"\n    min_time = connection.execute(\"select MIN(start) from rocpd_api;\").fetchall()[0][0]\n    max_time = connection.execute(\"select MAX(end) from rocpd_api;\").fetchall()[0][0]\n    if min_time is None:\n        raise Exception(\"Trace file is empty.\")\n\n    print(\"Timestamps:\")\n    print(f\"\\t    first: \\t{min_time/1000} us\")\n    print(f\"\\t     last: \\t{max_time/1000} us\")\n    print(f\"\\t duration: \\t{(max_time-min_time) / 1000000000} seconds\")\n\n    start_time = min_time / 1000\n    end_time = max_time / 1000\n\n    if start:\n        if \"%\" in start:\n            start_time = (\n                (max_time - min_time) * (int(start.replace(\"%\", \"\")) / 100) + min_time\n            ) / 1000\n        else:\n            start_time = int(start)\n        rangeStringApi = \"where rocpd_api.start/1000 >= %s\" % (start_time)\n        rangeStringOp = \"where rocpd_op.start/1000 >= %s\" % (start_time)","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/utils/rpd_utils.py#L54-L90","documentation":"rpd_to_chrome_trace opens the ROCm RPD profiling database and queries MIN(start) from rocpd_api; a NULL result means the API-event table has no rows, i.e. the captured profile contains no kernel/API activity, so conversion cannot proceed.","triggerScenarios":"Calling rpd_to_chrome_trace on an RPD sqlite file produced by a profiling session that recorded nothing — profiler started and stopped before work ran, wrong pass/iteration range, or capture failed silently.","commonSituations":"Short-lived benchmarks where the profiler window misses all kernels; RPD tool version/config capturing zero API records; converting placeholder DBs.","solutions":["Re-profile with a wider window: ensure GPU work occurs between start and stop","Verify with sqlite3 <file> 'select count(*) from rocpd_api;' that events exist before converting","Check the RPD/ROCprofiler capture configuration actually enabled API/kernel records","Discard empty runs and only convert DBs with nonzero event counts"],"exampleFix":"# before\nrpd_to_chrome_trace('empty.rpd')  # Exception: Trace file is empty.\n# after\nimport sqlite3\nif sqlite3.connect('run.rpd').execute('select count(*) from rocpd_api').fetchone()[0] > 0:\n    rpd_to_chrome_trace('run.rpd')","handlingStrategy":"validation","validationCode":"import sqlite3\ndef rpd_has_events(path: str) -> bool:\n    con = sqlite3.connect(path)\n    try:\n        return con.execute('select count(*) from rocpd_api').fetchone()[0] > 0\n    finally:\n        con.close()","typeGuard":"null","tryCatchPattern":"try:\n    rpd_to_chrome_trace(path)\nexcept Exception as e:\n    if 'Trace file is empty' in str(e):\n        logger.warning('empty RPD capture %s; skipping conversion', path)","preventionTips":["Ensure GPU work runs within the profiler window","Pre-check rocpd_api row counts before converting","Discard zero-event captures in batch conversion scripts"],"tags":["profiling","rocm","rpd","chrome-trace","sglang"],"backgroundTag":"empty-profile-capture","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}