Repository navigation
[Perf][KV Offload] Split external hit sources in one pass - #67530
Open
AdvayMonga wants to merge 1 commit into
Open
AdvayMonga wants to merge 1 commit into
AdvayMonga wants to merge 1 commit into
Conversation
Signed-off-by: Advay Monga <advaymonga@gmail.com>
AdvayMonga
marked this pull request as ready for review
November 13, 2026 18:03
AdvayMonga
requested review from
ApostaC,
NickLucche,
ivanium,
orozery,
wzhao18 and
xuechendi
as code owners
November 13, 2026 18:03
Contributor
|
IIUC this optimization will likely only benefit dense models, which are rarely used today. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
get_external_cache_hit_sourcesworks out which tier each offload hit token came from. It runs on the scheduler thread for every request admitted with a hit, and it sorts and sweeps every loaded chunk, so it gets slower as prompts get longer. For a single attention group the chunks are already in order and don't overlap, so this PR adds them up in one pass. Follow-up to #56318.Claims
Validation
Microbench, one attention group, 16 tokens per chunk, median of 200 calls on an M4 Pro. Three runs each side were within 0.05 ms.
Microbench script
Added one test case with mixed tiers and a gap, which goes through the new path.
pre-commitis clean.Details
The chunks are in order because the scheduler adds one range per chunk, front to back, when it plans the load. The new loop adds each range's length to its tier and counts any gaps as
external_unspecified. If a range starts before the previous one ends, it falls back to the existing sweep. That covers recurrent state and models with more than one KV cache group, so those behave exactly as before.I also removed the
CacheHitSource(...)wrap aroundget_load_source. It already returns aCacheHitSource, and the wrap was 0.7 ms of the 128k case.I couldn't find an open PR touching this function.
AI assistance (Claude) was used. I reviewed every line and ran the tests and benchmark above.
Pull Request Checklist
I used vLLM's
/pr-checklistskill. (Mandatory for agents, optional for humans).AI assistance was used during the creation of this PR.
Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.
Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.
Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.
Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.