Repository navigation
[AMD] [GLM5] skip redundant -inf pre-fill of HIP indexer MQA-logits - #28757
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
HaiShaw
left a comment
There was a problem hiding this comment.
Please run pre-commit to avoid lint error.
On the HIP DSA indexer path, fp8_mqa_logits defaulted to clean_logits=True, which torch.full(-inf)-initializes the [tokens x seq_len_kv] logits buffer every layer. That pre-fill is O(seq^2) and grows quadratically with context. The CUDA deep_gemm.fp8_mqa_logits path in the same function already passes clean_logits=False and relies on topk_transform to mask invalid positions via ks/ke/lengths. Align the HIP path with CUDA by passing clean_logits=False. GLM-5.1-MXFP4 / MI355X (gfx950) / TP4 / fp8 KV: -2..3% median TTFT across a 2-64 concurrency sweep, +9.3% isolated prefill throughput, median ITL and E2EL unchanged, GSM8K 93.6%->93.8% (no regression).
c8609c8 to
077c863
Compare
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
|
@amd-bot ci-status |
CI Status for PR #28757Merge verdict: Caution This PR's changed code is not exercised by any PR-CI test. The diff only affects the HIP Changed files: Executed CI failure attribution: AMD: 2 failures (0 related) · Others: 2 root-cause failures (0 related) + 5 fast-fail cascade jobs (NVIDIA base-c) AMD Executed Failures
Other Executed Failures
Fast-fail cascade (not independent failures): NVIDIA Details / what to do before merge
Generated by amd-bot using Claude Code CLI |
|
@Raiden-Makoto Can you add unit test file for the code change, and upload test results? |
…l-project#28757) Verifies fp8_mqa_logits(clean_logits=False) + masked topk selects identical KV positions as clean_logits=True, with a sanity check that clean_logits=False genuinely skips the -inf pre-fill.
|
Added a unit test for this change: It exercises the exact correctness guarantee behind Test results — AMD Instinct MI350X (gfx950), ROCm 7.2.0: |
…gl-project#28757) Co-authored-by: Raiden-Makoto <[email protected]>
Motivation
This affects HIP serving of DSA (DeepSeek Sparse Attention) models; it was found
and validated on GLM-5.1-MXFP4 (which uses the DSA indexer) at long context.
On the HIP DSA indexer path,
Indexer._get_topk_raggedcalls aiter'sfp8_mqa_logitswith the defaultclean_logits=True, whichtorch.full(-inf)-initializes the[tokens x seq_len_kv]logits buffer on everylayer before the kernel writes the valid positions. That pre-fill is O(seq^2)
and grows quadratically with context length, so at long context it becomes a
significant share of prefill time (~11% of prefill GPU time at 16x8192 on
gfx950).
The CUDA
deep_gemm.fp8_mqa_logitspath in the same function already passesclean_logits=Falseand relies ontopk_transformto mask invalid positions viaks/ke/lengths. The HIP path simply did not pass the flag, leaving theredundant fill in place. This aligns the HIP path with CUDA.
Modifications
python/sglang/srt/layers/attention/dsa/dsa_indexer.py: passclean_logits=Falseto both HIPfp8_mqa_logitscalls in_get_topk_ragged(the non-chunked and the budget-chunked branches).topk_transformalready receives the valid per-row range and ignoresout-of-range positions, so the
-infpre-fill is redundant. gfx950 behavioris otherwise unchanged; the CUDA path is untouched.
Accuracy Tests
GSM8K 5-shot, full 1319 questions, GLM-5.1-MXFP4, MI350X (gfx950), tp4,
fp8_e4m3 KV:
clean_logits=True)clean_logits=False)No regression (delta within run-to-run noise).
Speed Benchmarks
E2E
sglang.bench_serving(random, input 8192 / output 1024, median latencies),GLM-5.1-MXFP4 / MI350X / tp4 / fp8_e4m3 KV:
Baseline (
main):This PR (
clean_logits=False):Median TTFT improves 1.8-2.7% across the sweep; median ITL is unchanged
(within +/-0.5%) and median E2EL is flat-to-slightly-better, confirming the
change is prefill-side with no decode regression. The benefit scales with how
prefill-heavy the workload is (short outputs / RAG / long context).
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #28113605405
Latest PR Test (Extra): ❌ Run #28113605230