Skip to content

[Model] Add PW CUDA graph support for Inkling [2/N] - #48822

Merged
WoosukKwon merged 1 commit into
mainfrom
agent/inkling-breakable-cudagraph
Jul 16, 2026
Merged

[Model] Add PW CUDA graph support for Inkling [2/N]#48822
WoosukKwon merged 1 commit into
mainfrom
agent/inkling-breakable-cudagraph

Conversation

@WoosukKwon

@WoosukKwon WoosukKwon commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

This is the second independently mergeable slice carved out of #48768. It adds breakable (piecewise) CUDA graph support for Inkling on Model Runner V2:

  • automatically enables breakable CUDA graphs for InklingForCausalLM and InklingForConditionalGeneration
  • marks the Inkling attention boundary as eager and makes short-convolution metadata safe for uniform batched execution
  • preserves padded request counts and static attention metadata during piecewise capture/replay
  • keeps warmup and capture metadata independent
  • adds MRV2 CudaGraphManager coverage for fresh capture metadata

Inkling is assumed to always run with Model Runner V2. The legacy vllm/v1/worker/gpu_model_runner.py and vllm/v1/cudagraph_dispatcher.py paths are unchanged.

This PR intentionally contains no LoRA support and no Inkling MTP support. The small autoregressive speculator CUDA-graph utility adjustment is generic MRV2 metadata plumbing required to keep that existing runner compatible with the shared breakable graph path; this PR does not enable or test Inkling speculative decoding.

Duplicate-work check

I searched the open PRs for breakable Inkling, piecewise Inkling CUDA graph, and PW CUDA graph Inkling. The only match was #48768 because its description records this carve-out. Before publishing this PR, the corresponding breakable-CUDA-graph files and config hunk were removed from #48768, so the diffs do not duplicate each other.

