# kvmem
**Repository Path**: robotdna/kvmem
## Basic Information
- **Project Name**: kvmem
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-11-20
- **Last Updated**: 2026-11-20
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
**English** | [简体中文](README.zh-CN.md)
# KVMem
**Long-context conversations and AI agents on limited GPU memory.**
## News
- **2026-11-14 · AMD Radeon RX 9060 XT / 9070 / 9070 XT · Windows**\
The Radiance pre-release includes a 256K context preset for 16 GB GPUs, with DFlash2 and text and image input. A same-day package update added monitoring for GPU utilization, VRAM, temperature, and power. Choose `gfx1200` for the **RX 9060 XT** or `gfx1201` for the **RX 9070 / 9070 XT**. [v0.19.rad1 downloads and notes](https://github.com/kvmem/kvmem/releases/tag/v0.19.rad1)
- **2026-10-31 · NVIDIA GeForce RTX 20 / 30 / 40 / 50 and Tesla V100 · Windows**\
The stable dual-backend release gives NInfer and PolyStrata a shared console and chat interface and adds automatic VRAM budget estimation. NInfer supports layer splitting for multi-GPU DFlash2. Choose the package for your GPU. PolyStrata support on the V100 is experimental. [v0.19.1 downloads and notes](https://github.com/kvmem/kvmem/releases/tag/v0.19.1)
[All releases](https://github.com/kvmem/kvmem/releases) · [Quick start](#quick-start)
## Supported models by backend
These are the main model families supported with **KVMem history management enabled**. Choose the backend and model format together.
| Backend | Models | Model format |
|---|---|---|
| **[NInfer](docs/multi-backend-differences.md)** | **Qwen3.5 Dense** (0.8B / 2B / 4B / 9B / 27B), **Qwen3.6 / Qwen3.8 27B**, and compatible fine-tunes, including **Ternary Bonsai 2 27B** | `.ninfer` — use a compatible artifact or convert the weights first |
| **[llama.cpp](docs/multi-backend.md)** | **Qwen3.5 Dense**, **Qwen3.6 / Qwen3.8 27B**, **Ternary Bonsai 2 27B**, and other compatible full-attention GGUF models | `.gguf` |
| **[PolyStrata](docs/polystrata-integration.md)** | **Qwen3.6-35B-A3B**, **Ornith 1.5**, **Tiel Coder / Cyber-Tiel 35B-A3B**, compatible `qwen35moe` models, and **Gemma 4 26B-A4B** | `.gguf`; image input also needs a matching `mmproj` |
NInfer's KVMem integration currently covers **Dense** models; PolyStrata's covers the **`qwen35moe` MoE** architecture. Other models supported by those upstream engines are outside this KVMem scope. llama.cpp's KVMem adapter skips sliding-window-attention (SWA) and purely recurrent models.
Architecture support does not mean every size, quantization or feature combination has been tested. See the [Qwen3.5 Dense family coverage](docs/qwen35-dense-family.md), [Bonsai integration](docs/bonsai-integration.md) and [PolyStrata integration](docs/polystrata-integration.md). Availability, vision and MTP support depend on the model components and the [release package](https://github.com/kvmem/kvmem/releases).
## Supported GPUs by backend
The table covers the main GPU families for **KVMem**, with package and source-build differences noted below.
| Backend | GPU families / example cards | Scope |
|---|---|---|
| **NInfer** | **NVIDIA RTX 20 / 30 / 40 / 50**, **TITAN RTX**, **Tesla V100** | CUDA only. V100 needs an `sm_70` / CUDA 12 build or a matching older package. A100-class `sm_80` is a source compatibility target without KVMem hardware qualification. |
| **llama.cpp** | **NVIDIA RTX 20 / 30 / 40 / 50** (CUDA); **AMD Radeon RX 6800 / 6900**, **RX 7700 XT / 7800 XT / 7900 XT / XTX**, **RX 9060 XT / 9070 / 9070 XT** (HIP/ROCm) | AMD availability depends on the SDK, OS and compiled GPU targets; see the [ROCm guide](docs/rocm.md). RX 9060 XT has recorded KVMem long-context tests. |
| **PolyStrata** | **NVIDIA RTX 20 / 30 / 40 / 50** | KVMem uses one CUDA GPU. The opt-in AMD HIP source integration is **experimental**, pending AMD inference qualification; see [integration status](docs/polystrata-integration.md). |
RTX examples include **2060 / 2080 Ti**, **3060 / 3090**, **4060 Ti / 4090**, and **5050 Laptop / 5060 Ti / 5090**. The series name alone does not guarantee enough VRAM for a chosen model and configuration.
Choose a [release package](https://github.com/kvmem/kvmem/releases) matching your GPU, OS and backend. The unified Windows packages cover RTX 20 / 30 / 40 / 50 with NInfer and PolyStrata; llama.cpp and AMD use separate packages or source builds. A compiled target is not a test of every card: check the package's instructions and validation report for driver requirements and actual hardware coverage.
## What KVMem does
KVMem keeps complete native KV history in system RAM, with optional SSD tiering. The GPU holds the history needed for the current request and space for generation. It supports **NInfer, llama.cpp, PolyStrata and Radiance** through a local Web UI and OpenAI-compatible APIs. See the [Radiance integration guide](docs/radiance-integration.md) for its AMD qualification and supported combinations.
- **Long context:** Retrieve relevant KV history to manage long conversations and tool histories within a fixed GPU budget.
- **Extra-long / xhigh reasoning:** Reuse GPU generation space to sustain long reasoning and answers on limited VRAM, including the `xhigh` reasoning setting.
- **State reuse:** Reuse prefixes and checkpoints across conversations and tool continuations according to each backend's rules.
- **Memory tiering:** Manage KV history across RAM and SSD, loading selected history onto the GPU as needed.
## Demo: xhigh reasoning on a 16 GB GPU
**RTX 5060 Ti 16 GB · 27B IQ3 model · real local runs.** The pelican cycling animations below are original HTML outputs from the release video, generated with `medium` and `xhigh` reasoning settings.
| `medium` | `xhigh` |
|:---:|:---:|
|  |  |
KVMem makes room as generation proceeds, so **Gen reserve is reusable workspace, not the cumulative output limit**. Context, request limits and model stop conditions still apply. These are individual examples; see the [demo notes](docs/demos/pelican-reasoning.md) for provenance and scope.
## Downloads
**[Stable release](https://github.com/kvmem/kvmem/releases/latest)** · **[All releases, including previews and older versions](https://github.com/kvmem/kvmem/releases)**
Choose a package for your operating system, GPU and backend on the release page. Each release contains its downloads, checksums, driver requirements, model support and qualification notes. Supply model weights separately. Releases marked **Pre-release** are for testing.
## Quick start
1. Download and fully extract a package. **Use English paths for the package and models; the full paths must not contain Chinese characters.**
2. For a Windows console package, double-click `START-HERE-EN.bat`, then select the backend, model and GPU. Use `START-HERE-CN.bat` for Chinese.
3. Start the service. Once ready, open Chat from the console or connect your client to the API address shown there.
NInfer typically uses `.ninfer` models; llama.cpp uses GGUF. Model, quantization and vision support depend on the backend and release. For older packages without a one-click entry, follow the included instructions.
See [Windows one-click startup](docs/windows-one-click.md), the [Linux launcher](docs/linux-launcher.md) and the [console guide](docs/unified-console.md).
## API and configuration
The service provides OpenAI-compatible `/v1/chat/completions` and `/v1/responses` endpoints with streaming. Tool and multimodal support vary by backend. The API base is `http://127.0.0.1:/v1`; query `/v1/models` for the loaded model ID.
Configure context limits, GPU history budgets, generation reserve and RAM quotas through the console or launch options. Long contexts still need sufficient system RAM; model weights and inference workspaces also use GPU memory. See the [runtime guide](docs/multi-backend.md) and [backend differences](docs/multi-backend-differences.md) for parameters, defaults and supported combinations.
## Build from source
```sh
git clone --recurse-submodules https://github.com/kvmem/kvmem.git
cd kvmem
python scripts/prepare-backends.py
python scripts/prepare-backends.py --check
```
Engines use pinned submodules and integration patches. GitHub-generated source ZIPs omit submodule contents. See [source preparation and builds](docs/multi-backend-repository.md) for requirements and commands, and the [ROCm guide](docs/rocm.md) for AMD. Mainline source and published packages may have different capabilities.
## Documentation
| Topic | Guides |
|---|---|
| Startup, settings and support | [Runtime guide](docs/multi-backend.md) · [Backend differences](docs/multi-backend-differences.md) |
| KV retrieval and memory | [Graph recall](docs/graph-recall.md) · [RAM / SSD tiering](docs/active-kv-tiering.md) |
| Design and backend integration | [Architecture](docs/architecture.md) · [Memory backend contract](docs/memory-backend-contract.md) |
| Radiance on AMD | [Windows and Linux integration guide](docs/radiance-integration.md) · [Benchmark comparisons](docs/radiance/PERFORMANCE-COMPARISON.md) · [Radiance 1.17 execution and transfer measurements](docs/radiance-execution-overhead-20261107.md) |
| Builds and releases | [Development workflow](docs/multi-backend-repository.md) · [Backend versions and licenses](backends/versions.json) |
| Tests and performance | [Validation records](docs/multi-backend-validation.md) · [Performance report](docs/recommended-config-performance.md) · [Benchmark data](docs/benchmarks/) |
Reports retain their original versions, hardware and settings; their results do not apply to every package or device. Browse [docs/](docs/) for more topics.
## Community and feedback
**QQ group: 1040777853** · [GitHub Issues](https://github.com/kvmem/kvmem/issues)
Include the version, GPU, driver, model, launch settings and error logs when reporting an issue. Remove private conversation content from logs.
## Credits and licenses
Thanks to [ggml-org/llama.cpp](https://github.com/ggml-org/llama.cpp), [Neroued/ninfer](https://github.com/Neroued/ninfer), [iamwavecut/ninfer-all](https://github.com/iamwavecut/ninfer-all) and community contributors, including Ryan-gsq and contributors to 3090/4090 adaptations, adaptive MTP, fast prefill and ngram. LRFU/GQA max references [melis2023/kvmem-actkv](https://github.com/melis2023/kvmem-actkv). Thanks to testers including melis and redsnow23.
Each backend retains its upstream license and third-party notices; see the [backend manifest](backends/versions.json) and package licenses. cuBLAS follows the CUDA EULA. Models are distributed separately under their own terms.
## Paper and citation
[KVMem: Virtualizing Million-Token Agent Workspaces on a Consumer GPU](https://arxiv.org/abs/2609.04852)
BibTeX
```bibtex
@misc{chai2026kvmem,
title = {{KVMem}: Virtualizing Million-Token Agent Workspaces on a Consumer {GPU}},
author = {Di Chai and Leye Wang and Zeshen Su and Zhiguo Xia and Zhihang Yu},
year = {2026},
eprint = {2609.04852},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2609.04852}
}
```