Skip to content

[Bugfix][Core] Fix request-bound KV cache sizing - #101

Closed
lesj0610 wants to merge 20 commits into
mainfrom
lesj/request-constant-kv-pools-20260625
Closed

lesj0610 wants to merge 20 commits into
mainfrom
lesj/request-constant-kv-pools-20260625

Conversation

@lesj0610

@lesj0610 lesj0610 commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Purpose

Fix KV cache sizing for hybrid models that combine token-proportional attention KV with request-bound KV groups such as Mamba. The startup sizing path now accounts for the fixed request-bound blocks consumed from the shared BlockPool, and the auto-fit path reserves the BlockPool null block so derived capacity matches runtime admission.

The implementation keeps request-bound groups in the shared pool. That lets inactive request slots remain available to token KV instead of reserving a dedicated request-constant pool that this fix does not need. The PR also removes the inactive dedicated-pool fallback so the changed code path is the one that is actually exercised.

AI assistance: Codex was used during implementation and PR preparation; the submitter reviewed the changes.

Test Plan

  • Run syntax, lint, and format checks for the modified KV cache utility.
  • Run the KV cache utility and single-type KV cache manager tests that cover shared-pool request-bound sizing, CPU-offload variants, and null-block capacity accounting.
  • Check the patch for whitespace errors.

Test Result

Syntax, lint, format, and whitespace checks:

.venv/bin/python -m py_compile vllm/v1/core/kv_cache_utils.py
.venv/bin/python -m ruff check vllm/v1/core/kv_cache_utils.py
.venv/bin/python -m ruff format --check vllm/v1/core/kv_cache_utils.py
git diff --check

Result: passed.

Targeted tests:

.venv/bin/python -m pytest \
  tests/v1/core/test_kv_cache_utils.py \
  tests/v1/core/test_single_type_kv_cache_manager.py \
  -q

Result: 74 passed.

Commit hooks also passed for the latest cleanup commit, including ruff, format, mypy, SPDX, config validation, and related repository checks.


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. Not needed; this is an internal KV cache sizing fix.

lesj0610 added 2 commits June 25, 2026 08:58
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
@lesj0610 lesj0610 changed the title Support request-bound KV cache sizing [Core] Support request-bound KV cache sizing Jun 25, 2026
@lesj0610 lesj0610 changed the title [Core] Support request-bound KV cache sizing [Bugfix][Core] Fix request-bound KV cache sizing Jun 25, 2026
@lesj0610
lesj0610 marked this pull request as ready for review June 25, 2026 00:53
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

lesj0610 and others added 17 commits June 25, 2026 10:29
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
…-kv-pools-20260625

# Conflicts:
#	vllm/v1/core/kv_cache_manager.py

Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Co-authored-by: OpenAI Codex <codex@openai.com>
Signed-off-by: lesj0610 <lesj0610@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant