Conversation
… behind a protected prefix)
merceod
force-pushed
the
engine/kv-window-lifecycle
branch
from
September 23, 2026 23:14
77179c7 to
8bc4628
Compare
This branch has not been deployed
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.
Ports the windowing module and the KV release contract from #198 onto the resource-pool engine (
resources/kv/manager.py), so windowed autoregressive video can bound the committed context of a long rollout.What changed
RetentionPolicy(context_budget, protected_prefix)on aCacheStream(the existing stub, filled in) andKVManager.set_retention(request_id, policy, label=None).commitapplies the policy right after a stream's span is counted. The oldest unprotected whole pages go back to the arena,stored_lendrops by the freed count, andgenerationbumps so the dense backend re-gathers its prefix. This happens inside the commit, under the lock and beforecommit_done, so the pre-plan of the next step already sees the compacted stream and no admitted plan addresses freed pages.KVManager.protect_prefix/release_oldestfor explicit between-step drivers. Refused under an admitted step or while offloaded.mstar/engine/windowing.pywithWindowSchedule(pure window arithmetic, from Sliding Window Attention (AR video gen) + KV cache lifecycle management #198) andWindowedKVSession.bind(prefix), which installs the schedule's context horizon as the stream's retention.Why the release moved into the commit
#198 released pages between steps on the old allocator. With the pool's speculative pre-planning there is no safe moment between steps anymore (the next step is admitted and planned while the current one runs), so the release became a stream-level policy applied at commit. Streaming ASR or duplex speech models can use the same policy.
Tests
test/modular/test_kv_release.py(compaction, page floor, boundary and tail pages, admitted-step refusal, later plans over the compacted stream, page conservation, commit-time retention with sub-page carry-over, validation, reset) andtest/modular/test_windowing.py.ruffand the fulltest/modularpass. The Cosmos3 kv-mode rollout that drives this end to end is verified on H100 in #297.