feat(bypass): kernel source resolution + shape recovery for graph/Triton kernels - #1049
Open
lishuoshuo-amd wants to merge 2 commits into
Open
feat(bypass): kernel source resolution + shape recovery for graph/Triton kernels#1049lishuoshuo-amd wants to merge 2 commits into
lishuoshuo-amd wants to merge 2 commits into
Conversation
…/attn, handle graph-mode traces Add a repo-scan fallback that reverse-looks-up device kernel names against the on-disk sglang/aiter sources, so hand-written Triton and C++/HIP kernels resolve to editable sources without the Inductor-only kernel_file field or the stale op_to_source table. Extend the classifier with a Communication category and MoE/SDPA/GEMM/Elementwise rules. Recognize hipGraphLaunch so graph-internal kernels are attributed instead of unlinked, expose graph-coverage health, and skip the idle gate when a graph-mode trace is under-recorded.
…h kernels Kernels whose correlation->cpu_op chain is broken (CUDA-graph replay and Triton direct-launch) previously fell straight to shape_provenance=unresolved, leaving ~45% of graph-mode kernels (including routable hand-written Triton/KDA kernels) without a dispatchable shape. Add a shape-resolution waterfall keyed on the kernel identity, not a name allowlist: 1. torch_trace -- own cpu_op Input Dims (unchanged, precise) 2. capture_backfill -- same-name kernel's capture-time shape 3. launch_grid -- this kernel's launch grid/block geometry 4. tile_name -- BLOCK_SIZE_* tile embedded in the kernel name The reader now retains launch grid/block and builds name-keyed backfill/geometry indices; the report builder consumes them. launch_grid/tile_name fallbacks are geometry, not operand dims, so they are excluded from the analytical roofline to avoid poisoning the AI/bound-type estimate. Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
||
|
|
||
| # Length-prefixed token of an Itanium name (e.g. "5aiter" -> "aiter"). | ||
| _ITANIUM_TOKEN_RE = re.compile(r"(\d+)") |
|
|
||
|
|
||
| # Length-prefixed token of an Itanium name (e.g. "5aiter" -> "aiter"). | ||
| _ITANIUM_TOKEN_RE = re.compile(r"(\d+)") |
CI E2E report — ❌ Failed
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolve kernel sources by repo scan ...): repo-scan source resolution by device kernel name, comms/MoE/SDPA/GEMM/Elementwise classification, and graph-mode trace handling (hipGraphLaunch attribution + idle-gate skip on under-recorded graph traces).recover kernel shapes ...): a shape-resolution waterfall so graph-replay and Triton direct-launch kernels stop falling tounresolved.Motivation
On a real Kimi-K3 graph-mode trace, ~45% of kernel executions (63 distinct kernels, including routable hand-written Triton/KDA kernels) had a broken
correlation -> External id -> cpu_op -> Input Dimschain and resolved toshape_provenance=unresolved. The data is not lost, only displaced (capture-time record, launch geometry, or the tile-encoding name), so a general identity-keyed fallback recovers it.Shape waterfall (identity-keyed, no name allowlist)
torch_trace-- own cpu_op Input Dims (precise; unchanged)capture_backfill-- same-name kernel's capture-time shapelaunch_grid-- this kernel's launch grid/block geometrytile_name--BLOCK_SIZE_*tile parsed from the kernel nameunresolved-- none of the abovelaunch_grid/tile_nameare geometry (not operand dims) and are deliberately excluded from the analytical roofline so they cannot poison AI/bound-type estimates.Validation
unresolvedto 0 (the 3 becamelaunch_grid); the 12torch_tracerows are unchanged (no regression).Notes / follow-up (not in this PR)
launch_grid/tile_name-level shape should be allowed to satisfy the kernel_opt dispatch gate (non-empty trace shape REQUIRED) is left as a separate, opt-in decision, since geometry is coarser than operand shapes.Test plan
Made with Cursor