Skip to content

[Config] [Perf] DSv4.1 TP4 a8w4: fused-quant stage 1 for the 32/64/128 decode rows - #8665

Merged
yifehuan merged 5 commits into
ROCm:mainfrom
cpersson-amd:dsv41-decode-fq-rows
Dec 2, 2026
Merged

yifehuan merged 5 commits into
ROCm:mainfrom
cpersson-amd:dsv41-decode-fq-rows

Conversation

@cpersson-amd

@cpersson-amd cpersson-amd commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

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_moe is 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_sort before stage 2 (about 6 µs
per 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, 64
    and 128 of (5120, 640, 384, 6):

    • block_m 16 -> 32;
    • stage 1 -> flydsl_moe1_afp8_wfp4_bf16_t32x128x256_w3_gui_fp8;
    • stage 2 -> 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_moe under 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.

Tokens Real text before (µs) after (µs) Change Random tokens before (µs) after (µs) Change
24 73.2 64.5 -11.9% 74.7 65.5 -12.3%
32 79.6 70.0 -12.1% 82.7 73.1 -11.6%
48 89.4 79.8 -10.7% 94.7 84.2 -11.1%
64 100.8 88.5 -12.2% 106.0 92.9 -12.4%
96 121.3 105.2 -13.3% 128.0 111.5 -12.9%
126 134.6 116.5 -13.4% 123.2 104.2 -15.4%

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:

Concurrency TPOT before TPOT after Change Throughput before Throughput after Change
32 12.65 ms 12.10 ms -4.3% 2204 tok/s 2310 tok/s +4.8%
64 17.76 ms 17.05 ms -4.0% 3231 tok/s 3359 tok/s +4.0%
128 25.72 ms 24.72 ms -3.9% 4529 tok/s 4713 tok/s +4.1%

With DSpark and --monokernel, decode steps up to 64 rows run in the
monokernel, 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):

    Config Arm gsm8k (full, 5-shot, strict) niah_single_2 32k / 64k
    no spec before 0.9249 1.0 / 1.0
    no spec after 0.9257 (±0.007) 1.0 / 1.0
    DSpark + monokernel before 0.9242 1.0 / 1.0
    DSpark + monokernel after 0.9212 (±0.007) 1.0 / 1.0
  • Not run: MI250X/MI300X (gfx950-only rows).

Documentation

  • No documentation change is needed: config rows only.

Dependencies

  • No new third-party dependencies added

Relies on the stage-1 LDS-DMA wait fix from #8550, now merged.

Breaking Changes

None.

PR Self-Review

Reviewed revision

5e8b7ef47

Behavior 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_moe on 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.csv change: 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.

…-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]>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 8665 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

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]>
cpersson-amd and others added 2 commits November 26, 2026 08:29
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]>
@cpersson-amd
cpersson-amd marked this pull request as ready for review November 30, 2026 11:12
@cpersson-amd
cpersson-amd requested a review from a team November 30, 2026 11:12
@aiter-bot

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision 5e8b7ef4719b · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior 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_moe` on 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.csv` change: 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.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@SamiAario-AMD SamiAario-AMD self-assigned this Nov 30, 2026
cpersson-amd added a commit to cpersson-amd/aiter that referenced this pull request Nov 30, 2026
…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]>
@zufayu
zufayu requested a review from yifehuan December 1, 2026 04:43

@yifehuan yifehuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@yifehuan
yifehuan merged commit 8919dc2 into ROCm:main Dec 2, 2026
101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants