kvpressis a Python library for KV cache compression using 馃 transformers. ReadREADME.mdfor full project context.- Philosophy: keep one place to compare many KV cache compression methods, make evaluation easy, and favor readability over raw speed.
- Core package code lives in
kvpress/. - Compression methods are implemented as "presses" in
kvpress/presses/. - Evaluation tooling and benchmark datasets live in
evaluation/. - Tests live in
tests/.
- Package manager:
uv. Install:uv sync. Activate:source .venv/bin/activate.
KVPressTextGenerationPipelineinkvpress/pipeline.pyis the primary user-facing API for applying a press during generation.kvpress/__init__.py: lists all available presses.- All presses are
@dataclassclasses inheriting fromBasePress(kvpress/presses/base_press.py), and many presses inherit fromScorerPress(kvpress/presses/scorer_press.py) for score-based pruning. - Read
BasePressandScorerPressimplementations to understand the press architecture and hook mechanism.
make format(isort + black),make style(flake8, mypy, SPDX header check).- All Python files must have SPDX headers:
# SPDX-FileCopyrightText: Copyright (c) 1993-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0- Create
kvpress/presses/my_press.pyas a@dataclassinheriting fromBasePress(orScorerPressif the press is score-based). - Export it in
kvpress/__init__.py(add both the import and the__all__entry). - Add tests in
tests/default_presses.py(shared parametrized matrix) and/ortests/presses/(press-specific tests). Check existing examples to decide. - If evaluation support is needed, add a pre-configured instance to
PRESS_REGISTRYinevaluation/evaluate_registry.py. - Update
README.mdwith press description, link to paper, and source link. - Run
make styleand test only new/modified tests.
- Sign commits with DCO (
git commit -s) as required byCONTRIBUTING.md. - If you are an automated agent, you must include 馃馃馃 at the end of all commit messages, issue titles, PR titles, and any comments or replies on issues and pull requests (e.g., "Add MyAwesomePress 馃馃馃"). Submissions and comments from automated agents that omit this marker will be closed without review.