Skip to content

[DO NOT MERGE][Perf][Feat] Add generic cuteDSL LL FP32 router (GEMM) - #44343

Open
LopezCastroRoberto wants to merge 43 commits into
vllm-project:mainfrom
LopezCastroRoberto:perf/fp32_dotprod_router
Open

[DO NOT MERGE][Perf][Feat] Add generic cuteDSL LL FP32 router (GEMM)#44343
LopezCastroRoberto wants to merge 43 commits into
vllm-project:mainfrom
LopezCastroRoberto:perf/fp32_dotprod_router

Conversation

@LopezCastroRoberto

@LopezCastroRoberto LopezCastroRoberto commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Depends on: #50174

Motivation

This kernel is intended to be a generic low-latency fp32-router kernel. We should not expect it to outperform highly specialized PTX/CUDA kernels tuned for one exact router shape. The goal is different: make the CuTeDSL implementation competitive with those specialized kernels while keeping the code flexible enough to support new router shapes without writing a new kernel each time.

That flexibility matters because router shapes keep changing across new models. Without a dedicated shape-specific CUDA path, the fallback is typically cuBLAS/torch.mm, and the kernel-wise results show why a generic low-latency router kernel is still useful: even when it only ties or slightly trails the specialized dispatch kernel, it is dramatically faster than cuBLAS across these low-M router workloads.

Kernel-level results

Speedup is computed as baseline_us / ll_fp32w_us; values above 1.0x mean ll_fp32w is faster.

dispatch == fp32_router_gemm_dispatch

MiniMax-M3 (K=6144, N=128)

M Config ll_fp32w us dispatch us cuBLAS us Speedup vs dispatch Speedup vs cuBLAS
1 (384,1,1) 1.729 1.722 6.924 0.996x 4.005x
2 (384,1,1) 1.825 1.856 13.618 1.017x 7.462x
3 (384,1,1) 1.958 2.033 13.709 1.038x 7.002x
4 (384,1,1) 2.172 2.212 13.920 1.018x 6.409x
5 (384,1,1) 2.301 2.349 13.885 1.021x 6.034x
6 (384,2,1) 2.422 2.565 15.746 1.059x 6.501x
7 (256,1,1) 2.580 2.655 15.743 1.029x 6.102x
8 (384,2,1) 2.614 2.813 14.011 1.076x 5.360x
9 (384,1,1) 2.956 3.021 14.117 1.022x 4.776x
10 (384,2,1) 2.983 3.085 14.107 1.034x 4.729x
11 (384,1,1) 3.212 3.195 14.229 0.995x 4.430x
12 (192,2,1) 2.964 3.158 14.238 1.065x 4.804x
13 (384,1,1) 3.374 3.477 14.255 1.031x 4.225x
14 (192,2,1) 3.256 3.290 14.300 1.010x 4.392x
15 (256,1,1) 3.683 3.662 14.311 0.994x 3.886x
16 (192,2,1) 3.529 3.493 14.393 0.990x 4.078x
17 (384,1,1) 3.891 3.919 15.516 1.007x 3.988x
18 (192,2,1) 3.635 3.669 15.678 1.009x 4.313x
19 (256,1,1) 4.018 4.074 15.735 1.014x 3.916x
20 (192,2,1) 3.900 3.937 15.851 1.009x 4.064x
21 (256,1,1) 4.273 4.317 15.826 1.010x 3.704x
22 (192,2,1) 4.145 4.163 15.730 1.004x 3.795x
23 (384,1,1) 4.560 4.689 15.888 1.028x 3.484x
24 (192,2,1) 4.317 4.329 15.731 1.003x 3.644x
25 (384,1,1) 4.836 4.867 15.777 1.006x 3.262x
26 (128,2,1) 4.314 4.467 15.798 1.035x 3.662x
27 (384,1,1) 5.052 5.121 15.899 1.014x 3.147x
28 (128,2,1) 4.683 4.682 15.959 1.000x 3.408x
29 (384,1,1) 5.318 5.442 16.048 1.023x 3.018x
30 (128,2,1) 4.761 4.860 15.927 1.021x 3.345x
31 (384,1,1) 5.531 5.559 16.046 1.005x 2.901x
32 (192,2,1) 5.044 5.044 15.955 1.000x 3.163x

GLM5.2 (K=6144, N=256)

M Config ll_fp32w us dispatch us cuBLAS us Speedup vs dispatch Speedup vs cuBLAS
1 (384,1,1) 1.899 2.078 6.763 1.094x 3.561x
2 (384,1,1) 2.102 2.300 21.317 1.094x 10.141x
3 (384,1,1) 2.302 2.607 21.377 1.132x 9.286x
4 (128,1,1) 2.615 2.938 21.326 1.124x 8.155x
5 (128,1,2) 2.790 2.877 21.633 1.031x 7.754x
6 (128,1,1) 2.964 3.103 15.648 1.047x 5.279x
7 (128,1,2) 3.100 3.248 15.757 1.048x 5.083x
8 (128,2,2) 3.197 3.476 20.018 1.087x 6.261x
9 (128,1,2) 3.458 3.702 20.244 1.071x 5.854x
10 (128,2,2) 3.359 3.716 20.326 1.106x 6.051x
11 (128,1,1) 3.850 3.880 20.396 1.008x 5.298x
12 (128,2,2) 3.758 4.033 20.414 1.073x 5.432x
13 (256,1,2) 4.203 4.190 20.516 0.997x 4.881x
14 (128,2,2) 3.857 4.433 20.524 1.149x 5.321x
15 (256,1,2) 4.556 4.526 20.718 0.993x 4.547x
16 (128,2,2) 4.138 4.434 20.798 1.072x 5.026x
17 (256,1,2) 4.844 5.002 17.310 1.033x 3.573x
18 (128,2,2) 4.433 4.751 17.400 1.072x 3.925x
19 (256,1,2) 5.173 5.135 17.421 0.993x 3.368x
20 (128,2,2) 4.653 4.848 17.405 1.042x 3.741x
21 (256,1,2) 5.427 5.561 17.370 1.025x 3.201x
22 (128,2,2) 4.909 5.031 17.493 1.025x 3.563x
23 (256,1,2) 5.793 5.808 17.641 1.003x 3.045x
24 (128,2,2) 5.360 5.252 17.626 0.980x 3.288x
25 (256,1,2) 6.141 6.199 17.617 1.009x 2.869x
26 (128,2,2) 5.631 5.542 17.686 0.984x 3.141x
27 (256,1,2) 6.458 6.563 17.537 1.016x 2.716x
28 (128,2,2) 5.850 5.914 17.588 1.011x 3.006x
29 (256,1,2) 6.763 6.891 17.694 1.019x 2.616x
30 (128,2,2) 6.139 6.223 17.623 1.014x 2.871x
31 (256,1,2) 7.099 7.162 17.849 1.009x 2.514x
32 (128,2,2) 6.399 6.431 17.834 1.005x 2.787x

