Skip to content

[None][perf] Use a split radix Top-K for Mistral Large 4 DSpark verification on SM107 - #22249

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

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

Conversation

@yt0428

@yt0428 yt0428 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

Adds a CuTe DSL split radix Top-K selector for the indexer's DSpark verification step (next_n = 4) in the Mistral Large 4 SM107 (VR200) decode target, replacing the native indexer_topk_decode op for the shapes it covers.

Kernel (catalog/attention/_radix_topk_decode.py, cute_dsl_radix_topk_decode.py)

  • Each row is split into ten partitions (P10), selected with a radix pass, and merged with a radix merge, at the same output as the native op (up to exact ties).
  • The first pass reads 256-bit vectors from the 8-column boundary at or below each partition start, and filters neighbouring columns by predicate. That pass covers the digit-31..20 histogram and the negative-NaN count.
  • build_split compiles the selector. split_radix_topk_decode keeps the native op whenever:
    • the native op would not split the call into ten blocks;
    • the rows are not 32-byte aligned;
    • the width or row stride is not a multiple of 8.

Dispatch (mistral_large_4_nvfp4__sm_107__tp4/modeling.py)

  • The selector is built when the scorer width (the engine's max_seq_len) is between 20480 and 1048584 columns and top-k is 2048.
    • 20480 is the narrowest row the native op splits into ten blocks.
    • 1048584 is the split kernel's widest row.
  • A new _select_indexer_decode routes each call to one of three selectors:
    • the split selector, for next_n = 4, rows 4/8/16 and FP32 logits;
    • the existing one-CTA-per-row selector, for next_n = 1;
    • the native op, for everything else.
  • The prefill and decode targets both call it, replacing their duplicated selection code.

VR200 results

Check Result
Component T1, weighted (16 main + 34 guard shapes, 5/5 blocks) native 40.21 → 24.33 µs (−39.5%)
Per width, native → split (µs) 16K 22.42 → 13.89; 64K 33.80 → 18.95; 131K 36.17 → 21.15; 335K 45.42 → 28.29; 487K 54.24 → 33.24; 1M 76.19 → 55.94 (−26.6%)
End-to-end ABBA, 1000/ITL p50, before vectorization C1/TP8 +6.94% (ITL p50 4.13 → 3.87 ms); C4/TP4 +5.13% (thin request pairing, inconclusive)
Vectorization alone, C4/TP4 end-to-end, one A/B −0.64% (within noise)
Quality, before vectorization GSM8K, RULER, MMMU and GPQA at TP4 and TP8 all pass

Not measured yet

  • Vectorized C1/TP8 and near-1M end-to-end runs.
  • Quality with the vectorized kernel.
  • This exact branch on GPU.

Known differences

  • Top-K picks can differ from the native op when NaN or Inf appears inside the valid causal range; this shows up only in the synthetic test.
  • A compute-sanitizer memcheck run reported 33 host API errors that are still open.

Test Coverage

tests/unittest/_torch/modeling_v2/attention/test_modeling_v2_split_radix_topk_decode.py checks the selector against the native op. Cases cover:

  • causal selection at batch 1/2/4, which is rows 4/8/16 at next_n 4, with ordinary inputs, ties and boundaries, at 16K and 64K columns;
  • protection shapes up to 1048584 columns;
  • partition starts at every offset inside a 256-bit vector;
  • the unaligned-layout fallback and the native partition fallback;
  • non-finite semantics, invalid inputs and sentinel tie counts;
  • CUDA graph replay with dynamic lengths.

On VR200: 32/32 unit tests pass, plus 264 harness correctness checks at the fast and 1M widths with 6600 graph replays.

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

The P10 split stage's first pass (digit 31..20 histogram and the
negative-NaN count) now reads 256-bit vectors from the 8-column boundary
at or below each partition start, filtering neighbouring columns by
predicate. Selection, the emit pass and the merge are unchanged. Logits
whose rows are not 32-byte aligned, or whose width or row stride is not
a multiple of 8, use the native op; the scorer arena's production views
satisfy these conditions.

Validation on VR200 (SM107):
- T0: 32 unit tests pass, including new tests for partition starts at
  every offset inside a vector and for the unaligned-layout fallback.
  Harness correctness at the fast and 1M production widths passes
  (264 checks, 6600 dynamic CUDA graph replays).
- T1 (frozen protocol, 3 seeds x hot/cycling x 5 interleaved blocks,
  epsilon 1%): committed P10 -> vectorized P10 weighted complete call
  28.30 -> 24.32 us (-14.1%), B1 -12.9%, 5/5 blocks; 334K -17%,
  487K -22%, full 1M rows -27%; rows up to 16K within +-1%. Against
  native the weighted reduction is -39.5% (was -29.7%), and full 1M
  rows move from +0.9% to -26.6%. All protection shapes pass.
- T3 (C4/TP4, one AB pair, original 393-trajectory protocol, same
  node): ITL p50 4.390 -> 4.419 ms (-0.64% speed, within noise),
  243/243 requests and zero errors in both arms. 110 equal-length
  paired requests show a 0.51% lower mean ITL for B. The C4 context
  mix (median 66K, none above 524K) predicts about 0.6%, so no
  end-to-end gain is established for C4; long-context (C1/TP8 or near
  1M) end-to-end runs were not performed.

Signed-off-by: yt0428 <[email protected]>
… scorer widths

