kvcached is a free, open source machine learning infrastructure project written in Python and released under Apache-2.0. It has 1,506 GitHub stars, 181 forks and 105 open issues, and was last pushed 35 hours ago. On this registry it ranks #60 of 87 tracked projects in Machine Learning Infrastructure, with 5 head-to-head comparisons available.

What is kvcached?

kvcached is an Apache-2.0 Python library that gives LLM serving engines a virtual-memory-style, elastic KV cache, letting several models share one GPU's memory instead of partitioning it rigidly — it is built for ML infrastructure and platform engineers who serve LLMs on shared or capacity-constrained GPUs.

What it is

kvcached (the KV cache daemon) is a KV cache library for LLM serving and training on shared GPUs, published in the Python ecosystem under the AI & Machine Learning / Machine Learning Infrastructure category. It works by decoupling GPU virtual addressing from physical memory allocation for KV caches: a serving engine initially reserves virtual memory only, and that reservation is later backed with physical GPU memory when the cache is actively used. That decoupling is what makes allocation demand-driven and sharing flexible, and it is why the project describes itself as bringing an OS-style virtual memory abstraction to LLM systems. The repository carries 1,506 stars, 181 forks and 105 open issues.

The concrete problem it solves is the rigid memory partitioning that serving engines rely on today, where each model is given a fixed slice of device memory before any request arrives. Under dynamic or mixed workloads that pre-allocated cache memory sits idle while other models are starved, so GPU utilization stays low relative to what the hardware can actually do. kvcached replaces that static partition with elastic allocation and reclamation that tracks live load, allowing multiple LLMs, or an LLM alongside other GPU work, to occupy the same device without committing fixed slices to each. It is not a serving engine itself; it integrates with the engines teams already run.

Key capabilities

  • Elastic KV cache that allocates and reclaims KV memory dynamically to match live load.
  • GPU virtual memory management that decouples logical KV from physical GPU memory through runtime mapping.
  • A memory control CLI, kvcached, for enforcing memory limits.
  • A frontend router with sleep mode, which routes requests to target models and puts idle models to sleep.
  • Integration with mainstream serving engines: SGLang ≥ v0.4.9 (tested to v0.5.15) and vLLM ≥ v0.8.4 (tested to v0.24.0).
  • Prefix caching support, covering automatic prefix caching (APC) for vLLM and RadixCache for SGLang under a configurable memory bound, documented in examples/09_prefix_caching.
  • Attention and parallelism coverage across MHA, GQA, MLA, sliding window and hybrid attention, with pipeline parallelism and example models such as DeepSeek-V3, Qwen3-8B, GPT-OSS-20B and Gemma-4-12B-it.

Who uses it and how

  • Teams serving multiple LLMs, which can share a GPU's memory elastically and be deployed concurrently instead of under fixed partitioning.
  • Serverless LLM deployments, where KV cache is allocated only when needed so models can spin up and down on demand.
  • Compound AI systems on limited hardware, where memory is allocated elastically across specialised models in a pipeline such as retrieval, reasoning and summarisation.
  • GPU workload colocation, where LLM inference coexists with training jobs, fine-tuning or vision models on the same device.
  • Kubernetes and OpenShift multi-model serving: Red Hat's Sardeenz builds on kvcached for running LLMs dynamically in production under limited resources, as featured in April 2026.

Getting started

The README points readers to the worked examples under kvcached/examples, including a simple example that runs an unmodified vLLM engine with dynamically allocated memory. There is no packaged install command stated in the excerpt, so the examples directory is the practical entry point.

How it compares

kvcached sits below the serving engines rather than competing with them: it is a KV cache and memory management layer that plugs into vLLM and SGLang, both of which it names as supported engines rather than alternatives. Ollama appears among the project's topics, placing it in the same broad self-hosted LLM serving conversation, but the README frames kvcached purely as the layer that makes those engines share GPU memory elastically.

When to use it — and when not to

A self-hoster must already operate a supported serving engine at a qualifying version, along with the GPU drivers and Python environment that engine needs, and integration work is bounded by the tested version ranges listed above. Elastic sharing offers the least benefit to anyone running a single model on a dedicated GPU with steady load, who gains little from dynamic reclamation. The project also carries 105 open issues and an example-heavy README that does not spell out installation, so teams wanting a packaged, one-command deployment should weigh that before adopting it.

project readme (upstream, from github) — read inline
kvcached logo

Python Engines Blog arXiv: GPU OS vision
arXiv: Multi LLM Serving Slack Join DeepWiki Homepage License

Make GPU Sharing Flexible and Easy

Make GPU Sharing Flexible and Easy