E2E serving results (MiniMax-M3)

Batch main run pr run main median ITL pr median ITL median ITL diff main tok/s pr tok/s tok/s diff
1 2 3 5.73 5.73 +0.0% 173.79 173.79 +0.0%
2 3 3 6.44 6.44 +0.0% 308.71 308.72 +0.0%
3 3 2 7.60 7.64 +0.5% 392.90 391.41 -0.4%
4 3 3 7.55 7.53 -0.3% 527.77 529.02 +0.2%
5 2 3 8.62 8.53 -1.0% 574.68 579.33 +0.8%
6 3 2 8.97 8.92 -0.6% 662.75 668.50 +0.9%
7 2 2 9.29 9.31 +0.2% 745.72 747.07 +0.2%
8 2 2 9.26 9.23 -0.3% 857.08 859.11 +0.2%
9 2 3 10.18 10.19 +0.1% 878.64 873.63 -0.6%
10 3 3 10.42 10.40 -0.2% 955.08 954.98 -0.0%
11 3 2 10.72 10.72 +0.0% 1019.76 1021.32 +0.2%
12 3 2 11.07 10.99 -0.7% 1077.26 1081.18 +0.4%
13 3 3 11.25 11.32 +0.6% 1147.66 1138.11 -0.8%
14 2 3 11.44 11.42 -0.2% 1209.73 1206.35 -0.3%
15 2 2 11.79 11.74 -0.4% 1260.54 1264.29 +0.3%
16 2 3 11.70 11.66 -0.3% 1348.45 1356.88 +0.6%

Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Comment thread .buildkite/test_areas/kernels.yaml Outdated
Comment on lines +183 to +184
- pytest -v -s tests/kernels/test_ll_bf16_gemm.py
- pytest -v -s tests/kernels/test_ll_fp32w_gemm.py

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably break up the kernel job, this gonna run alot unnecessarily

@LopezCastroRoberto
LopezCastroRoberto marked this pull request as ready for review July 13, 2026 11:31

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@LopezCastroRoberto LopezCastroRoberto mentioned this pull request Jul 13, 2026
4 tasks
LopezCastroRoberto and others added 3 commits July 16, 2026 09:15
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: Roberto L. Castro <38211239+LopezCastroRoberto@users.noreply.github.com>
@LopezCastroRoberto LopezCastroRoberto changed the title [Perf] Add cuteDSL generic LL FP32 router (GEMM) [Perf][Feat] Add generic cuteDSL LL FP32 router (GEMM) Jul 16, 2026
@mergify mergify Bot removed the needs-rebase label Jul 16, 2026
LopezCastroRoberto and others added 4 commits July 17, 2026 10:04
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>


if __name__ == "__main__":
pytest.main([__file__, "-v"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we unify tests with the other LL Gemms such that they live all in one file and parametrize over the dtype

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can keep them separated for now, as there is not a clean merge: ll_bf16 has two variants (dotprod, splitk), requires K-dim to be divisible by 8, only covers M in {1-16} range... Since this is just a test file, I prefer not to over-complicate things

cute.autovec_copy(bt0, br0)
br0_f32 = br0.load().to(cutlass.Float32)

if const_expr(EPB == 2):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd prefer non capital argument instead of EPB

tidx: cutlass.Int32,
local_wid: cutlass.Int32,
M_PER_GROUP: cutlass.Constexpr,
M_OFFSET: cutlass.Int32,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above (stylistic advice)

a_dtype: torch.dtype
token_groups: int = 1
epb: int = 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to inline CompileKey within class or keep it out of it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I migrated the kernel to the warmup contract already, so this shouldn't be a problem anymore

_LL_BF16_WARMUP_M_RANGE = range(1, 17)

_LL_FP32W_WARMUP_M_RANGE = range(1, 17)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need such large warmup range considering we restrict dispatch within gate_linear dispatch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to actually increase it up to 32 for this kernel :). But this shouldn't be a big deal in terms of compilation time.

@mergify

mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @LopezCastroRoberto.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label Jul 28, 2026
LopezCastroRoberto and others added 5 commits August 12, 2026 10:11
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: Roberto L. Castro <38211239+LopezCastroRoberto@users.noreply.github.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
@LopezCastroRoberto LopezCastroRoberto changed the title [Perf][Feat] Add generic cuteDSL LL FP32 router (GEMM) [DO NOT MERGE][Perf][Feat] Add generic cuteDSL LL FP32 router (GEMM) Aug 12, 2026
@mergify mergify Bot removed the needs-rebase label Aug 12, 2026
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants