Skip to content

[AMD][DSV4] feat: MXFP8 activation passthrough in fused_moe - #4954

Merged
yifehuan merged 4 commits into
ROCm:mainfrom
karverma-amd:amd/mxfp8-dispatch-fused-moe
Aug 25, 2026
Merged

yifehuan merged 4 commits into
ROCm:mainfrom
karverma-amd:amd/mxfp8-dispatch-fused-moe

Conversation

@karverma-amd

Copy link
Copy Markdown
Contributor

DSv4's MoE is w4a8: MXFP4 weights (per_1x32), so the kernels consume fp8 activations carrying group-32 e8m0 microscales. When a caller has already produced exactly that -- an MXFP8 all-to-all dispatch, for instance -- fused_moe should take the activations as-is and only sort the scale, which is what the neighbouring fp4x2 pre-quantized branch already does.

Without this, such a caller lands on a path that re-derives scales, which is the round trip the format was chosen to avoid. Nothing errors; the cost is simply paid again.

12 lines, mirroring the existing pre-quantized branch. No existing path changes: the new branch is reached only when activations arrive as fp8 with a scale already attached.

Motivating consumer is SGLang's MoRI expert-parallel dispatch, which can then quantize on the send side over live tokens rather than leaving the receiver to quantize over a padded all-to-all buffer.

Measured with the matching SGLang change on DeepSeek-V4-Pro, MI355X, TP8 + DP8 attention + EP8/MoRI + EAGLE MTP, 8192 in / 1024 out: +6.4% to +9.8% output throughput and -6.2% to -9.3% TPOT across concurrency 4-64. GSM8K 0.945 over 1319 questions, zero invalid.

Adds op_tests/test_moe_mxfp8_passthrough.py: the branch fails silently in both directions -- absent, it costs throughput with no error; miswired, it reinterprets scale bytes and returns wrong numbers rather than raising. The test pins the group-32 one-byte scale layout and checks the passthrough returns finite, correctly shaped output across the decode token range including the single-token and zero-token cases.

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

DSv4's MoE is w4a8: MXFP4 weights (per_1x32), so the kernels consume fp8
activations carrying group-32 e8m0 microscales. When a caller has already
produced exactly that -- an MXFP8 all-to-all dispatch, for instance --
fused_moe should take the activations as-is and only sort the scale,
which is what the neighbouring fp4x2 pre-quantized branch already does.

Without this, such a caller lands on a path that re-derives scales, which
is the round trip the format was chosen to avoid. Nothing errors; the
cost is simply paid again.

12 lines, mirroring the existing pre-quantized branch. No existing path
changes: the new branch is reached only when activations arrive as fp8
with a scale already attached.

Motivating consumer is SGLang's MoRI expert-parallel dispatch, which can
then quantize on the send side over live tokens rather than leaving the
receiver to quantize over a padded all-to-all buffer.

Measured with the matching SGLang change on DeepSeek-V4-Pro, MI355X,
TP8 + DP8 attention + EP8/MoRI + EAGLE MTP, 8192 in / 1024 out:
+6.4% to +9.8% output throughput and -6.2% to -9.3% TPOT across
concurrency 4-64. GSM8K 0.945 over 1319 questions, zero invalid.

Adds op_tests/test_moe_mxfp8_passthrough.py: the branch fails silently
in both directions -- absent, it costs throughput with no error; miswired,
it reinterprets scale bytes and returns wrong numbers rather than raising.
The test pins the group-32 one-byte scale layout and checks the
passthrough returns finite, correctly shaped output across the decode
token range including the single-token and zero-token cases.

Co-authored-by: Cursor <cursoragent@cursor.com>
@karverma-amd
karverma-amd requested a review from a team August 24, 2026 03:48
@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; main branch always runs both MI35X and MI300X
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: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
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 4954 --add-label <label>

PR title tags:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf] and op tags like [MLA] are left untouched. Add the no-auto-title label to opt this PR out of title tagging.

Comment thread op_tests/test_moe_mxfp8_passthrough.py Resolved
karverma-amd and others added 3 commits August 24, 2026 15:23
Replace PyTorch layout and source-text assertions with an end-to-end
comparison of pre-quantized fp8 activations against internal requantization,
using shuffled MXFP4 weights, GateMode.INTERLEAVE, and the serving env knob
that keeps the fp8 activation path active at decode batch sizes.

Co-authored-by: Cursor <cursoragent@cursor.com>
The CI style job runs black plus a pinned ruff 0.16.0. Drop the unused aiter
import, rewrite the kwargs helper as a dict literal (C408), and add the SPDX
header every other op_tests module carries. Behaviour is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ization

The previous assertion compared the passthrough against a differently-quantized
reference, so its tolerance was absorbing quantizer noise rather than measuring
the branch. Pre-quantizing with the same HIP MX quantizer the internal path uses
removes that variable entirely: both sides hand identical fp8 bytes and
identical scale values to the same GEMM, leaving only the scale sort, and the
outputs are then bit-identical. Exact equality is both a stronger claim and a
simpler one than any tolerance.

Verified sensitive by mutation rather than by passing: skipping the sort, sorting
with inter_dim instead of model_dim, and sorting a row-rotated scale each fail
all three token counts, while the unmodified branch passes all three.

Drops a torch-oracle comparison that disagreed by 0.71 on the unmodified path as
well as the passthrough, so it was measuring a weight-layout mismatch in the
harness rather than this branch. Absolute correctness of the a8w4 MoE is already
covered by test_moe_2stage.py and flydsl_tests/test_flydsl_moe_a8w4.py.

Co-authored-by: Cursor <cursoragent@cursor.com>
@zufayu
zufayu requested a review from yifehuan August 25, 2026 01:22

@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 dismissed valarLip’s stale review August 25, 2026 14:44

it's ok now, the test have been updated

@yifehuan
yifehuan merged commit f3e702a into ROCm:main Aug 25, 2026
54 checks passed
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.

3 participants