AlignPred: Error-Controlled KV Cache Compression via Alignment and Predictive Coding
Organizations: Hunan University · Central China Normal University · Tencent
Abstract
Long-running agents retain KV caches across turns and sessions for hours or days. Compressing these persistent caches requires reducing storage while controlling reconstruction error. We present AlignPred, a codec that combines local alignment with predictive coding under a configurable KV reconstruction-error budget. Local orthogonal transforms align related heads or layers into a common coordinate frame, allowing AlignPred to combine token-wise prediction with same-token prediction across heads or layers. Residuals are quantized on an error-bounded lattice and entropy-coded, without learned predictors, encoder-side mode search, or large joint transforms. Across three attention mechanisms, AlignPred requires less storage than the evaluated baselines at comparable measured reconstruction error. Against the evaluated CPU codec implementations, it decodes at least 1.6 times faster while matching or improving encode time. AlignPred achieves near-native task scores at substantially compressed operating points on LongBench-Pro at 128K context. AlignPred's SGLang HiCache integration reduces persistent target-KV storage by 42-72% relative to native HiCache, with comparable latency.
Figures & tables
| Baseline | Storage | Encode | Decode |
|---|---|---|---|
| KVCodec | 1.10–1.30 | 5.3–6.8 | 5.4–6.3 |
| KVTC-style | 1.13–1.18 | 1.3–1.6 | 3.3–3.7 |
| Rotation + SZ3 | 1.07–1.10 | 1.02–1.04 | 1.6–2.1 |
Appendix figures & tables27 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Compressed cache | Streams/object | Blocks/group | |
|---|---|---|---|---|
| Qwen3.5-9B | Full-attention K/V | 256 | 16 | 4 heads each |
| GLM-5.3-Flash | Post-LN latent | 512 | 3 | 4, 4, 3 layers |
| DeepSeek-V4-Flash | C4 CSA latent | 512 | 6 | layers |
| Item | Setting |
|---|---|
| Input caches | All methods cover the same cache positions and retain positional encoding where applicable, keeping their input representations consistent. |
| FP8 reference | E4M3FN, scale 1. FP16 inputs clamped to . |
| KVCodec | Adapted software-codec reference: unrotated token layout, lossless x265, veryfast preset, three B-frames with adaptive selection, and at most 256 positions per GOP. |
| KVTC-style | Adapted transform-coding reference: joint PCA, quantization, and Deflate. DeepSeek uses three-layer groups. Shared PCA parameters are excluded from bpv. |
| SZ3 auto | Official SZ3 auto on the same caches and frozen means as Ours. Rotation + SZ3 applies fitted rotations, and unrotated SZ3 auto does not. Figure 7 , Table 7 , Table 11 , and Table 12 . |
| Residual-only reference | Component-ablation control (Table 9 , first row): error-lattice quantization plus rANS, with alignment and prediction disabled. |
| Method | Primary setting | Role here |
|---|---|---|
| CacheGen | Remote KV streaming | Related persistent/remote KV system |
| KVTC | Persistent KV storage | Adapted transform-coding reference |
| KVCodec | Remote KV reuse | Adapted software-codec reference |
| LLM.265 | Video codec as tensor codec | Related codec-style KV compression |
| SZ3 auto | Error-bounded array compression | Generic error-controlled baseline |
| KIVI, TurboQuant | GPU-resident KV quantization | Task quality at different storage sizes |
| AlignPred | Full-width joint PCA | |
|---|---|---|
| Transform matrices | matrices, | One matrix, |
| Parameter storage | ||
| Transform work | ||
| Decomposition size | ||
| Decomposition work | per GPA iteration |
| Model | Ours | KVCodec | KVTC-style | Rotation + SZ3 |
|---|---|---|---|---|
| Qwen3.5-9B | 4.347 (2.67) | 5.642 (2.51) | 4.931 (2.58) | 4.775 (2.60) |
| GLM-5.3-Flash | 5.025 (2.66) | 6.035 (2.66) | 5.909 (3.07) | 5.395 (2.59) |
| DeepSeek-V4-Flash | 5.049 (2.66) | 5.547 (2.66) | 5.974 (3.03) | 5.404 (2.60) |
| Ours | KVCodec | KVTC-style | ||||||
|---|---|---|---|---|---|---|---|---|
| bpv | Error (%) | bpv | Error (%) | bpv | Error (%) | |||
| 4 | 2.398 | 10.61 | 8 | 2.224 | 21.05 | 3.5 | 2.632 | 16.52 |
| 3 | 2.787 | 7.98 | 6.452 | 2.499 | 17.13 | 4 | 3.186 | 9.58 |
| 2 | 3.352 | 5.33 | 6 | 2.593 | 15.96 | 4.5 | 3.610 | 5.91 |
| 1.5 | 3.761 | 4.00 | 4 | 3.137 | 10.69 | 6 | 4.931 | 2.58 |
| 1.25 | 4.024 | 3.33 | 3 | 3.536 | 8.04 | 7 | 5.760 | 2.13 |
| Ours | KVCodec | KVTC-style | ||||||
|---|---|---|---|---|---|---|---|---|
| bpv | Error (%) | bpv | Error (%) | bpv | Error (%) | |||
| 6 | 2.479 | 15.96 | 12 | 2.199 | 32.03 | 3.5 | 2.775 | 24.64 |
| 4 | 3.037 | 10.65 | 9.537 | 2.494 | 25.46 | 4 | 3.301 | 16.70 |
| 3 | 3.443 | 7.99 | 8 | 2.730 | 21.37 | 4.5 | 3.804 | 10.75 |
| 2 | 4.022 | 5.33 | 6 | 3.136 | 16.02 | 6 | 5.087 | 3.96 |
| 1.5 | 4.437 | 4.00 | 4 | 3.733 | 10.69 | 7 | 5.909 | 3.07 |
| Ours | KVCodec | KVTC-style | ||||||
|---|---|---|---|---|---|---|---|---|
| bpv | Error (%) | bpv | Error (%) | bpv | Error (%) | |||
| 8 | 2.128 | 21.00 | 8 | 2.412 | 20.96 | 3.5 | 2.864 | 27.21 |
| 6.366 | 2.429 | 16.81 | 6 | 2.794 | 15.76 | 4 | 3.413 | 18.67 |
| 6 | 2.509 | 15.86 | 4 | 3.361 | 10.53 | 4.5 | 3.886 | 11.24 |
| 4 | 3.065 | 10.62 | 3 | 3.783 | 7.92 | 6 | 5.111 | 4.22 |
| 3 | 3.468 | 7.97 | 2 | 4.406 | 5.29 | 7 | 5.974 | 3.03 |
| Qwen3.5-9B | GLM-5.3-Flash | DeepSeek-V4-Flash | ||||||
|---|---|---|---|---|---|---|---|---|
| bpv | Error (%) | bpv | Error (%) | bpv | Error (%) | |||
| 3 | 3.193 | 7.79 | 8 | 2.427 | 20.71 | 8 | 2.439 | 20.65 |
| 2 | 3.769 | 5.20 | 4 | 3.389 | 10.36 | 4 | 3.400 | 10.37 |
| 1.5 | 4.187 | 3.90 | 2 | 4.378 | 5.18 | 2 | 4.386 | 5.19 |
| 1.25 | 4.450 | 3.25 | 1 | 5.395 | 2.59 | 1 | 5.404 | 2.60 |
| 1 | 4.775 | 2.60 | 0.5 | 6.402 | 1.30 | 0.5 | 6.406 | 1.30 |
| Qwen3.5-9B | GLM-5.3-Flash | DeepSeek-V4-Flash | ||||||
|---|---|---|---|---|---|---|---|---|
| bpv | Error (%) | bpv | Error (%) | bpv | Error (%) | |||
| 3 | 3.481 | 7.80 | 8 | 2.668 | 20.72 | 8 | 2.544 | 20.47 |
| 2 | 4.058 | 5.20 | 4 | 3.632 | 10.36 | 4 | 3.511 | 10.30 |
| 1.5 | 4.477 | 3.90 | 2 | 4.628 | 5.18 | 2 | 4.504 | 5.17 |
| 1.25 | 4.742 | 3.25 | 1 | 5.650 | 2.59 | 1 | 5.524 | 2.59 |
| 1 | 5.069 | 2.60 | 0.5 | 6.649 | 1.30 | 0.5 | 6.535 | 1.30 |
| Model | Multiplier | Auxiliary | Specific | Specific total |
|---|---|---|---|---|
| Qwen3.5-9B | 1 | 4.347 | 4.132 | 4.216 |
| 4 | 2.398 | 2.210 | 2.294 | |
| 8 | 1.525 | 1.369 | 1.453 | |
| GLM-5.3-Flash | 1 | 5.025 | 4.901 | 5.071 |
| 4 | 3.037 | 2.920 | 3.090 | |
| 8 | 2.100 | 1.995 | 2.165 |
| 4.644 | 4.547 | 4.473 | 4.437 | 4.452 | |
| 4.599 | 4.497 | 4.419 | 4.381 | 4.397 | |
| 4.572 | 4.467 | 4.387 | 4.347 | 4.363 | |
| 4.570 | 4.464 | 4.383 | 4.342 | 4.358 | |
| 4.594 | 4.491 | 4.411 | 4.371 | 4.386 | |
| 4.644 | 2.665 | 1.740 | ||
| 4.347 | 2.398 | 1.525 | ||
| 4.342 | 2.399 | 1.533 | ||
| 4.386 | 2.451 | 1.595 |
| Model | Partition | Views | bpv |
|---|---|---|---|
| Qwen3.5-9B | 4 heads / layer | 4 | 4.347 |
| 2 adjacent layers | 8 | ||
| 4 adjacent layers | 16 | 4.360 | |
| 8 layers, K or V | 32 | 4.529 | |
| GLM-5.3-Flash | layers | 4 | 5.025 |
| layers | 6 | 5.031 |
| Model | Compressed path |
|---|---|
| Qwen | Four 64-token pages per object, separate K/V streams, and 32 objects per decode batch. Aligned host staging feeds layerwise GPU inverse transforms and FP16 page scatter. |
| GLM | Post-LN MLA latent, grouped 4/4/3 layers. Rank-0 decoding with 32-object batches, two host/GPU slots, GPU inverse transforms, and ordered BF16 broadcasts. |
| DeepSeek | Pre-FP8 C4 CSA values, grouped layers. Rank-0 decoding with eight-object batches, two host/GPU slots, inverse transforms, broadcasts, and native FP8 writeback. |
| Common | In-memory indices, object read-ahead, page mappings, and event-guarded buffer reuse. Raw tails and native sidecar paths are retained. |
| Item | Setting |
|---|---|
| Models | Qwen3.5-9B: FP16, TP1. GLM-5.3-Flash: BF16, TP8. DeepSeek-V4-Flash: BF16 compute, native mixed FP8 cache, TP8. |
| Matrix | Three models 32,768/65,536/131,072-token prefixes concurrent requests native HiCache/Ours . |
| Input/output | distinct InfiniteBench book documents per model, the first of one fixed prompt bank, identical across arms and lengths. Each prefix is followed by 64 appended IDs. Greedy generation of exactly 256 tokens, ignoring EOS. |
| Phases | Each arm writes its own L3 files online during the first requests’ chunked prefill. The writer drains and stops. A fresh reader then serves the same requests concurrently from L3. |
| Timing | TTFT: request submission to first token, averaged over the requests. Persistence completion: first submission to the L3 write of the batch’s last target-KV page. Reading, decoding, H2D, inverse transforms, communication, and native writeback are included. |
| Graph/warmup | Prefill graphs disabled. Full decode graphs for batch sizes – . Unrelated full-chunk and 64-token warmups. For , readers also run -request EXTEND batches ( ) over an unrelated cached prefix. Startup and warmup excluded. |
| Model | CPU wall (s) | TTFT (s) | Persist before TTFT |
|---|---|---|---|
| Qwen | 8.690 | 0.180 | 87.5% |
| GLM | 2.130 | 0.263 | 100.0% |
| DeepSeek | 2.803 | 0.044 | 100.0% |
| Model | Write TTFT (s) | Rehit TTFT (ms) | Stored KV (MiB) | |||
|---|---|---|---|---|---|---|
| Native | Ours | Native | Ours | Native | Ours | |
| Qwen | 9.105 | 9.286 | 843.3 | 469.5 | 2048.0 | 577.1 |
| GLM | 6.390 | 6.653 | 628.0 | 502.1 | 704.0 | 227.7 |
| DeepSeek | 7.176 | 7.221 | 316.4 | 302.0 | 192.0 | 110.8 |
| Model | Ctx | Write TTFT (ms) | Rehit TTFT (ms) | Stored KV (MiB) | |||
|---|---|---|---|---|---|---|---|
| Native | Ours | Native | Ours | Native | Ours | ||
| Qwen | 32K | 4082.0 | 4204.3 | 547.3 | 307.1 | 1024.0 | 287.6 |
| 64K | 9105.3 | 9285.6 | 843.3 | 469.5 | 2048.0 | 577.1 | |
| 128K | 22294.3 | 22491.2 | 1615.5 | 856.0 | 4096.0 | 1161.9 | |
| GLM | 32K | 3268.9 | 3356.3 | 479.7 | 391.9 | 352.0 | 114.0 |
| 64K | 6390.0 | 6653.2 | 628.0 | 502.1 | 704.0 | 227.7 | |
| Model | Ctx | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| N | O | N | O | N | O | N | O | ||
| Qwen | 32K | 547 | 307 | 658 | 413 | 928 | 621 | 1441 | 996 |
| 64K | 843 | 470 | 1123 | 680 | 1616 | 1045 | 2619 | 1747 | |
| 128K | 1615 | 856 | 2086 | 1251 | 3021 | 1963 | 6320 † | 6431 † | |
| GLM | 32K | 480 | 392 | 521 | 429 | 764 | 771 | 1270 | 1157 |
| 64K | 628 | 502 | 708 | 576 | 1140 | 1087 | 1741 | 1776 | |
| Model | Ours | KVCodec | KVTC-style | Rotation + SZ3 | |
|---|---|---|---|---|---|
| Qwen3.5-9B | Encode | 1266 | 7468 | 2079 | 1308 |
| Decode | 564 | 3321 | 1918 | 926 | |
| GLM-5.3-Flash | Encode | 676 | 3589 | 888 | 704 |
| Decode | 231 | 1239 | 759 | 493 | |
| DeepSeek-V4-Flash | Encode | 976 | 6675 | 1401 | 994 |
| Decode | 338 | 2126 | 1245 | 682 |
KV-Cache Compression
Key-value cache compression reduces the memory and bandwidth needed to retain attention states during long-context inference.
See all 257 papers