Skip to content

fix(usage): exclude resumed prefill work from cache hits - #4383

Merged
jundot merged 2 commits into
jundot:mainfrom
arnavprabhu:fix/prefill-pause-cache-usage
Oct 9, 2026
Merged

jundot merged 2 commits into
jundot:mainfrom
arnavprabhu:fix/prefill-pause-cache-usage

Conversation

@arnavprabhu

Copy link
Copy Markdown
Contributor

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.
  • Default suite: python -m pytest -n 3 --dist loadgroup — 17,281 passed, 628 skipped.
  • The first full run hit the cluster disconnect timing test. It passed on retry, on main, and in the full rerun.
  • The extended pause tests fail before the fix: 20 failed, 4 passed. They check repeated pauses, cold and warm prefixes, intermediate and final outputs, and prompt-rate calculation.
  • Black and Ruff pass for the test file. Source files have no new Ruff findings compared with 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

  • I read CONTRIBUTING.md.
  • I understand every change in this PR and can explain it in review.
  • No UI or UX changes.

@jundot jundot left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

@jundot
jundot merged commit 9d19962 into jundot:main Oct 9, 2026
1 check passed
jundot added a commit that referenced this pull request Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prefill pauses count newly computed tokens as cached and underreport prompt throughput

2 participants