[Core] Don't count preempted tokens in prefix cache hit rate#25787
Merged
zhuohan123 merged 2 commits intomainfrom Sep 27, 2025
Merged
[Core] Don't count preempted tokens in prefix cache hit rate#25787zhuohan123 merged 2 commits intomainfrom
zhuohan123 merged 2 commits intomainfrom
Conversation
Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request correctly modifies the prefix cache hit rate calculation to exclude tokens from preempted requests. The changes are implemented by adding a preemption counter to requests, which is then used to separate statistics for new and preempted requests. The implementation is clean and directly addresses the issue. The associated refactoring in the scheduler improves code readability. I have reviewed the changes and found no issues.
zhuohan123
commented
Sep 26, 2025
| self.encoder_cache_manager.free(preempted_req) | ||
| preempted_req.status = RequestStatus.PREEMPTED | ||
| preempted_req.num_computed_tokens = 0 | ||
| preempted_req.num_preemptions += 1 |
Member
Author
There was a problem hiding this comment.
Note: this line is the only actual change in this file, all other changes are code style change.
WoosukKwon
approved these changes
Sep 26, 2025
Collaborator
WoosukKwon
left a comment
There was a problem hiding this comment.
LGTM. Thanks for doing this.
pdasigi
pushed a commit
to pdasigi/vllm
that referenced
this pull request
Oct 2, 2025
…oject#25787) Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
yewentao256
pushed a commit
that referenced
this pull request
Oct 3, 2025
Signed-off-by: Zhuohan Li <zhuohan123@gmail.com> Signed-off-by: yewentao256 <zhyanwentao@126.com>
lywa1998
pushed a commit
to lywa1998/vllm
that referenced
this pull request
Oct 20, 2025
…oject#25787) Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
alhridoy
pushed a commit
to alhridoy/vllm
that referenced
this pull request
Oct 24, 2025
…oject#25787) Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
rtourgeman
pushed a commit
to rtourgeman/vllm
that referenced
this pull request
Nov 10, 2025
…oject#25787) Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
devpatelio
pushed a commit
to SumanthRH/vllm
that referenced
this pull request
Nov 29, 2025
…oject#25787) Signed-off-by: Zhuohan Li <zhuohan123@gmail.com>
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.
Purpose
Do not count preempted tokens in prefix cache hit rate. See #25780 for details.
Test
Existing test should pass, and now when we run:
We see
Prefix cache hit ratedroped from 30% to 0.2%.Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.