Repository navigation
Slice rotary embeddings per chunk in ChunkPress 馃馃馃 - #309
Merged
maxjeblick merged 1 commit intoOct 26, 2026
Merged
Conversation
Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
maxjeblick
self-requested a review
October 25, 2026 21:31
Collaborator
|
/ok to test 4c373e3 |
maxjeblick
approved these changes
Oct 26, 2026
maxjeblick
left a comment
Collaborator
There was a problem hiding this comment.
Thanks a lot for the PR, code LGTM
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.
PR description
ChunkPressslicedhidden_states,keysandvaluesper chunk but forwarded the fullkwargs["position_embeddings"]to the inner press. Presses that recompute window queries (SnapKVPress,PyramidKVPress,TOVAPress,CompactorPress,NonCausalAttnPress,DropKVPress) take the last positions of those embeddings, so each chunk's queries were rotated as if they were at the end of the full context. The relative distance to the chunk keys was wrong for every chunk but the last, and the tokens kept in a chunk depended on how much text came after it.This passes a copy of
kwargswithposition_embeddingssliced to the chunk. Presses that do not useposition_embeddingsare unaffected.The new test compresses the same random hidden states and keys once as a single 32 token chunk and once as the first chunk of a 128 token input, and checks that the first chunk keeps the same keys. It fails before the fix and passes after.
tests/presses,tests/test_press_call.pyandtests/test_per_layer_compression_press.pypass (732 passed, 4 skipped on CPU).Checklist
Before submitting a PR, please make sure:
make test)make style, on errors try fix withmake format)git commit -sFixes #308
AI tools were used to find this bug and to write the fix, the test and this description. The tests were run locally before and after the change.