Skip to content

[None][perf] Fuse FP8 quantization and GEMM for Mistral Large 4 low-M decode on SM107 - #22250

Merged
yt0428 merged 7 commits into
NVIDIA:feat/mistral-large-4from
yt0428:codex/ml4-vr200-pr-fp8-quant
Nov 16, 2026
Merged

yt0428 merged 7 commits into
NVIDIA:feat/mistral-large-4from
yt0428:codex/ml4-vr200-pr-fp8-quant

Conversation

@yt0428

@yt0428 yt0428 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai summary

Description

Fuses the activation's K128 FP8 quantization and the FP8 block-scale GEMM into one CuTe DSL launch for the low-M decode projections of the Mistral Large 4 SM107 (VR200) decode target. It removes the separate quantization kernel and the global activation scratch between the two.

Kernel (ops/gemm/_fused_fp8_quant_gemv.py)

  • A split-K GEMV-style kernel quantizes the activation fragment in shared memory and accumulates with FP8 MMA.
  • Each CTA issues its FP8 weights and K128 weight scales before griddepcontrol.wait, up to eight K128 slots ahead, and refills a register ring as slots are consumed. This streams weights during the previous kernel's tail.
  • The kernel requires that weights and weight scales are not written by the immediately preceding kernel.

Entry (ops/gemm/cute_dsl_fused_fp8_block_scale_linear.py)

  • Has one tactic (split-K, warps) per (M, N, K), for 62 cells across every per-rank FP8 projection of the TP8 and TP4 decode target at M = 1, 2, 4, 8, 12, 16. The projections are wq, wo, the indexer's wq_b, shared-expert gate/up and down, and dense gate/up and down.
  • Any shape outside the table runs the existing MXFP8 kernel (cute_dsl_fp8_block_scale_linear), so the target's _linear_fp8 calls the entry unconditionally.
  • Both files live under the mistral_large_4_nvfp4__sm_107__tp4 target's own ops/gemm/, not catalog/, because only this target calls them. This follows the modeling_v2 op-ownership rule.

Tactic selection

  • A VR200 sweep timed every valid split-K × warps configuration at prefetch depth 8. It ran 4320 CUDA-graph timings over 72 TP8/TP4 cells, with L2-resident and streamed weights.
  • A cell is kept only where its fastest tactic beats MXFP8 by at least 3% in both weight modes.
  • 10 cells fall back to MXFP8: wq_b, dense down and 6144×6144 at M = 12/16, and TP4 dense gate/up (12288×6144) at M ≥ 4.

VR200 results (synthetic CUDA-graph component timing; the MXFP8 baseline uses tactics from the C1/TP8 and C4/TP4 autotuner caches)

Check Result
Weighted 332-call gate, C1/TP8 (M=4) +41.1% L2-resident / +40.8% streamed, 15/15 blocks
Weighted 332-call gate, C4/TP4 (M=16) +7.5% / +7.6%, 15/15 blocks
Per cell vs MXFP8 none slower; median +31.7% / +30.9%
First-call compile, DSpark M=4..16 about 5 s per topology (0.2–0.4 s per shape)
Largest per-call scratch 3.45 MiB

Not measured yet: an end-to-end serving A/B with this table. Tactics were selected on the same sweep they are judged by, which carries about 1% selection bias.

Merge note: this PR and the LowM GEMM 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_cute_dsl_fused_fp8_block_scale_linear.py

  • test_certified_cells: every one of the 62 table cells is driven from op.CELLS under certifying(op), with three input draws per cell.
  • A dispatch test checks per-rank TP8 and TP4 shapes against the fused path. It also checks that M=32 and an untuned shape (wq_b at M=16) stay on MXFP8.
  • The test_modeling_v2_claims.py gates (cells-driven test, no cross-target file sharing) cover the new owned entry.

On VR200, 421 unit tests pass with this table. The untuned-shape dispatch case was added afterwards and has not run on GPU. The SM107 kernel tests skip on other GPUs.

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

Add a CuTe DSL kernel that quantizes the activation to K128 FP8 and runs
the FP8 GEMM in one launch, without a global activation scratch, and
route the SM107 decode target's FP8 linears through it for 4-row TP8
steps.

Signed-off-by: yt0428 <[email protected]>
The modeling_v2 claims gate requires every catalog entry that declares
cells to have a test parametrized off its CELLS. Replace the hard-coded
shape list in the fused FP8 block-scale linear test with
test_certified_cells, driven from op.CELLS under certifying(op), keeping
three input draws per cell.

