Skip to content

[SM100] Mega MoE: widen SF ring stride arithmetic to 64-bit - #169

Merged
zcnrex merged 1 commit into
sgl-project:devfrom
yuukidach:fix/mega-moe-sf-stride-u64
Nov 28, 2026
Merged

zcnrex merged 1 commit into
sgl-project:devfrom
yuukidach:fix/mega-moe-sf-stride-u64

Conversation

@yuukidach

Copy link
Copy Markdown

Summary

MegaMoEBuffer sizes l1_sf_buffer, l2_sf_buffer, and shared_l2_sf_buffer with 64-bit byte counts (Buffer::get_num_bytes_per_rank()), and TMA reads those SF buffers using 64-bit cuuint64_t strides, whereas the kernel's SF ring write offsets in sm100_fp8_fp4_mega_moe.cuh still multiplied kNumSFRingTokens / kNumSharedSFTokens in 32-bit uint32_t:

  • Byte-addressed L2 SF store (!kIsNVFP4): k_uint_idx * mn_stride wraps 2^32 (4 GiB) when the full-pool SF ring exceeds 4 GiB (e.g., ep_size=8, num_experts=384, topk=4, num_max_tokens_per_rank=32768, where kNumSFRingTokens = 17,879,040 and mn_stride = 71,516,160 bytes wraps at k_uint_idx >= 61), leaving the upper SF columns read by 2D TMA zero-initialized.
  • Word-addressed L1 / L2 SF stores (local_sf_ptr and kIsNVFP4 sf_u32_ptr): j * kNumSFRingTokens and n_block_idx * mn_stride_u32 wrap uint32_t once the SF buffer exceeds 2^32 uint32_t words (16 GiB).

Widen the SF ring stride/offset multiplications in sm100_fp8_fp4_mega_moe.cuh to uint64_t so kernel stores match the 64-bit buffer layout and TMA descriptors.

Verification

  • Instantiated and compiled sm100_fp8_fp4_mega_moe_impl (MmaKind::NVFP4 TMA/SIMT pull and MmaKind::MXFP8FP4) with nvcc -std=c++20 -O3 -arch=sm_100a.

@zcnrex
zcnrex merged commit 9d1777d into sgl-project:dev Nov 28, 2026
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.
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.

2 participants