kvcached

ovg-projectApache-2.0活跃维护

为 LLM 推理提供虚拟化弹性 KV Cache,让多个推理任务动态共享 GPU 显存,减少显存碎片和浪费,提升 GPU 利用率。

Virtualized Elastic KV Cache for Dynamic GPU Sharing and Beyond

v0.1.6发布于 2026-10-03 19:47 UTC2,038star +5 / 7 天239fork同步于 2026-11-10 17:47 UTC

怎么上手

由 README 提炼,执行前请确认
pip install kvcached --no-build-isolation
硬件要求按 README 说明

README 未给出具体显存容量要求;支持 NVIDIA GPU,v0.1.6 起支持 AMD GPU(ROCm),ROCm 下自动改用非连续 KV 布局。

支持 ROCm / AMD有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

给 LLM 推理引擎加上 OS 式虚拟内存,让多模型弹性共享 GPU 显存

为 LLM 推理提供虚拟化弹性 KV Cache,让多个推理任务动态共享 GPU 显存,减少显存碎片和浪费,提升 GPU 利用率。

核心能力

  • 按需分配与回收 KV 缓存,随实时负载弹性伸缩
  • 解耦 GPU 虚拟地址与物理显存,运行时再映射
  • 用 CLI 或 revisioned API 强制内存上限
  • 内置前端路由与空闲模型 sleep 模式
  • 支持 vLLM 与 SGLang 的自动前缀缓存

容易踩的坑

