Skip to content

[Perf] [AMD] dsv4: reuse the q_lora fp8 quant for the C4 indexer wq_b (4/8) - #41903

Merged
HaiShaw merged 6 commits into
sgl-project:mainfrom
AMD-yanfeiwang:perf/dsv4-indexer-qlora-quant-reuse
Oct 16, 2026
Merged

HaiShaw merged 6 commits into
sgl-project:mainfrom
AMD-yanfeiwang:perf/dsv4-indexer-qlora-quant-reuse

Conversation

@AMD-yanfeiwang

@AMD-yanfeiwang AMD-yanfeiwang commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

On the fused qk-norm/rope path (gfx95/gfx1250), MQALayer._forward_prepare already quantizes the normed q_lora to fp8 group-128 (_fused_rmsnorm_fp8_quant) for the attention wq_b. The C4 indexer's wq_b takes the same q_lora and quantizes it again with a standalone dynamic_per_group_scaled_quant. For DeepSeek-V4-Pro that adds 30 extra launches per decode/verify step.

Modifications

  • _forward_prepare passes the existing quant (q_lora_quant) through C4Indexer.forward -> forward_c4_indexer -> compute_q, and the indexer wq_b consumes it directly.
  • It is dropped (set to None) when the indexer trims q_lora to fewer queries. The non-fused path, the multi-stream path, NPU and the low-ratio arms are unchanged. forward_c4_indexer only receives the kwarg when it is set.

Accuracy Tests

  • The quantized input is the same tensor the attention wq_b already uses, so the indexer wq_b input is identical to its own quant of q_lora.
  • DeepSeek-V4-Pro TP8, stock image lmsysorg/sglang-rocm:v0.5.20-rocm724-mi35x-20260927 + this PR only: gsm8k 200q 0.965. A capture-time print confirmed that the reuse path runs on all 8 ranks.
  • On the stack below, DSpark b6 gsm8k 1319q over 2 boots: before 0.945 / 0.939, after 0.945 / 0.948. Accept length 4.36 -> 4.37.

Speed Tests and Profiling

Kernel: each removed dynamic_per_group_scaled_quant launch shows as 4.3 us in the graph-mode trace (about 3.8 us after subtracting profiler overhead). With 30 launches per step, the trace estimate was about 0.11-0.13 ms per step. The measured E2E saving is 0.06-0.09 ms per step, which is about 2-3 us per launch.

E2E, DeepSeek-V4-Pro fp8, TP8 MI355X, image lmsysorg/sglang-rocm:v0.5.20-rocm724-mi35x-20260927, 8k in / 1k out. Measured on our DSv4 decode stack: #41383 (FlyDSL fused decode, with ROCm/aiter#5882 and the aiter fp32-out HGEMM fix), the DSpark verify ring write, #38919 + #38920 (env on), the MoE small-batch sort and the fp32 GEMM aiter route. Before = that stack; after = stack + this PR. It was developed there; the diff on main is the same minus the #38920 kv_score_input plumbing. 2 boots x 3 reps, paired:

cell step time before -> after (ms) delta mean [min, max] (ms) steady decode tok/s
plain c8 11.87 -> 11.79 -0.65% -0.077 [-0.100, -0.043] 674 -> 678
plain c32 15.60 -> 15.54 -0.39% -0.061 [-0.087, -0.035] 2053 -> 2062
DSpark b6 c2 14.85 -> 14.76 -0.60% -0.089 [-0.113, -0.078] 859 -> 864
DSpark b6 c4 17.36 -> 17.30 -0.33% -0.058 [-0.135, -0.021] 1407 -> 1417
DSpark b6 c16 (1 boot) 26.26 -> 26.27 +0.06% (noise) -
DSpark b6 c64 (1 boot) 45.13 -> 45.05 -0.18% (noise) -

All 24 two-boot pairs are faster.

Checklist


CI States

Latest PR Test (Base): ❌ Run #38719443823
Latest PR Test (Extra): ❌ Run #38719443685
Latest PR Test (AMD ROCm 10): ❌ Run #38719443733

On the fused qk-norm/rope path (gfx95/gfx1250), _forward_prepare already
quantizes the normed q_lora to fp8 group-128 for the attention wq_b. The C4
indexer's wq_b takes the same q_lora and quantized it again. Pass the existing
quant through C4Indexer.forward -> forward_c4_indexer -> compute_q instead,
saving one quant launch per C4 layer per step. It is dropped when the indexer
trims q_lora; the multi-stream path is unchanged.
@AMD-yanfeiwang
AMD-yanfeiwang marked this pull request as ready for review October 3, 2026 11:16
@kkHuang-amd kkHuang-amd added amd run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci) labels Oct 13, 2026
@AMD-yanfeiwang AMD-yanfeiwang changed the title [AMD][DSV4] Reuse q_lora fp8 quant for the C4 indexer wq_b [AMD][DSV4][4/8] reuse the q_lora fp8 quant for the C4 indexer wq_b- #44005 Oct 13, 2026
@AMD-yanfeiwang AMD-yanfeiwang changed the title [AMD][DSV4][4/8] reuse the q_lora fp8 quant for the C4 indexer wq_b- #44005 [AMD][DSV4][4/8] reuse the q_lora fp8 quant for the C4 indexer wq_b Oct 13, 2026
@Duyi-Wang Duyi-Wang removed the run-ci-extra CI: also run the extra suite (requires run-ci) label Oct 15, 2026
@kkHuang-amd kkHuang-amd added the run-ci-extra CI: also run the extra suite (requires run-ci) label Oct 15, 2026
@Duyi-Wang Duyi-Wang changed the title [AMD][DSV4][4/8] reuse the q_lora fp8 quant for the C4 indexer wq_b [Perf] [AMD] dsv4: reuse the q_lora fp8 quant for the C4 indexer wq_b (4/8) Oct 16, 2026

@HaiShaw HaiShaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None none q_lora_quant is only set at HIP/gfx95/gfx1250

@HaiShaw
HaiShaw merged commit 2adc76a into sgl-project:main Oct 16, 2026
213 of 267 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amd deepseek run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants