Merged
Conversation
rltakashige
commented
Apr 13, 2026
| f"cached ({100 * prefix_hit_length / len(all_prompt_tokens):.1f}%)" | ||
| ) | ||
| prompt_tokens = remaining_tokens | ||
| else: |
Collaborator
Author
There was a problem hiding this comment.
We don't need to do this twice
rltakashige
commented
Apr 13, 2026
| ) | ||
| cache_snapshots: list[CacheSnapshot] | None = ssm_snapshots_list or None | ||
|
|
||
| if kv_prefix_cache is not None and matched_index is not None and is_exact_hit: |
Collaborator
Author
There was a problem hiding this comment.
Save prefix cache at prefill time rather than decode time
Collaborator
Author
There was a problem hiding this comment.
We don't do this in the batch generator anyway atm
Evanev7
reviewed
Apr 14, 2026
Member
Evanev7
left a comment
There was a problem hiding this comment.
do you actually use the prefill tps in the kv cache anywhere or just plumbing?
| all_prompt_tokens: mx.array | ||
| prefix_hit_length: int | ||
| matched_index: int | None | ||
| cache_snapshots: list[CacheSnapshot] | None |
Evanev7
approved these changes
Apr 14, 2026
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.
Motivation
For using Exo-Bench extensively, there are many cases that we could use prefix caching to speed up the benchmarks, especially when the focus is on the token generation.
At the same time, it's very clear that prefix caching decode tokens is not very useful in most current scenarios. Surprisingly, even for non-thinking models, the chat template means that a continued conversation will be formatted such that the existing cache is not effective.
We already (slightly accidentally) do this for the batch generator - we should do it for the sequential generator too.
Changes
We can now speed up exo bench by having a use prefix caching flag. Of course, for most accurate pp results, it is better to not have it, but this speeds up tg and large benchmarking significantly.
Updated methodology to match
Test Plan
Manual Testing
Tested on many configurations that the difference in results is negligible, even with multiple --pp options.