Repository navigation
[SM100] BF16 Mega MoE: share expert counts and send buffers in smem - #178
Merged
Merged
Conversation
PR #161 made the host size the dispatch region as max(expert_token_count, dispatch_send_buffer), matching the union it added to the FP8xFP4 kernel. The BF16 kernel shares that host function but kept the two as separate 1 KiB-aligned fields, so its SharedStorage is 1 KiB larger than the launched dynamic smem and its barriers sit past the end. On B300 the 2-rank bf16xbf16 test (hidden 1024, 8 experts) faults on warp 1's dispatch-barrier init (Warp Out-of-range Address, STS at smem 0x35c40 with smem_size=219524), and DeepEP reports it later as symmetric.hpp:136 Cuda failure 700. The two lifetimes are disjoint in the BF16 kernel as well: the counts are last used before the dispatch NVLink barrier and the pull buffer only after. Co-Authored-By: Claude Opus 5.5 <[email protected]>
zcnrex
added a commit
that referenced
this pull request
Nov 28, 2026
Git carried the three PRs' edits through the *_inference renames. Co-Authored-By: Claude Opus 5.5 <[email protected]>
aryatsc
added a commit
to aryatsc/DeepGEMM
that referenced
this pull request
Nov 28, 2026
Brings in sgl-project#170, sgl-project#165, sgl-project#169, sgl-project#178 and sgl-project#171. Conflicts: - csrc/jit_kernels/impls/sm100_fp8_fp4_mega_moe.hpp: the K=64 switch is now `uses_packed_fp4_weights(config.mainloop)` (sgl-project#165); the row-shuffled FP8 x FP4 layout asserts that mainloop instead of `config.use_sm107_k64`. The kernel template takes the mainloop in place of the two K=64 / K=96 flags, followed by this branch's four parameters. - deep_gemm/include/deep_gemm/impls/sm100_fp8_fp4_mega_moe.cuh: sgl-project#165's mainloop plan and validity check replace the K=64 static assert; the base MMA loop is taken from dev (now under `run_base_loop`) with this branch's SFB word order for row-shuffled packed FP4 weights re-applied in it.
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.
Problem
On B300, every BF16 Mega MoE launch on
devI tried hits an illegal memory access. DeepEP reports it later assymmetric.hpp:136 ... Cuda failure 700.#161 changed
get_pipeline_config_for_mega_moeto size the dispatch region asmax(expert_token_count, dispatch_send_buffer), matching the union it added to the FP8xFP4 kernel. The BF16 kernel uses the same host function but still lays the two out as separate 1 KiB-aligned fields. ItsSharedStorageis therefore 1 KiB larger than the dynamic smem it is launched with, and every mbarrier sits past the end.Evidence (2-rank, hidden 1024, 8 experts, top-2):
CUDA_LAUNCH_BLOCKING=1moves the error to thebf16_mega_moelaunch. It happens in the first non-graph call, so CUDA graphs and DeepEP are not involved.Warp Out-of-range AddressatSTS.64 [R3+0x35c40], which is warp 1 initialising the dispatch barriers. 0x35c40 = 220224 >smem_size=219524.Fix
Put the two fields in a union, as in the FP8xFP4 kernel. Their lifetimes are disjoint here too: the counts are last used before the dispatch NVLink barrier, and the pull buffer is used only after it.
sizeof(SharedStorage)now equals the hostsmem_size(219524).Tests (B300, fix vs dev)
test_mega_moe.py2-rank bf16 (therun_tests.shcase), corr + 24 graph replays, x3--post-expert-normtest_mega_moe.py --num-processes 8 --mma-type bf16xbf16(default shape)test_mega_moe_bf16_trtllm.pyThe upstream-sync PR renames this kernel to
sm100_bf16_mega_moe_inference.cuhwith the same separate fields, so it needs the same change.🤖 Generated with Claude Code