Skip to content

Tracking kernels - #6

Draft
cleonard530 wants to merge 108 commits into
mainfrom
tracking_kernels
Draft

cleonard530 wants to merge 108 commits into
mainfrom
tracking_kernels

Conversation

@cleonard530

@cleonard530 cleonard530 commented Jul 23, 2026 •

Copy link
Copy Markdown
Owner

Ignore everything else, this is just for me to track the kernels that I have personally gone through to make sure immutable tensors in the TORCH_LIBRARY schemas are truly immutable.

The checked-off kernels passed the validation in scripts/smoke_test_all_ops.py. The script verifies that immutable parameters remain bitwise unchanged before and after each call, and it correctly fails when a parameter that should be mutable is incorrectly marked as immutable.

The unchecked kernels are ones that are currently skipped because I have the wrong SM version. They are not failing.

GEMM (gemm.hpp, 21 ops)

  • 1. fp8_fp4_gemm_nt,
  • 2. fp8_fp4_gemm_nn,
  • 3. fp8_fp4_gemm_tn,
  • 4. fp8_fp4_gemm_tt
  • 5. m_grouped_fp8_fp4_gemm_nt_contiguous,
  • 6. m_grouped_fp8_fp4_gemm_nn_contiguous,
  • 7. m_grouped_fp8_fp4_gemm_nt_masked
  • 8. k_grouped_fp8_gemm_tn_contiguous,
  • 9. k_grouped_fp8_gemm_nt_contiguous
  • 10. bf16_gemm_nt,
  • 11. bf16_gemm_nn,
  • 12. bf16_gemm_tn,
  • 13. bf16_gemm_tt
  • 14. m_grouped_bf16_gemm_nt_contiguous,
  • 15. m_grouped_bf16_gemm_nn_contiguous,
  • 16. m_grouped_bf16_gemm_nt_masked
  • 17. k_grouped_bf16_gemm_tn_contiguous
  • 18. cublaslt_gemm_nt,
  • 19. cublaslt_gemm_nn,
  • 20. cublaslt_gemm_tn,
  • 21. cublaslt_gemm_tt

Attention (attention.hpp, 6 ops)

  • 1. fp8_gemm_nt_skip_head_mid
  • 2. fp8_fp4_mqa_logits,
  • 3. fp8_mqa_logits
  • 4. get_paged_mqa_logits_metadata
  • 5. fp8_fp4_paged_mqa_logits,
  • 6. fp8_paged_mqa_logits

Layout (layout.hpp, 8 ops)

  • 1. transform_sf_into_required_layout
  • 2. get_tma_aligned_size
  • 3. get_mn_major_tma_aligned_tensor,
  • 4. get_mn_major_tma_aligned_packed_ue8m0_tensor,
  • 5. get_k_grouped_mn_major_tma_aligned_packed_ue8m0_tensor
  • 6. set_mk_alignment_for_contiguous_layout,
  • 7. get_mk_alignment_for_contiguous_layout,
  • 8. get_theoretical_mk_alignment_for_contiguous_layout

Mega MoE (mega.hpp, 6 ops)

  • 1. get_token_alignment_for_mega_moe,
  • 2. get_block_m_for_mega_moe,
  • 3. get_symm_buffer_size_for_mega_moe
  • 4. _slice_symm_buffer_for_mega_moe (private)
  • 5. fp8_fp4_mega_moe,
  • 6. bf16_mega_moe

Runtime (runtime.hpp, 9 ops)

  • 1. set_num_sms,
  • 2. get_num_sms
  • 3. set_tc_util,
  • 4. get_tc_util
  • 5. set_pdl,
  • 6. get_pdl
  • 7. set_ignore_compile_dims,
  • 8. set_block_size_multiple_of
  • 9. init

Einsum (einsum.hpp, 2 ops)

  • 1. einsum,
  • 2. fp8_einsum

Hyperconnection (hyperconnection.hpp, 1 op)

  • 1. tf32_hc_prenorm_gemm

RayWang96 and others added 30 commits November 21, 2025 00:13
…bf16_bias

support bf16 bias in deepgemm2
Allow the SM100 FP8 1D1D GEMM with accumulation to produce either FP32
or BF16 output (matching the bias/C dtype). Extends `early_return`
checks and `sm100_fp8_gemm_1d1d_impl`'s static assert, and adds bf16
bias coverage to the normal enumerator in tests/generators.py.
Extend the SM90 FP8 paged MQA logits kernel and host wrapper to cover
block_kv=32 and next_n=4 on post-deepseek-ai#304 code.

