Repository navigation
[SM100] Mega MoE: Inkling2 weight layout, SiTU for NVFP4 / FP8xFP8, broadcast output - #149
Merged
Merged
Conversation
…roadcast output - `weight_layout='inkling2'`: read checkpoint expert tensors in place (per-row gate/up interleave, CUTLASS 128x4 SF atoms); TMA descriptors permute L1 rows into the `megamoe` SMEM order, so the epilogue is unchanged. - SiTU activation allowed for `nvfp4xnvfp4` and `fp8xfp8`. - `broadcast_y` + `SymmBuffer(gather_output=True)`: the combine writes each row into every rank's gathered `y`, replacing an all-gather after the kernel. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Accept empty broadcast batches: locate `y` through its storage, since an empty tensor's `data_ptr()` is null (Python and C++ checks) - Compute the `y` offset only for `broadcast_y`, with integer math - Keep a broadcast `y` when `DG_COMM_KERNEL_DEBUG` zeroes the buffer - Release `gathered_y` in `SymmBuffer.destroy()` Co-Authored-By: Claude Opus 5.5 <[email protected]>
zcnrex
marked this pull request as ready for review
November 13, 2026 18:26
This was referenced Nov 13, 2026
zcnrex
added a commit
to zcnrex/sglang
that referenced
this pull request
Nov 18, 2026
0.2.9 adds the MegaMoE Inkling2 weight layouts, SiTU and broadcast output (sgl-project/DeepGEMM#149, sgl-project#151). Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Inkling2 routed experts (no shared experts; NVFP4 layers and FP8 layers with per-32 UE8M0 scales) use a SiTU-style capped SwiGLU and are loaded with gate/up rows interleaved per row and weight SFs in CUTLASS 128x4 atoms. Running them through
fp8_fp4_mega_moetoday needs:nvfp4xnvfp4/fp8xfp8(it was gated tofp8xfp4).megamoe-layout copy of every L1 weight and SF (~1 GB per NVFP4 layer, ~2 GB per FP8 layer per GPU), since the serving engine's other MoE paths keep the checkpoint layout.Change
SymmBuffer/transform_weights_for_mega_moechecks now acceptnvfp4xnvfp4andfp8xfp8withactivation='situ'.weight_layout='inkling2'. Reads the loaded tensors in place (routed only, not localized):megamoeSMEM order, so the MMA and epilogue are unchanged.broadcast_y. WithSymmBuffer(..., gather_output=True),sym_buffer.gathered_yholds every rank's output rows (rank-major). The combine stores each finished row into every peer'sgathered_yover NVLink, then the epilogue fences, grid-syncs, and exchanges anoutput_ready_grid_idxtag with each peer soyis complete on return. Cleared withcombine_ready_grid_idxfor graph replay.use_inkling2_weightsandbroadcast_yadded tofp8_fp4_mega_moe; both default off, so existing callers are unaffected.0f96f72. Its dispatch count push differed from [SM100] Mega MoE: batch the dispatch counters and let every SM wait on the NVLink barrier #147; this keeps [SM100] Mega MoE: batch the dispatch counters and let every SM wait on the NVLink barrier #147's version (redfor SIMT pull,atomotherwise).Tests
GB300, EP4 (4 ranks), CUDA 13.0, this branch built with
build_sgl_deep_gemm.sh. Synthetic experts with Inkling2 shapes (384 experts, top-8, hidden 4608, intermediate 2304): NVFP4, and FP8 with per-32 UE8M0 scales. Random routing, 1/8/64/256 tokens per rank.inkling2layout =megamoelayout. In-placeinkling2weights vstransform_weights_for_mega_moecopies, SiTU: bitwise equal for NVFP4 and FP8xFP8 at every size. Kernel time is the same (CUDA graph, us,megamoe/inkling2):Same results as the original patch.
inkling2outputs from this branch vs the same patch on0f96f72(v0.2.6, the build SGLang runs): bitwise equal, 32/32 (2 layers x 4 sizes x 4 ranks). So the port ontodev, including the count-push conflict, changes no output.Existing paths unchanged.
megamoelayout with SwiGLU, NVFP4 and FP8xFP8: this branch vsdev(75cfbcd) bitwise equal, 32/32. Kernel time within 0.3%.broadcast_y. Real Inkling2 layers 0 (NVFP4) and 40 (FP8xFP8) interleaved on one shared symmetric buffer. Broadcast output vs plainy+ NCCL all-gather: bitwise equal at 1/7/64/253/1024 tokens eager and under CUDA-graph replay (3 replays each, with and without broadcast), and eager at 4096 and 16384 tokens.Empty broadcast batches and debug mode. Same layers: 0-token broadcast calls interleaved with 7/64/253-token calls, and 3 CUDA-graph replays of a 0-token call followed by a 7-token call, all bitwise equal to the NCCL reference. Also bitwise equal with
DG_COMM_KERNEL_DEBUG=1.SymmBuffer.destroy()frees the allocation while the object is still alive.Not run:
tests/test_mega_moe.py(needs DeepEP), fp8xfp4, shared experts, B200, CC 10.7.🤖 Generated with Claude Code