Repository navigation
Fix MegaMoE combine readiness under CUDA graph replay (cherry-pick deepseek-ai#451) - #59
Merged
zyongye merged 3 commits intoNov 12, 2026
Conversation
CUDA graph replay can reuse the kernel grid ID. Clear local peer-ready flags before the existing pull barrier so a later replay cannot consume the previous invocation's combine data when inputs change. Preserve the workspace layout and existing barriers. Validated on 8 B300 ranks with input staging, unequal/empty source ranks, and successive CUDA graph replays with updated inputs (3 tests passed per rank). Co-authored-by: Codex <[email protected]> Signed-off-by: foreverrookie <[email protected]> (cherry picked from commit d7442af)
Reset peer-ready flags before the existing pull barrier, matching the FP8/FP4 path and preventing stale completion tags on graph replay. Co-authored-by: OpenAI Codex <[email protected]> Signed-off-by: foreverrookie <[email protected]> (cherry picked from commit 7e924a8)
… NVFP4 kernels Apply the readiness reset of deepseek-ai#451 to the SM100 FP8xFP4 SiTU and NVFP4 MegaMoE kernels, which tag combine readiness with the grid index in the same way. The SM90 kernel already clears it before the pull barrier. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Thien Tran <[email protected]>
gau-nernst
force-pushed
the
megamoe-graph-replay-readiness
branch
from
November 12, 2026 06:16
ea1e31f to
dfb8c57
Compare
6 tasks done
This was referenced Nov 13, 2026
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.
Cherry-pick of deepseek-ai#451 ("Reset MegaMoE combine readiness for CUDA graph replay", still open upstream) onto
dev, extended to the SiTU and NVFP4 kernels. This is the MegaMoE counterpart of #48 (deepseek-ai#478). deepseek-ai#478 notes that MegaMoE combine readiness has the same stale-tag problem and that deepseek-ai#451 addresses it.Problem
MegaMoE tags combine readiness with the launch's
%gridid(grid index + 1). A CUDA graph kernel node keeps the same%grididon every replay, so at EP > 1 a rank can accept a peer's readiness tag left over from the previous replay. It then reads that peer's combine data before the current launch's L2 writes land, and returns stale outputs.Fix (upstream)
Before the existing dispatch pull barrier, each rank clears its local
combine_ready_grid_idxflags with one system-scope store per rank. The barrier orders that reset before every peer's current L2 completion notification. There is no new barrier and no workspace or ABI change.Commits
layout/mega_moe.cuh, which I merged withdev's current description.devand tag readiness the same way. The SM90 kernel already clears these flags before the pull barrier.sm100_fp4_fp4_mega_moedoes not use readiness tags.Test
4x GB200,
python tests/test_mega_moe.py --num-processes 4 --num-max-tokens-per-rank 1000 --num-tokens 1000 --hidden 2560 --intermediate-hidden 640 --num-experts 256 --num-topk 8 --num-shared-experts 0 --emu-reference --num-correctness-tests 1:dev(0f7698f)CUDA graph replay 2 differs from the eager launchThis graph check covers the FP8×FP4 SwiGLU kernel. The BF16, SiTU and NVFP4 kernels receive the identical change. In this repo's tests, the BF16 check needs a DeepEP baseline, and the SiTU and NVFP4 tests do not compare graph replays against eager launches.
AI assistance (Claude) was used for this port and its validation.
🤖 Generated with Claude Code