[Bugfix] Set num_cached_tokens = num_computed_tokens if unset#1471
Closed
gcanlin wants to merge 1 commit into
Closed
[Bugfix] Set num_cached_tokens = num_computed_tokens if unset#1471gcanlin wants to merge 1 commit into
gcanlin wants to merge 1 commit into
Conversation
Signed-off-by: gcanlin <canlinguosdu@gmail.com>
Closed
2 tasks
linyueqian
approved these changes
Feb 25, 2026
Collaborator
There was a problem hiding this comment.
LGTM.
One minor question: should the num_cached_tokens assignment be done unconditionally (i.e. drop the if < 0 guard) to match the base scheduler's behavior exactly? The base scheduler always sets num_cached_tokens = num_computed_tokens without a guard. The defensive check is fine for now, just wondering if there's a reason to prefer it over the unconditional approach.
linyueqian
reviewed
Feb 25, 2026
Collaborator
linyueqian
left a comment
There was a problem hiding this comment.
Correction on my earlier comment: I checked the base vLLM scheduler (vllm/v1/core/sched/scheduler.py:798) and it also uses the same if request.num_cached_tokens < 0 guard. So the approach here is perfectly consistent with upstream. No concerns at all!
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.
PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.
Purpose
Request.num_cached_tokensis initialized to -1 :self.num_cached_tokens = -1inRequest.py. The base vLLM scheduler setsnum_cached_tokens = num_computed_tokenswhen scheduling requests. ButOmniGenerationScheduleroverridesschedule()with a fast path that never updatednum_cached_tokensTest Plan
Test Result
Before(crash):
After:
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model. Please runmkdocs serveto sync the documentation editions to./docs.BEFORE SUBMITTING, PLEASE READ https://github.com/vllm-project/vllm-omni/blob/main/CONTRIBUTING.md (anything written below this line will be removed by GitHub Actions)