Skip to content

Merge deepseek-ai/DeepGEMM main (public release 26/11/26, #525) into dev - #177

Merged
zcnrex merged 4 commits into
devfrom
chunan/sync-upstream-261126
Nov 28, 2026
Merged

zcnrex merged 4 commits into
devfrom
chunan/sync-upstream-261126

Conversation

@zcnrex

@zcnrex zcnrex commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Merges deepseek-ai/DeepGEMM main (public release 26/11/26, deepseek-ai#525) into dev. Parents are dev (c7b056f, #165) and upstream 09e7d8e7. A second merge brings in dev up to 12be8d3 (#169, #178, #171). Git carried their edits through the *_inference renames, and each file's changed lines match dev's own diff.

What the merge keeps

  • Mega MoE: keeps dev's kernels (NVFP4, TRT-LLM layouts, SiTU, norm, SIMT pull, SM103 K96 / SM107 K128) and moves them to upstream's renamed *_inference paths. Upstream's async-proxy fences and L2 k-block dependency waits are ported into the FP8/FP4 and BF16 kernels. Upstream's *_inference Python names alias dev's functions. Upstream's deep_gemm/mega_moe package is not taken.
  • Mega mHC: takes upstream's kernel (Shifted only), with dev's in-CTA Norm, task queue, FlashInfer 128x4 SF and non-exclusive TMEM on top. Upstream's get_num_splits is kept, because dev's split refinement measured 3.5–5.2% slower on 3 rows.
  • GEMM / HC: upstream's bias path, FP32 HC prenorm input, and the FP8 stochastic-rounding epilogue in the sgl binding. DeepJIT is pinned to 6e4bba88.

Fixes on top of a plain merge

  1. mHC CUDA 720 on SM107. Upstream launches cooperatively, which fails together with CU_SHARED_MEMORY_MODE_ALLOW_OVERSIZED_SHARED_MEMORY (in-CTA Norm). The launch is now cooperative only when oversized mode is not used; that mode already keeps one CTA per SM resident.
  2. mHC in-CTA Norm gate. In-CTA Norm was 3.6–4.0% slower at T=32768, hidden=7168 with the dual routed/shared SF output. It now defaults off for that case (y_shared_sf and hidden >= 7168), and DG_MHC_IN_CTA_NORM overrides the default.
  3. sgl tests: reduce → splitKreduce. Upstream's bench L2 flush now launches a torch reduce_kernel, so the old kineto name matched twice. Upstream's own tests already use splitKreduce.

Validation

Base is #165 (65167ac, same tree as dev c7b056f) against this merge. Both arms run on the same GPU in ABBA order with 2 reps each. A row is flagged when merge/base > 1.03 and more than twice the A/A spread. "Geo" is the merge/base geomean; lower is faster.

Tests. The full sgl suite passes on SM107 (VR) and on B300, except for failures that also occur on base:

  • B300 test_mega_moe.py bf16xbf16, 2-rank, graph replay: IMA inside DeepEP symmetric.hpp. It failed 3/3 on base and 3/3 on merge. The cause is the BF16 kernel's shared-memory layout, fixed by [SM100] BF16 Mega MoE: share expert counts and send buffers in smem #178, which is now merged in here (not re-run on B300).
  • VR: test_cublaslt_batched_syrk diff 7.2e-7, plus DeepEP NCCL IB RETRY_EXC_ERR in the multi-rank Mega MoE tests (environment).

Upstream's FP32/BF16-input HC test passes.

After the dev re-sync (SM107, base = dev 12be8d3, ABBA). Both suites give 25 passed, 3 failed, with the same 3 failures (the syrk tolerance and the DeepEP IB errors above).

Row Geo (merge/base)
Mega mHC 0.895
Mega MoE NVFP4 1-rank decode T32 / prefill T4096 0.998 / 1.000
Mega MoE EP4 global_tokens (two NVFP4 shapes) 0.999 / 0.996
Mega MoE fp8xfp4 SiTU top16 masked decode T40 / T160 1.023 / 1.010

The fp8xfp4 decode rows are a harness artifact, not a kernel cost. Upstream changed bench_kineto's L2 flush from .zero_() to .sum(), and each arm imports its own deep_gemm.testing. Two bisect runs on SM107 (8 reps per cell, timed from HBM GB/s) show this:

Arm T40 vs base T160 vs base
merge +0.8..1.1% +0.4..0.5%
merge, all 6 ported fences and the new nvlink_barrier sync removed +1.0% +0.5%
base timed with merge's .sum() flush +0.9% +0.5%
merge timed with base's .zero_() flush +0.2% −0.0%

The vs-#165 numbers below (1.011 / 1.006) have the same cause.

Area SM107 (VR) geo B300 geo Flagged
Attention 0.982 0.967 B300: 1 row at 13 us (70→67 TFLOPS; integer-us timer, kernel source unchanged)
BF16 GEMM 1.001 0.928 0
FP8 GEMM 0.971 0.920 0
m-grouped contiguous 0.998 0.978 0
m-grouped masked 0.972 0.909 0
HC prenorm 0.967 0.936 0
Mega mHC ~0.89 (every row ≤ base) 0.895 0
Mega MoE NVFP4 1-rank decode T32 / T128 1.002 / 1.001 0.866* / 1.001 0
Mega MoE NVFP4 1-rank prefill T4096 0.999 0.958 0
Mega MoE fp8xfp4 SiTU top16 masked decode T40 / T160 1.011 / 1.006 0.932 / 0.962 0
Mega MoE EP4 global_tokens (two NVFP4 shapes) 1.001 / 0.958 – 0
Mega MoE EP8 fp8xfp4 T4096 – 0.997 0
Mega MoE EP8 / EP4 NVFP4 T4096 – 1.000 / 1.000 0

* B300 decode T32 has 30% A/A noise.

E2E (SM107, internal NVFP4 mega-MoE model, DEP16 on 16 GPUs, ABBA arms). Both arms load their own deep_gemm package; this was checked on every rank.

base base2 merge merge2
GSM8K-200 (T=1.0, top_p 0.95) 96.5 96.0 97.0 96.0
  • Prefill (median ms, mean of the 2 arms): 16x8k 400.1 → 399.2, 16x32k 1325.1 → 1327.9, 16x64k 2402.8 → 2399.5, R16x32k 1219.4 → 1222.0, R64x2k 402.8 → 401.2. All within ±0.4%.
  • The short-prompt rows R16x2k and R16x4k come out +1.4% / +1.1%, but base-vs-base2 already differs by 4.3% / 2.2% there. The 64x2k row has multi-second outlier reps in both arms.

E2E (SM107, open NVFP4 MoE model with BF16 Mega MoE layers, TP4/EP4 on 4 GPUs, layernorm-SP prefill through Mega MoE, prefill CUDA graphs on). Base = dev 12be8d3, merge = this branch.

base merge merge2 base2
GSM8K (all 1319) 95.4 95.3 94.9 94.8
32k prefill, conc 1, mean TTFT (ms) 348.3 344.3 345.5 341.9
8k/1k conc 1, TPOT (ms) 4.49 4.49 4.49 4.49
8k/1k conc 32, output tok/s 2741 2795 2770 2796
32k/256 conc 8, input tok/s 67680 67292 67029 67613

Before #178, this model crashed at startup on both base and merge (illegal memory access in the BF16 Mega MoE layers).

Open items (not in this PR)

  • test_mega_moe_sgl.py runs the legacy-baseline bench even for MMA types it skips for correctness (e.g. nvfp4xnvfp4). When DeepEP is installed, it fails the SF-shape assert on both base and merge. To get the B300 NVFP4 EP numbers above, the bench was gated on can_compare_bitwise in both arms.

🤖 Generated with Claude Code

lightseek-bot and others added 4 commits October 20, 2026 13:07
A CUDA graph kernel node keeps the same %gridid on every replay. The
mega_mhc split barriers tag each execution with %gridid, so after a replay
a barrier line still holds encode_state(grid_idx, kNumSplits), which is
exactly the state the next replay waits for. A Mix or Norm waiter whose
m-block init CTA has not started yet proceeds immediately and reads the
previous replay's split partials.

Tag executions with an epoch instead. The epoch and an exit count live in
the unused tail of the first barrier line, so the host-side buffer is
unchanged. Every CTA reads the epoch after cudaGridDependencySynchronize,
and the last CTA to retire resets the exit count and advances the epoch.

Signed-off-by: lightseek-bot <[email protected]>
* Public release 26/11/26

* Add 2026.11.26 News entry for deepseek-ai#525
…#525) into dev

Mega MoE keeps dev's kernels (NVFP4, TRT-LLM layouts, SiTU, norm, SIMT pull,
SM103 K96 / SM107 K128) at upstream's renamed *_inference paths, with
upstream's async-proxy fences ported into the FP8/FP4 and BF16 kernels and the
L2 k-block dependency waits. Upstream's *_inference Python names alias dev's
functions; upstream's deep_gemm/mega_moe package is not taken.

Mega mHC takes upstream's kernel (Shifted only) with dev's in-CTA Norm, task
queue, FlashInfer 128x4 SF and non-exclusive TMEM on top. The launch is
cooperative only without the SM107 oversized shared-memory mode (CUDA 720
otherwise), and in-CTA Norm defaults off for the dual routed/shared SF output
at hidden >= 7168.

GEMM/HC: upstream bias path, FP32 HC prenorm input, FP8 stochastic rounding
epilogue in the sgl binding; sgl tests match cuBLASLt's 'splitKreduce' since
the bench L2 flush now launches a torch reduce kernel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git carried the three PRs' edits through the *_inference renames.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@zcnrex
zcnrex marked this pull request as ready for review November 28, 2026 18:36
@zcnrex
zcnrex merged commit 6840aa7 into dev Nov 28, 2026
aryatsc added a commit to aryatsc/DeepGEMM that referenced this pull request Nov 28, 2026
Brings in sgl-project#177 (deepseek-ai public release 26/11/26, deepseek-ai#525) and deepseek-ai#478.

No textual conflicts: this branch's changes follow the renames
(csrc/apis/mega_moe.hpp -> mega_moe_inference.hpp,
impls/sm100_fp8_fp4_mega_moe.{hpp,cuh} -> ..._inference.{hpp,cuh},
scheduler/mega_moe.cuh -> scheduler/mega_moe/inference.cuh).
Jzz1943 pushed a commit to Jzz1943/DeepGEMM that referenced this pull request Dec 1, 2026
The upstream merge (sgl-project#177) added a 2D-only `check_sf_layout` to
`FP8CastWithClampEpilogue::check`, which rejects the 4D
`[ceil(m / 128), n / 128, 32, 4]` SFD that `fp8_einsum` accepts since sgl-project#136.
DeepSeek V4.1's FP8 `wo_a` einsum (FlashInfer `wo_b` handoff) asserted at
server warmup. Validate the 4D shape there as `fp8_einsum` does, and add
the 4D case to the sgl einsum test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

3 participants