Manuscript Offprint

arXiv:2610.18140

SparPR: Runtime KV-Cache Recovery for Resource-Constrained LLM Inference on Consumer Hardware

Jieyun Deng, Keming Hu, Yanghe Liu, Li Feng

Abstract

Running large language models (LLMs) on consumer hardware is bottlenecked by the key-value (KV) cache, which grows with every decoded token and quickly exhausts the memory and bandwidth of a single consumer GPU. We present SparPR (Sparse Partial Recomputation), a runtime KV-cache recovery mechanism that does not modify model weights and requires no offline training. SparPR couples three online decisions: Query-Aware key-block selection scores historical blocks against the current query; dynamic budget control estimates per-block copy and recompute costs to decide how many blocks to retain; and on-demand local recomputation with cost-aware fallback merges retained blocks into continuous spans and switches between sparse recomputation and full recovery according to a runtime cost comparison. Implemented on FlexGen/FlexLLMGen, SparPR is evaluated on a single consumer laptop (RTX 3070 Ti 8 GB, Ryzen 9 6900HX, 16 GB RAM). It cuts end-to-end latency by 31%, 52%, and 63% at 1k, 2k, and 4k prompt tokens respectively, with 1.4×−2.7×1.4 \times -2.7 \times higher throughput, and completes an 8k-token workload in 44 minutes where the FlexGen baseline times out. Under a fixed cache budget, SparPR retains a Needle Accuracy that stays well above StreamingLLM and H2O at every keep ratio, and ablation studies confirm that the three mechanisms act jointly.

1 Introduction

Deploying large language models (LLMs) on consumer hardware (laptops and single-GPU machines) is increasingly common for offline, privacy-sensitive, and cost-sensitive workloads. The dominant cost is the key-value (KV) cache, which grows linearly with the number of tokens processed and quickly turns limited GPU memory and host-device bandwidth into first-order bottlenecks [1, 2, 3]. On datacenter GPUs these costs can be absorbed by large memory and high bandwidth; on a consumer laptop they translate into lower throughput, higher latency, and out-of-memory (OOM) failures long before the model's nominal context window is reached [4].

Existing work addresses parts of this problem. Layered-execution and offloading methods [2] place weights, activations, and caches across GPU, CPU, and disk to improve runnability. Cache-retention methods [4, 5, 7, 8, 9] select a subset of the historical cache to keep. Local-recovery methods [6] recompute or reload only part of the cache to avoid restoring everything. These lines of work answer whether the system can run, which information to keep, and how to recover it,

*Corresponding author. E-mail: fengli_xjtu@163.com respectively, but they do not form a unified runtime loop that couples query relevance, budget control, and recovery-path selection.

In this paper we ask three questions that arise once a model no longer fits its KV cache in GPU memory: (i) which historical blocks are most relevant to the current query and therefore worth keeping; (ii) how many blocks should be retained given the context length, bandwidth, and compute cost; and (iii) whether the retained blocks should be restored by local recomputation or by full recovery. To answer them, we propose SparPR (Sparse Partial Recomputation), a runtime optimization method for KV-cache recovery on consumer hardware.

Our contributions are as follows.

  • A Query-Aware key-block selection mechanism that scores historical blocks by their relevance to the current query and performs Top-k selection, converting uniform cache access into relevance-driven access.

  • A dynamic budget control mechanism that estimates per-block copy and recompute costs and adaptively derives the target keep ratio and block count, with a conservative lower bound (Minimum Keep Floor).

  • An on-demand local recomputation with cost-aware fallback mechanism that merges discrete key blocks into continuous spans and selects between sparse and dense recovery paths by a runtime cost comparison (Dense Fallback Threshold).

  • A full prototype on FlexGen/FlexLLMGen, evaluated on a single consumer laptop, that cuts latency by 31%–63% at 1k–4k tokens and completes an 8k-token workload where the FlexGen baseline times out.

References (11)

  • OPT: Open Pre-trained Transformer Language Models
  • High-Throughput Generative Inference of Large Language Models with a Single GPU. ICML, 2023
  • Fast and Memory-Efficient Exact Attention with IO-Awareness
  • ICLR, 2024
  • Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models
  • Query-Aware Sparsity for Efficient Long-Context LLM Inference
  • Efficient Generative LLM Inference with Recallable Key-Value Eviction
  • User-Query-Driven Selective Recomputation for Efficient KV Cache Reuse in Retrieval-Augmented Generation
  • Chang, W. Bao, et al. ShadowKV: KV Cache in Shadows for High-Throughput Long-Context LLM Inference
  • To Restore or To Recompute, That Is the Question
  • Adaptive KV Management on a Single Commodity GPU (LeoAM) (opens arXiv in a new tab)