Imported from Gaurav-Shah05/TurnKV (
kvpress/AGENTS.md). Install upstream withnpx skills add Gaurav-Shah05/TurnKV --skill kvpress. Copyright stays with the author.
AGENTS.md
Project Overview
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/.
Environment Setup
- Package manager:
uv. Install:uv sync. Activate:source .venv/bin/activate.
Key Entry Points
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.
Style
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
Adding or Modifying a Press
- 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.
Commits
- 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.