Skip to content

Fix ChunkKV selection for batched inputs 🤖🤖🤖 - #319

Open
0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix-chunkkv-batch-selection
Open

0z5a wants to merge 1 commit into
NVIDIA:mainfrom
0z5a:fix-chunkkv-batch-selection

Conversation

@0z5a

@0z5a 0z5a commented Nov 4, 2026

Copy link
Copy Markdown

Summary

ChunkKVPress computes chunk scores for every example but previously applied the first example's selected chunks to the entire batch. Select and gather chunks independently for each example so a later example keeps its own high-scoring tokens.

If selection of a trailing partial chunk gives examples different retained lengths, raise a clear error: the dense cache tensor cannot represent that ragged result. Single-example partial chunks and batches with equal retained lengths continue to work.

Fixes #317.

Validation

  • Four CPU tests passed with PyTorch and Transformers 5.2, covering independent selections, partial chunks, ragged-length rejection, and single-example behavior. Three fail on the original implementation.
  • make style passed, including flake8, mypy, and SPDX checks; Black and isort checks passed for changed files.
  • These are cache-compression tests with deterministic scores; no model accuracy or GPU performance benchmark was run.

Signed-off-by: 0z5a <dezhen.lu@student.uni-tuebingen.de>
@copy-pr-bot

copy-pr-bot Bot commented Nov 4, 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.

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.

ChunkKVPress applies the first sample’s selected chunks to the entire batch 🤖🤖🤖

1 participant