Signed-off-by: yt0428 <[email protected]>
Issue each CTA's FP8 weights and K128 weight-scale bytes before
griddepcontrol.wait, up to eight K128 slots, refilling a register ring
as slots are consumed. Each lane loads two 16-byte chunks per weight
row per slot, and the activation fragment uses the same K permutation
through a bank-conflict-free shared-memory layout. The slot loop is
fully unrolled, and for M <= 8 MMA rows 8-15 are constant zeros.

Weights and weight scales must not be written by the immediately
preceding kernel; the tests create weights before activations.

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

The fused K128 quantization and FP8 GEMM entry is called only by the
mistral_large_4_nvfp4__sm_107__tp4 target, so it moves from
catalog/gemm/ to that target's ops/gemm/, following the modeling_v2
op-ownership rule. Its CuTe DSL kernel moves beside it as the private
module _fused_fp8_quant_gemv.py instead of living in the shared
cute_dsl_kernels/rubin/ library, and its test moves to the owned-entry
path under models/mistral_large4/mistral_large_4_nvfp4__sm_107__tp4/.

The decode target's _linear_fp8 now always calls the entry. The entry's
tactic table already admits only the four M=4 TP8 per-rank shapes and
runs the MXFP8 kernel at every other shape, so the tp_size == 8 and
M == 4 check in the target duplicated it. Dispatch is unchanged for the
TP4 and TP8 shapes. The dispatch test now selects the path by the wq
projection's per-rank width (TP8 1024, TP4 2048) instead of tp_size.

Signed-off-by: yt0428 <[email protected]>
… M up to 16

Extend the fused K128 quantization and FP8 GEMM table from the four TP8
M=4 shapes to every per-rank FP8 projection of the SM107 decode target
at TP8 and TP4: wq, wo, the indexer's wq_b, the shared expert's gate/up
and down, and the dense layer's gate/up and down, each at M = 1, 2, 4,
8, 12 and 16. One tactic per (N, K) serves every M.

The TP8 tactics are the fastest M=4 configurations at the kernel's
default prefetch depth in a probe of the weight-streaming kernel,
averaged over L2-reused and cold weights. This retunes three of the four
existing cells for that kernel: shared-expert gate/up (16, 8) -> (16, 4),
shared-expert down (1, 8) -> (1, 4) and wo (4, 8) -> (1, 4). A partial
M=8 probe of TP8 wq timed the same tactics between 3% faster and 12%
slower than at M=4, and 41-49% below the M=8 baseline.

The TP4-only shapes (wq 2048x6144, shared-expert gate/up 3072x6144,
shared-expert down 6144x1536, wo 6144x2048, dense gate/up 12288x6144)
were not probed. Each keeps the warps and, as nearly as K allows, the
K128 slots per CTA of the nearest probed shape with the same N or K.

None of these tactics has been through the weighted A/B gate, and M
other than 4 and the TP4 shapes have no per-shape timing yet.

Signed-off-by: yt0428 <[email protected]>
Replace the one-tactic-per-(N, K) table with one tactic per (M, N, K),
each the fastest Split-K and warps count at the kernel's default
prefetch depth in a VR200 sweep of every valid configuration (4320
CUDA-graph timings over the 72 TP8/TP4 cells, L2-resident and streamed
weights). The fastest tactic depends on M: above M=8 it moves to eight
warps and more Split-K slices.

A cell is kept only where its tactic beats the MXFP8 kernel by at least
3% in both weight modes. 62 cells remain. The indexer's wq_b, the dense
layer's down projection and the 6144x6144 shape above M=8, and the TP4
dense gate/up projection from M=4, now run the MXFP8 kernel; no fused
tactic beat it there (down to -58% for TP4 dense gate/up at M=16).

On VR200 (synthetic component timing; baseline MXFP8 tactics from the
C1/TP8 and C4/TP4 autotuner caches):
- Weighted 332-call A/B/AA gate: C1/TP8 (M=4) +41.1% / +40.8%, PASS;
  C4/TP4 (M=16) +7.5% / +7.6%, PASS (the previous table: -12.6%, FAIL).
- Per cell: no cell slower than the MXFP8 kernel; median +31.7% with
  L2-resident and +30.9% with streamed weights.
- First-call compile 0.2-0.4 s per shape: about 5 s per topology for
  the M=4..16 DSpark shapes. Largest per-call scratch 3.45 MiB.
- The entry's unit tests pass (421) with this table.

The dispatch test also checks a shape the table leaves to the MXFP8
kernel (wq_b at M=16).

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

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #84738 [ skip ] completed with state SUCCESS. Commit: c6e2b6a
Skipping testing for commit c6e2b6a

