Skip to content

Sync nv_dev with upstream #316 (Mega MoE optimizations & benchmarks) - #328

Merged
RayWang96 merged 2 commits into
deepseek-ai:nv_devfrom
Barry-Delaney:user/jinshik/nv_dev_316
May 8, 2026
Merged

RayWang96 merged 2 commits into
deepseek-ai:nv_devfrom
Barry-Delaney:user/jinshik/nv_dev_316

Conversation

@Barry-Delaney

Copy link
Copy Markdown

Summary

Cherry-picks upstream 891d57b (deepseek-ai PR #316: "Add various optimizations and Mega MoE benchmarks") onto nv_dev (currently at c491439, the merge of PR #314).

Conflicts resolved against the NV-side commits from PR #314 (f6d98f2, 12cb7c0, a97b74d):

  • deep_gemm/include/deep_gemm/scheduler/paged_mqa_logits.cuh — keep NV's host-passed num_next_n_atoms runtime parameter, plus 891d57b's kIsVarlen template + binary-search SM work distribution + varlen path.
  • deep_gemm/include/deep_gemm/impls/sm90_fp8_paged_mqa_logits.cuh — keep NV's kNumKVMulticast template + cluster multicast logic; add 891d57b's kIsVarlen template parameter with static_assert(!kIsVarlen) (SM90 doesn't support varlen).
  • csrc/jit_kernels/impls/smxx_fp8_fp4_paged_mqa_logits.hpp — unified Args struct (num_next_n_atoms + is_varlen + indices); SM90 instantiation passes is_varlen=false explicitly; SM100 TMA-box rule uses 891d57b's (is_varlen or next_n >= 2) ? 2 : 1.
  • csrc/apis/attention.hpp — host computes num_next_n_atoms to match the post-Add various optimizations and Mega MoE benchmarks #316 SM100 kernel (kNextNAtom = (is_varlen or next_n >= 2) ? 2 : 1, kNumNextNAtoms = ceil_div(next_n, kNextNAtom)); SM90 multicast hard-codes num_next_n_atoms = 1. Without this fix next_n=5 over-schedules by 5/3 and triggers IMA.
  • tests/test_attention.py — keep NV's block_kv ∈ {32, 64} and next_n=4 for SM90 multicast; add 891d57b's outer is_varlen loop (varlen is SM100-only).

Test plan

Validated on B300 SXM6 (sm103, arch_major == 10, 8-GPU) and H200 NVL (sm90, arch_major == 9, 1-GPU).

zheanxu and others added 2 commits April 24, 2026 18:41
* Merge with private repo

* Add Mega MoE Benchmark

* Minor fix

* Update

---------

Co-authored-by: Chenggang Zhao <[email protected]>
…ions and Mega MoE benchmarks) into nv_dev

Brings in deepseek-ai PR deepseek-ai#316 'Add various optimizations and Mega MoE benchmarks'
on top of the nv_dev branch (currently at c491439, the merge of PR deepseek-ai#314).

Conflicts resolved against the NV-side commits from PR deepseek-ai#314 (f6d98f2, 12cb7c0,
a97b74d):

  * deep_gemm/include/deep_gemm/scheduler/paged_mqa_logits.cuh: keep NV's
    host-passed num_next_n_atoms runtime parameter, plus 891d57b's kIsVarlen
    template + binary-search SM work distribution + varlen path.
  * deep_gemm/include/deep_gemm/impls/sm90_fp8_paged_mqa_logits.cuh: keep NV's
    kNumKVMulticast template + cluster multicast logic; add 891d57b's kIsVarlen
    template parameter with static_assert(!kIsVarlen) (SM90 doesn't support
    varlen).
  * csrc/jit_kernels/impls/smxx_fp8_fp4_paged_mqa_logits.hpp: unified Args
    struct (num_next_n_atoms + is_varlen + indices); SM90 instantiation passes
    is_varlen=false; SM100 TMA-box rule uses 891d57b's
    (is_varlen or next_n >= 2) ? 2 : 1.
  * csrc/apis/attention.hpp: host computes num_next_n_atoms to match the
    post-deepseek-ai#316 SM100 kernel rule
    (kNextNAtom = (is_varlen or next_n >= 2) ? 2 : 1,
     kNumNextNAtoms = ceil_div(next_n, kNextNAtom));
    SM90 multicast hard-codes num_next_n_atoms = 1. Without this fix, next_n=5
    over-schedules by 5/3 and triggers IMA on SM100.
  * tests/test_attention.py: keep NV's block_kv in {32, 64} and next_n=4 for
    SM90 multicast; add 891d57b's outer is_varlen loop (varlen is SM100-only).

Validated on B300 SXM6 (sm103) and H200 NVL (sm90):
test_attention.py passes the full enumeration on both architectures with no
IMA; numerical diff < 1e-3 (FP8) / 0.02 (FP4).
@RayWang96
RayWang96 merged commit 67fc648 into deepseek-ai:nv_dev May 8, 2026
RayWang96 pushed a commit that referenced this pull request Jun 2, 2026
…s) into nv_dev