Kernel (deep_gemm/include/deep_gemm/impls/sm90_fp8_paged_mqa_logits.cuh):
  - Keep MMA tile at kComputeBlockKV=64 and let block_kv vary (32 or
    64). Each WGMMA iteration covers kNumBlocksPerMMA = 64 / block_kv
    physical blocks with one TMA copy each.
  - Load block_table entries with a loop of scalar __ldg's so
    block_table_stride no longer has to be a multiple of
    kNumBlocksPerMMA.
  - Add kNumKVMulticast template parameter for next_n=4; compute
    kNextNPerCTA = kNextN / kNumKVMulticast and split Q rows across
    two CTAs in a cluster via cta_rank_in_cluster, keeping smem and
    register budgets within SM90 limits (WGMMA N=256 otherwise
    exceeds kNumMathRegisters=104).
  - Use cute::cluster_id_in_grid().x for the scheduler index.

Host wrapper (csrc/jit_kernels/impls/smxx_fp8_fp4_paged_mqa_logits.hpp):
  - Select num_kv_multicast = 2 when SM90+next_n=4 else 1. Build
    Q/weights TMA descriptors with next_n_per_cta * num_heads box,
    size smem from next_n_per_cta, launch with
    cluster_dim=num_kv_multicast.
  - Emit the extra kNumKVMulticast template arg only for SM90; SM100
    instantiation is unchanged.

Other:
  - Add utils::shfl_sync helper in common/utils.cuh.
  - tests/test_attention.py: extend enumerate_paged_mqa_logits to
    cover block_kv=32 and next_n=4 on SM90; call
    get_paged_mqa_logits_metadata with num_clusters = num_sms /
    num_kv_multicast; initialize block_table with torch.zeros so
    unused slots hold a valid block id.
The post-deepseek-ai#304 metadata kernel hard-codes num_next_n_atoms from next_n,
which assumes the SM100 time-atomization scheme. On SM90 next_n=4 the
cluster-multicast design processes one full q per cluster with no
atomization, so the hard-coded value over-schedules by 2x; when the
kernel scheduler (kNumNextNAtoms=1 in the SM90 template) decodes those
entries it steps past context_lens and triggers an illegal memory access
in sm90_fp8_paged_mqa_logits.

Fixes:
  - Pipe num_next_n_atoms as a runtime parameter into the metadata
    kernel (deep_gemm/include/deep_gemm/scheduler/paged_mqa_logits.cuh)
    and let the host decide. attention.hpp computes it based on arch +
    next_n + num_kv_multicast so SM90 multicast passes 1 while SM100
    keeps 2 for next_n=4, matching the respective kernel template.
  - Relax the schedule_meta size assertion in attention.hpp to
    'num_sms / num_kv_multicast + 1' so the check matches the cluster
    grid rather than the SM grid for SM90 next_n=4.
  - Relax the block_kv assertion in get_paged_mqa_logits_metadata to
    accept block_kv in {32, 64} and internally use the compute block
    size (64) on SM90, so callers can pass the physical block_kv the
    matching fp8_fp4_paged_mqa_logits call uses.
