Repository navigation
fix(usage): exclude resumed prefill work from cache hits - #4383
Merged
Merged
Conversation
jundot
approved these changes
Oct 9, 2026
jundot
left a comment
Owner
There was a problem hiding this comment.
Confirmed on main that a cold request paused by the prefill throttle reports its own prefilled tokens as cached. Keeping the resume offset as is and only subtracting the resumed part in the output fixes the usage without touching the resume path. LGTM, merging.
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.
Summary
A prefill pause adds newly computed tokens to the resume offset. The same offset is reported as
cached_tokens, so clients see false cache hits and a lower prompt rate.Track the work kept after a pause and subtract it from the output's cache count. Keep the resume offset in place and clear the new counter on cold retries.
Fixes #4374
Validation
Apple M5 Pro, 64 GB, macOS 27.0.1, Python 3.12.13.
python -m pytest tests/test_scheduler_prefill_eviction_progress.py tests/test_scheduler.py tests/test_prefill_oom_graceful.py tests/test_request.py -q— 570 passed.python -m pytest -n 3 --dist loadgroup— 17,281 passed, 628 skipped.main, and in the full rerun.main.Real-model check:
mlx-community/Qwen3-0.6B-4bit, 128 prompt tokens, 8 greedy output tokens, 16-token prefill chunks. Forced one pause after 32 computed tokens. Before the fix, the cold request reports 32 cached tokens and the 16-token warm prefix reports 48. After the fix, they report 0 and 16. Generated tokens match the runs without pauses.Checklist