Link to invocation

@yt0428

yt0428 commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

/bot skip --comment "Format check only"

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85105 [ skip ] triggered by Bot. Commit: a17746f Link to invocation

@tensorrt-cicd

Copy link
Copy Markdown
Collaborator

PR_Github #85105 [ skip ] completed with state SUCCESS. Commit: a17746f
Skipping testing for commit a17746f

Link to invocation

@yt0428
yt0428 merged commit 416b15a into NVIDIA:feat/mistral-large-4 Nov 16, 2026
8 checks passed
yizhang-nv added a commit to yizhang-nv/TensorRT-LLM that referenced this pull request Nov 17, 2026
…M decode on SM107

Port of feat/mistral-large-4 416b15a (NVIDIA#22250) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22250's
__sm_107__tp4). The target-local entry falls back to the family's
cute_dsl_fp8_block_scale_linear, where this branch keeps that entry.

The decode target's K128 FP8 projections go through
cute_dsl_fused_fp8_block_scale_linear: at the (M, N, K) shapes it has tuned
(M = 1 to 16 rows at the TP4 and TP8 per-rank widths), the activation
quantization is fused into a split-K GEMV; every other shape runs the Rubin
MXFP8 kernel as before. The context path keeps the MXFP8 kernel.

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

Port of feat/mistral-large-4 416b15a (NVIDIA#22250) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22250's
__sm_107__tp4). The target-local entry falls back to the family's
cute_dsl_fp8_block_scale_linear, where this branch keeps that entry.

The decode target's K128 FP8 projections go through
cute_dsl_fused_fp8_block_scale_linear: at the (M, N, K) shapes it has tuned
(M = 1 to 16 rows at the TP4 and TP8 per-rank widths), the activation
quantization is fused into a split-K GEMV; every other shape runs the Rubin
MXFP8 kernel as before. The context path keeps the MXFP8 kernel.

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
…M decode on SM107

Port of feat/mistral-large-4 416b15a (NVIDIA#22250) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22250's
__sm_107__tp4). The target-local entry falls back to the family's
cute_dsl_fp8_block_scale_linear, where this branch keeps that entry.

The decode target's K128 FP8 projections go through
cute_dsl_fused_fp8_block_scale_linear: at the (M, N, K) shapes it has tuned
(M = 1 to 16 rows at the TP4 and TP8 per-rank widths), the activation
quantization is fused into a split-K GEMV; every other shape runs the Rubin
MXFP8 kernel as before. The context path keeps the MXFP8 kernel.

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
…M decode on SM107

Port of feat/mistral-large-4 416b15a (NVIDIA#22250) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22250's
__sm_107__tp4). The target-local entry falls back to the family's
cute_dsl_fp8_block_scale_linear, where this branch keeps that entry.

The decode target's K128 FP8 projections go through
cute_dsl_fused_fp8_block_scale_linear: at the (M, N, K) shapes it has tuned
(M = 1 to 16 rows at the TP4 and TP8 per-rank widths), the activation
quantization is fused into a split-K GEMV; every other shape runs the Rubin
MXFP8 kernel as before. The context path keeps the MXFP8 kernel.

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
…M decode on SM107

Port of feat/mistral-large-4 416b15a (NVIDIA#22250) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22250's
__sm_107__tp4). The target-local entry falls back to the family's
cute_dsl_fp8_block_scale_linear, where this branch keeps that entry.

The decode target's K128 FP8 projections go through
cute_dsl_fused_fp8_block_scale_linear: at the (M, N, K) shapes it has tuned
(M = 1 to 16 rows at the TP4 and TP8 per-rank widths), the activation
quantization is fused into a split-K GEMV; every other shape runs the Rubin
MXFP8 kernel as before. The context path keeps the MXFP8 kernel.

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
…M decode on SM107

Port of feat/mistral-large-4 416b15a (NVIDIA#22250) onto this branch, in the
sm_107 tp target (mistral_large_4_nvfp4__sm_107__tp, NVIDIA#22250's
__sm_107__tp4). The target-local entry falls back to the family's
cute_dsl_fp8_block_scale_linear, where this branch keeps that entry.

The decode target's K128 FP8 projections go through
cute_dsl_fused_fp8_block_scale_linear: at the (M, N, K) shapes it has tuned
(M = 1 to 16 rows at the TP4 and TP8 per-rank widths), the activation
quantization is fused into a split-K GEMV; every other shape runs the Rubin
MXFP8 kernel as before. The context path keeps the MXFP8 kernel.

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.

2 participants