Skip to content

[None][perf] Add a global split to sparse MLA decode for low-row decode on SM107 - #22252

Merged
yizhang-nv merged 2 commits into
NVIDIA:feat/mistral-large-4from
yt0428:codex/ml4-vr200-pr-sparse-mla
Nov 16, 2026
Merged

yizhang-nv merged 2 commits into
NVIDIA:feat/mistral-large-4from
yt0428:codex/ml4-vr200-pr-sparse-mla

Conversation

@yt0428

@yt0428 yt0428 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

Adds a global-workspace split-K variant (global16) to the CuTe DSL sparse MLA decode kernel for low-row decode on SM107 (VR200).

At 1–8 generation rows, the existing cluster split runs too few CTAs to fill the GPU. The global variant instead runs 16 independent split CTAs per row, writing FP32 partials (516 elements per row, split and head: the 512-wide normalized output plus LSE) to a per-call workspace, then merges them with one combine launch.

What changes

  • _ds_mla_sparse_decode_kernel.py: the global-partials path and the combine kernel sit behind a compile-time global_partials flag that defaults to False. The cluster variants compile to the same code as before.
  • cute_dsl_ds_mla_sparse_decode.py:
    • build() compiles the global variant only when the device capability is (10, 7).
    • A call runs it when 1 <= rows <= 8 and rows * 16 <= num_sms.
    • Rows above 8, other architectures, and SM103 (B300) keep the cluster split.
    • The workspace is allocated per call through PyTorch, so stream and CUDA graph pool lifetimes are preserved.

Impact on other targets: only the Mistral Large 4 NVFP4 targets call this op (sm_103 tp4/tep4, sm_107 tp4/tep4). Behaviour on SM103 is unchanged. On SM107, sm_107__tep4 takes the global path at the same row counts as sm_107__tp4.

VR200 results

These were measured with the earlier gate, which ran the global path at rows 4 and 8 on 212 SMs.

Check Result
Operator matrix (720 cells; contexts 16K–487K; rows 4/8/16) heads8 11.80 → 10.04 µs (−14.9%); heads16 12.28 → 10.40 µs (−15.3%); 5/5 blocks
Rows-16 subset (cluster fallback) +0.55%, within protection
Wide query (64 query heads, 128K) −15.0% / −15.4%
K-B → sparse MLA → V-B chain, C1 heads8/rows4 14.98 → 12.00 µs (−19.9%)
End-to-end ABBA, 1000/ITL p50, C1/TP8 +1.82% (pairs +2.00% / +1.64%)
End-to-end ABBA, C4/TP4 +3.30%, descriptive only. One pair had only 62 common requests, and protection was not established.

At rows 16, global16 was 18–20% slower than the cluster split, so rows 16 stay on the cluster split.

Not measured yet: the gate now runs global16 at rows 1–8 whenever they fit in one wave, instead of only rows 4 and 8. Rows 1, 2, 3, 5, 6 and 7 on the global path have not been timed on GPU.

Test Coverage

tests/unittest/_torch/modeling_v2/attention/test_modeling_v2_cute_dsl_ds_mla_sparse_decode.py

  • test_global_split_boundaries_and_dynamic_graph: heads 8/16, rows 1–8 and 16, NoPE on/off, with dynamic CUDA graph replay.
  • test_global_split_concurrent_graph_workspaces: concurrent graphs with independent workspaces, run directly and through the wrapper.
  • test_global_split_at_1m_large_address (large): 1M-key pools above 4 GiB.
  • test_global_split_row_gate (CPU-only): the rows × SMs gate.
  • test_low_row_wrapper_padded_query_and_graph: rows 1–9 and 16 through the wrapper, with a padded query.

The global-split GPU tests also run on B300 pre-merge.

On VR200 the rows-4/8 version passed 14 focused tests, 4 real 1M-pool tests, 24 bitwise checks against the cluster path, 22 wrapper-wiring tests, and 108 fallback cells × 100 graph replays. The widened row gate's tests have not run on GPU yet.

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • If PR introduces API changes, an appropriate PR label is added - either api-compatible or api-breaking. For api-breaking, include BREAKING in the PR title.

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

