[ROCm][DSV4][Perf] Keep C4 decode metadata dense on gfx950 - #54121
Closed
Fangzhou-Ai wants to merge 1 commit into
Closed
Fangzhou-Ai wants to merge 1 commit into
Fangzhou-Ai wants to merge 1 commit into
Conversation
Assisted-by: OpenAI Codex Signed-off-by: fai <fangzhouai@gmail.com>
Fangzhou-Ai
requested review from
AndreasKaratzas,
dllehr-amd,
hongxiayang,
tjtanaa and
zyongye
as code owners
August 27, 2026 23:32
Fangzhou-Ai
marked this pull request as draft
August 28, 2026 00:16
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
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
Keep DeepSeek-V4 C4 decode top-k metadata dense on gfx950 and let the native
Triton sparse-attention kernel consume the
[batch, topk]indices plus per-rowlengths directly.
Previously the C4 path mapped local top-k indices to global cache slots, built a
ragged indptr, packed every dense row into a second flat buffer, and then read
that ragged representation in every C4 attention layer. The new gfx950 path
removes that repack. gfx942 and other architectures retain the existing ragged
path.
The shared global-index mapper also now masks padded rows before reading their
request or block-table metadata. This is required because FULL graph padding can
carry sentinel request IDs and top-k values; the safety change is shared by the
existing NVIDIA/XPU callers.
Scope and C128
This PR intentionally changes C4 decode only. C128 metadata remains ragged.
C128 already exposes dense indices, but its active row width changes with
sequence length while FULL graphs capture fixed shapes and strides. Reusing the
C4 flag naively could capture width 128 and later clamp a longer C128 row during
replay. A safe C128 follow-up needs a graph-stable physical-capacity contract,
row-strided dense input support, and short-capture-to-long-replay coverage.
Also, C128 performs its conversion once per shared metadata build rather than
once per C128 layer, so its expected latency benefit is much smaller.
Correctness and memory
stale dense tails, and long-to-short-to-long graph replay.
[B, K]output replaces the same-capacity flat ragged allocationand removes the small
[B + 1]indptr. It does not increase GPU memory.by the local-head-count unit matrix, but were not run end to end.
Performance
MI355X/gfx950 graph-replay microbenchmark, 51 interleaved samples after warmup:
TP8 serving used 8k input / 1k output random requests. The comparator is the
arithmetic mean of two unchanged-code control runs with identical server and
prompt settings; the candidate was a third isolated run.
Validation
Full GSM8K, 5-shot, deterministic no-thinking generation completed all 1,319
examples:
Equivalent direct server command:
Equivalent direct serving benchmark command:
Duplicate-work check
No open PR duplicates this change. #41105 is the closest conceptual neighbor,
but it fuses CUDA top-k generation with the page-table transform; it does not
change the ROCm gfx950 sparse-decode consumer or eliminate its post-transform
repack. #51714 adds an optional external AITER/Gluon decode backend and still
expects ragged metadata. #50566, #46172, and #52628 optimize different decode or
metadata stages. #52212 is merged and is the native gfx950 Triton baseline for
this PR.
AI assistance
OpenAI Codex assisted with investigation, implementation, testing, benchmarking,
review, and drafting. The human submitter directed and reviewed the work and is
responsible for understanding and defending every changed line and for rerunning
the relevant validation before merge.