Skip to content

Conversation

@zhuohan123
Copy link
Member

@zhuohan123 zhuohan123 commented Sep 26, 2025

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:

vllm bench throughput   --model NousResearch/Hermes-3-Llama-3.1-8B   --dataset-name random   --num-prompts 1000 --input-len 1024 --output-len 1024

We see

INFO 09-26 14:24:45 [loggers.py:127] Engine 000: Avg prompt throughput: 0.0 tokens/s, Avg generation throughput: 7097.7 tokens/s, Running: 260 reqs, Waiting: 475 reqs, GPU KV cache usage: 100.0%, Prefix cache hit rate: 0.2%

Prefix cache hit rate droped from 30% to 0.2%.


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.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Copy link
Contributor

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

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

self.encoder_cache_manager.free(preempted_req)
preempted_req.status = RequestStatus.PREEMPTED
preempted_req.num_computed_tokens = 0
preempted_req.num_preemptions += 1
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this line is the only actual change in this file, all other changes are code style change.

@WoosukKwon WoosukKwon added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 26, 2025
Copy link
Collaborator

@WoosukKwon WoosukKwon left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for doing this.

@zhuohan123 zhuohan123 enabled auto-merge (squash) September 26, 2025 22:38
@zhuohan123 zhuohan123 merged commit 8bf8f45 into main Sep 27, 2025
44 checks passed
@zhuohan123 zhuohan123 deleted the zhuohan/fix-prefix-caching-stat branch September 27, 2025 00:16
pdasigi pushed a commit to pdasigi/vllm that referenced this pull request Oct 2, 2025
yewentao256 pushed a commit that referenced this pull request Oct 3, 2025
xuebwang-amd pushed a commit to xuebwang-amd/vllm that referenced this pull request Oct 10, 2025
lywa1998 pushed a commit to lywa1998/vllm that referenced this pull request Oct 20, 2025
alhridoy pushed a commit to alhridoy/vllm that referenced this pull request Oct 24, 2025
xuebwang-amd pushed a commit to xuebwang-amd/vllm that referenced this pull request Oct 24, 2025
rtourgeman pushed a commit to rtourgeman/vllm that referenced this pull request Nov 10, 2025
devpatelio pushed a commit to SumanthRH/vllm that referenced this pull request Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants