Skip to content

[Perf] [NVIDIA] sgl-kernel: Build FlashMLA natively for sm_107a - #45884

Closed
zcnrex wants to merge 2 commits into
sgl-project:mainfrom
zcnrex:flashmla-sm107a
Closed

zcnrex wants to merge 2 commits into
sgl-project:mainfrom
zcnrex:flashmla-sm107a

Conversation

@zcnrex

@zcnrex zcnrex commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

On CC 10.7 devices, flashmla_ops runs the sm_100f family binary. Native sm_107a codegen is faster for the FlashMLA kernels DeepSeek-V4.1 uses (fused core_attn decode/prefill), measured with per-kernel profiles of a serving run. Numbers are available on request.

The pinned CUTLASS (147f567) lists no SM107, so an sm_107a build compiles but silently loses features. This happens in three headers:

  • arch/config.h: the SM100A/F MMA and TMA enables
  • arch/reg_reconfig.h: CUDA_CTA_RECONFIG_ACTIVATED, so warpgroup_reg_alloc/dealloc (setmaxnreg) become no-ops and the warp-specialized kernels spill
  • arch/grid_dependency_control.h: CUTLASS_GDC_ENABLED (PDL)

Modifications

  • cmake/flashmla.cmake: when nvcc --list-gpu-arch reports compute_107, add -gencode=arch=compute_107a,code=sm_107a and patch the fetched CUTLASS headers. This is the same approach as the existing SM103 config.h patch.
  • cmake/patch_cutlass_sm107.py: an idempotent patch of the three headers. Each anchor must match exactly once.

Builds with an nvcc that lacks compute_107 are unchanged.

Accuracy Tests

On a CC 10.7 device, with flashmla_ops built from this branch's cmake:

  • The binary contains sm_100, sm_103a and sm_107a code.
  • The sm_107a SASS has the same 254 USETMAXREG as the sm_100f build, and core_attn no longer spills.
  • tests/test_flashmla.py and tests/test_flashmla_mega.py: 28 passed.
  • DeepSeek-V4.1-Flash served end to end (TP4/EP4, DSpark) without errors.

A model-level accuracy eval is still to do (draft).

Speed Tests and Profiling

Per-kernel A/B against the sm_100f binary on the same device, ABBA-ordered serving profiles: fused core_attn decode and prefill are faster. The other FlashMLA kernels are neutral. The end-to-end difference at bs32 128K/1K is within run-to-run noise.

Checklist

Related: the same CUTLASS patch for the DeepGEMM and FlashMLA forks (links below).

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #39844141095
Latest PR Test (Extra): ❌ Run #39844140984
Latest PR Test (AMD ROCm 10): ❌ Run #39844140982

The pinned cutlass has no SM107 entries in its arch lists, so a sm_107a
build compiles but loses the SM100 MMA/TMA paths, setmaxnreg register
reconfiguration and PDL. Patch the three headers (arch/config.h,
arch/reg_reconfig.h, arch/grid_dependency_control.h) and add the
sm_107a gencode when nvcc supports compute_107.

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

zcnrex commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator Author

Related: #45884 (sglang flashmla_ops build), sgl-project/DeepGEMM#113 (DeepGEMM JIT), sgl-project/FlashMLA#20 (FlashMLA wheel). All three use the same CUTLASS SM107 patch.

CUTLASS v4.8.0+ supports SM107 natively (arch/config.h SM107A/F,
reg_reconfig.h, grid_dependency_control.h, struct Sm107) and already
carries the SM103 defines, so drop both header patches.

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

zcnrex commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator Author

Status update: this PR is on hold, and its current branch does not build.

Plan: once FlashMLA#20 lands in a released sgl-flash-mla and #45635 merges, I'll repurpose this PR to bump the sgl-flash-mla pin. I'll drop the in-tree CUTLASS change unless the remaining sgl-kernel FlashMLA paths need it.

@zcnrex
zcnrex marked this pull request as ready for review October 22, 2026 21:06
@zcnrex

zcnrex commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: this is superseded.

@zcnrex zcnrex closed this Oct 29, 2026
@zcnrex
zcnrex deleted the flashmla-sm107a branch October 29, 2026 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant