Skip to content

Slice rotary embeddings per chunk in ChunkPress 馃馃馃 - #309

Merged
maxjeblick merged 1 commit into
NVIDIA:mainfrom
sebxt:fix/chunkpress-wrong-rope-positions
Oct 26, 2026
Merged

maxjeblick merged 1 commit into
NVIDIA:mainfrom
sebxt:fix/chunkpress-wrong-rope-positions

Conversation

@sebxt

@sebxt sebxt commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

PR description

ChunkPress sliced hidden_states, keys and values per chunk but forwarded the full kwargs["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 kwargs with position_embeddings sliced to the chunk. Presses that do not use position_embeddings are 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.py and tests/test_per_layer_compression_press.py pass (732 passed, 4 skipped on CPU).

Checklist

Before submitting a PR, please make sure:

  • Tests are working (make test)
  • Code is formatted correctly (make style, on errors try fix with make format)
  • Copyright header is included
  • All commits are signed-off using git commit -s

Fixes #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.

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@maxjeblick
maxjeblick self-requested a review October 25, 2026 21:31
@maxjeblick

Copy link
Copy Markdown
Collaborator

/ok to test 4c373e3

@maxjeblick maxjeblick left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR, code LGTM

@maxjeblick
maxjeblick merged commit 2d66e74 into NVIDIA:main Oct 26, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ChunkPress scores every chunk with the rotary embeddings of the end of the full sequence 馃馃馃

2 participants