Skip to content

Rewrite worker block tables after SWA eviction - #42276

Open
AbhiOnGithub wants to merge 2 commits into
vllm-project:mainfrom
AbhiOnGithub:issue-42273-swa-block-table
Open

AbhiOnGithub wants to merge 2 commits into
vllm-project:mainfrom
AbhiOnGithub:issue-42273-swa-block-table

Conversation

@AbhiOnGithub

@AbhiOnGithub AbhiOnGithub commented May 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #42273

Summary:

  • Track requests whose CPU-side block tables are rewritten by SWA skipped-block removal.
  • Have the scheduler send the full rewritten block table for those cached requests instead of only incremental new blocks.
  • Update both worker block-table paths to overwrite rows when a rewrite is requested.
  • Add scheduler/core/worker regressions for SWA eviction and block-table replacement.

Tests:

  • .venv/bin/python -m pytest tests/v1/core/test_scheduler.py::test_schedule tests/v1/core/test_scheduler.py::test_swa_eviction_sends_block_table_rewrite_for_cached_request tests/v1/core/test_single_type_kv_cache_manager.py tests/v1/simple_kv_offload/test_scheduler.py::test_eager_store_and_load_roundtrip tests/v1/worker/test_gpu_model_runner.py::test_update_states_rewrites_cached_block_table -v (13 passed)
  • .venv/bin/python -m ruff check vllm/v1/core/kv_cache_coordinator.py vllm/v1/core/kv_cache_manager.py vllm/v1/core/sched/output.py vllm/v1/core/sched/scheduler.py vllm/v1/core/single_type_kv_cache_manager.py vllm/v1/worker/gpu/model_runner.py vllm/v1/worker/gpu_model_runner.py tests/v1/core/test_scheduler.py tests/v1/core/test_single_type_kv_cache_manager.py tests/v1/core/utils.py tests/v1/simple_kv_offload/test_scheduler.py tests/v1/worker/test_gpu_model_runner.py (passed)

@mergify mergify Bot added the v1 label May 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a mechanism to handle block table rewrites for cached requests, specifically addressing scenarios where Sliding Window Attention (SWA) eviction replaces earlier logical slots with null blocks. The KVCacheManager and KVCacheCoordinator now track when a block table is updated, and the Scheduler communicates this via a new block_table_rewrite_req_ids field in CachedRequestData. Correspondingly, the GPU model runners have been updated to overwrite the block table instead of appending when a rewrite is signaled. I have no feedback to provide as no review comments were submitted.

@AbhiOnGithub
AbhiOnGithub force-pushed the issue-42273-swa-block-table branch from ec0e963 to 4aafaa6 Compare May 11, 2026 05:54
Track when sliding-window eviction rewrites existing logical block slots and send the rewritten row to workers so stale entries are replaced instead of appended past.

Signed-off-by: Abhishek Gupta (AbhiOnGithub) <12324923+AbhiOnGithub@users.noreply.github.com>
@AbhiOnGithub
AbhiOnGithub force-pushed the issue-42273-swa-block-table branch from 4aafaa6 to 2ebc56a Compare May 11, 2026 05:55

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

@mergify

mergify Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @AbhiOnGithub.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify Bot added the needs-rebase label May 23, 2026
@mergify mergify Bot added the mrv2 Model Runner V2 specific label Jul 31, 2026
theminghuang added a commit to theminghuang/vllm that referenced this pull request Aug 10, 2026
…refix caching is off

vllm-project#48017 was described as a pure no-op that skips the pointless LRU
hash-split when prefix caching is disabled, but the merged condition
(block.block_hash is None and self.enable_caching) routes every freed
block through append_n instead of prepend_n on that path. Since
allocation pops from the head of FreeKVCacheBlockQueue, this silently
flipped block reuse from LIFO (immediate reuse of a small hot set of
ids) to FIFO (cycling the entire block-id space) - contradicting both
the PR description and the in-code cache-locality rationale.

This change implements the optimization as described: with caching off,
skip the partition entirely, decrement refcounts, and prepend_n the
freed blocks, preserving the pre-vllm-project#48017 reuse order. Behavior with
prefix caching enabled is untouched.

The reuse order is observable: on TPU v7x the accidental FIFO order
deterministically triggers E0200 RuntimeUnexpectedCoreHalt (SparseCore
UserFatal) minutes into sustained serving, bisected to vllm-project#48017 across
20+ isolation runs (evidence:
https://github.com/vllm-project/vllm-torchtpu/blob/mhhua/sc2-sparsecore-halt-evidence/docs/sc2-sparsecore-halt-2026-08.md).
Reuse order also interacts with the stale block-table entries of vllm-project#42273
(see discussion in that issue) - the proper decoupling is vllm-project#42276-style
worker-side slot rewrites, after which reuse order is functionally
neutral on all platforms.

Signed-off-by: theminghuang <theminghuang@gmail.com>
Signed-off-by: Ming Huang <mhhua@google.com>
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity within 90 days. It will be automatically closed if no further activity occurs within 30 days. Leave a comment if you feel this pull request should remain open. Thank you!

@github-actions github-actions Bot added the stale Over 90 days of inactivity label Oct 31, 2026

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

mrv2 Model Runner V2 specific needs-rebase stale Over 90 days of inactivity v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SWA eviction leaves stale block table entries

1 participant