Skip to content

[7/N][warmup][DSv4] Migrate router GEMM kernels - #50177

Open
LopezCastroRoberto wants to merge 14 commits into
vllm-project:mainfrom
LopezCastroRoberto:warmup_migration/dsv4_4
Open

LopezCastroRoberto wants to merge 14 commits into
vllm-project:mainfrom
LopezCastroRoberto:warmup_migration/dsv4_4

Conversation

@LopezCastroRoberto

@LopezCastroRoberto LopezCastroRoberto commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Depends on: #53566

For more details, see parent PR: #49627 and tracking issue #49349

Description

This PR migrates the DSv4 router GEMM kernels to the shared JIT warmup contract.

What Changed

  • Migrated low-latency BF16 and BF16x3 router GEMMs.
  • Moved specialization selection into kernel-owned dispatch methods.
  • Added compile-only CuTeDSL and Triton paths.
  • Preserved existing tuning tables, runtime heuristics, and performance specializations.
  • Removed the corresponding legacy router warmup orchestration.
  • Added dispatch-equivalence and kernel-specific warmup tests.

@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 changed the title [2/N][warmup][DSv4] Migrate MoE kernels [3/N][warmup][DSv4] Migrate MoE kernels Jul 28, 2026
@mergify mergify Bot added deepseek Related to DeepSeek models nvidia v1 labels Jul 28, 2026
@mergify

mergify Bot commented Jul 29, 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 29, 2026
@LopezCastroRoberto
LopezCastroRoberto marked this pull request as draft July 29, 2026 17:11
@LopezCastroRoberto LopezCastroRoberto changed the title [3/N][warmup][DSv4] Migrate MoE kernels [6/N][warmup][DSv4] Migrate router GEMM kernels Aug 24, 2026
@mergify mergify Bot removed the needs-rebase label Aug 24, 2026
@mergify mergify Bot removed the needs-rebase label Sep 11, 2026
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
@mergify

mergify Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Hi @LopezCastroRoberto, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
@mergify

mergify Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Hi @LopezCastroRoberto, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
@mergify

mergify Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Hi @LopezCastroRoberto, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
@mergify

mergify Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Hi @LopezCastroRoberto, the pre-commit checks have failed. Please run:

uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-files

Then, commit the changes and push to your branch.

For future commits, pre-commit will run automatically on changed files before each commit.

LopezCastroRoberto added a commit to LopezCastroRoberto/vllm that referenced this pull request Sep 12, 2026
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
LopezCastroRoberto added a commit to LopezCastroRoberto/vllm that referenced this pull request Sep 12, 2026
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
@LucasWilkinson

Copy link
Copy Markdown
Contributor

/ci run

@LucasWilkinson
LucasWilkinson enabled auto-merge (squash) September 13, 2026 20:49
@github-actions

Copy link
Copy Markdown

✅ Triggered Buildkite CI #88682 for commit 139b1c3f1772.

@mergify

mergify Bot commented Sep 23, 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 Sep 23, 2026
douglas-reid added a commit to douglas-reid/vllm that referenced this pull request Oct 9, 2026
…h.compile branch freezing

In GateLinear.forward, Tier 1 (ll_bf16_gemm, the CuTe DSL low-latency
BF16->FP32 router GEMM for M <= 16 on SM90+) was gated by an inline
Python conditional on x.shape[0]. Unlike Tier 2
(torch.ops.vllm.fp32_router_gemm_dispatch) and Tier 4
(torch.ops.vllm.rocm_bf16x3_router_gemm_dispatch), Tier 1 did not wrap
its runtime x.shape[0] check in a custom op.

When GateLinear is called from @support_torch_compile model code,
vLLM's TorchCompileWithNoGuardsWrapper drops all Dynamo guards, so a
plain Python branch on x.shape[0] is frozen at first trace: tracing
first at M > 16 (e.g. M = 2048 during warmup) freezes the branch to
False and permanently falls back to Tier 5
torch.mm(x, weight.T, out_dtype=torch.float32) during decode, while an
M <= 16 first trace would freeze ll_bf16_gemm in at M = 8192.

Tier 1 requires bf16 weights + out_dtype=torch.float32 + bias=False +
unquantized + SM90+ and a gate called from @support_torch_compile model
code. On main that is Gemma 4 (Gemma4Router.proj), Nemotron-H
(force_fp32_compute=True keeps bf16 weights when specialized kernels
exist), and MiMo-V2 when moe_router_dtype is bfloat16. After this change,
Gemma 4 decode (M <= 16) and prefill (M > 16) use different GEMM kernels,
so router logits may differ in the last ULP across batch sizes; this is
Tier 1's pre-existing design (DeepSeek already behaves this way) and
VLLM_BATCH_INVARIANT gating is handled at init by vllm-project#59985. The c1_pdl
warmup gap is addressed by vllm-project#50177.

Changes:
1. Register torch.ops.vllm.ll_bf16_router_gemm_dispatch(x, weight,
   max_tokens) so 0 < x.shape[0] <= max_tokens is evaluated dynamically
   at runtime outside the compiled FX graph, calling
   ll_bf16_gemm(x.contiguous(), weight) for 0 < m <= max_tokens and
   falling back to Tier 5 torch.mm(x, weight.T, out_dtype=torch.float32)
   otherwise.
2. Update test_gate_linear_torch_compile_dynamic_m_dispatch to drop
   guards via guard_filter_fn and run decode calls under
   torch.compiler.set_stance("fail_on_recompile") so the test fails on
   main and passes with the custom op.

Signed-off-by: Douglas Reid <21148125+douglas-reid@users.noreply.github.com>
@LopezCastroRoberto LopezCastroRoberto added the warmup Related to the warmup system label Oct 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek Related to DeepSeek models DSv4 inkling needs-rebase nvidia ready ONLY add when PR is ready to merge/full CI is needed v1 warmup Related to the warmup system

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

2 participants