Papers
Topics
Authors
Recent
Search
2000 character limit reached

PackKV: Efficient KV Cache Compression Framework

Updated 6 January 2026
  • PackKV is a GPU-resident framework that employs token-aware lossy quantization and bit-packing to reduce Key–Value cache memory in transformer LLMs.
  • It integrates a five-stage pipeline—buffering, quantization, encode-aware repacking, bit-packing, and seamless appending—to optimize cache access and throughput.
  • Experimental results show up to 18.7× reduction in GPU memory usage and 2.7× throughput gains, maintaining accuracy within defined tolerances.

PackKV is a high-throughput Key–Value (KV) cache compression and management framework specifically designed to alleviate the memory bottlenecks in transformer-based LLMs during long-context inference. By integrating LLM-aware lossy quantization, token-aware bit-packing, and a fused decompression-compute pipeline, PackKV achieves order-of-magnitude reductions in GPU memory requirements and substantial end-to-end throughput gains, without compromising model accuracy under user-defined tolerances (Jiang et al., 30 Dec 2025).

1. Motivation and Background

In standard transformer-based LLMs such as LLaMA and GPT, autoregressive decoding requires maintenance of a KV cache at every layer. For a context of length TT, batch size BB, number of attention heads HH, and head dimension DD, the per-model cache shape is [B,T,H,D][B, T, H, D] for each of the K and V arrays. As TT and BB scale, especially with modern 8B–30B parameter models and extended context windows (e.g., T=32KT=32\text{K}), the KV cache easily exceeds 100 GB in FP16, substantially exceeding model parameter memory. This explodes DRAM utilization, limiting both achievable context lengths and batch sizes. Furthermore, during decoding, the cache is predominantly read through memory-bound matrix–vector multiplications (e.g., 93.7% of GPU time at 100K context), making KV cache access the critical system bottleneck. Existing quantization and pruning solutions yield at best moderate compression and do not eliminate corresponding bandwidth or decompression costs, thus motivating the design objectives of PackKV (Jiang et al., 30 Dec 2025).

2. Framework Architecture

PackKV implements a five-stage, GPU-resident pipeline that interfaces transparently between the model’s KV cache generation and attention computation. The key architectural stages are as follows:

  1. Buffering & Blocking: Incoming K and V vectors are buffered in memory until a fixed block size NN (e.g., $64$ tokens) is reached, forming tiles of shape BB0 (K) and BB1 (V) for efficient coalesced access.
  2. Token-wise Quantization: Each vector within the block is quantized using a relative scale, BB2 for a chosen BB3, with reconstructed value BB4 and error BB5.
  3. Encode-aware Repacking: Vector packs of size BB6 are greedily or median-sorted grouped such that the per-pack bit range (maxBB7min) is minimized, thus reducing the bitwidth needed for representation.
  4. Bit-packing Encoding: Each pack is stored as a header BB8 where BB9 for range HH0, followed by the payload which stores the HH1 quantized values offset by HH2 and concatenated using HH3-bit encoding.
  5. Seamless Appending: Each compressed block is tagged with indices, supporting direct expansion as context grows, without format transformation or multiple kernel invocations.

At inference, a single CUDA kernel fuses both decompression and GEMV: each thread loads packed data, unpacks, reconstructs into half-precision, and directly computes the dot product with the query vector HH4 in registers, thus eliminating repeated global memory IO (Jiang et al., 30 Dec 2025).

3. Lossy Compression and Quantization

PackKV’s sole lossy operation is token-wise quantization, ensuring all remaining transformations are lossless relative to this quantized representation. For each token and channel, the quantization uses a scale set per block: HH5

HH6

with reconstruction error tightly bounded by HH7. By empirical tuning (e.g., rel_quant_scale of 0.10 for HH8 and 0.20 for HH9), PackKV matches or surpasses the quantization error profile of state-of-the-art 2–4 bit schemes (e.g., KIVI) at far lower bitwidths (Jiang et al., 30 Dec 2025).

Encode-aware repacking groups vectors to minimize intra-pack value range, and thus necessary bitwidth per pack, using either a greedy centroid-based O(DD0) method or a V-Median O(DD1) strategy (sorting by the V vector’s trailing DD2 dimensions), yielding 4.5–19.7% further compression beyond quantization and bit-packing alone.

Bit-packing encodes each pack into DD3 bits payload with compact headers, optimally fitting into cache-aligned 32 or 64 bit chunks when DD4. This capitalizes on highly peaked quantized K and V histograms, with the typical DD5 (Jiang et al., 30 Dec 2025).

4. Computational Efficiency and Throughput

PackKV fuses decompression and compute into a single CUDA kernel. For example, given a K-cache block, the core loop iterates over pack indices, unpacks bitfields into half2 registers, reconstructs floating-point values, and immediately accumulates the dot-product with the query—all in registers/shared memory. Compared to standard decompress–then–GEMV approaches, this reduces DRAM traffic by DD6–DD7 and eliminates any global memory write-back of decompressed values.

Time complexity is DD8 per output, identical to standard GEMV. Memory requirements drop from DD9 to [B,T,H,D][B, T, H, D]0 where [B,T,H,D][B, T, H, D]1 (compression ratio) is [B,T,H,D][B, T, H, D]2 (K) and [B,T,H,D][B, T, H, D]3 (V) on average. Temporary GPU memory is only [B,T,H,D][B, T, H, D]4 for block processing.

On NVIDIA A100 GPUs (LLaMA3.1-8B, Mistral-8B @ 128K context), PackKV achieves [B,T,H,D][B, T, H, D]5 (K) and [B,T,H,D][B, T, H, D]6 (V) the GB/s throughput of cuBLAS, with end-to-end decode acceleration of [B,T,H,D][B, T, H, D]7 (K) and [B,T,H,D][B, T, H, D]8 (V) over baseline (Jiang et al., 30 Dec 2025).

5. Experimental Results

PackKV was evaluated on LLaMA2-7B/13B, LLaMA3.1-8B, DeepSeek-R1-Llama-8B, Mistral-8B-2410, and Phi-4 using benchmarks such as CoQA, GSM8K, MMLU, Winogrande, GPQA_D, and SQuAD_C with context lengths up to [B,T,H,D][B, T, H, D]9K and batch sizes up to TT0. Main quantitative findings:

Baseline K Cache Compression Ratio V Cache Compression Ratio
2-bit KIVI 5.91× 6.00×
PackKV (token+bitpack) 15.30× (+153.2%) 18.67× (+179.6%)

PackKV maintained TT1 accuracy drop relative to full FP16 inference, outperforming KIVI at equivalent accuracy thresholds. Greedy repacking improves K by TT2, V by an additional TT3, while V-Median achieves TT4 improvement at linear time.

Multi-GPU scaling was demonstrated up to 4 A100s with near-perfect weak scaling (throughput drop TT5). Peak GPU DRAM bandwidth decreases proportional to the achieved compression ratio, enabling increased batch sizes and longer contexts.

6. Practical Integration and Open Source Considerations

PackKV implements block-independent, indexable buffer formatting, and all compression and decompression logic is embedded in CUDA custom kernels using shared memory and half2 vector instructions. Pack alignment (8–16 entries per pack) avoids bank conflicts. The buffer is amenable to efficient streaming generation implementations (e.g., in PyTorch custom ops). Bandwidth and memory efficiency are further improved via the elimination of superfluous kernel launches and the strictly append-only nature of the compressed cache format (Jiang et al., 30 Dec 2025).

Full codebase, scripts, and integration examples are released at https://github.com/BoJiang03/PackKV. The open-source release supports immediate integration into generic transformer inference pipelines.

PackKV differs fundamentally from prevailing KV compression techniques. Unlike standard quantization (KIVI, 2–4 bit per channel) which is typically channel-wise for TT6 and token-wise for TT7, PackKV employs token-wise quantization and LLM-aware repacking for both. Unlike structured composite retention approaches (e.g., KVCompose (Akulov et al., 5 Sep 2025)) or online subspace compression (e.g., OjaKV (Zhu et al., 25 Sep 2025)), PackKV’s approach is fully orthogonal and can, in principle, be combined with those strategies for further memory–bandwidth reductions. Furthermore, unlike methods requiring expensive offline pre-processing, PackKV injects negligible latency and eliminates all global decompression overhead.

The empirical results demonstrate that, at comparable or lower error budgets, PackKV delivers over TT8 the memory reduction of leading quantization baselines, and TT9 to BB0 improvements in end-to-end decoding throughput, representing a significant advance in the practical deployment of long context LLMs on memory-limited commodity GPUs (Jiang et al., 30 Dec 2025).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to PackKV.