Repository navigation
[Config] [Perf] DSv4.1 TP4 a8w4: fused-quant stage 1 for the 32/64/128 decode rows - #8665
Conversation
…-step barrier The stage-1 main loop waited vmcnt(tile_m//32//fp4_ratio + B loads) before the barrier that hands the A LDS buffer to ds_read. On gfx950 that leaves the previous half's A LDS-DMA racing the other waves' ds_read: the DSv4.1 TP4 a8w4 kernel (t32x128x256 gui fp8) wrote garbage into 4-row x 16-column output blocks of rows 16-31 on every few calls, and two runs on the same input disagreed in 4-26 rows. Leave only the B loads in flight. Co-authored-by: Claude Opus 5.5 <[email protected]> Signed-off-by: Carl Persson <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
One backend per PR: PR title tags & labels: Reviews: |
The LDS-DMA wait fix removed the last use of fp4_ratio (ruff F841), and the shortened vmcnt expression now fits on one line. Co-authored-by: Claude Opus 5.5 <[email protected]> Signed-off-by: Carl Persson <[email protected]>
cb9ab23 to
cec5312
Compare
The scale loads share the A LDS-DMA's scheduling region, and LLVM may place them between the two DMAs, so counting them in vmcnt can leave a DMA in flight. Only the B loads, issued behind sched_barrier(0) in later phases, are guaranteed to be younger. Reword the comment accordingly; no code change. Co-authored-by: Claude Opus 5.5 <[email protected]> Signed-off-by: Carl Persson <[email protected]>
…e rows
The 32, 64 and 128 token rows of the (5120, 640, 384, top-6) key used a
tile_m=16 stage 1 with a bf16 intermediate, so every call also ran a separate
MXFP8 quant of the intermediate before stage 2. They now use the 256 row's
pair: the t32 stage 1 that writes MXFP8 itself and the layout stage 2.
fused_moe on MI355X, CUDA graph, 40 captured routings, median of 3 rounds:
real-text routing 24 / 32 / 48 / 64 / 96 / 126 tokens:
73.2 / 79.6 / 89.4 / 100.8 / 121.3 / 134.6 -> 64.5 / 70.0 / 79.8 / 88.5 / 105.2 / 116.5 us
random-token routing 24 / 32 / 48 / 64 / 96 / 126 tokens:
74.7 / 82.7 / 94.7 / 106.0 / 128.0 / 123.2 -> 65.5 / 73.1 / 84.2 / 92.9 / 111.5 / 104.2 us
Against a torch reference with an fp32 intermediate, rel. L2 error is
2.71e-2 / 2.67e-2 / 2.68e-2 (32 / 64 / 126 tokens) vs 2.73e-2 / 2.69e-2 /
2.70e-2 before.
Needs the stage-1 LDS-DMA wait fix (ROCm#7158): without it this stage 1
corrupts rows 16-31 of a sorted block.
Co-authored-by: Claude Opus 5.5 <[email protected]>
Signed-off-by: Carl Persson <[email protected]>
cec5312 to
3691b0a
Compare
READY FOR HUMAN REVIEWPR Self-ReviewRevision Author self-review accepted. Readiness report: Author answers
Show the author's self-review answersBehavior and intentValidation and unverified scopePR-specific questionChanged op testsPR state
Copilot findings
Code and op-test hygiene
Required CI
Shadow mode reports what would block but keeps the status successful. Set |
…40 rows 13 of the 32 (5120, 640) rows, gfx950: - E=384 top-6, 4096-32768 and E=128 top-3, 2048, 8192-32768: same stage 1 and block_m, stage 2 switches to the FP8 version of the same kernel. - E=128, 1024 and 4096: retuned with --flydsl-stage2-fp8, FP8 stage 2. - E=128, 8 and 256, E=384, 4: retuned, BF16 stage 2. A row changes only where fused_moe is at least ~3% faster at both token counts it serves. The E=384 32-128 rows are left to ROCm#8665. fused_moe on MI355X, CUDA graph, two runs, no env flag (E=384 with routing captured from vLLM, E=128 uniform): E=384 -6% at 3072 to -14% at 32768; E=128 -10% at 5-8, -6% at 129-256, -4% at 513-2048, -9% at 2049-4096 and -7% to -13% from 6144 up. Co-authored-by: Claude Opus 5.5 <[email protected]> Signed-off-by: Carl Persson <[email protected]>
Summary
The 32, 64 and 128 token rows of the DeepSeek V4.1 Flash TP4 a8w4 key
(5120, 640, 384 experts, top-6) now use the same kernel pair as the 256 row:
the t32 stage 1 that writes MXFP8 itself and the layout stage 2 that reads it.
This drops the separate MXFP8 quant of the intermediate that ran between the
stages on every call.
fused_moeis 11–15% faster from 24 to 126 tokens,and vLLM decode without speculative decoding gains about 4% throughput at
concurrency 32–128.
Motivation
These rows used a tile_m=16 stage 1 with a bf16 intermediate, so each MoE call
also launched
fused_dynamic_mxfp8_quant_moe_sortbefore stage 2 (about 6 µsper layer at 126 rows in a vLLM decode trace). The 1–16 and 256+ rows already
use fused-quant pairs; 32–128 was the only gap. Lookup rounds up to a power
of two, so these rows serve 17–128 tokens: decode at 17–128 concurrent
requests, or about 3–21 with DSpark (6 tokens per request).
Changes
aiter/configs/model_configs/dsv41_fp8_tuned_fmoe.csv, gfx950 rows 32, 64and 128 of (5120, 640, 384, 6):
flydsl_moe1_afp8_wfp4_bf16_t32x128x256_w3_gui_fp8;flydsl_moe2_layout_afp8_wfp4_bf16_t32x256x128_atomic_nt_sbm32.The us/err/tflops columns are left empty, as on other hand-set rows in this
file. No other table has these keys, so the merge never has to rank them.
Performance
MI355X,
fused_moeunder CUDA-graph replay, 40 routings captured from vLLM,4 rotating weight copies, median of 3 rounds (spread ≤ 2 µs). Before: the
current rows on the same build. Token counts cover both ends of each row.
vLLM serving, DeepSeek-V4.1-Flash TP4 on 4x MI355X, no speculative decoding,
random 8k in / 1k out, median of 3 runs. Both arms use the same build and
differ only in this CSV:
With DSpark and
--monokernel, decode steps up to 64 rows run in themonokernel, so only the 128 row applies (about 11–21 requests). At
concurrency 16 and 32 the difference is within run-to-run noise (acceptance
length varies from 1.4 to 2.1 on random prompts); concurrency 8 is unchanged.
Testing
Unit tests added or updated
Performance benchmarks run
Tested on MI250X
Tested on MI300X
Accuracy against a torch reference with an fp32 intermediate (no
intermediate quant), all token counts above, both routings: rel. L2 error
2.67e-2 – 2.72e-2 after vs 2.69e-2 – 2.73e-2 before. The fused stage 1
quantizes from fp32 accumulators instead of a bf16 intermediate.
Every run logged the dispatched kernels; each row picked the pair above,
in the benchmark and in both serving configs.
vLLM accuracy on the serving runs above (main 9b38c833ee):
Not run: MI250X/MI300X (gfx950-only rows).
Documentation
Dependencies
Relies on the stage-1 LDS-DMA wait fix from #8550, now merged.
Breaking Changes
None.
PR Self-Review
Reviewed revision
5e8b7ef47Behavior and intent
The 32, 64 and 128 token rows of the DeepSeek V4.1 Flash TP4 a8w4 key move from a tile_m=16 stage 1 with a bf16 intermediate to the 256 row's t32 fused-quant stage 1 and layout stage 2. This removes the separate MXFP8 quant of the intermediate between the stages, which cost about 6 µs per layer at 17–128 tokens.
Validation and unverified scope
fused_moeon MI355X under CUDA-graph replay with 40 routings captured from vLLM: 11–15% faster from 24 to 126 tokens. Relative L2 error against a torch reference with an fp32 intermediate is unchanged (2.67e-2 to 2.72e-2 after, 2.69e-2 to 2.73e-2 before), and the dispatch logs show the new pair. vLLM DeepSeek-V4.1-Flash TP4 serving: about 4% higher throughput at concurrency 32–128 without speculative decoding. Full gsm8k and niah_single_2 32k/64k are unchanged within noise. Not run: MI250X/MI300X (the rows are gfx950-only).PR-specific question
Only three rows of
dsv41_fp8_tuned_fmoe.csvchange: gfx950, 256 CUs, tokens 32/64/128, model_dim 5120, inter_dim 640, 384 experts, top-6, Silu, bf16 output, fp8 activations, fp4 weights, per_1x32. Lookup rounds token counts up to a power of two, so these rows serve 17–128 tokens of that shape only. No other table has this key; the dsv41_fp4 tables use fp4 activations, which is a different key. Every other shape, including the 1–16 and 256+ rows of this key, keeps its previous row.Changed op tests
None.
AI disclosure: written with Claude Opus 5.5 (Cursor); reviewed and run by the
author.