Repository navigation
[7/N][warmup][DSv4] Migrate router GEMM kernels - #50177
LopezCastroRoberto wants to merge 14 commits into
Conversation
|
This pull request has merge conflicts that must be resolved before it can be |
aec29f7 to
5efe9bd
Compare
|
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-filesThen, commit the changes and push to your branch. For future commits, |
|
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-filesThen, commit the changes and push to your branch. For future commits, |
|
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-filesThen, commit the changes and push to your branch. For future commits, |
|
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-filesThen, commit the changes and push to your branch. For future commits, |
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
Signed-off-by: LopezCastroRoberto <rocastro@redhat.com>
|
/ci run |
|
✅ Triggered Buildkite CI #88682 for commit |
|
This pull request has merge conflicts that must be resolved before it can be |
…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>
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