Repository navigation
[AMD][DSV4] feat: MXFP8 activation passthrough in fused_moe - #4954
Merged
Merged
Conversation
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>
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
PR title tags: |
Merged
4 of 5 tasks
valarLip
previously requested changes
Aug 24, 2026
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>
yifehuan
dismissed
valarLip’s stale review
August 25, 2026 14:44
it's ok now, the test have been updated
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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