kvcached (KV cache daemon) is a KV cache library for LLM serving/training on shared GPUs. By bringing OS-style virtual memory abstraction to LLM systems, it enables elastic and demand-driven KV cache allocation, improving GPU utilization under dynamic workloads.

kvcached achieves this by decoupling GPU virtual addressing from physical memory allocation for KV caches. It allows serving engines to initially reserve virtual memory only and later back it with physical GPU memory when the cache is actively used. This decoupling enables on-demand allocation and flexible sharing, bringing better GPU memory utilization under dynamic and mixed workloads. Check out more details in the blog.

Key Features

  • Elastic KV cache: allocate and reclaim KV memory dynamically to match live load.
  • GPU virtual memory: decouple logical KV from physical GPU memory via runtime mapping.
  • Memory control CLI: enforce memory limits with kvcached CLI.
  • Frontend router and sleep mode: route requests to the target models and put models to sleep when idle.
  • Support mainstream serving engines: integrate with SGLang and vLLM.
  • Prefix caching: support automatic prefix caching (APC) with a configurable memory bound. See the example doc for details.

📢 Updates

  • [2026-04] kvcached is featured by Red Hat for running LLMs dynamically in production under limited resources! Red Hat's Sardeenz builds on kvcached to provide dynamic multi-model serving with Kubernetes and OpenShift support. See the blog post for more details. [▶ View Demo]

  • [2026-04] Added prefix caching support. kvcached now supports automatic prefix caching (APC) for vLLM and RadixCache for SGLang, enabling cross-request prefix reuse while maintaining elastic memory management.

  • [2026-03] Added pipeline parallelism support. MLA models (DeepSeek-V3, DeepSeek-V2 etc.) and GPT-OSS hybrid attention models (openai/gpt-oss-20b) are now also supported in vLLM. GPT-OSS support in SGLang updated to v0.5.9.

Supported engines and models

Engine Versions Attention types Example models
SGLang ≥ v0.4.9 (tested up to v0.5.15) MHA / GQA / MLA / sliding window / hybrid DeepSeek-V3, Qwen3-8B, GPT-OSS-20B, Qwen3.5-9B, Gemma-4-E2B-it, Gemma-4-12B-it
vLLM ≥ v0.8.4 (tested up to v0.24.0) MHA / GQA / MLA / sliding window / hybrid DeepSeek-V3, Qwen3-8B, GPT-OSS-20B, Qwen3.5-9B, Gemma-4-E2B-it, Gemma-4-12B-it

See #425 for per-model results on each engine and KV layout.

Example use cases

Multi‑LLM serving Multi‑LLM serving
kvcached allows multiple LLMs to share a GPU's memory elastically, enabling concurrent deployment without the rigid memory partitioning used today. This improves GPU utilization and saves serving costs.
Serverless LLM Serverless LLM
By allocating KV cache only when needed, kvcached supports serverless deployments where models can spin up and down on demand.
Compound AI systems Compound AI systems
kvcached makes compound AI systems practical on limited hardware by elastically allocating memory across specialized models in a pipeline (e.g., retrieval, reasoning, and summarization).
GPU workload colocation GPU workload colocation
kvcached allows LLM inference to coexist with other GPU workloads such as training jobs, fine-tuning, or vision models.

See concrete examples here: kvcached/examples.

kvcached in action

The following simple example shows how kvcached enables an unmodified vLLM engine run with dynamically allocated memory.

kvcached in action

Performance: Multi-LLM serving

kvcached enables dynamic memory sharing between LLMs, allowing them to share the same GPU memory elastically. As a comparison, the current serving engines need to statically reserve GPU memory at startup.

This benchmark shows the performance benefits of kvcached when serving three Llama-3.1-8B models on an A100-80G GPU under workloads with intermittent peaks. kvcached can achieve 2-28x TTFT reduction compared to the current serving engines. This performance gain can be converted to significant cost savings for LLM serving. Without kvcached, the systems have to provision more GPUs to achieve the same performance. Details can be found in benchmarks/bench_latency_benefit.

TTFT mean TTFT p99

Installation

Prerequisites

  • Python (tested with 3.9 - 3.13)
  • SGLang (tested with v0.5.15) or vLLM (tested with v0.19.0)

kvcached can be installed as a plugin with existing SGLang or vLLM environment.

Install from PyPI

pip install kvcached --no-build-isolation

Install from source

# under the project root folder

pip install -e . --no-build-isolation --no-cache-dir
python tools/dev_copy_pth.py

Using Docker

kvcached installed with original engine dockers.

docker pull ghcr.io/ovg-project/kvcached-sglang:latest   # kvcached-v0.1.5-sglang-v0.5.10
docker pull ghcr.io/ovg-project/kvcached-vllm:latest     # kvcached-v0.1.5-vllm-v0.19.0

We prepare an all-in-one docker for developers:

