Dataset Viewer
Auto-converted to Parquet Duplicate
Search is not available for this dataset
pdf
pdf

KV-cache and weight compression measurements (RTX 3090, llama.cpp)

How much compression can be added on top of the KV-cache formats and weight formats that llama.cpp already has? We measured it on one RTX 3090 (24 GB) with Qwen3-4B and Qwen3.5-2B. It is a measurement study with mostly negative results and proposes no new method.

Paper: paper.pdf (v3.0, 2026-10-23). All measurement records R1-R87 with methods and caveats: RESULTS.md. Code, llama.cpp patches, scripts, figures and result summaries: https://github.com/NeoXider/llm-compression-measurements

Cite / archive: https://doi.org/10.5281/zenodo.23578725 (Zenodo, v3.0.1)

The short version

  • Lossless coding only works for 16-bit data. BF16 weights with a fixed-rate exponent code are 24% smaller, give bit-identical logits and decode 1.03-1.05x as fast as BF16. Nothing lossless fits Q8_0/Q4_0 blocks on the GPU: every fixed-rate code we built is larger than its base. Variable-rate coders save 7-21% on the CPU only.
  • F16 KV: a lossless type (15.25 bits per value) saves under 5% of KV bytes and decodes slowly (0.14-0.85x), and its overflow pool fills after about 8K tokens of real text, so its long-context rows are not lossless. A lossy 12-bit type (4 mantissa bits dropped) has Q8_0-level quality (KL 0.0028), is 20% smaller at a filled 120K context and decodes 1.15x as fast as F16.
  • Q8_0 and Q4_0 KV: a GQA-grouped decode kernel reaches 1.11x (Q8_0) and 1.16x (Q4_0) of F16 decode speed at 120K on Qwen3-4B, where the stock kernels give 0.64x and 0.60x (measured before upstream PR #30202). Process VRAM drops from 20.3 GB to 12.5 and 8.1 GB. On Qwen3.5-2B, with KV in only 6 of 24 layers, the same kernel is slower than the stock one.
  • Q4_0 KV quality: the loss comes from the Q4_0 format itself (KL 0.068 with llama.cpp's rotation), not from the computation path. Keeping 2 of every 128 values exact halves the KL (0.033) for 11% more bytes.
  • Weights, lossy: mixed-precision recipes are the practical option. BF16 with the FFN in Q8_0 is 23% smaller and 1.15-1.19x faster; Q8_0 with the FFN in Q6_K is 11% smaller; Q4_K_M with embedding and output in Q4_K is 10% smaller.
  • Lazily mapped KV buffer: process VRAM follows the filled tokens (20.1 GB eager against 3.0 GB at 702 tokens of a 120K context). A known technique, reproduced in llama.cpp.
  • Combined (compressed weights and KV together, Qwen3.5-2B): 25% less memory with KL 0.001, but decode is 1.09x / 0.99x / 0.82x at 4K / 32K / 120K.

Figures

All figures are in the GitHub repository under figures/. Grey is the base format, green ours lossless, orange ours lossy.

fig27_dashboard

The whole study on one page: VRAM, speed, KV size on each base, KL, weight recipes, lossless weights.

fig60_bf16_weights_real

BF16 weights on real inference: size and decode speed of the lossless and lossy weight types against BF16 (Qwen3.5-2B).

fig84_combo_qwen3_4b_kv

Qwen3-4B: decode, prefill and process VRAM at 120K for each KV type and decode kernel.

fig82_combo_vram_120k

Process VRAM at a filled 120K context for the compressed-weights and KV combinations.

fig80_combo_decode_ad

Decode speed of the combinations relative to the uncompressed base at 4K / 32K / 120K.

fig83_combo_quality_kl

KL of the combinations against the uncompressed base (context 4096, prefill path).

fig31_quality_scoreboard

Tasks passed on the frozen 39-case suite and needle-in-a-haystack results.

Caveats

  • One consumer GPU and two models.
  • Every speed window was shared with desktop applications (4-28% GPU use) and is marked dirty in the data.
  • KL is measured on prefill at 4K context only; long-context quality rests on needle retrieval.
  • The task suite has 39 cases, too few to separate the variants.
  • Rows for server GPUs are analytic projections, not measurements.

Code is MIT, the paper text and figures are CC BY 4.0. Author: NeoXider.

Downloads last month
38