Skip to content

[DSV4.1Flash] Bound the a8w4 MoE activation quant to the live token count - #6610

Merged
vgokhale merged 2 commits into
ROCm:mainfrom
heachary:heachary/dsv41_flash/moe-quant-live-tokens
Oct 20, 2026
Merged

vgokhale merged 2 commits into
ROCm:mainfrom
heachary:heachary/dsv41_flash/moe-quant-live-tokens

Conversation

@heachary

Copy link
Copy Markdown
Contributor

Motivation

Under expert parallelism the activation buffer handed to fused_moe_2stages is
MoRI's dispatch receive buffer, sized for the worst case rather than for what
actually arrived: max_num_tokens * ep_size, which is 32768 rows for
DeepSeek-V4.1-Flash at DP8/EP8. Only the dispatched rows are valid.

The mxfp4 quant call sites already bound their work with
num_rows=num_local_tokens. The two mxfp8 (a8w4) call sites did not, so
per_1x32_mx_quant_hip streamed all 32768 rows for stage 1 and all
32768 * topk rows for stage 2 no matter how few tokens the rank received.

On an MI355X decode profile of DeepSeek-V4.1-Flash (DP8/EP8,
mori_high_throughput) those two quant kernels were 40.5% of all GPU kernel
time
: 164us for stage 1 and 434us for stage 2 per MoE layer, against 186us and
227us for the GEMMs they feed.

Summary of changes

Pass num_rows=num_local_tokens at the two mxfp8 call sites in
aiter/fused_moe.py, matching what the mxfp4 siblings in the same function
already do. fused_dynamic_mxfp8_quant_moe_sort already forwards num_rows to
the split path, so this only supplies a value that was being dropped.

Two lines, no new API, no behavior change when num_local_tokens is None.
The sorted scale region the GEMMs consume is unchanged.

Results

8x MI355X (gfx950), DeepSeek-V4.1-Flash, DP8/EP8 with mori_high_throughput,
speculative decoding off. 8192 in / 1024 out, 256 prompts at concurrency 64.
Measured against a stock vLLM nightly (0.32.0rc1.dev190+g3f1bcfd82)

Performance

Metric Baseline With patch Delta
Output token throughput (tok/s) 1103.58 1832.17 +66.0%
Total token throughput (tok/s) 9932.18 16489.55 +66.0%
Median TPOT (ms) 54.16 32.76 -39.5%
Mean TPOT (ms) 54.68 32.61 -40.4%
Median ITL (ms) 51.40 29.98 -41.7%
Mean TTFT (ms) 3392.14 2380.31 -29.8%
Benchmark duration (s) 237.54 143.08 -39.8%

Accuracy

gsm8k, 5-shot, all 1319 questions, strict-match.

Arm exact_match stderr Delta
Baseline 0.9196 0.0075 —
With patch 0.9280 0.0071 +0.0084

Reproduction

Server:

export VLLM_ROCM_USE_AITER=1
export VLLM_ROCM_USE_AITER_MOE=1
export VLLM_ROCM_USE_AITER_TRITON_SPARSE_MLA=True
export VLLM_USE_BREAKABLE_CUDAGRAPH=1
export VLLM_USE_RUST_FRONTEND=1

vllm serve /model/DeepSeek-V4.1-Flash \
  --served-model-name deepseek-ai/DeepSeek-V4.1-Flash \
  --tensor-parallel-size 1 \
  --data-parallel-size 8 \
  --enable-expert-parallel \
  --all2all-backend mori_high_throughput \
  --moe-backend aiter \
  --max-model-len 16384 \
  --gpu-memory-utilization 0.9 \
  --max-num-batched-tokens 8192 \
  --max-cudagraph-capture-size 1024 \
  --block-size 128 \
  --tokenizer-mode deepseek_v41 \
  --tool-call-parser deepseek_v41 \
  --reasoning-parser deepseek_v41 \
  --enable-auto-tool-choice \
  --language-model-only \
  --no-swa-bounded-replay \
  --no-enable-prefix-caching \
  --disable-uvicorn-access-log \
  --attention-config '{"indexer_kv_dtype":"mxfp4","indexer_sparse_logits":true}'

Benchmark:

vllm bench serve \
  --model deepseek-ai/DeepSeek-V4.1-Flash \
  --tokenizer /model/DeepSeek-V4.1-Flash \
  --dataset-name random \
  --random-input-len 8192 \
  --random-output-len 1024 \
  --ignore-eos \
  --num-prompts 256 \
  --max-concurrency 64 \
  --temperature 0 \
  --seed 0 \
  --percentile-metrics ttft,tpot,itl,e2el \
  --metric-percentiles 50,90,99

Accuracy:

lm_eval --model local-completions --tasks gsm8k --num_fewshot 5 \
  --model_args base_url=http://localhost:8000/v1/completions,model=deepseek-ai/DeepSeek-V4.1-Flash,tokenizer_backend=None,num_concurrent=64,max_retries=3,timeout=3600

Under EP the activation buffer handed to aiter is MoRI's dispatch receive
buffer, sized for the worst case (max_num_tokens * ep_size = 32768 rows for
DSv4.1-Flash at DP8/EP8) with only the dispatched rows valid. The mxfp4 quant
call sites bound their work with num_rows=num_local_tokens; the two mxfp8
(a8w4) call sites did not, so per_1x32_mx_quant_hip streamed all 32768 rows for
stage 1 and all 32768*topk rows for stage 2 no matter how few tokens arrived.

fused_dynamic_mxfp8_quant_moe_sort already forwards num_rows to the split path,
so this just supplies the value the mxfp4 siblings already pass.

On an MI355X decode profile of DSv4.1-Flash (DP8/EP8, mori_high_throughput) the
two quant kernels were 40.5% of all GPU kernel time: 164us for stage 1 and
434us for stage 2 per MoE layer, against 186us/227us for the GEMMs they feed.
Isolated on the live/padded shapes this change is worth 2.2-3.5x on those
kernels; the sorted scale region the GEMMs consume is unchanged.

Co-authored-by: Cursor <[email protected]>
@heachary
heachary requested a review from a team October 16, 2026 05:21
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

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

Extended tests (opt-in via labels):

Label Tests
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 gfx1201 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 6610 --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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants