Skip to content

Sync nv_dev with upstream #462, #471 and #478 - #509

Merged
RayWang96 merged 10 commits into
deepseek-ai:nv_devfrom
lucifer1004:sync/nv_dev-upstream-462-471-478
Nov 19, 2026
Merged

RayWang96 merged 10 commits into
deepseek-ai:nv_devfrom
lucifer1004:sync/nv_dev-upstream-462-471-478

Conversation

@lucifer1004

Copy link
Copy Markdown
Collaborator

Summary

Merges upstream 5081f85 (#478) into nv_dev at b64107f (#459). This brings in #462 (Public release 26/09/30) and #471; the merge base is 78b6900.

The branch keeps the topology of the previous nv_dev syncs (#314, #328, #349, #384): an explicit non-fast-forward merge with the upstream commit as the second parent. Please merge without squashing.

Commits:

API

The API follows upstream, with one addition:

  • MQA logits: clean_logits is removed, max_seqlen_k is required, and the SM100 paged metadata is varlen-only.
  • fp8_mqa_logits, fp8_paged_mqa_logits and fp8_gemm_nt_skip_head_mid are removed, as upstream removed them.
  • GEMM and einsum epilogues take upstream's EpilogueClass objects.
  • Addition: fp8_fp4_mqa_logits and fp8_fp4_paged_mqa_logits take a logits_dtype keyword (torch.float32 or torch.bfloat16) after max_seqlen_k / max_context_len. It defaults to the weights' precision: BF16 weights reduce in BF16 and require BF16 logits; FP32 and FP16 weights default to FP32 logits. The default is the same on every architecture.

On SM100, upstream 26/09/30 made the dense and paged MQA kernels MX-only, with BF16 weights and BF16 logits. c83713d restores FP32 weights with FP32 logits for MX inputs.

Upstream also removed the non-MX branch (kIsMXSF: FP8 with per-token FP32 KV scales). This sync does not restore it, matching upstream and vllm-project/DeepGEMM dev. On SM100, non-MX FP8 MQA logits are now available only through nv_dev's dense FP16-weight path, and non-MX paged MQA logits are not available. Callers of that format, such as V3.2-style indexers, need to convert to MXFP8 or use FP16 weights for dense. V4/V4.1 use MX inputs and are not affected.

Conflict resolution

  • Epilogues: the SM120 BF16 and FP8/FP4 GEMM kernels move from epilogue/transform.cuh to the epilogue/operators.cuh operator API (EpilogueOperatorArgs, Identity); HeadSplits and apply_index_n are gone. SM120 GEMMs reject custom epilogue classes. The SM120 BF16 einsum takes C. Its native path accepts only a plain BF16 store, and this is checked before D is written.
  • MQA logits: adopted upstream's dense, paged and sparse host code. Kept nv_dev's SM120 dense, paged and sparse paths, the SM90 block_kv=32 and next_n=4 multicast, and the SM100 FP16-weight path.
  • Sparse MQA logits: followed upstream's kNumMaxHeads layout and the kPartialTailFlag bit in the KV split header. Kept nv_dev's metadata, device, alignment and weight-stride checks, the 16-byte paged KV stride, and workspace reuse under graph capture (Sparse MQA logits follow-ups for nv_dev: 16-byte paged KV stride, workspace reuse under graph capture #459).
  • Mega MoE, mega_mhc, locality domain, layout and runtime: upstream.
  • Docs: README is upstream. docs/scaling-factor-format.md describes the new API.
  • Tests:
    • SM120 tests use the new API: no clean_logits, the 0x3fffffff KV count mask, a required max_seqlen_k.
    • New coverage: the plain FP8 GEMM store branches and the SM120 einsum C input.
    • test_nv_attention_restoration.py no longer imports removed helpers. It checks the SM100 unified dense kernel with MXFP8 inputs and FP32/BF16 weights, eager against scheduled, bitwise.

SM120 device layer

The SM120 device headers are byte-identical to lucifer1004/DeepGEMM-sm120 v0.2.0, which targets the 26/09/30 epilogue-operator API. The sparse MQA layout (layout/sparse_mqa_logits.cuh) is no longer vendored; it is the shared file upstream maintains.

The kernel therefore asserts every part of that layout it reads: struct sizes and field offsets, slot packing, and the KV split flag mask. A future upstream format change, such as another flag, fails to compile instead of producing wrong logits. Both current flags are hints the SM120 kernel may ignore, because it bounds-checks every KV token it copies.

The DeepGEMM-sm120 compile gate passes against this branch and against vllm-project/DeepGEMM dev (44cba7d). With an extra flag bit added to the layout it fails as intended. Format changes are caught at compile time, but changes in meaning are not, so syncs should still run tests/test_sm120_attention.py on SM120.

Validation

CUDA 13.2, torch 2.13.0+cu132. Each run uses a freshly built package and an empty JIT cache.

  • SM120 (RTX PRO 6000 Blackwell): all 712 SM120 tests pass:

    File(s) Passed
    test_sm120_attention.py 114
    test_sm120_gemm.py 73
    GEMM regressions and native rejections 356
    BF16 GEMM, odd N and einsum 58
    quantization, layout and scale-factor compatibility 93
    hyperconnection 18

    After the last commit, test_sm120_attention.py was re-run from an empty JIT cache and passed again.

  • SM90 (H200): every file was run on this branch and on nv_dev b64107f; nothing regresses.

    • Pass on both: test_attention.py (dense, paged and sparse MQA logits), test_bf16.py, test_fp8_fp4.py, test_einsum.py, test_layout.py, test_hyperconnection.py, test_legacy.py, test_mega_gate.py, test_mega_mhc.py, test_pack_ue8m0.py, and the Mega MoE SM90 and contract tests.
    • test_nv_attention_restoration.py: 105 passed on both; fewer skipped cases, because the clean_logits and legacy-wrapper variants were removed.
    • test_lazy_init.py: 3 passed. On b64107f no tests are collected.
    • test_locality_domain.py (new upstream): 3 tests need MLOPart, which the H200 host does not provide.
  • SM103 (B300, single GPU): every test file passes on this branch:

    • test_attention.py: dense, paged and sparse MQA logits, the full SM100 matrix.
    • test_nv_attention_restoration.py: 78 passed. This includes the FP16-weight path and the restored FP32 weights/logits, eager against scheduled, bitwise.
    • test_bf16.py, test_fp8_fp4.py, test_einsum.py, test_layout.py, test_hyperconnection.py, test_lazy_init.py, test_legacy.py, test_locality_domain.py, test_mega_gate.py, test_mega_mhc.py, test_pack_ue8m0.py.
    • Mega MoE: the main, protocol and SiTU contract tests pass. test_mega_moe.py and test_nvfp4_mega_moe.py pass their correctness checks with --num-processes 1.

The merge introduces no new git diff --check warnings against nv_dev. No conflict markers remain, and no project include points at a removed header.

Cautions

  • Multi-GPU SM100 Mega MoE was not run; the B300 allocation is single-GPU.
  • SM100 FP16-weight paged MQA is still not supported, as before this sync.

🤖 Generated with Claude Code

zheanxu and others added 10 commits September 10, 2026 14:31
* Public release 26/09

* Update News
Add locality-aware Mega MoE execution, GEMM epilogue classes with BF16
stochastic rounding, wider sparse MQA head support, and packed SF strides.
Improve Indexer and Mega MoE pipelines, update attention and Mega Gate
interfaces, and include runtime and correctness fixes.

Export the current source through the OSS filter while retaining public
release history and the Mega MoE task-info release-ordering fix.

Co-authored-by: Anyi Xu <[email protected]>
Co-authored-by: huahuaquq <[email protected]>
Co-authored-by: TwenTy_ <[email protected]>
Co-authored-by: xyf007 <[email protected]>
Co-authored-by: Yongqi Zhuo <[email protected]>
Co-authored-by: yukuai26 <[email protected]>
Co-authored-by: Zhean Xu <[email protected]>
Add FP8CastWithClamp with optional clamped-element counts, consolidate
GEMM epilogue conversions, and accept 128-byte paged sparse KV strides.
Keep the Mega MoE localizer alive until test teardown and bump the
package version to 2.8.2.

Co-authored-by: xyf007 <[email protected]>
Co-authored-by: yukuai26 <[email protected]>
Co-authored-by: Zhean Xu <[email protected]>
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]>
…i#432: Public Release 26/09) as merged into nv_dev

deepseek-ai#447 brought the content of upstream 66081d4 (deepseek-ai#432) and 78b6900 (deepseek-ai#441)
into nv_dev, but was squash-merged, so neither commit became an ancestor
of nv_dev and the merge base with main stayed at 559d79f (deepseek-ai#377). This
merge records 78b6900 as the second parent without changing any file, so
the next upstream merge starts from 78b6900 instead of re-applying 26/09.

Checked before recording: of the 128 files upstream changed between
559d79f and 78b6900, 97 are byte-identical on nv_dev; a three-way merge
of 78b6900 changes no file outside its conflicts except
smxx_clean_logits.cuh, which upstream deleted and nv_dev keeps for the
SM120 and SM100 FP16-weight MQA logits; and every upstream-side line in
the 25 conflicted files is present on nv_dev or replaced by an nv_dev
change (SM120 arch/alignment generalizations, deepseek-ai#459, deepseek-ai#396).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rriers under CUDA graph replay) into nv_dev

Brings deepseek-ai PRs deepseek-ai#462 (057ca59, Public release 26/09/30), deepseek-ai#471
(1fc9c66) and deepseek-ai#478 (5081f85) onto nv_dev (b4c138c). Merge base is 78b6900.

API follows upstream:
  * MQA logits: `clean_logits` is removed, `max_seqlen_k` is required, and
    the SM100 paged metadata is varlen-only. nv_dev keeps one extension: a
    `logits_dtype` keyword (FP32 or BF16, after `max_seqlen_k` /
    `max_context_len`). It defaults to BF16 on SM100 and FP32 on SM90/SM120.
  * The legacy `fp8_mqa_logits` / `fp8_paged_mqa_logits` wrappers and
    `fp8_gemm_nt_skip_head_mid` are removed, as upstream removed them.
  * GEMM/einsum epilogues take upstream's `EpilogueClass` objects.

Conflict resolution highlights:
  * Epilogues: the SM120 BF16 and FP8/FP4 GEMM kernels move from
    `epilogue/transform.cuh` to the `epilogue/operators.cuh` operator API
    (`EpilogueOperatorArgs`, `Identity`); `HeadSplits` and `apply_index_n`
    are gone. The device files match DeepGEMM-sm120 v0.2.0. SM120 GEMMs
    reject custom epilogue classes; the SM120 BF16 einsum takes `C` and
    accepts only a plain BF16 store on its native path, checked before `D`
    is written.
  * MQA logits: adopt upstream's dense/paged/sparse host code while keeping
    nv_dev's SM120 dense, paged and sparse paths, the SM90 block_kv=32 and
    next_n=4 multicast, and the SM100 FP16-weight path.
  * Sparse MQA logits: follow upstream's `kNumMaxHeads` layout and the
    `kPartialTailFlag` bit in the KV split header. nv_dev keeps its metadata,
    device, alignment and weight-stride checks, the 16-byte paged KV stride
    (deepseek-ai#459) and workspace reuse under graph capture (deepseek-ai#459).
  * Mega MoE, mega_mhc, locality domain, layout and runtime: upstream.
  * README: upstream. docs/scaling-factor-format.md describes the new API.
  * Tests: SM120 tests move to the new API (no `clean_logits`, 0x3fffffff
    KV count mask, required `max_seqlen_k`) and add coverage for the plain
    FP8 GEMM store branches and the SM120 einsum `C` input.
    test_nv_attention_restoration.py no longer imports removed helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
)

Upstream 26/09/30 made the SM100 dense and paged MQA logits kernels take
BF16 weights and write BF16 logits only. nv_dev callers pass FP32 weights
and read FP32 logits, so port vllm-project#46: the SM100 kernel
is templated on the weights and logits types again, and the host accepts
FP32 or BF16 weights on SM100 (MX inputs).

`logits_dtype` now defaults to the weights' precision: BF16 weights reduce
in BF16 and require (and default to) BF16 logits; FP32 and FP16 weights
default to FP32 logits. This is the same default on every architecture.

Non-MX FP8 inputs on SM100 still take the FP16-weight path only.

Tests: test_nv_attention_restoration.py checks the SM100 unified dense
kernel with MXFP8 inputs and FP32/BF16 weights, eager against scheduled,
bitwise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The SM120 sparse MQA kernel reads `layout/sparse_mqa_logits.cuh`, which is
shared with SM100 and follows upstream. Assert the parts of it the kernel
reads (struct sizes and field offsets, slot packing, KV split flag mask), so
a future upstream format change fails to compile instead of producing wrong
logits. The device file matches DeepGEMM-sm120 v0.2.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The MQA logits APIs no longer take `clean_logits`. Also note that the SM100
FP16-weight path is the only non-MX FP8 MQA logits path on SM100.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RayWang96
RayWang96 merged commit c9b569a into deepseek-ai:nv_dev Nov 19, 2026
lucifer1004 added a commit to lucifer1004/DeepGEMM that referenced this pull request Nov 19, 2026
…deepseek-ai#441, deepseek-ai#462, deepseek-ai#471) as merged into nv_dev

deepseek-ai#509 synced these upstream commits into nv_dev but was squash-merged, which kept
their changes and dropped their ancestry. Without it the next upstream sync
would see them as unmerged and re-apply them from an older merge base. This
merge uses the 'ours' strategy: the tree is unchanged.
RayWang96 added a commit that referenced this pull request Nov 19, 2026
RayWang96 added a commit that referenced this pull request Nov 19, 2026
Merge of pull/509/head (72e97d7) without squashing, so that the upstream
merges 78b6900 and 5081f85 stay recorded in nv_dev's history.
Replaces the squash commit c9b569a and its revert c54abc4 (#511).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
RayWang96 added a commit that referenced this pull request Nov 19, 2026
SM120 batch invariance under deterministic algorithms (stacked on #509)
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.

5 participants