Sliding Window Attention (AR video gen) + KV cache lifecycle management - #198
Open
merceod wants to merge 10 commits into
Open
Sliding Window Attention (AR video gen) + KV cache lifecycle management#198merceod wants to merge 10 commits into
merceod wants to merge 10 commits into
Conversation
stephen-dwq
reviewed
Aug 1, 2026
Collaborator
There was a problem hiding this comment.
nit: should these test files be moved into ./test/?
stephen-dwq
reviewed
Aug 1, 2026
| tail = st.get("ar_tail") | ||
| if tail is None: | ||
| pixels = self._decode_pixels(new) | ||
| else: |
Collaborator
There was a problem hiding this comment.
I think we can do some reshuffling here:
"ar_tail" is obtained from stream_tail[:,:,-st["ar_ctx"]:] (line 2271), so tail.shape[2] <= ar_ctz. Then, ctx = tail[:, :, -st["ar_ctx"]:] (line 2263) is a noop.
Because it's a noop, torch.cat([ctx, new.to(ctx.dtype)], dim=2) (line 2264) is the same computation as torch.cat([tail, new.to(tail.dtype)], dim=2) (line 2270).
We can hoist the conditional assignment on line 2270 into the if-else statements above.
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.
What does this PR do?
Adds windowed autoregressive video generation to M*: instead of denoising a whole clip at once, the video is produced window-by-window, and each finished window streams to the decoder while the next one denoises. Two layers:
Engine (model-agnostic):
Cosmos3 (first adopter, opt-in):
Cross-window attention through committed K/V with eviction (built on the release primitives above) lands next on this branch.
How was it tested?
Checklist
ruff check .passes