Repository navigation
fix(cache): restart continuous cache streak after compute steps - #1114
Merged
DefTruth merged 3 commits intoOct 13, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
Fixes continuous cache streak accounting after compute steps, including separate-CFG execution.
Changes:
- Correct streak resets for normal and CFG paths.
- Add regression coverage for both CFG execution orders.
File summaries
| File | Description |
|---|---|
tests/api/test_refresh_context.py |
Adds regression tests for cache limits and CFG modes. |
src/cache_dit/caching/cache_contexts/cache_context.py |
Corrects cache streak tracking. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Forced warmup or computation-mask steps can leave stale streak counters and incorrectly reject the next cache opportunity.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
src/cache_dit/caching/cache_contexts/cache_context.py:263
- The CFG streak has the same stale-counter problem: a CFG compute forced by an early
can_cache()return (such as an interleaved warmup or dynamic computation-mask step) does not clear this value, so the next non-adjacent CFG cache candidate can be rejected before this branch gets a chance to restart the streak. Reset or derive the CFG streak from adjacency before enforcing the limit, and cover both CFG execution orders with an interleaved forced-compute case.
else:
self.cfg_continuous_cached_steps = 1
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Balanced
Reset per-branch streaks when the previous step was not cached. Remove redundant cap resets and simplify hit counting. Cover interleaved warmup, dynamic computation masks, both CFG orders, and repeated cache checks in regression tests.
This was referenced Sep 26, 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.

Summary
Problem
When
max_continuous_cached_steps=1blocks a cache hit,can_cache()resets the streak counter to zero. The next non-adjacent hit was appended without setting the counter back to one, so the following adjacent step was also allowed.With four warmup steps and 19 denoising steps, the buggy sequence was
[4, 6, 7, 9, 10, 12, 13, 15, 16, 18]; the limit should produce[4, 6, 8, 10, 12, 14, 16, 18].Test plan
pytest tests/api/test_refresh_context.py -q(9 passed)pre-commit run --files src/cache_dit/caching/cache_contexts/cache_context.py tests/api/test_refresh_context.py