Skip to content

feat(mega): capture MXFP4 L1 pool across ring wraps - #12

Merged
morgendave merged 2 commits into
mainfrom
codex/mxfp4-full-pool-capture
Sep 8, 2026
Merged

morgendave merged 2 commits into
mainfrom
codex/mxfp4-full-pool-capture

Conversation

@morgendave

@morgendave morgendave commented Sep 5, 2026 •

Copy link
Copy Markdown

Fix native MXFP4 MegaMoE training when the block-padded expert pool exceeds the reusable communication ring. The forward kernel now optionally persists the exact dispatched FP8 L1 rows and column-major UE8M0 scales in a full-pool destination while continuing to use the bounded ring for compute. Includes a distributed extreme-routing regression with active pool 1536 rows and ring capacity 768 rows; forward capture and backward pass on 2x B300.


Note

Medium Risk
Touches a hot SM100 fused MoE forward path and backward synchronization; optional buffers default off, but incorrect capture or barriers could affect distributed training correctness.

Overview
Adds optional saved_l1_acts / saved_l1_acts_sf to FP8×FP4 MegaMoE so training can keep the full block-padded expert pool when it is larger than the reusable L1 ring. The dispatch path still feeds the ring for compute, but when capture is enabled it also writes the exact FP8 rows and column-major UE8M0 scales into caller-provided pool buffers.

The change threads through Python → C++ bindings → JIT launcher → sm100_fp8_fp4_mega_moe, with compile-time kSaveL1Acts and stricter tensor layout checks (including block_m alignment for saved preact/down pools). Backward gets a full-grid barrier when route gradients run without W13 dgrad, so route reduction sees L2-dgrad/SwiGLU rows from every CTA; PRE_DOWN unweighted h-weighting is gated on kCompileW13Dgrad.

Tests extend --active-saved-pool to the FP8 path (ring-wrap regression, capture vs gathered inputs, backward using saved L1), tighten POST_DOWN semantics, and broaden wgrad/route-only checks (including multi-rank backward).

Reviewed by Cursor Bugbot for commit affab4d. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: medium. Left a non-blocking comment and did not approve: this PR changes a performance-critical MXFP4 MegaMoE dispatch/capture path (CUDA kernel, JIT, and public API), which is above the low-risk auto-approval threshold. Cursor Bugbot completed with no issues; human review is needed. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium. Left a non-blocking comment and did not approve: this PR changes a performance-critical MXFP4 MegaMoE dispatch/capture path (CUDA kernel, JIT, and public API), which is above the low-risk auto-approval threshold. Cursor Bugbot completed with no issues; human review is needed. No reviewers were assigned.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Approver

@morgendave

Copy link
Copy Markdown
Author

Sealed at affab4d17a8effc20fb03cc3ac973acc7c4a0c87 with downstream integration pinned by Fireworks #47249 at 3ab8a343b44ac396f88abc6c6ec6c4e4a1288558.

The full 8×B300 DSV4-Flash 262K native-MXFP4 MegaMoE E2E passed forced-rank-imbalance correctness, three bitwise-identical 262K forward replays, DPO, DCP save/fresh-trainer replay/same-trainer resume, weights-only RL restore, four RL hotloads (all K3 below 0.004), and complete-step profiling. Final warm F/B was 9.239s, matching the sealed 9.203s local median. No remaining integration or correctness blocker; human review is the only merge gate.

@morgendave
morgendave merged commit af33cd8 into main Sep 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants