Practical overview
When it fits
Use Kvpress when you are building or studying Transformers-based LLM inference and want to apply or compare training-free KV-cache compression, especially for context-heavy workloads.
Who it is for
- Developers adding KV-cache compression to Transformers-based language-model inference.
- Researchers comparing cache compression approaches for LLM workloads.
Documented uses
- Apply a compression method to context tokens during model prefilling.
- Use a compressed context for text generation and questions about that context.
- Configure experimental periodic cache compression during token generation.
- Compare compression approaches and investigate memory or timing measurements using the linked notebooks.
Requirements & limits
The project is a public GitHub repository identified as open source under the Apache-2.0 license. The README documents installation through pip or a local uv-managed checkout.
- The custom
kv-press-text-generationpipeline handles chat templates and tokenization, according to the README. - Prefill compression is the default; decoding compression is separately described as experimental.
- DecodingPress uses a target cache size and compression interval rather than the prefill press's compression-ratio setting.
- The README describes multi-GPU inference through Accelerate and links notebooks for memory and timing measurements.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install Kvpress and prepare a Transformers pipeline
Set up the documented text-generation pipeline for a model and a KV-cache compression method.
Before you start
- Python environment with pip, or a local development environment with uv.
- A Transformers model identifier; the example uses Qwen/Qwen3-8B.
- The README's pipeline example specifies device_map="auto" and dtype="auto".
Steps
Install the package with the command below, or clone the repository and run the command below from its directory.
pip install kvpressuv syncImport
pipelinefrom Transformers and a press such asExpectedAttentionPressfrom kvpress.Create a pipeline with the
kv-press-text-generationtask and the chosen model identifier.Set a context, optionally provide a question, and create the press with a
compression_ratio.
Expected outcome
A configured pipeline call can apply the selected press to context tokens and return an answer for a question about that context.
Guide limitations
- The example describes API usage; it does not establish performance or hardware compatibility for a particular model.
- Optional evaluation and flash-attention dependencies are installed separately using the documented uv extras.
Configure experimental decoding-time compression
Prepare a pipeline using the documented DecodingPress wrapper to compress the cache periodically during generation.
Before you start
- Kvpress and Transformers installed.
- A Transformers model identifier; the example uses meta-llama/Llama-3.1-8B-Instruct.
- A ScorerPress, such as KnormPress, as the wrapper's base press.
Steps
Initialize the
kv-press-text-generationpipeline with the model and the documented device and model options.Create
DecodingPresswith a base ScorerPress, a compression interval, and a target cache size.Pass the wrapper as the
pressargument when calling the pipeline with context and a question.
Expected outcome
The configured wrapper is set to compress the cache at intervals during token generation toward the chosen target size.
Guide limitations
- Decoding compression is identified as experimental.
- Not all presses are compatible; the documentation supports ScorerPresses as base presses.
- The example's CUDA device and flash-attention option are example configuration, not a guarantee of availability or compatibility.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 13 October 2026
- Original website title
- NVIDIA/kvpress · Official homepage title · retained in its source language

