Skip to content

[Bugfix][KV Connector] Safely fill circular buffers in DecodeBench - #54879

Merged
ivanium merged 1 commit into
vllm-project:mainfrom
majunze2001:fix/decode-bench-circular-buffer-fill
Sep 3, 2026
Merged

ivanium merged 1 commit into
vllm-project:mainfrom
majunze2001:fix/decode-bench-circular-buffer-fill

Conversation

@majunze2001

@majunze2001 majunze2001 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Purpose

DecodeBench fills allocated cache blocks with synthetic values to emulate an external prefill. Qwen QSA circular buffers can pack exact int64 MRoPE positions alongside BF16 key state. Applying the configured nonzero BF16 fill
to the entire circular-buffer row corrupts those positions, which can make the QSA pre-indexer access its cosine/sine table out of bounds and trigger a CUDA IMA.

This change identifies KV-cache groups containing CircularBufferSpec layers and explicitly zero-fills their selected blocks. Other cache groups continue to use the configured DecodeBench mean and standard deviation. The regression test also verifies that only the selected circular-buffer row is modified.

Duplicate-work check

No issue is linked to this change. Searches of open vLLM PRs and issues for DecodeBench CircularBuffer, DecodeBench Qwen3.8, and QSA illegal memory DecodeBench found no existing fix.

Test Plan

  • Exercise a worker-side CircularBufferSpec cache initialized with nonzero
    values and verify that DecodeBench zeros the selected row while leaving every
    other row unchanged.
  • Run the complete DecodeBench connector unit-test file.
  • Run pre-commit on both changed files.
  • Run a Qwen3.8 Flash Next DecodeBench GPU E2E with the default nonzero fill
    configuration.
  • Run Qwen3-0.6B as a non-circular DecodeBench control.

Commands run locally:

../vllm/.venv/bin/python -c 'import runpy,sys,types; sys.modules["readline"]=types.ModuleType("readline"); sys.argv=["pytest","tests/v1/kv_connector/unit/test_decode_bench_connector.py","-q"]; runpy.run_module("pytest",run_name="__main__")'
../vllm/.venv/bin/pre-commit run --files vllm/distributed/kv_transfer/kv_connector/v1/decode_bench_connector.py tests/v1/kv_connector/unit/test_decode_bench_connector.py
git diff --check

Equivalent model-server invocations used for the E2E runs:

vllm serve Qwen/Qwen3.8-Flash-Next-FP8 \
  --tensor-parallel-size 4 \
  --max-model-len 4096 \
  --max-num-batched-tokens 4096 \
  --max-num-seqs 4 \
  --enable-prefix-caching \
  --kv-transfer-config \
  '{"kv_connector":"DecodeBenchConnector","kv_role":"kv_both","kv_connector_extra_config":{"fill_mean":0.015,"fill_std":0.0}}'

vllm serve Qwen/Qwen3-0.6B \
  --max-model-len 4096 \
  --max-num-batched-tokens 4096 \
  --max-num-seqs 8 \
  --enable-prefix-caching \
  --kv-transfer-config \
  '{"kv_connector":"DecodeBenchConnector","kv_role":"kv_both"}'

Test Result

  • tests/v1/kv_connector/unit/test_decode_bench_connector.py: 12 passed.
  • Changed-file pre-commit hooks: passed, including Ruff, mypy, SPDX, and the
    repository-specific validation hooks.
  • git diff --check: passed.
  • Qwen3.8 Flash Next, tensor parallel size 4: 10/10 completion requests
    returned HTTP 200 with the requested output lengths. This included the prior
    3,002-token prompt plus 512-token generation regression shape, a 1,024-token
    generation, replayed prefixes, and concurrent requests. The server remained
    healthy, with no CUDA illegal memory access, engine failure, or CUDA core
    dump.
  • Qwen3-0.6B non-circular control: 8/8 completion requests returned HTTP 200,
    including replayed-prefix, long-generation, and concurrent workloads. The
    normal attention group retained the configured default fill_mean=0.015,
    and the run observed a 29.6% local prefix-cache hit rate.

Model accuracy evaluation is not applicable because DecodeBench deliberately uses synthetic KV values and does not produce meaningful accuracy results. The model-serving E2E tests above cover the affected circular-buffer path and a non-circular control.

AI assistance disclosure: OpenAI Codex was used for this PR.

Co-authored-by: OpenAI Codex <noreply@openai.com>
Signed-off-by: Jeff Ma <jeffjma@umich.edu>
@mergify mergify Bot added bug Something isn't working kv-connector labels Sep 2, 2026
@majunze2001
majunze2001 marked this pull request as ready for review September 2, 2026 15:03

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

@ivanium ivanium left a comment

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.

LGMT thanks for the fix!

@ivanium ivanium added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 2, 2026
@ivanium

ivanium commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

/ci run

@ivanium
ivanium enabled auto-merge (squash) September 2, 2026 21:00
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

✅ Triggered Buildkite CI #86944 for commit a556fb47bf0b.

@ivanium
ivanium merged commit 31e9c13 into vllm-project:main Sep 3, 2026
40 of 41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working kv-connector ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants