█

AI/TLDR

Buy me a coffee
Buy me a coffee

kvcached

Elastic, virtual-memory KV cache that lets several LLMs share one GPU

Serving & DeploymentOpen source
Language
Python
License
Apache-2.0
$pip install kvcached --no-build-isolation
IN SHORT

What is kvcached?

kvcached (short for KV cache daemon) is an open-source KV cache library for LLM serving and training on shared GPUs. It sits in the Serving & Deployment category of the Models & Inference tools and is open-source, written in Python and licensed Apache-2.0. To get started: install the package.

Overview

kvcached (short for KV cache daemon) is an open-source KV cache library for LLM serving and training on shared GPUs. It brings an operating-system-style virtual memory abstraction to the key-value cache that serving engines keep for every in-flight request, so that cache memory is allocated elastically as load rises and handed back when it falls, instead of being reserved up front.

Diagram comparing three GPUs each statically reserved for one model with a single GPU where kvcached lets three models share memory
Without kvcached each model statically reserves its own GPU; with it, several models share one GPU's memory elastically.kvcached README ↗

The trick is decoupling GPU virtual addresses from physical memory. A serving engine running with kvcached first reserves only virtual address space for its KV cache and backs it with physical GPU memory when the cache is actually used. Engines no longer need to claim a fixed slice of the card at startup with a flag like --gpu-memory-utilization, which is what normally forces one model per GPU.

It installs as a plugin into existing SGLang and vLLM environments, and the project documents support for MHA, GQA, MLA, sliding-window and hybrid attention models on both engines. Around the allocator it adds a memory-control CLI, a frontend router with a sleep mode for idle models, and prefix caching with a configurable memory bound. The project is Apache-2.0 licensed and comes out of research on GPU multitasking for LLMs, described in the papers the README cites.

What it does

  • Elastic KV cache: allocates and reclaims KV memory dynamically to match live load instead of reserving it statically at startup
  • GPU virtual memory: maps logical KV cache to physical GPU memory at runtime, so memory is only committed when a cache is in use
  • Plugs into unmodified SGLang and vLLM via environment variables, with prebuilt Docker images for each engine
  • kvctl memory-control shell and the kvtop live view to list, watch and cap each engine's KV memory (absolute or as a percentage of GPU RAM)
  • Frontend router that directs requests to the target model and puts idle models to sleep
  • Prefix caching support — automatic prefix caching on vLLM and RadixCache on SGLang — with a configurable memory bound

Getting started

kvcached installs into an existing SGLang or vLLM environment (the README lists Python 3.9–3.13). Install it, switch it on with two environment variables, and launch the engine as you normally would.

Install the package

Install from PyPI into the same environment as your serving engine. Alternatively, pull one of the project's engine images: ghcr.io/ovg-project/kvcached-sglang or ghcr.io/ovg-project/kvcached-vllm.

bashbash
pip install kvcached --no-build-isolation

Enable kvcached

Set these variables before starting the engine. With kvcached enabled there is no need to pass a memory-utilization limit — it manages KV memory itself.

bashbash
export ENABLE_KVCACHED=true
export KVCACHED_AUTOPATCH=1

Launch your engine as usual

Start SGLang or vLLM normally; running several servers side by side on one GPU is where the elastic cache pays off.

bashbash
# SGLang
python -m sglang.launch_server --model meta-llama/Llama-3.2-1B-Instruct --port 30000

# vLLM
vllm serve meta-llama/Llama-3.2-1B-Instruct --port=12346

Watch and cap memory with kvctl

The kvctl shell ships with the package. Inside it, list shows each engine's KV usage, limit or limit-percent caps it, and kvtop opens a live usage view.

bashbash
kvctl
# kvcached> list
# kvcached> limit-percent <ipc> 40
# kvcached> kvtop

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Serve several LLMs on one GPU so they share memory elastically instead of each claiming a fixed partition
Bar chart of mean time to first token at 12 to 20 requests per second, with and without kvcached, on a log scale
The project's multi-LLM benchmark (three Llama-3.1-8B models on one A100-80G): mean time to first token with and without kvcached.kvcached README ↗
  • Run serverless-style deployments where models spin up and down on demand and only hold KV memory while active
  • Fit a compound AI pipeline of specialised models (retrieval, reasoning, summarisation) onto limited hardware
  • Co-locate LLM inference with training, fine-tuning or vision workloads on the same GPU

How kvcached compares

kvcached alongside other open-source serving & deployment tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Transformers★ 169kHugging Face Transformers is a Python framework that defines and runs state-of-the-art pretrained models for text, vision, audio, and multimodal tasks, for both inference and training.
vLLM★ 97.9kA high-throughput LLM serving engine that uses PagedAttention and continuous batching to serve many requests at once.
SGLang★ 39.2kA serving framework for LLMs and multimodal models that boosts throughput by reusing shared prompt prefixes across requests.
Modular Platform★ 30.2kModular's AI platform: the MAX inference framework with an OpenAI-compatible serving endpoint and GPU kernel library, plus the Mojo language and compiler.
DeepInfer★ 26.5kDeepSeek's own large-scale inference framework for its models, with expert parallelism, confidence-scheduled speculative decoding and NVIDIA plus Ascend support.
TensorRT-LLM★ 15.2kNVIDIA's library that compiles LLMs into optimized engines for the fastest inference on its data-center GPUs.
OpenVINO★ 13.3kAn open-source toolkit from Intel that converts and optimizes deep learning models, then runs fast inference on CPU, GPU, and NPU hardware.
kvcached★ 2.1kElastic, virtual-memory KV cache that lets several LLMs share one GPU