Refactor the MXFP8 fused-MLP overrides onto stock parameters - #11
Merged
Conversation
MXFP8FusedGroupedMLP now subclasses stock GroupedExperts directly: the FusedGroupedExperts inheritance is replaced by self-owned w13 registration, stock-layout checkpoint hooks, and param-init/sharding remap helpers, so future MXFP8 fusion paths extend this module without that dependency (none are wired here). Everything renames under the "MXFP8 fused MLP" umbrella (module, classes, factories, debugmodel flavors); the dense class keeps its small FusedSwiGLU base. Bitwise-verified on both paths (5-step deterministic NGPU=2 runs, losses and grad norms identical to the previous revision). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both override classes now keep the stock parameters (w1/w2/w3 dense, w1_EFD/w2_EDF/w3_EFD grouped) and stack the gate/up weights into the composite's w13 operand at forward time, byte-identical to the old merge-hook mapping; the module no longer depends on fused_swiglu. Ckpt-paired 2-GPU runs match the fused-param arm bitwise at print precision (grouped exactly; dense exactly once grad clipping is inert), and fresh-init state dicts match the stock modules bitwise. 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.
Review vehicle for the self-owned MXFP8 fused-MLP refactor. Base =
swiglu-mxfp8-upstream, so this diff is exactly what would land on the open upstream PR (pytorch#4257) on approval. Two commits (honest trail of the design evolution; can squash at approval):88e2e8928— rebase the grouped class offFusedGroupedExpertsonto stockGroupedExperts(self-owned w13), umbrella naming (mxfp8_fused_mlp.py,MXFP8FusedMLP/MXFP8FusedGroupedMLP, one test file).9f44233d3— drop the fused w13 parameterization entirely, dense included: both overrides keep STOCK parameters (w1/w2/w3Linears;w1_EFD/w2_EDF/w3_EFD) and pack the two projections at forward time (torch.stack(..., dim=1/2)— byte-identical to the old merge-hook mapping). All parameter-lifecycle machinery deletes: no param surgery, no state-dict hooks, no init/sharding remaps. The module ends with zerofused_swiglu.pyimports;overrides/fused_swiglu.py(merged-in-main) stays byte-untouched. A future fully-fused grouped path wires in as just another forward-pack + composite (3-line docstring note is the only structural gesture — no knob shipped here).Why stock params
torch.equalper key).Size
Cumulative diff vs main: +846 / −0 (4 files: module 619, tests 200, two registry flavors 27). No validation check or test assertion removed; suite is 8 tests in one file.
Evidence (raw logs in
agent_scratch/upstream_swiglu/validation/{fused_mlp_refactor,stock_params}/)max_norm=1e8, clip coef exactly 1.0) both arms are exactly equal all steps. The sole divergence is the clip total-norm's FP reduction shape (one(H,2,D)grad vs two(H,D)grads), inherent to dropping the fused parameter, not a packing defect.overrides/fused_swiglu.pybyte-identical to main.On approval: fast-forward both commits onto
swiglu-mxfp8-upstream(no history rewrite) and refresh the pytorch#4257 title/description.🤖 Generated with Claude Code