Repository navigation
Add EchoPress - #300
Add EchoPress#300ljwljwljwljw wants to merge 3 commits into
Conversation
Approximate KVzip scores through virtual context reconstruction during prefill. Reconstruct the first chunk exactly and calibrate later virtual scores per request, layer, and KV head. Signed-off-by: Jiawei Lin <jiawei.lin@epfl.ch>
|
Hi @ljwljwljwljw, thanks for your PR ! We don't accept custom kernels in kvpress. Could you remove the triton kernel and only use the torch backend ? Feel free to let a comment in the docstring to link to your fork with the kernel |
|
@ljwljwljwljw I've let a first series of comments. The goal of kvpress is to provide short and easy to read paper reproduction. I believe the code could be very largely compacted if you remove all the unused variants and don't duplicate code from |
- Remove the Triton kernel. - Remove the exact_first_chunk, guard_tokens, score_calibration, calibration_direction, calibration_scope and scoring_backend options. - Reuse get_query_states. - Inherit KVzipPress.__call__, prepare and __post_init__; override _perform_kvzip_compression only. Let KVzipPress keep its tokenizer so that the chunks can be built before the compression phase. - Assert that the KVzip+ normalization is disabled. Signed-off-by: Jiawei Lin <jiawei.lin@epfl.ch>
|
Thanks for your review! I updated the code to addresses all the comments above:
Since EchoPress runs the parent |
|
Thanks for the updates, the code is now much more compact and readable I believe. I will review again. For the warning, feel free to re-write the post init entirely: assert 0 <= self.compression_ratio < 1, "Compression ratio must be between 0 and 1"
assert self.chunk_size > 0, "Chunk size must be positive"
assert not self.kvzip_plus_normalization, "EchoPress does not support the KVzip+ normalization"
self._reset_internal_parameters() |
|
/ok to test 98fee38 |
Signed-off-by: Jiawei Lin <jiawei.lin@epfl.ch>
Updated. Thanks! |
PR description
Add
EchoPress, a training-free approximation to KVzip that reuses prefill queries and cached keys to score virtual context repetitions. Paper: https://arxiv.org/abs/2610.00412EchoPress virtually reconstructs context by rotating queries during prefill. It performs a single KVzip-style reconstruction pass on the first chunk, capped at 2K tokens, then uses the exact KVzip scores from that chunk to calibrate the virtual scores of subsequent chunks.
Evaluation
EchoPressmatches KVZip's accuracy on both RULER-4K and LongBench. Benchmark details can be found in our paper.Code changes
echoentry in the evaluation registry.Checklist
Before submitting a PR, please make sure:
Tests are working (
make test)Code is formatted correctly (
make style, on errors try fix withmake format)Copyright header is included
All commits are signed-off using
git commit -s(new press)
mypress_press.pyis in thepressesdirectory(new press)
MyPressis in__init__.py(new press)
README.mdis updated with a 1 liner about the new press in the Available presses section(new press) New press is in the
default_presseslist intests/default_presses.py(new press) A docstring is provided that follows the same structure as the existing ones