docker pull ghcr.io/ovg-project/kvcached-dev:latest

More instructions can be found here. GB200 dockers are on the way.

Documentation

kvcached is indexed on DeepWiki for LLM-powered documentation.

The documentation covers:

  • Core architecture and memory management system
  • Integration with vLLM and SGLang
  • Multi-model serving and controller system
  • Deployment guides and configuration reference
  • Performance benchmarking and analysis
  • Development tools and testing

Testing

kvcached can be enabled by setting the following environmental variables:

export ENABLE_KVCACHED=true
export KVCACHED_AUTOPATCH=1

If you are using the engine-specific dockers, you can test kvcached by running the original engines' benchmark scripts. For example:

# for sglang
python -m sglang.launch_server --model meta-llama/Llama-3.2-1B-Instruct --port 30000
python -m sglang.bench_serving --backend sglang-oai --model meta-llama/Llama-3.2-1B-Instruct --dataset-name sharegpt --request-rate 10 --num-prompts 1000 --port 30000

# for vllm
vllm serve meta-llama/Llama-3.2-1B-Instruct --port=12346
vllm bench serve --model meta-llama/Llama-3.2-1B-Instruct --request-rate 10 --num-prompts 1000 --port 12346

[!NOTE] If you prefer to disable prefix caching, use --no-enable-prefix-caching for vLLM and --disable-radix-cache for SGLang.

When kvcached is enabled, there is NO need to set memory utilization limit (e.g., using --gpu-memory-utilization) as kvcached will automatically manage the memory.

[!NOTE] AMD / ROCm: on ROCm (HIP) builds, kvcached automatically defaults to the non-contiguous KV-cache layout. The contiguous layout (the default on NVIDIA) hands vLLM's ROCm attention backend strided per-layer KV tensors it cannot read correctly, whereas non-contiguous matches the layout the backend expects. You can override with KVCACHED_CONTIGUOUS_LAYOUT=true|false, but contiguous is not recommended on ROCm.

If you installed kvcached using its source code, you can also do the following:

cd benchmarks/simple_bench
./start_server.sh [sglang|vllm] --venv-path $VENV_PATH --model meta-llama/Llama-3.2-1B-Instruct
# Wait until LLM server is ready
./start_client.sh [sglang|vllm] --venv-path $VENV_PATH --model meta-llama/Llama-3.2-1B-Instruct

The benchmark scripts automatically set ENABLE_KVCACHED=true. Please refer to each script for instructions on how to run inference with kvcached.

[!NOTE] We haven’t fully tested kvcached with every version of SGLang and vLLM (there are too many!). If you run into issues with a specific version, please open an issue---we'll look into it and fix it within a few hours.

Contributing

We are grateful for and open to contributions and collaborations of any kind.

We use pre-commit to ensure a consistent coding style. You can set it up by

pip install pre-commit
pre-commit install

Before pushing your code, please run the following check and make sure your code passes all checks.

pre-commit run --all-files

Contacts

kvcached is developed by many contributors from the community. The best way to contact us for questions, issues, and contributions, is through our Slack channel or GitHub Issues.

Trusted and deployed by

Google    LinkedIn    Intel    AMD    Red Hat    Adobe    Sony    ByteDance    Alibaba Cloud    Tencent    Moreh    Parasail

Citation

If you find kvcached useful, please cite our paper:

@article{xing2025towards,
  title={Towards Efficient and Practical GPU Multitasking in the Era of LLM},
  author={Xing, Jiarong and Qiao, Yifan and Mo, Simon and Cui, Xingqi and Sela, Gur-Eyal and Zhou, Yang and Gonzalez, Joseph and Stoica, Ion},
  journal={arXiv preprint arXiv:2508.08448},
  year={2025}
}

@article{yu2026prism,
  title={Prism: Cost-Efficient Multi-LLM Serving via GPU Memory Ballooning},
  author={Yu, Shan and Qiao, Yifan and Ma, Mingyuan and Li, Yangmin and Yang, Shuo and Tong, Xinyuan and Wang, Yang and Xie, Zhiqiang and An, Yuwei and Cao, Shiyi and Bao, Ke and Vij, Deepak and Ding, Xiaoning and Wang, Yichen and Lu, Qingda and Wang, Zhong and Gao, Gao and Xu, Harry and Shu, Junyi and Xing, Jiarong and Sheng, Ying},
  journal={OSDI},
  year={2026}
}

Frequently asked questions

Is kvcached free to use?

kvcached is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does kvcached do?

Virtualized Elastic KV Cache for Dynamic GPU Sharing and Beyond

What is kvcached written in?

kvcached is primarily written in Python. Its source is publicly available at https://github.com/ovg-project/kvcached, and it has 1,506 GitHub stars.