需 PyTorch >= 2.10 且引擎版本受限(SGLang ≥ v0.5.11、vLLM ≥ v0.17.0),版本不匹配易出问题;启用后不要再设 --gpu-memory-utilization,内存由 kvcached 自行管理;需设置 ENABLE_KVCACHED=true 与 KVCACHED_AUTOPATCH=1 才会生效

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.1.6
  1. v0.1.6最新正式版2026-10-03 · 2026-10-03 19:47 UTC

    v0.1.6 Release

    Special thanks to @shipiyouniao and @rishabhsinha17, the core contributors of this release.

    vLLM support up to v0.30

    • Up to 0.25: #394; 0.26+: #493, #500; 0.27+: #492
    • 0.28 V2 model runner (attention-only): #494, #523; 0.29 Model Runner V2: #491, #515, #512, #517, #518, #464, #521; 0.30: #535

    SGLang support up to v0.5.20

    • 0.5.11-0.5.15: #353, #459, #468, #411, #444
    • 0.5.16+: #513, #514, #516, #525, #520
    • KV pool ownership under TP: #415; one shm segment per KV pool: #528; FP8 KV: #388

    New models

    • Hybrid linear attention (Qwen3.5, Qwen3.8): vLLM #310, #397, #522; SGLang #314, #318
    • Gemma 3/4: #396, #445, #472

    Features

    • AMD GPU support (ROCm/HIP) (#354)
    • Instance memory limits (#414) and observability snapshots (#385, #474)
    • Configurable vLLM sleep mode in the controller (#486, #484, #479)

    Performance and build

    • Page allocator in C++ (#319), KVCacheBlock reuse (#300), fewer device memory queries (#456)
    • PyTorch stable ABI (#497, #505); PyTorch >= 2.10 and Python >= 3.10 are now required

    Stability

    • TP/PP mapping failures are propagated (#373), page map/unmap is transactional (#418), and a data race on page counters is fixed (#443)
    • An exhausted KV pool is a scheduling miss instead of a crash (#301, #453, #511)
    • Correct KV capacity when engines start next to each other on one GPU (#448, fixes #193)
    • kvctl limit back to the startup value grows the pool again (#499)
    • shm segments and sockets are cleaned up on shutdown (#482, #480)
    • Editable installs no longer leave kvcached silently disabled (#481)
    • The prefix cache cap is enforced and evicts by page, so its memory is actually released (#390, #527)
    • The vLLM prefix cache cap counts every KV cache group (#534)
  2. v0.1.52026-04-07 · 2026-04-07 17:25 UTC
    查看更新说明

    v0.1.5 Release

    Features

    • Support Prefix Caching (APC) in vLLM (#274, #275, #283)
    • Support APC in SGLang with Mem Bound (#282)
    • Support Pipeline Parallelism (#246)
    • Support MLA model in vLLM (#261)
    • Support GPT-OSS in vLLM (#259)
    • Support GPT-OSS in SGLang v0.5.9 (#268)
    • Support vLLM v0.19.0
    • Support SGLang v0.5.10

    Bug Fixes

    • Fix RadixCache Patch version issue in SGLang (#296)
    • Fix bug when enable APC with GPT-OSS (#292)
    • Fix async scheduler support on MP backend (#288)
    • Fix reshape KV cache tensors in vLLM patches (#285)
    • Fix ENOENT on the socket path when tp=1 (#276)

    Maintenance

    • Update default cached tokens (#290)
    • Refactor: merge alloc_mla_kv_cache into alloc_kv_cache for SGLang interfaces (#278)
    • Update scripts to adapt to new vLLM versions (#270)

    Documentation

    • Update README for recent changes (#293)
    • Add Sardeenz demo link (#287)
  3. v0.1.42026-03-05 · 2026-03-05 05:57 UTC
    查看更新说明

    v0.1.4 Release

    Bug Fixes

    • Fix chat template warmup issue (#253)

    Features

    • Support SGLang v0.5.9
    • Support vLLM v0.16.0 (#243)
    • Support Python 3.13 (#260)
    • Support MLA models with multi-page-size (#240)
    • Support ElasticMLAMemoryPool (#238)
    • Support SGLang page-size>1 (#237)
    • Support GPT-OSS in SGLang-v0.5.6 (#249)

    Maintenance

    • Delete redundant functions in SGLang patches (#239)
    • Update the launch script (#255)
    • Update ignorance of vscode settings (#244)

    Documentation

    • Add Updates section in README (#251)
    • Update launch script
  4. v0.1.32026-01-10 · 2026-01-10 23:39 UTC
    查看更新说明

    v0.1.3 Release

    Bug Fixes

    • Fix unique IPC socket when TP is enabled (#219)
    • Support flashinfer kvcache shape for vLLM (#216)
    • Fix exceptions in vLLM prefix-cache-related APIs (#212)
    • Export missing autopatch env (#196)
    • More precise vLLM version detection (#194)
    • Fix memory tracker IPC name collision (#192)
    • Fix type casting in get_avail_physical_pages (#190)
    • Fix vLLM version range (#182)
    • Fix SGLang clear() function support (#150)
    • Fix langchain AgentExecutor import (#209)
    • Fix type casting issue (#204)

    Features

    • Add example for hybrid attention models (#218)

    Documentation

    • Add deepwiki to README (#220)
    • Update README with kvcached caching note (#188)
    • Add action video and blog link (#178)

    Maintenance

    • kvcached description update (#180)
    • Example READMEs venv path fix (#179)
  5. v0.1.22025-10-19 · 2025-10-19 08:14 UTC
    查看更新说明
    • Fix KV cache allocation bugs
    • Enhance examples
    • Add GSMK8 benchmark
    • Update docs and dockers

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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.

    • 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: enforce memory limits with the kvcached CLI or the revisioned production-control API.
    • 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-10] kvcached v0.1.6 supports vLLM v0.30 (including Model Runner V2) and SGLang v0.5.20, hybrid linear-attention models (Qwen3.5, Qwen3.8), Gemma 4, and AMD GPUs (ROCm).

    • [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

    EngineVersionsAttention typesExample models
    SGLang≥ v0.5.11 (tested up to v0.5.20)MHA / GQA / MLA / sliding window / hybridDeepSeek-V3, Qwen3-8B, GPT-OSS-20B, Qwen3.5-9B, Qwen3.8-27B, Gemma-4-E2B-it
    vLLM≥ v0.17.0 (tested up to v0.30.0)MHA / GQA / MLA / sliding window / hybridDeepSeek-V3, Qwen3-8B, GPT-OSS-20B, Qwen3.5-9B, Qwen3.8-27B, Gemma-4-E2B-it, Gemma-4-12B-it

    The minimum versions follow from the PyTorch requirement below. See #425 for per-model results on each engine and KV layout.

    Example use cases

    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.

    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.

    Installation

    Prerequisites

    • Python (tested with 3.10 - 3.13)
    • PyTorch >= 2.10 (kvcached builds against the PyTorch stable ABI)
    • SGLang (tested with v0.5.20) or vLLM (tested with v0.30.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
    

    Using Docker

    kvcached installed with original engine dockers.

    docker pull ghcr.io/ovg-project/kvcached-sglang:latest   # kvcached-v0.1.6-sglang-v0.5.20
    docker pull ghcr.io/ovg-project/kvcached-vllm:latest     # kvcached-v0.1.6-vllm-v0.30.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.

    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

    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}
    }