Skip to content

[Bugfix][Model Runner] Bound dummy seq_lens by max_model_len - #53671

Draft
zupengwang wants to merge 1 commit into
vllm-project:mainfrom
zupengwang:fix/full-cudagraph-seq-lens
Draft

zupengwang wants to merge 1 commit into
vllm-project:mainfrom
zupengwang:fix/full-cudagraph-seq-lens

Conversation

@zupengwang

Copy link
Copy Markdown
Contributor

Purpose

Fixes #53658.

V1 GPUModelRunner._dummy_run could assign every dummy request a sequence
length equal to the total CUDA graph capture size. When that capture size was
larger than max_model_len, a dummy request claimed more KV pages than its
block-table row could address. This could cause an out-of-bounds block-table
read in TRITON_ATTN or a page-mask shape mismatch in FLEX_ATTENTION.

This change:

  • clamps scalar and tensor dummy sequence lengths to max_model_len;
  • preserves the legal total capture size, which may exceed max_model_len
    because it represents multiple batched requests;
  • adds a V1 FULL-cudagraph FLEX_ATTENTION regression test whose capture size
    exceeds the model length.

I checked open PRs by issue number and relevant keywords immediately before
publishing. I found no duplicate PR and no existing PR from this branch.

Test Plan

  1. Reproduce the unpatched block-table boundary with the standalone unified
    attention reproducer at 4096, 4097, and 4128 tokens for
    max_model_len=4096.
  2. Run the new engine-level regression on an RTX 3090 with the V1 runner,
    FLEX_ATTENTION, FULL cudagraph mode, max_model_len=1024, and capture size
    1032.
  3. Run the adjacent cudagraph dispatch and manager tests.
  4. Run the relevant Ruff, formatting, and mypy pre-commit hooks, plus
    git diff --check.

Test Result

  • Unpatched baseline:
    • 4096 tokens: clean (RC=0)
    • 4097 tokens: CUDA error: an illegal memory access was encountered
      (RC=1)
    • 4128 tokens: CUDA error: an illegal memory access was encountered
      (RC=1)
  • CUDA_VISIBLE_DEVICES=5 .venv/bin/python -m pytest -q -s tests/v1/cudagraph/test_cudagraph_mode.py::test_full_cudagraph_capture_size_exceeds_max_model_len
    • 1 passed, 14 warnings in 32.26s
  • .venv/bin/python -m pytest -q tests/v1/cudagraph/test_cudagraph_dispatch.py tests/v1/cudagraph/test_cudagraph_manager.py
    • 16 passed, 14 warnings in 35.37s
  • pre-commit run ruff-check --files tests/v1/cudagraph/test_cudagraph_mode.py vllm/v1/worker/gpu_model_runner.py
    • Passed
  • pre-commit run ruff-format --files tests/v1/cudagraph/test_cudagraph_mode.py vllm/v1/worker/gpu_model_runner.py
    • Passed
  • pre-commit run mypy-3.12 --hook-stage manual --files tests/v1/cudagraph/test_cudagraph_mode.py vllm/v1/worker/gpu_model_runner.py
    • Passed
  • git diff --check
    • Passed

The umbrella changed-files pre-commit command did not complete because the
unrelated actionlint hook initialization hit SSL: UNEXPECTED_EOF_WHILE_READING;
a retry later hung and was stopped. The relevant Ruff, format, and mypy hooks
listed above completed successfully.

No model evaluation was run because this change only constrains invalid dummy
capture metadata and does not alter real-request model outputs.

AI assistance was used for issue analysis, implementation, and test execution.
I reviewed every changed line and verified the behavior and test results.


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Co-authored-by: OpenAI <support@openai.com>
Signed-off-by: Zupeng Wang <71580390+zupengwang@users.noreply.github.com>
@mergify mergify Bot added nvidia bug Something isn't working labels Aug 25, 2026
@zupengwang
zupengwang marked this pull request as ready for review August 25, 2026 04:05
@zupengwang
zupengwang requested a review from njhill as a code owner August 25, 2026 04:05

@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.

@njhill njhill added the mrv1-only Issues/PRs which apply only to Model Runner V1 (not applicable to Model Runner V2) label Aug 25, 2026
@zupengwang
zupengwang marked this pull request as draft September 12, 2026 05:31

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

bug Something isn't working mrv1-only Issues/PRs which apply only to Model Runner V1 (not applicable to Model Runner V2) nvidia

Projects

Status: No status

2 participants