Testing

  • pre-commit run
    • all hooks passed
  • .venv/bin/python -m pytest tests/models/inkling/test_contract_validation.py -q
    • 4 passed
  • .venv/bin/python -m pytest tests/v1/cudagraph/test_breakable_cudagraph.py::test_piecewise_capture_builds_fresh_metadata_for_both_passes -q
    • 1 passed (run with the existing precompiled extension and this worktree's Python source overlaid)

Model evaluation

Served thinkingmachines/Inkling-NVFP4 on four GB200 GPUs with TP4, Model Runner V2, and without MTP/speculative decoding:

export VLLM_USE_V2_MODEL_RUNNER=1
export FLASH_ATTENTION_CUTE_DSL_CACHE_ENABLED=1
export CUDA_VISIBLE_DEVICES=0,1,2,3
export HF_HOME=/tmp/hf-woosuk

.venv/bin/vllm serve thinkingmachines/Inkling-NVFP4 \
  --tokenizer-mode inkling \
  --reasoning-parser inkling \
  --tool-call-parser inkling \
  --enable-auto-tool-choice \
  --tensor-parallel-size 4 \
  --max-model-len 8192 \
  --gpu-memory-utilization 0.8 \
  --kernel-config.enable_flashinfer_autotune=False \
  --trust-remote-code

Both PIECEWISE (51/51) and FULL (51/51) CUDA graph capture completed successfully. Four concurrent GSM8K prompts were then sent through /v1/chat/completions with max_tokens=2048 and temperature=0. Result: 4/4 correct, with all requests finishing normally.

The lower memory utilization and 8192-token test length leave KV-cache headroom for the approximately 551 GiB checkpoint; the default 0.9 utilization did not leave enough free memory for KV allocation on this host.

AI assistance

AI assistance was used to help carve out the existing implementation, add tests, run validation, and prepare this PR. The human submitter will review every changed line and is responsible for understanding and defending the change end-to-end.

@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 repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@WoosukKwon WoosukKwon added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 16, 2026
@WoosukKwon
WoosukKwon force-pushed the agent/inkling-breakable-cudagraph branch from 7dd4824 to baf523c Compare July 16, 2026 15:46
Enable breakable PIECEWISE CUDA graph capture for Inkling while keeping attention metadata padded and static across warmup and capture.

Co-authored-by: Bugen Zhao <i@bugenzhao.com>
Co-authored-by: Giancarlo Delfin <32987265+TheEpicDolphin@users.noreply.github.com>
Co-authored-by: Isotr0py <Isotr0py@outlook.com>
Co-authored-by: Isotr0py <mozf@inferact.ai>
Co-authored-by: Jee Jee Li <jeejeelee@inferact.ai>
Co-authored-by: Roger Wang <hey@rogerw.io>
Co-authored-by: Yifan Qiao <yifanqiao@inferact.ai>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai>
@WoosukKwon
WoosukKwon force-pushed the agent/inkling-breakable-cudagraph branch from baf523c to b00967e Compare July 16, 2026 15:48
@WoosukKwon WoosukKwon changed the title [Model] Add breakable CUDA graph support for Inkling [2/N] [Model] Add ㅖㅉ CUDA graph support for Inkling [2/N] Jul 16, 2026
@WoosukKwon WoosukKwon changed the title [Model] Add ㅖㅉ CUDA graph support for Inkling [2/N] [Model] Add PW CUDA graph support for Inkling [2/N] Jul 16, 2026
@WoosukKwon
WoosukKwon merged commit 251f7e4 into main Jul 16, 2026
120 checks passed
@github-project-automation github-project-automation Bot moved this to Done in NVIDIA Jul 16, 2026
@WoosukKwon
WoosukKwon deleted the agent/inkling-breakable-cudagraph branch July 16, 2026 17:28
njhill added a commit to njhill/vllm that referenced this pull request Jul 21, 2026
vllm-project#48822 made breakable piecewise graph replay pad batch metadata to the
captured shape (num_reqs padded to min(num_tokens, max_num_reqs), with
zero-length trailing requests). That breaks backends whose attention
runs eagerly as graph break points and reads the real batch from the
forward context: the DSA indexer decode path expands the padded request
count by next_n (deepgemm asserts batch_size * next_n == weights rows),
and the sparse MLA prefill path cannot build TMA descriptors for
zero-length padding requests. This crashed DeepSeek-V4-Flash on the V2
runner (deepgemm attention.hpp:371 assert on B200; flashmla phase1.cuh
TMA failure on GB200) and would equally affect MiniMax-M3 Sparse.

The padding is not needed by the in-graph kernels either: the runner
always pads slot_mapping to the captured token count, and in-graph
kernels self-pad from it - Inkling's sconv_seq_metadata fills the tail
rows from slot_mapping.shape[0] and fused_sconv skips slot == -1 rows,
independent of the batch metadata shapes.

So restore the pre-vllm-project#48822 invariant at both replay-side padding sites:
piecewise descriptors carry num_reqs=None again, and the model state
builds replay metadata with real (unpadded) sizes for piecewise graphs.
Capture-time metadata keeps the padded shapes for free because the
capture dummy batch is exactly the captured size.

Validated on GB200: DeepSeek-V4-Flash gsm8k (TP2+EP, MTP, fp4 indexer
cache, FULL_AND_PIECEWISE) 0.9492 at the previously-crashing commit vs
0.0000/engine-crash without the fix; breakable cudagraph and dispatch
unit tests unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Nick Hill <nickhill123@gmail.com>
njhill added a commit to njhill/vllm that referenced this pull request Jul 21, 2026
The tests/models/inkling suite (8 files: FA4 kernels, sconv metadata,
MoE weight layout, contract validation, MTP input fusion, QKV prep, MM
towers) was not referenced by any CI job, so none of it ran in CI -
including the contract-validation tests that vllm-project#48822 itself modified.
Add a B200 job (the FA4 tests require SM100; they skip elsewhere) to
the Models - Basic group.

Suite runs in ~6.5 min on 1 GPU; validated 194/194 passing at current
main on GB200.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Nick Hill <nickhill123@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nvidia ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant