Skip to content

[None][perf] Use a direct BF16 GEMM for Mistral Large 4 narrow decode projections on SM107 - #22251

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

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

Conversation

@yt0428

@yt0428 yt0428 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

Routes the narrow BF16 decode projections (N = 160, 512, 576 at K = 6144) of the Mistral Large 4 SM107 (VR200) decode target to FlashInfer's direct dense BF16 GEMM kernel with fixed tactics, instead of cuBLAS. At M ≤ 16 these projections are launch- and latency-bound under cuBLAS.

What changes

  • New entry low_m_cublas_mm (LowMCublasMm, a subclass of the shared CublasMm), in the mistral_large_4_nvfp4__sm_107__tp4 target's own ops/gemm/low_m_cublas_mm.py. It lives there, not in catalog/, because only this target calls it. This follows the modeling_v2 op-ownership rule.

  • A fixed table of 10 (M, N, K) cells maps to direct-kernel tactics: draft 3/6/12×576; target 4×{576, 512, 160}, 8×{576, 512, 160} and 16×160.

  • Every call is gated on:

    • SM107;
    • BF16 operands and output with no bias;
    • a plain output buffer and no group;
    • contiguous row-major A, column-major B and 32-byte alignment;
    • the exact shape.

    Anything else, including FP32 router logits and collective output buffers, runs torch.ops.trtllm.cublas_mm as before. There is no mutable tactic cache.

  • The target imports low_m_cublas_mm as cublas_mm, so its call sites are unchanged. catalog/gemm/cublas_mm.py is not modified.

VR200 results

Measured on the first 4 cells (3×576, 4×160, 4×512, 4×576):

Check Result
Screen median, cuBLAS → direct (µs) 3×576 4.662 → 2.160; 4×160 3.514 → 1.843; 4×512 3.725 → 2.271; 4×576 4.691 → 2.332
C1/TP8 weighted 206-call mix hot 912.5 → 674.4 µs (−26.1%); cold 946.1 → 732.6 µs (−22.6%)
C4/TP4 (fallback protection) hot −0.03%, cold +0.004%; worst fallback regression 0.43%, inside the 3% gate
End-to-end ABBA, 1000/ITL p50 C1/TP8 +2.01% (ITL p50 4.12/4.14 → 4.06/4.05 ms); C4/TP4 +0.68%, within the 1% noise band

Not measured yet

  • The 6 cells added later (6×576, 12×576, 8×{576, 512, 160}, 16×160) have not been timed on GPU. Their tactics were chosen from M=16 screen trends.
  • This PR and the SparseMLA PR have not been measured together.

Merge note: this PR and the fused FP8 linear PR each add one import line at the same spot in the target's modeling.py. Whichever merges second keeps both lines; nothing else overlaps. Both PRs add the same ops/__init__.py and ops/gemm/__init__.py.

Test Coverage

tests/unittest/_torch/modeling_v2/models/mistral_large4/mistral_large_4_nvfp4__sm_107__tp4/gemm/test_modeling_v2_low_m_cublas_mm.py

  • Certified-cell accuracy against a cuBLAS reference for every table cell.
  • Explicit fallback shapes (M = 6/8/12/16 outside the table, larger M) and the non-table dtype and layout paths.
  • The module skips without a CUDA device instead of asserting at import, because the CPU stage collects this directory.
  • The test_modeling_v2_claims.py gates cover the new owned entry.

On VR200 the original 4-cell version passed 33 tests, plus 63 fallback cases with 6300 graph replays. The 10-cell table has 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

Extend the fixed direct-kernel table from 4 to 10 shapes, adding
draft 6x576 and 12x576 and target 8x576, 8x512, 8x160 and 16x160 at
K=6144. 16x512, 16x576 and larger M stay on cuBLAS.

Tests cover explicit fallback shapes.

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

low_m_cublas_mm is called only by the mistral_large_4_nvfp4__sm_107__tp4
target, so it moves out of the shared catalog/gemm/cublas_mm.py into
that target's ops/gemm/low_m_cublas_mm.py, following the modeling_v2
op-ownership rule. The table, tactic gate and entry move unchanged; the
entry still subclasses the shared CublasMm and falls back to it.

Its tests move from the shared cublas_mm test to the owned-entry path
tests/unittest/_torch/modeling_v2/models/mistral_large4/
mistral_large_4_nvfp4__sm_107__tp4/gemm/test_modeling_v2_low_m_cublas_mm.py,
which skips without a CUDA device instead of asserting at import, since
the CPU stage collects that directory. catalog/gemm/cublas_mm.py and its
test match the base branch again.

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 #84739 [ skip ] triggered by Bot. Commit: 17e3629 Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #84739 [ skip ] completed with state SUCCESS. Commit: 17e3629
Skipping testing for commit 17e3629

Link to invocation

@yizhang-nv
yizhang-nv merged commit 3dfa750 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
… decode projections

Port of feat/mistral-large-4 3dfa750 (NVIDIA#22251) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22251's
__sm_107__tp4). The target's test directory gets package markers, as the
other targets' do.

The sm_107 tp target's BF16 projections go through low_m_cublas_mm, a
target-local op: the narrow decode shapes of the target and draft kv_a and
indexer projections (M up to 16 rows, N 160 to 576, K 6144) run a direct
kernel with a fixed tactic each; every other shape takes the cublas_mm entry.

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

Port of feat/mistral-large-4 3dfa750 (NVIDIA#22251) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22251's
__sm_107__tp4). The target's test directory gets package markers, as the
other targets' do.

The sm_107 tp target's BF16 projections go through low_m_cublas_mm, a
target-local op: the narrow decode shapes of the target and draft kv_a and
indexer projections (M up to 16 rows, N 160 to 576, K 6144) run a direct
kernel with a fixed tactic each; every other shape takes the cublas_mm entry.

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
… decode projections

Port of feat/mistral-large-4 3dfa750 (NVIDIA#22251) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22251's
__sm_107__tp4). The target's test directory gets package markers, as the
other targets' do.

The sm_107 tp target's BF16 projections go through low_m_cublas_mm, a
target-local op: the narrow decode shapes of the target and draft kv_a and
indexer projections (M up to 16 rows, N 160 to 576, K 6144) run a direct
kernel with a fixed tactic each; every other shape takes the cublas_mm entry.

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
… decode projections

Port of feat/mistral-large-4 3dfa750 (NVIDIA#22251) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22251's
__sm_107__tp4). The target's test directory gets package markers, as the
other targets' do.

The sm_107 tp target's BF16 projections go through low_m_cublas_mm, a
target-local op: the narrow decode shapes of the target and draft kv_a and
indexer projections (M up to 16 rows, N 160 to 576, K 6144) run a direct
kernel with a fixed tactic each; every other shape takes the cublas_mm entry.

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
… decode projections

Port of feat/mistral-large-4 3dfa750 (NVIDIA#22251) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22251's
__sm_107__tp4). The target's test directory gets package markers, as the
other targets' do.

The sm_107 tp target's BF16 projections go through low_m_cublas_mm, a
target-local op: the narrow decode shapes of the target and draft kv_a and
indexer projections (M up to 16 rows, N 160 to 576, K 6144) run a direct
kernel with a fixed tactic each; every other shape takes the cublas_mm entry.

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
… decode projections

Port of feat/mistral-large-4 3dfa750 (NVIDIA#22251) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22251's
__sm_107__tp4). The target's test directory gets package markers, as the
other targets' do.

The sm_107 tp target's BF16 projections go through low_m_cublas_mm, a
target-local op: the narrow decode shapes of the target and draft kv_a and
indexer projections (M up to 16 rows, N 160 to 576, K 6144) run a direct
kernel with a fixed tactic each; every other shape takes the cublas_mm entry.

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