Brings in upstream commits d30fc36 (TMEM alloc/dealloc sync fix, deepseek-ai#292)
and 7f2a703 (public release 26/04: Mega MoE, FP4 indexer, and related
refactors, deepseek-ai#304), plus three NV-side commits:

  - Enable bf16 bias output for FP8 GEMM on SM100 (xueweil)
  - SM90 paged MQA logits: support kv_block=32 and next_n=4 (Ray)
  - Fix SM90 paged MQA logits for post-deepseek-ai#304 metadata/schedule API mismatch

The upstream deepseek-ai#304 refactor reshapes the attention/MQA layer; conflicts
with the pre-merge nv_dev code are resolved by taking the post-deepseek-ai#304
version. Also drops the redundant __syncthreads() in
sm100_bmk_bnk_mn.cuh that was added by nv_dev's 8e866e4; deepseek-ai#304 removed
the equivalent sync upstream (replaced with NamedBarrier.sync in
sibling SM100 kernels) so keeping the nv_dev version would diverge
from upstream's final sync design.
…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).
…_dev_316

Sync nv_dev with upstream deepseek-ai#316 (Mega MoE optimizations & benchmarks)
Phase 1a: infrastructure + dense FP8 GEMM kernel for SM120a (CC 12.0).

Architecture: warp-level mma.sync with block-scaled UE8M0 scale factors,
B128 XOR swizzle, persistent scheduling, register-based epilogue.

New files:
- SM120 heuristics, JIT codegen, MMA PTX wrappers, ldmatrix/swizzle utils
- CUDA kernel with warp-specialized TMA/math pipeline (3-9 stages)

Modified files:
- Arch detection, compiler flags (-gencode for SM120a)
- API dispatch (arch_major == 12), SF layout transform
- Default recipe for SM120

Correctness: 8/8 shapes pass (diff < 0.001 cosine distance)
Performance: ~73 TFLOPS (baseline, optimization pending)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
… only

Drop the non-warp-specialized kernel path for SM120a (matching SM90/SM100
architecture), merging the warp-specialized implementation into the main
sm120_fp8_fp4_gemm_1d1d kernel. Add FP4 GEMM support using packed SMEM
with the mxf4nvf4 m16n8k64 MMA instruction.

Key changes:
- Consolidate: remove non-spec path, always BM=128/BK=128/384 threads
- FP4: packed 4-bit SMEM (CU_TENSOR_MAP_DATA_TYPE_16U4_ALIGN8B), standard
  ldmatrix, uint16_t scale factors (scale_vec::2X), kKSteps=2 vs FP8's 4
- Heuristic: simplified to warp-spec only, correct SMEM sizing for FP4
- API: enable FP4 on SM120a (arch_major==12), add fp8_fp4_gemm_nt binding
- Fix SF hoist bug: hoist SFA/SFB independently for mixed gran_k configs

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Kernel: Add TMA descriptor runtime update (tensormap.replace) in producer
  loop for K-grouped group transitions, fix SF_K_ALIGNMENT to kGranKA*4,
  fix SMEM layout (pipeline data at offset 0 for B128 swizzle alignment,
  tensor map descriptors at end), fix epilogue bounds for multi-group output.

- MMA wrappers: Replace CUTLASS mma_sm120.hpp dependency with custom inline
  asm using "+f" read-write constraints for accumulator registers. Eliminates
  CUTLASS header dependency and gives explicit control over MMA operand
  encoding for both FP8 (m16n8k32) and FP4 (m16n8k64) block-scaled MMA.

- JIT launcher: Add sm120_k_grouped_fp8_fp4_gemm_1d1d() with proper TMA
  descriptor creation (first_k base, FP4-aware stride), SF TMA covering
  concatenated groups, CD TMA with num_groups outer dimension.

- API dispatch: Add arch_major==12 path in k_grouped_fp8_gemm_nt_contiguous,
  relax recipe assertion to support gran_k=32/128, add SM120 SF layout
  transform with auto-detection of transposed K-major scale factors.

- Tests: Add dedicated SM120 K-grouped test (7 configs including zero-K
  edge case), fix K-major selection for SM120 in generators, fix test
  dispatch for SM120 in test_fp8_fp4.py, update FP4 test with perf comparison.

Tested: Dense FP8 8/8, Dense FP4 10/10, K-grouped FP8 7/7 — all PASS.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Einsum support:
- Add GemmType::Batched to FP8/FP4 and BF16 kernels with 3D TMA load/store
- Add IndexType::SF_K for batched SF coordinate computation
- Add MN-major B support to BF16 kernel (scalar SMEM loads, single-atom constraint)
- BF16 bhr,hdr->bhd: 384 TFLOPS, FP8: 681 TFLOPS (batch=8, b=8192)

M-grouped BF16:
- Add contiguous and masked M-grouped BF16 GEMM launchers

HC prenorm TF32:
- New fused GEMM + sqr_sum kernel using mma.sync.m16n8k8 TF32 (226T peak)
- BF16 A -> FP32 cast with fused sqr_sum accumulation
- Atom-aware FP32 B fragment loading from K-major SMEM
- Split-K support for large K / small M shapes
- 24/24 test shapes PASS, ~1.1 TB/s bandwidth on large shapes

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Dense (ragged): 651 TFLOPS peak (80% of FP8 MMA peak 814T), 40/40 tests pass.
Paged (KV cache): 320 TFLOPS peak, 1.36 TB/s DRAM (91% of HBM BW), 8/8 tests pass.

Kernel design: warp-specialized mma.sync m16n8k32 FP8 (no block_scale).
8 math warps × 16 KV rows each = 128 BLOCK_KV. In-warp 2-shfl reduction
across 4 threads (lane%4) — only ~10 cycles, negligible vs MMA time.
Global stores are fire-and-forget on SM120a, so no epilogue warps needed.

Key parameters: block_qh=128, num_heads=64, head_dim=128, 2 Q stages,
3 KV stages, 84KB SMEM (83% of 101KB capacity).

Paged variant: 2 groups of 4 warps, SPLIT_KV=128, per-group KV pipeline.
Fixed metadata split_kv mismatch and register budget overflow (TMA regs
64→40 to stay within 65536 register limit).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- skip_head_mid: Add SM120 dispatch in attention.hpp for EpilogueHeadSplits.
  Fix three issues: TMA CD descriptor uses d.size(-1)/d.stride(-2) instead
  of n; kernel uses stride_d parameter for D row stride and bounds checks;
  TMA store coordinates apply epilogue N-index remapping.

- MN-major B: Fix kernel TMA coordinate for M-grouped BF16 with MN-major B.
  Group offset moves to outer=K coordinate (not inner=N) when kBKMajor=false.

- FP8 kernel stride_d: Add stride_d parameter to decouple D tensor stride
  from computation dimension n, enabling epilogue transforms that expand N.
Yuanhang Sun and others added 29 commits June 5, 2026 01:32
…r changes

The SM120 MQA-logits work modified the shared launchers in two ways that broke
SM100 (and were latent on SM90), surfacing as test_attention failures on B300
(baseline=origin/nv_dev passes, sm120 HEAD fails). No SM100/SM90 device kernel
(.cuh) changed, so this is purely a host launch-config regression.

1. Dense MQA SMEM under-allocation (smxx_fp8_fp4_mqa_logits.hpp). The SMEM size
   dropped the `(num_math_threads / 128) * 2` mbarrier pairs that the SM90/SM100
   kernels still allocate (the SM120 kernel does not). On SM100 this under-sized
   the dynamic SMEM; compute-sanitizer reports an "Invalid __shared__ write" in
   sm100_fp8_mqa_logits, faulting (CUDA_ERROR_ILLEGAL_ADDRESS) at large configs
   such as seq_len_kv=130560. Restore the term for arch != 12.

2. Paged-MQA metadata capacity assert (smxx_fp8_fp4_paged_mqa_logits.hpp). An
   unconditional `smem_size <= SM120ArchSpec::smem_capacity` (99 KB) was added to
   the metadata launcher, which runs on every arch. On SM90/SM100 (228 KB) a
   large (varlen) batch's metadata SMEM legitimately exceeds 99 KB and falsely
   tripped the assert. Gate the capacity check to the running arch.

Verified on B300 (sm100): compute-sanitizer memcheck clean on the previously
out-of-bounds config (seq_len=510, seq_len_kv=130560); full test_attention
(dense + paged, NextN 1-6, FP8/FP4) passes. Fix (1) also corrects a latent
SMEM under-allocation on SM90.
Strip changes that should not ship upstream and align comment style with the
existing codebase (terse, no decorative banners). No change to production
GEMM/attention behavior — only removes a dev-only bench path and trims comments.

- .gitignore: revert to upstream; personal ignores (docs_internal/, benchmarks/,
  ncu_reports/, internal/) moved to local .git/info/exclude.
- Remove dev-only sm120_fp8_gemm_bench API and its override_layout tile-override
  param (gemm.hpp, __init__.py, sm120_fp8_fp4_gemm_1d1d.hpp); config selection
  collapses to the standard get_best_config path.
- Trim changelog-/rationale-style block comments to single lines (shared rationale
  lives in commit history): MQA-logits SMEM, paged-MQA capacity assert,
  cd_n_contiguous, split-K SF alignment, latency model, einsum MN-major notes.
- De-duplicate the AB-swap "transposed output" rationale (kept once in config.hpp)
  and the UE8M0 SF-tile note.
- Remove decorative // ==== banner comments from sm120 .cuh (no other kernel uses them).
- Remove an unused num_waves local in the SM120 latency model (clears a
  -Wunused-variable warning).
- Remove tests/test_split_k_swap.py (standalone dev harness, not pytest-style).
The SM120 fp8/fp4 1D1D kernel iterated every ceil(M_sum/BLOCK_M) m-block and
computed invalid (m_indices == -1) padding tiles against expert 0. SM90 skips
these via Scheduler::is_computation_valid, but that helper is marked SM90-only
and the SM120 producer issued the A/B/SF TMA copies unconditionally.

At MoE decode the contiguous worst-case M_sum reserves a block per local expert
(min(M*topk, local_experts)) while only a few are routed, so most m-blocks are
empty padding. Computing them wastes a full-width GEMM tile — the dominant cost
of EP decode. Measured on RTX PRO 6000, EP gate_up (N=4096, K=4096, 64 local
experts, ~20 routed): worst-case 20-valid + 45-empty of 65 blocks = 304us vs the
20 real blocks alone = 170us; the empty tiles cost 134us (44%).

Add the m_indices < 0 skip-continue to both the producer and consumer
while-loops. The check is identical in both, so no barrier ops are issued for
skipped blocks and the warp-specialized pipeline stays in sync. Empty experts
now cost nothing: EP decode MoE GEMM drops ~1.8x (304 -> 169us), matching the
TP-sharded layout. The all-valid path (prefill/dense) is unchanged.

Validated: m-grouped contiguous correctness for fp8xfp8 / fp4xfp4 / fp8xfp4
(diff < 2%), worst-case-padded result == tight, all-65-valid timing unchanged.
Adds the reverse of the existing fp8-A x fp4-B mixed path: A is fp4 (e2m1), B is
fp8 (e4m3), via mxf8f6f4 .e2m1.e4m3 (m16n8k32). Lets the expert weight sit on the
well-filled M axis and the (few) decode tokens on a small N axis.

- mma/sm120.cuh: fp4_fp8_mixed_mma_block_scaled (.e2m1.e4m3).
- common/sm120_utils.cuh: ldmatrix_m8n16_x4_b4x16_p64 + load_a_fragment_b4x16
  (4-reg b4x16 unpack for the fp4 A operand; same addressing as the fp8 A load).
- impls/sm120_fp8_fp4_gemm_1d1d.cuh: kAIsFP4 template flag; A loaded as
  fp4-unpacked (b4x16 + <<2), TMA_A_BYTES = SMEM_A/2, MMA dispatch, perNTileX4
  disabled for kAIsFP4.
- jit_kernels/impls/sm120_fp8_fp4_gemm_1d1d.hpp: detect A=fp4 & B=fp8 (a_is_fp4);
  is_fp4 redefined to symmetric fp4xfp4 (value-identical for existing cases);
  emit kAIsFP4.
- heuristics/sm120.hpp: a_padded_fp4 -> the fp4 A operand uses unpacked b4x16
  SMEM (row = block_k, swizzle 128), mirroring the fp4 B handling.
- tests/generators.py: add the FP4_A x FP8_B QuantConfig (32,128,True,False) to
  the SM120 sweep; the FP8 operand of a mixed config is 1D-scaled (per-token,
  recipe (1, gran)), not per-block.

Validated on RTX PRO 6000: full fp8_fp4 sweep (normal / m-grouped contiguous /
m-grouped masked, all dtype configs incl. the new FP4_A x FP8_B) passes
(diff < max_diff, ~0.007 for fp4xfp8). Existing paths unchanged (a_is_fp4
defaults false). SM100 untouched.

Note: for MoE decode this orientation is bandwidth-saturated (~92% DRAM) and only
~3-6% faster than the standard layout; the empty-tile skip is the real EP-decode
lever. The K-grouped launcher A-stride is not yet wired for fp4-A.
Behavior-preserving cleanups from upstream review.

gemm.hpp: pull the SM120 arm of fp8_fp4_gemm_nt into a dedicated
fp8_fp4_gemm_nt_sm120() helper and dispatch in natural arch order
(9/10 share the SF-transform path, then 12). Add a shared
sm120_to_k_major() helper for the "repack packed-FP4 / contiguous to
force K-major" idiom, reused by the FP8/FP4 NT GEMM, the m-grouped
contiguous arm, and the BF16 GEMM.

runtime.hpp: replace the coupled arch==12 ternaries in
get_theoretical_mk_alignment_for_contiguous_layout() with a per-arch
ContiguousMKAlignment policy plus a single shrink loop.

SM90/SM100/SM120 results are unchanged; verified on SM120 with
test_fp8_fp4.py and test_bf16.py.
The BF16 einsum tests compared DeepGEMM's bf16 output against cuBLAS's
at 1e-10 (near bit-exact). On SM120 the two differ only in FP32
accumulation order (cuBLAS uses a multi-accumulator K-reduction at
small M), so ~0.2% of low-magnitude outputs differ by 1 ULP and the
comparison lands ~8e-9 -- not a DeepGEMM accuracy issue (both match the
FP64 truth equally, ~1.4e-6).

Keep the strict 1e-10-vs-cuBLAS bound for SM90/SM100, loosen to 1e-7
only on SM120, and add an architecture-independent FP32-reference
correctness check on SM120 (calc_diff < 1e-5; DeepGEMM measures ~1.4e-6).
feat: add sm120 support for DeepGEMM
Signed-off-by: JaredforReal <[email protected]>
… into nv_dev

Brings deepseek-ai PR deepseek-ai#377 (559d79f, including deepseek-ai#364 and deepseek-ai#343) onto
nv_dev (a6b593d = deepseek-ai#369 merge). Merge base is 88965b0.

Conflict resolution highlights:
  * MQA: adopt deepseek-ai#377's unified SM100 implementation and common MMA/PTX
    refactor while preserving nv_dev's SM90 next_n=4 multicast and
    block_kv=32 support, dedicated SM120 paths, FP16/BF16 weights, and
    16-head indexer coverage.
  * Scheduler safety: retain zero-context and empty-varlen handling; drive
    producer prefetch from the scheduler's actual next query; bound the
    SM90 block_kv=32 odd-page tail before reading block tables.
  * FP16 weights: port the implementation to the new headers and preserve
    padded host offsets, per-warpgroup row indexing, and per-row compressed
    window bounds.
  * GEMM/layout: combine deepseek-ai#377's grouped scale-factor, PSUM, zero-padding,
    and Mega-MoE changes with nv_dev's SM120 dense/grouped dispatch.
  * Tests: merge upstream coverage with nv_dev's SM90/SM100/SM120 cases and
    add regressions for empty metadata, skipped requests, FP16 compressed
    windows, and the SM90 odd physical-page tail.

Validation:
  * All Git-tracked Python files pass py_compile.
  * No unresolved conflicts, conflict markers, missing project includes, or
    references to removed headers were found.
  * CUDA build/JIT and GPU numerical tests were not run because this host has
    no nvcc, PyTorch, or visible GPU tooling.
Elect one lane for the raw PTX UMMA issue path, order CTA-local KV scale loads before consumption, and fence TMEM handoff between producer and consumer.
… match what was in the legacy code

Signed-off-by: Chris Leonard <[email protected]>
…helper code from generate_pyi.py

Signed-off-by: Chris Leonard <[email protected]>
…updates so I updated it to inlcude the type hints

Signed-off-by: Chris Leonard <[email protected]>
…ybind default arguments are no longer there

Signed-off-by: Chris Leonard <[email protected]>
…ther minor formatting issues. Also added comments with examples to help describe each step. These will be removed (as well as main()) in a followup commit, but wanted them here for reference

Signed-off-by: Chris Leonard <[email protected]>
…TORCH_LIBRARY; deep_gemm/_C.py can keep using torch.ops.load_library.

Signed-off-by: Chris Leonard <[email protected]>
… function that was leftover from migration, replaces torch_compat with torch/all.h, and updated the sm120 files to use torch/all.h instead of torch/python.h
…_library_macros

- Drop torch_library_macros.hpp; register ops via TORCH_FN directly and rename
  torch_library_utils namespace to torch_utils.
- Use at::ScalarType/torch.dtype for logits_dtype instead of int + _SCALAR_TYPE dict.
- Align schema/wrapper param names with C++ impl (fused_kv_cache,
  activation_clamp_opt, *_tuple/*_tuple_opt), propagated to _C.py, mega/__init__.py,
  and tests.
- Prefix slice_symm_buffer_for_mega_moe with _ to mark it private.

Signed-off-by: Chris Leonard <[email protected]>
…o align it with the C++ names

Signed-off-by: Chris Leonard <[email protected]>
cleonard530 pushed a commit that referenced this pull request Sep 24, 2026
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.

8 participants