feat: add windowed attention in action tokenizer encoder#25
Open
tashapais wants to merge 1 commit into
Open
Conversation
Adds WindowedFrameAttention: for each pair of consecutive frames (t, t+1), concatenates their P patch embeddings into a 2P sequence, applies self-attention, and mean-pools to a single embedding. Compared to mean pool + concat, patches from both frames can interact before pooling, giving richer inter-frame signal for action inference. Controlled by use_windowed_attention (default False) on LatentActionModel and LatentActionsConfig. The action head input shrinks from embed_dim*2 to embed_dim.
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
WindowedFrameAttentiontomodels/latent_actions.py: for each pair of consecutive frames (t, t+1), concatenates all patch embeddings from both frames into a 2P sequence, applies self-attention, then mean-pools to a single E-dimensional vector.LatentActionsEncodergainsuse_windowed_attention=False(default). When enabled, the old mean pool + concat path is replaced byWindowedFrameAttention + simpler head (E -> action_dim).LatentActionModel,LatentActionsConfig,training.yaml, andtrain_latent_actions.py.Why windowed attention over mean pool + concat:
Mean pooling discards patch-level spatial structure before frames are combined. With windowed attention, patches from frame t and frame t+1 can cross-attend before pooling, allowing the model to focus on the specific regions that changed (e.g., a moving sprite, a door opening) rather than averaging everything uniformly.
Test plan
use_windowed_attention: trueintraining.yamland compare action codebook diversity vs baselineuse_windowed_attention: false(default) produces identical behavior to main