Repository navigation
perf(megamoe): overlap MXFP8 input replay and accelerate weighted backward - #7
Merged
davidhe91 merged 2 commits intoDec 3, 2026
Conversation
davidhe91
merged commit Dec 3, 2026
1a3dcd6
into
davidhe91:megamoe-ascend950-integration
1 check failed
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.
MXFP8 selective input replay currently runs as a separate dispatch/quantization launch before backward, and activation replay loses the adjacent-expert Vector preparation pipeline. The weighted SwiGLU-gradient path also uses a small scalar-synchronized reduction tile. This change overlaps Pull input restoration with backward and reduces weighted-backward overhead while retaining both probability-weighting modes.
MegaMoeNumericsOptions(apply_probs_before_fc2=...)and its defaultFalse. Both before- and after-FC2 branches remain available. Keep the upstream delayed conversion for post-FC2 weighting. Push retains its separate replay path; Token Wave retains its existing supported combinations.Matched single-host eight-card results
Base
3b677e1; candidate2f3c1b2. Ascend950, CANN 9.2.2 / PTA 2.12, EP8, 4096 tokens/card, H7168, I2560, 64 routed experts, TopK8, one same-width fused shared expert, fixed balanced routing, Pull, FP32 partial weight gradients. Device routing is enabled for all ten benchmark cases.100 warmups followed by 3 × 100 samples per case; take the maximum across eight ranks for each iteration, then P50. Forward/backward use Event timing; full F+B uses independently measured wall time. The measured MoE includes preparation, routed/shared expert execution, communication and waits. Router logits/top-k generation, Attention, FSDP, optimizer, inter-iteration gradient clearing and the pre-timing barrier are outside the window. Independent phase maxima/P50s are not additive.
This performance-only rerun reuses the pinned native payloads and prior exact-source numerical validation. It does not repeat numerical comparisons, profiling or phase-memory sampling.
With input + activation replay, candidate backward adds 0.759 ms (6.4%) after FC2, or 0.766 ms (6.5%) before FC2, relative to its own saved-tensor path. These selective cases do not separately enable shared-expert replay. Full MoE checkpoint includes the shared expert; its backward timing includes the recomputed forward and does not represent a full Transformer-layer checkpoint.
Before-FC2 forward regresses by 5.0% without replay and 8.7% with input + activation replay; its cause is not established. The gain is concentrated in backward. The 1.5% full-checkpoint and 2.0% default saved-path reductions are small observations; the run has no confidence interval or randomized case ordering. Prior matched saving-mode memory checks found peak allocated memory effectively unchanged. This change targets overlap/throughput rather than additional peak-memory savings. Single-host EP8 does not validate EP64 inter-node performance.
Full-module useful MFU uses 865 TFLOPS/card and 4.058744 TFLOP/card forward, twice that backward; replay FLOPs are excluded. Candidate F+B MFU is 73.25% before FC2 without replay, 70.11% before FC2 with input + activation replay, and 53.05% for after-FC2 full MoE checkpoint. These are module measurements, not core-kernel measurements.
Validation
git diff --checkpassed.ModelArts job:
c3798e42-09b7-47dc-9539-1c01333d4a52. Evidence:obs://s3-asset-g-ma-hlge-infra-training/r00988599/ai-trials/20261203-ep8-rebased-integration-v3/results/ep8-rebased-integration-20261203T045539Z-832f602b/node0/(comparison CSV/JSON, all-rank timing/numerics/memory, device-test XML and native/source identities).Target-width reports:
obs://s3-asset-g-ma-hlge-infra-training/r00988599/ai-trials/20261203-ep8-rebased-integration-fullwidth-oracle-v5/results/ep8-rebased-integration-20261203T050914Z-a1cdb2c4/node0/(full-width-p0.json,full-width-p1.json; original status records the post-test summary error).Latest performance-only evidence:
obs://s3-asset-g-ma-hlge-infra-training/r00988599/ai-trials/20261203-megamoe-ep8-fullshape-perf-2f3c1b2-v1/results/fullshape-performance-20261203T053812Z-f3977f57/node0/(10 cases, 24,000 rank/iteration samples and 80 resolved-runtime records independently checked; source/native identities, raw global-max P50s and useful MFU verified).