Build and dispatch the SM107 split radix selector for any decode scorer
width from 20480 to 1048584 columns, instead of only the 1048584-column
width with a 1048832-column row stride. Below 20480 columns the native
op never splits a row into ten blocks, so the selector would always
fall back; 1048584 is the split kernel's widest row.

split_radix_topk_decode already keeps the native op when the native op
would not split the call into ten blocks, or when the rows are not
32-byte aligned with a width that is a multiple of 8, so the exact
width and stride checks at the call site are dropped. next_n 4, rows
4/8/16, fp32 logits and top-k 2048 are still required.

Component timings so far cover the 1048584-column width only.

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 #84737 [ skip ] triggered by Bot. Commit: 0d83eb1 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #84737 [ skip ] completed with state SUCCESS. Commit: 0d83eb1
Skipping testing for commit 0d83eb1

Link to invocation

@yizhang-nv
yizhang-nv merged commit 3976d54 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
…fication on SM107

Port of feat/mistral-large-4 3976d54 (NVIDIA#22249) onto this branch. The
selector and its kernel live in the family (ops/attention/
cute_dsl_radix_topk_decode and kernels/_radix_topk_decode), and the native
fallback is the family's indexer_topk_decode; the op test sits under the
family's ops tests.

The sm_107 tp target selects the decode indexer's top-k for DSpark
verification (next_n 4, 4/8/16 rows, 20480 to 1048584 columns) with
split_radix_topk_decode: ten partitions per row and a radix merge. A call the
native op would not split into ten blocks, or whose rows are not 32-byte
aligned with a width that is a multiple of 8, keeps the native op. next_n 1
keeps the one-CTA-per-row selector.

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-topk branch November 18, 2026 02:52
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 20, 2026
…fication on SM107

Port of feat/mistral-large-4 3976d54 (NVIDIA#22249) onto this branch. The
selector and its kernel live in the family (ops/attention/
cute_dsl_radix_topk_decode and kernels/_radix_topk_decode), and the native
fallback is the family's indexer_topk_decode; the op test sits under the
family's ops tests.

The sm_107 tp target selects the decode indexer's top-k for DSpark
verification (next_n 4, 4/8/16 rows, 20480 to 1048584 columns) with
split_radix_topk_decode: ten partitions per row and a radix merge. A call the
native op would not split into ten blocks, or whose rows are not 32-byte
aligned with a width that is a multiple of 8, keeps the native op. next_n 1
keeps the one-CTA-per-row selector.

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
…fication on SM107

Port of feat/mistral-large-4 3976d54 (NVIDIA#22249) onto this branch. The
selector and its kernel live in the family (ops/attention/
cute_dsl_radix_topk_decode and kernels/_radix_topk_decode), and the native
fallback is the family's indexer_topk_decode; the op test sits under the
family's ops tests.

The sm_107 tp target selects the decode indexer's top-k for DSpark
verification (next_n 4, 4/8/16 rows, 20480 to 1048584 columns) with
split_radix_topk_decode: ten partitions per row and a radix merge. A call the
native op would not split into ten blocks, or whose rows are not 32-byte
aligned with a width that is a multiple of 8, keeps the native op. next_n 1
keeps the one-CTA-per-row selector.

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
…fication on SM107

Port of feat/mistral-large-4 3976d54 (NVIDIA#22249) onto this branch. The
selector and its kernel live in the family (ops/attention/
cute_dsl_radix_topk_decode and kernels/_radix_topk_decode), and the native
fallback is the family's indexer_topk_decode; the op test sits under the
family's ops tests.

The sm_107 tp target selects the decode indexer's top-k for DSpark
verification (next_n 4, 4/8/16 rows, 20480 to 1048584 columns) with
split_radix_topk_decode: ten partitions per row and a radix merge. A call the
native op would not split into ten blocks, or whose rows are not 32-byte
aligned with a width that is a multiple of 8, keeps the native op. next_n 1
keeps the one-CTA-per-row selector.

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
…fication on SM107

Port of feat/mistral-large-4 3976d54 (NVIDIA#22249) onto this branch. The
selector and its kernel live in the family (ops/attention/
cute_dsl_radix_topk_decode and kernels/_radix_topk_decode), and the native
fallback is the family's indexer_topk_decode; the op test sits under the
family's ops tests.

The sm_107 tp target selects the decode indexer's top-k for DSpark
verification (next_n 4, 4/8/16 rows, 20480 to 1048584 columns) with
split_radix_topk_decode: ten partitions per row and a radix merge. A call the
native op would not split into ten blocks, or whose rows are not 32-byte
aligned with a width that is a multiple of 8, keeps the native op. next_n 1
keeps the one-CTA-per-row selector.

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
…fication on SM107

Port of feat/mistral-large-4 3976d54 (NVIDIA#22249) onto this branch. The
selector and its kernel live in the family (ops/attention/
cute_dsl_radix_topk_decode and kernels/_radix_topk_decode), and the native
fallback is the family's indexer_topk_decode; the op test sits under the
family's ops tests.

The sm_107 tp target selects the decode indexer's top-k for DSpark
verification (next_n 4, 4/8/16 rows, 20480 to 1048584 columns) with
split_radix_topk_decode: ten partitions per row and a radix merge. A call the
native op would not split into ten blocks, or whose rows are not 32-byte
aligned with a width that is a multiple of 8, keeps the native op. next_n 1
keeps the one-CTA-per-row selector.

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