🤖 Generated with Claude Code

…n SM107

Run the global16 split for 1 to 8 rows on SM107 whenever the
rows x 16 CTAs fit in one wave of the SMs, instead of only rows 4 and 8
on exactly 212 SMs. Rows above 8 keep the cluster split.

Tests cover global rows 1-9 and 16 and a CPU-only row-gate check.

Signed-off-by: yt0428 <[email protected]>
@yt0428

yt0428 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "Format check only"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #84735 [ skip ] triggered by Bot. Commit: 071a751 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #84735 [ skip ] completed with state SUCCESS. Commit: 071a751
Skipping testing for commit 071a751

Link to invocation

@yizhang-nv
yizhang-nv merged commit cf9dd3f into NVIDIA:feat/mistral-large-4 Nov 16, 2026
10 checks passed
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 17, 2026
… for low-row decode on SM107

Port of feat/mistral-large-4 cf9dd3f (NVIDIA#22252) onto this branch, where the
op and its kernel live in the family (ops/attention/cute_dsl_ds_mla_sparse_decode
and kernels/_ds_mla_sparse_decode_kernel) and the op test under the family's
ops tests.

On SM107, a decode call with 1 to 8 rows whose 16 CTAs per row fit in one wave
of the SMs runs 16 independent split CTAs per row and one combine launch,
instead of the cluster split. Each call allocates its FP32 partial workspace
through PyTorch, so stream and CUDA-graph pool lifetimes are kept. Other shapes
and devices keep the cluster path.

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 17, 2026
The ops the SM107 decode ports bring (NVIDIA#22249, NVIDIA#22250, NVIDIA#22251, NVIDIA#22252) are
tested on sm_107 only; feat/mistral-large-4 lists none of their tests.
l0_gr100 now runs the split radix top-k test, the sparse MLA decode test (its
global-split cases need sm_107) and the sm_107 tp target's test directory
(low_m_cublas_mm and the fused FP8 GEMV).

Signed-off-by: Yi Zhang <[email protected]>
@yt0428
yt0428 deleted the codex/ml4-vr200-pr-sparse-mla branch November 18, 2026 02:52
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 20, 2026
… for low-row decode on SM107

Port of feat/mistral-large-4 cf9dd3f (NVIDIA#22252) onto this branch, where the
op and its kernel live in the family (ops/attention/cute_dsl_ds_mla_sparse_decode
and kernels/_ds_mla_sparse_decode_kernel) and the op test under the family's
ops tests.

On SM107, a decode call with 1 to 8 rows whose 16 CTAs per row fit in one wave
of the SMs runs 16 independent split CTAs per row and one combine launch,
instead of the cluster split. Each call allocates its FP32 partial workspace
through PyTorch, so stream and CUDA-graph pool lifetimes are kept. Other shapes
and devices keep the cluster path.

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 20, 2026
The ops the SM107 decode ports bring (NVIDIA#22249, NVIDIA#22250, NVIDIA#22251, NVIDIA#22252) are
tested on sm_107 only; feat/mistral-large-4 lists none of their tests.
l0_gr100 now runs the split radix top-k test, the sparse MLA decode test (its
global-split cases need sm_107) and the sm_107 tp target's test directory
(low_m_cublas_mm and the fused FP8 GEMV).

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 23, 2026
… for low-row decode on SM107

Port of feat/mistral-large-4 cf9dd3f (NVIDIA#22252) onto this branch, where the
op and its kernel live in the family (ops/attention/cute_dsl_ds_mla_sparse_decode
and kernels/_ds_mla_sparse_decode_kernel) and the op test under the family's
ops tests.

On SM107, a decode call with 1 to 8 rows whose 16 CTAs per row fit in one wave
of the SMs runs 16 independent split CTAs per row and one combine launch,
instead of the cluster split. Each call allocates its FP32 partial workspace
through PyTorch, so stream and CUDA-graph pool lifetimes are kept. Other shapes
and devices keep the cluster path.

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 23, 2026
The ops the SM107 decode ports bring (NVIDIA#22249, NVIDIA#22250, NVIDIA#22251, NVIDIA#22252) are
tested on sm_107 only; feat/mistral-large-4 lists none of their tests.
l0_gr100 now runs the split radix top-k test, the sparse MLA decode test (its
global-split cases need sm_107) and the sm_107 tp target's test directory
(low_m_cublas_mm and the fused FP8 GEMV).

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 23, 2026
… for low-row decode on SM107

Port of feat/mistral-large-4 cf9dd3f (NVIDIA#22252) onto this branch, where the
op and its kernel live in the family (ops/attention/cute_dsl_ds_mla_sparse_decode
and kernels/_ds_mla_sparse_decode_kernel) and the op test under the family's
ops tests.

On SM107, a decode call with 1 to 8 rows whose 16 CTAs per row fit in one wave
of the SMs runs 16 independent split CTAs per row and one combine launch,
instead of the cluster split. Each call allocates its FP32 partial workspace
through PyTorch, so stream and CUDA-graph pool lifetimes are kept. Other shapes
and devices keep the cluster path.

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 23, 2026
The ops the SM107 decode ports bring (NVIDIA#22249, NVIDIA#22250, NVIDIA#22251, NVIDIA#22252) are
tested on sm_107 only; feat/mistral-large-4 lists none of their tests.
l0_gr100 now runs the split radix top-k test, the sparse MLA decode test (its
global-split cases need sm_107) and the sm_107 tp target's test directory
(low_m_cublas_mm and the fused FP8 GEMV).

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 24, 2026
… for low-row decode on SM107

Port of feat/mistral-large-4 cf9dd3f (NVIDIA#22252) onto this branch, where the
op and its kernel live in the family (ops/attention/cute_dsl_ds_mla_sparse_decode
and kernels/_ds_mla_sparse_decode_kernel) and the op test under the family's
ops tests.

On SM107, a decode call with 1 to 8 rows whose 16 CTAs per row fit in one wave
of the SMs runs 16 independent split CTAs per row and one combine launch,
instead of the cluster split. Each call allocates its FP32 partial workspace
through PyTorch, so stream and CUDA-graph pool lifetimes are kept. Other shapes
and devices keep the cluster path.

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 24, 2026
The ops the SM107 decode ports bring (NVIDIA#22249, NVIDIA#22250, NVIDIA#22251, NVIDIA#22252) are
tested on sm_107 only; feat/mistral-large-4 lists none of their tests.
l0_gr100 now runs the split radix top-k test, the sparse MLA decode test (its
global-split cases need sm_107) and the sm_107 tp target's test directory
(low_m_cublas_mm and the fused FP8 GEMV).

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 26, 2026
… for low-row decode on SM107

Port of feat/mistral-large-4 cf9dd3f (NVIDIA#22252) onto this branch, where the
op and its kernel live in the family (ops/attention/cute_dsl_ds_mla_sparse_decode
and kernels/_ds_mla_sparse_decode_kernel) and the op test under the family's
ops tests.

On SM107, a decode call with 1 to 8 rows whose 16 CTAs per row fit in one wave
of the SMs runs 16 independent split CTAs per row and one combine launch,
instead of the cluster split. Each call allocates its FP32 partial workspace
through PyTorch, so stream and CUDA-graph pool lifetimes are kept. Other shapes
and devices keep the cluster path.

Signed-off-by: Yi Zhang <[email protected]>
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 26, 2026
The ops the SM107 decode ports bring (NVIDIA#22249, NVIDIA#22250, NVIDIA#22251, NVIDIA#22252) are
tested on sm_107 only; feat/mistral-large-4 lists none of their tests.
l0_gr100 now runs the split radix top-k test, the sparse MLA decode test (its
global-split cases need sm_107) and the sm_107 tp target's test directory
(low_m_cublas_mm and the fused FP8 GEMV).

Signed-off-by: Yi Zhang <[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