Brings deepseek-ai PR #347 (88965b0, also pulls 714dd1a 'Update test_mega_moe.py')
onto nv_dev (currently at ac1f285 = #316 merge #328 + PR #342 IMA guard).
Merge base is 891d57b.

Conflicts resolved (5 files):
  * scheduler/paged_mqa_logits.cuh: take #347's refresh_num_kv_and_advance +
    reversed metadata allocation; drop nv_dev's PR #342 exist_q_atom_idx guard
    and get_atom_advance (both subsumed — reversed alloc keeps current_q_atom_idx
    in-bounds, refresh_num_kv_and_advance reproduces the varlen 1-or-2 advance).
    NV's host-passed num_next_n_atoms survives in the auto-merged metadata kernel
    (verified: single param, no inline recompute, coherent with reversed alloc).
  * csrc/apis/gemm.hpp: drop redundant C/D dtype asserts (#347 cleanup; the
    pre-existing d-dtype check + d==c check already cover them).
  * sm100_fp8_fp4_gemm_1d1d.cuh: take #347's unconditional BF16/FP32 C/D assert
    (supersedes nv_dev's accumulation-only assert).
  * tests/generators.py: take #347's broadened BF16-accumulation enumeration
    (out_dtype==bf16 and (dtype==bf16 or arch==10)) — strict superset of nv_dev's
    fp8+SM100 case.
  * tests/test_attention.py: merge both — keep NV's SM90 next_n=4 multicast +
    num_clusters metadata sizing; add #347's pool-size limits, batch_size=4096,
    and block_table/context_lens sanity asserts.

Auto-merged metadata kernel + smxx_fp8_fp4_paged_mqa_logits.hpp + attention.hpp
verified coherent across all three layers (kernel signature / launch / host call
all carry num_next_n_atoms + is_varlen + indices).

Validated on B-card (SM100) and H200 (SM90) incl next_n=4 multicast.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
lucifer1004 added a commit to lucifer1004/DeepGEMM that referenced this pull request Sep 15, 2026
Resolve the nv_dev sync using an ordinary merge, following the ancestry-preserving approach of prior sync PRs deepseek-ai#314, deepseek-ai#328, deepseek-ai#349 and deepseek-ai#384. Audit all 75 target-side changed paths, including 59 conflicts and seven automatically changed paths, against the prepared main-API implementation.

Retain DeepJIT, native SM120 kernels, restored nv_dev attention and MegaMoE contracts, and the validated NVFP4 WAR fix. Preserve the target's FP16 MQA indexing include; this is the only tree change relative to the validated integration head.

Standard standalone build, delivered-package import, 81 host protocol tests, 349 SM120 focused tests, packing and HC passed. Runtime sources are unchanged; prior bounded hardware and sanitizer evidence applies. Existing combined IDE indexing build limitations and previously documented qualification limits remain.
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