MUSA: add calibrated FP8 MoE backend selection on S5000#114
Merged
Conversation
yeahdongcn
force-pushed
the
xd/musa-60024-auto-moe-gemm
branch
from
July 21, 2026 09:12
cfd88fa to
9e16196
Compare
yeahdongcn
marked this pull request as ready for review
July 21, 2026 19:29
yeahdongcn
force-pushed
the
xd/musa-60024-auto-moe-gemm
branch
from
July 22, 2026 06:39
599cb80 to
7fd1582
Compare
yeahdongcn
force-pushed
the
xd/musa-60024-auto-moe-gemm
branch
from
July 22, 2026 06:48
7fd1582 to
92ed7ab
Compare
yeahdongcn
force-pushed
the
xd/musa-60024-auto-moe-gemm
branch
from
July 22, 2026 07:36
92ed7ab to
943e5e0
Compare
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.
Summary
Mdecode windows;eager prefill calls, and use the established upstream path in between;
normal serving path while retaining generic diagnostic overrides;
DeepGEMM identity, and graph-replay evidence tooling.
Mishidden_states.shape[0]for one MoE invocation, not HTTP batch size orper-expert route count.
Rebase status
v0.24.0-dev@4416dc24b00afcb46ebe96b34308fda96d30ed36(Qwen3.5 MoE optimizations, Qwen3.5 moe optimizations #113)
599cb804080e886344098a68c4e2a01fbbd90210943e5e0eaefc8d25cb24c249da0842b6205add64The measured head has tree
b1e8cc7bb4b0b4b38985b64220bc60e1c6c8238b.The review head has tree
dfee058a43cc3755318ea8fdc86aed01479b08ffand differsonly by a fail-closed DeepGEMM scale-expansion guard plus its regression test
(two files, 37 added and two replaced lines). Calibrated block-scale layouts
do not enter the new exception branch, so the measured production paths and
hardware attribution are unchanged; the latest head was rechecked with the
focused Python/meta suites rather than rerunning the full serving matrix.
The review commits are:
MUSA: add calibrated FP8 MoE backend dispatchbench: add S5000 FP8 MoE calibration toolsbuild: package the MUSA JIT include markerdocs: document S5000 FP8 MoE backend selectionQwen3.5 compiled serving on the current base also needs the GDN compile fix
from #115 (
511cde18fe6a80cec15d8083a9e70a28c07ee057, currently open). TheQwen A/B below applied that identical validation-only fix to both arms, so its
performance delta remains attributable to this dispatcher. DSV2/DSV4 do not
depend on #115, and this PR intentionally does not duplicate the GDN change.
The offline folded-Qwen TP4 shape is
E=257, N=256, K=2048, topk=9. Itsmulti-route sweep and graph replay qualify
M <= 48for the synthetic foldedshape, but the live
Qwen3_5MoeForConditionalGenerationcheckpoint followsthe
qwen3_5.pypath and does not activate the post-#113 shared-expert fold.The production auto policy therefore intentionally retains the existing
E=256/topk=8behavior and has no E=257 threshold.Final auto policy
MME=256/topk=8M <= 13E=257/topk=9M <= 5M <= 5M <= 3E=64)M = 1E=64)Unknown devices/shapes, unsupported layouts, and unsafe capture states fail
closed. Explicit
upstreambypasses both GEMV and DeepGEMM for diagnosticrollback. Diagnostic grouped GEMM remains disabled in
autountil it hasseparate correctness and serving evidence.
S5000 serving A/B
Environment: isolated 8x S5000, driver
3.3.5-server, torch/torch_musa2.9.1.post1+musa5.2.0s5000, torchada0.1.72, MATE/flash_attn_30.2.4.Every row used exact 4096 input and 1024 output tokens at BS 1/4/16/64, prefix
caching off, independent cache roots, normal compiled/captured serving, zero
failed requests, and exact per-request output lengths. DSV2 rows are
three-repetition medians; DSV4 and Qwen3-VL rows are one paired repetition.
No measured regression crosses the predeclared 3% remediation gate. The DSV2
single-token decode gain survives the stricter capture boundary without a
material regression at the larger batch sizes. Qwen3-VL uses an uncalibrated
E=128,N=192MoE shape and verifies thatautoremains on upstream.The missing Qwen3.5-35B-A3B base-vs-PR comparison was rerun on an isolated TP4
S5000 lease on 10.20.35.71. The base arm was exact post-#113 plus the common
PR115-equivalent GDN compile fix; the candidate was the measured PR head plus
the identical fix. The arms used their separately compiled native extensions, torchada
0.1.76, normal compilation/CUDAGraph, independent measurement caches, exact
4096/1024 token lengths, and three repetitions except BS64. Logs prove that
base had no auto dispatcher, while candidate selected the E=256/topk=8 M13
GEMV policy in both eager and capture and retained DeepGEMM for large prefill.
This directly validates the shipped E256/M13 policy: it improves BS1/4 decode
by about 9% and leaves BS16/64 within 0.5% of the post-#113 base.
A separate folded-shape experiment was completed on 10.20.35.88 with the
common GDN fix applied identically to both validation arms. It passed normal
compiled startup, CUDAGraph capture, the DeepGEMM prefill gate, and semantic
output. Both arms already contained the existing E=256/topk=8 policy; the
candidate-only E=257/M48 policy was not observed, so this table is a no-op
policy check rather than a base-vs-PR comparison.
Because the new policy was not exercised and the conservative no-regression
screen failed at BS64 TPOT by 1.03%, the M48 candidate was removed from the
PR worktree. The measured result therefore remains an upstream-path
no-op check, not evidence for an E=257 threshold.
Correctness and tests
torch/MUSA container using meta tensors; device capability was stubbed only
to avoid driver initialization and no MUSA kernel was executed
raising before the DeepGEMM eligibility gate
py_compile, andgit diff --checkM=1/2/3: eightbalanced/random/hot replays per point, bitwise-equal outputs and zero max
absolute difference
M=1GEMV=1/upstream=0;M=2/3GEMV=0/upstream=1
10.20.35.88; candidate E=257/M48 policy not observed, so upstream behavior
retained
10.20.35.71; BS1/4 improve by 9.84%/9.00% and BS16/64 stay within 0.5%
The earlier headline serving table remains withdrawn: its Qwen baseline
compiled TileLang kernels inside the measured BS1 run while the candidate
inherited a warm global cache, and it predates #113.
Scope
This optimizes S5000 block-128 E4M3 FP8 MoE execution. It does not make a raw
MXFP8 checkpoint directly executable; MXFP8 weights still require transcoding
to the supported representation.