Repository navigation
[Fix] [AMD] ct-fp8-moe: Mark the pre-shuffled CT FP8 MoE weights is_shuffled - #47870
Conversation
[AMD] Update ROCm AITER pin to 4ad9983
…huffled process_weights_after_loading already calls shuffle_weight() on w13 and w2 for the AITER runner -- since sgl-project#17503 -- but has never set the is_shuffled marker. aiter.fused_moe reads that marker -- getattr(w, "is_shuffled", False) -- so it sees False and dispatches the preshuffle_off CK instance for weights that are in fact shuffled. The Quark w8a8 fp8 MoE scheme does the same shuffle and does set the marker; this is the only AITER MoE scheme that omits it. With AITER past ROCm/aiter#6736 the mislabel is no longer silent: _require_shuffled_gfx950_fp8 rejects an unshuffled-looking per_Tensor or per_Token fp8 MoE call on gfx950, so the call raises instead of running the wrong kernel. That fails test_compressed_tensors_fp8_moe_layout.py::test_aiter on all three ROCm flavors and blocks advancing the AITER pin. Set is_shuffled=True on both tensors after the existing shuffle. Verified on MI355X: with the current pin 285579b62 the test passes before and after; with candidate bd4ff1c70 it fails without this change and passes with it, and the loaded CK instance moves from preshuffle_off to preshuffle_on.
|
@lunarwhite — your #45486 added One thing I could not determine: the unpatched path still passes your test on @ch-wan — flagging you as author of the AITER MoE runner abstraction (#23597); |
|
Remaining red is unrelated — the @lunarwhite @ch-wan — ready for review whenever you have a moment. |
…eights copy_or_rebind_param copies the shuffled weights into the existing Parameter, which drops the is_shuffled marker set by shuffle_weight. aiter.fused_moe uses the marker to select the preshuffled CK MoE kernels and to apply tuned fMoE configs. Restore it after each copy, as done for the compressed-tensors FP8 MoE path in sgl-project#47870.
|
Related: #48219 fixes the same bug class in the unquantized BF16 MoE path (layers/quantization/unquant.py). Different mechanism — there shuffle_weight does set the marker and copy_or_rebind_param drops it when copying into the existing Parameter, whereas this path never set it at all. |
Motivation
CompressedTensorsW8A8Fp8MoE.process_weights_after_loadingalready pre-shufflesthe expert weights for AITER. The shuffle was introduced in #17503 (2026-02-16)
and later narrowed to the AITER runner in #45486;
is_shuffledhas never beenset in this file:
but it never sets the
is_shuffledmarker that AITER reads to pick a kernel.aiter/fused_moe.pyresolves the flag withso the default
Falsewins and AITER has no way to know the weights arealready in its shuffled layout. The sibling Quark scheme
(
quark/schemes/quark_w8a8_fp8_moe.py) performs the identical shuffle andsets the marker; this path is the only AITER MoE scheme that shuffles without
tagging.
Two consequences:
preshuffle_offCK instance forweights that are shuffled — kernel and data layout disagree. Visible in
the log as
module_moe_ck2stages_f8_f8_preshuffle_off_b16_silu_per_token_mulWeightStage2.added
_require_shuffled_gfx950_fp8, which rejects an unshuffled-lookingper_Tensor/per_Tokenfp8 MoE call on gfx950. Because this path reportsis_shuffled=False, the call now raises:This is how the problem surfaced: it fails
test/registered/unit/layers/quantization/test_compressed_tensors_fp8_moe_layout.py::test_aiteron all three ROCm flavors in the AMD AITER Scout run that pins AITER to
bd4ff1c70, and it blocks advancing the AITER pin past285579b62.The AITER-side guard is behaving correctly — it caught a real mislabel on our
side. Tagging the tensors is the fix.
Modifications
Set
is_shuffled = Trueonw13_weightandw2_weightimmediately after theexisting
shuffle_weight()calls, matchingquark_w8a8_fp8_moe.process_weights_after_loading. No change to the shuffleitself, to the quantization, or to any non-AITER path — the block is already
gated on
strategy == CHANNEL and _use_aiter and runner_backend.is_aiter().Accuracy Tests
Offline on MI355X (gfx950), one GPU, container
rocm/sgl-dev:v0.5.23-rocm724-mi35x-20261030, SGLang tree pinned to the Scout's01fde5cb6. Every AITER pin verified three ways (aiter/_version.py,git rev-parse HEAD,importlib.metadata) before each run.test_compressed_tensors_fp8_moe_layout.py285579b62(current pin)…preshuffle_**off**…bd4ff1c70(Scout candidate)bd4ff1c70(Scout candidate)…preshuffle_**on**…285579b62(current pin)…preshuffle_**on**…The kernel name is the point: the weight bytes are identical in every row, only
the marker changes, and AITER switches to the instance that matches the layout
this scheme already produces. Row 4 shows the patch is safe on the currently
pinned AITER — it is not coupled to the pin bump.
Also verified: reverting only
44b4fea64(the aiter#6736 commit) on thecandidate restores the pass without this patch, confirming the attribution.
Speed Tests and Profiling
Not measured. The change selects the CK instance that matches the data layout
rather than the mismatched one, so a throughput difference is plausible; this PR
does not claim one.
What this does not cover
The shuffle block is gated on
QuantizationStrategy.CHANNEL. A TENSOR-strategyCT FP8 MoE still reaches AITER with genuinely unshuffled weights, and on a newer
AITER would hit the same guard legitimately. That case needs either a shuffle for
the tensor-strategy path or an explicit non-AITER route; it is out of scope here
and no regression is introduced for it.
Checklist
test_compressed_tensors_fp8_moe_layout.py, which this makes pass on a newer AITER.CI States
Latest PR Test (Base): ❌ Run #41410341187
Latest PR Test (Extra): ❌ Run #41410341144
Latest PR Test (AMD ROCm 10): ❌ Run #41410341013
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: