Wire the fully-fused grouped-GEMM MXFP8 plan behind fusion_plan - #12
Draft
wolfcomos wants to merge 1 commit into
Draft
Wire the fully-fused grouped-GEMM MXFP8 plan behind fusion_plan#12wolfcomos wants to merge 1 commit into
wolfcomos wants to merge 1 commit into
Conversation
MXFP8FusedGroupedMLP.Config and the mxfp8_fused_grouped_mlp factory gain a
fusion_plan knob ("swiglu" default, byte-inert; "grouped_gemm_swiglu"),
porting the gate-proven composite of the four fused torchao grouped-GEMM
ops. The stock w1_EFD/w3_EFD parameters pack to the kernels' 32-block
[E, 2F, D] GLU row order at forward time (byte-verified in the tests); the
factory installs the pad_multiple=256 TorchAO dispatcher the kernels
require, refuses other dispatchers, and raises actionably (naming the
torchao module and cudnn requirement) until the torchao ops land upstream.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Stacked on
swiglu-mxfp8-upstream(pytorch#4257) — this diff is exactly the follow-up wiring change: +1087/−29 across the override module, the single test file, and one registry flavor. Kernel dependency: pytorch/ao#4820 (the four fused grouped-GEMM ops); until it merges, selecting the plan raises with the dependency named. On approval this becomes the separate upstream pytorch/torchtitan PR, opened after pytorch#4257 merges and ao#4820 lands.What it adds
MXFP8FusedGroupedMLP.Configgainsfusion_plan: Literal["swiglu", "grouped_gemm_swiglu"] = "swiglu":"swiglu"(default): unchanged — the existing composite,pad_multiple=128."grouped_gemm_swiglu": the whole routed-experts MLP runs through [mxfp8 training] Add fused grouped GEMM + SwiGLU + MXFP8 quantization ops for MoE routed experts pytorch/ao#4820's four ops (FC1 grouped GEMM + SwiGLU + dual MXFP8 quantization in one launch, FC2 GEMM, fused dSwiGLU backward, wgrad). Parameters stay stock — the forward packsw1_EFD/w3_EFDinto the kernels' 32-block[E, 2F, D]order (byte-verified against the proven mapping, with an unpack round-trip test). The factory installs thepad_multiple=256dispatcher the kernels' hard per-expert alignment requires (update-in-place for an existing TorchAO dispatcher, swap for AllToAll, refuse otherwise), and raises actionably on unknown plans,fuse_activation=Falseunder this plan, or missing ops.Because both plans share the stock-parameter structure from pytorch#4257, the plan differs only in its forward pack + composite: checkpoints, fresh init, and sharding are identical across plans and identical to stock modules. Only 3 executable pre-existing lines changed in the module (import, dispatcher call re-indent,
derivekwarg); the swiglu Functions/helpers/forward are byte-untouched.Evidence
deepseek_v3_debugmodel_mxfp8_fused_mlpflavor run from a shared seed checkpoint at the base commit vs this commit (NGPU=2 EP=2, 5 deterministic steps) — every printed loss and grad-norm equal (8.12229/3.6271 → 4.52541/2.4915, both arms).deepseek_v3_debugmodel_mxfp8_grouped_gemm_mlp, fresh init, EP=2): plan active on all 5 MoE layers, loss 8.036 → 4.682.torch.compilevs eager bitwise on outputs and all three weight grads, rejection matrix, checkpoint-keys == stock, and the 32-block pack byte-verification. Reference helpers and thresholds are identical to the previously gate-proven suite.overrides/fused_swiglu.pyremains byte-untouched.Performance
Measured end-to-end with these kernels at DSv3-16B EP=4 (details and pad-tax table in pytorch/ao#4820): +2.3% tokens/s over the pad-matched unfused MXFP8 baseline at bs4, +5.0% at bs8, with paired-seed loss-parity gates and a 3-seed × 500-step convergence protocol.
🤖 Generated with Claude Code