基础设施 4.0 · 优秀 2026-11-04 · 论文

KVGuard: A KV Cache Safety Checker for LLM Serving Systems

LLM 服务的 KV cache 内存安全:PagedAttention 式块分配器暴露出一类此前未研究的内存安全 bug(double-freeuse-after-free越界未初始化读权限违规),不崩溃却静默污染输出或破坏请求隔离;CUDA 层 sanitizer 因不理解块表模型而失效KVGuard 为每个物理 KV 块维护影子块,记录权限与初始化状态,在 vLLM/SGLang 工作流边界做五项检查在引入违规的边界报错原型覆盖两系统历史上全部 29 个真实 bug,另发现 8 个未知违规零误报;TPOT 开销 3.0%/7.4%,内存 0.11%

打开原文回到归档

KVGuard: A KV Cache Safety Checker for LLM Serving Systems

  • ID: caf54955
  • 来源: https://arxiv.org/abs/2611.06138
  • 作者: Jonguk Cheong, Myungbin Hwang, Eulgyu Kim, Byoungyoung Lee
  • 发表: 2026-11-04 - arXiv 2611.06138 - cs.CR
  • 证据: opencli arxiv paper 2611.06138 -f json 元数据与摘要(2026-11-09 抓取)

Abstract(原文)

Modern LLM serving systems manage the KV cache through PagedAttention, a custom GPU allocator that partitions a single CUDA-allocated region into fixed-size physical blocks and maps each request to those blocks through a CPU-built block table. This block-based design exposes a previously unstudied class of memory safety bugs in the KV cache, including double-free, use-after-free, out-of-bounds access, uninitialized read, and permission violation, which silently corrupt outputs or break request isolation without ever crashing the system. Existing memory sanitizers cannot detect them, because they reason about CUDA-level addresses rather than KV cache blocks, requests, and block tables, and their redzone- and quarantine-based designs do not fit the scarce GPU memory budget of LLM serving. This paper presents KVGuard, the first systematic memory-safety abstraction for KV cache management in LLM serving systems. KVGuard maintains a compact shadow block for each physical KV block, recording per-request permission and per-entry initialization, and uses this metadata to perform five safety checks across the PagedAttention workflow, spanning CPU allocation, block table construction and translation, and GPU-side block table lookup and KV entry access. Each check fires at the boundary that introduced the violation, enabling early detection during development rather than reporting downstream output corruption many requests later. A prototype of KVGuard on vLLM and SGLang covers all 29 historical real-world KV cache safety bugs collected from the two systems' patch histories. KVGuard further found 8 previously unknown safety violations while reporting no false positives. It adds 3.0% and 7.4% geomean TPOT overhead on Qwen 2.5 14B on vLLM and SGLang and at most 0.11% of the KV cache in memory overhead, two orders of magnitude below NVIDIA Compute Sanitizer on the same workloads.

中文要点

LLM 服务的 KV cache 内存安全:PagedAttention 式块分配器暴露出一类此前未研究的内存安全 bug(double-free、use-after-free、越界、未初始化读、权限违规),不崩溃却静默污染输出或破坏请求隔离;CUDA 层 sanitizer 因不理解块表模型而失效。KVGuard 为每个物理 KV 块维护影子块,记录权限与初始化状态,在 vLLM/SGLang 工作流边界做五项检查、在引入违规的边界报错。原型覆盖两系统历史上全部 29 个真实 bug,另发现 8 个未知违规、零误报;TPOT 开销 3.0%/7.4%,内存 ≤0.11%。

Field Notes

  • KV cache 块分配器是一类新的内存安全面,失败模式是静默污染而非崩溃
  • 影子元数据+边界检查:29 个历史 bug 全覆盖、8 个新发现,开销比 NVIDIA Compute Sanitizer 低两个数量级