More GPUs or a Smaller Cache? Tensor Parallelism versus KV Compression for Memory-Bound LLM Serving
Organizations: MIT and Vizuara
Abstract
When an LLM serving deployment runs out of KVcache room, there are two well-established ways out. Tensor parallelism shards the weights and the KV cache across two, four, or eight devices, buying memory headroom at the price of an all-reduce on every layer and a hardware bill that grows with the device count. The algorithms community shrinks the cache in place, with KV quantisation and eviction keeping a single GPU and spending a little quality instead. Compression papers report memory ratios, parallel-scaling papers report throughput curves, and almost nobody puts the two on the same cost axis. We place tensor-parallel configurations (degree 1 to 8) and KV-compressed configurations (16/8/4-bit, keep-ratios down to 0.25) on one costnormalised axis, cost per million tokens against latency, using a profiled simulator calibrated on A100, A40, and H100 hardware, and we go looking for the cost-equivalence crossover. We do not find one. Across two models (Llama-2 at 7B and 70B), three GPU types, and every level of memory relief we could construct, compression is cheaper by 1.20x to 2.00x. A 7B model on an 80 GB device cannot exhaust its KV budget within its own context window, and the boundary that decides between the strategies is model size relative to device memory, at roughly 36B parameters for an 80 GB card. Below that wall, compression dominates and extra GPUs are largely wasted spend; above it, tensor parallelism stops being a choice and becomes an entry ticket: Llama-2-70B is infeasible on one A100 at any KV setting, because the binding resource is weights, which KV compression does not touch. Tensor parallelism is the only lever that improves latency (compression makes per-token latency worse, by 8 to 93%, through batching contention), while compression is the only lever that multiplies capacity per dollar (16.5x, against 1.21x for an eightfold spend on GPUs).
Figures & tables
| Regime | Intended source | Realised here |
|---|---|---|
| Short chat | ShareGPT | W1 (synthetic, 2048+256, unsaturated) |
| Long-context | LongBench / RULER | not reachable (profiling caps at 4k) |
| Large batch | ShareGPT batched | W2 (synthetic, 3840+256, 30 QPS) |
| Long + batched | RULER batched | W2 on Llama-2-70B (hardest bound) |
| Setting | Value |
|---|---|
| Models | Llama-2-7B (primary); Llama-2-70B (above threshold) |
| GPUs | A100-80GB, A40-48GB, H100 |
| Prices (assumed) | 1.00, $3.50 per GPU-hour |
| TP degree | 1, 2, 4, 8 (memory , measured all-reduce, cost ) |
| KV compression | bit-width 16/8/4 keep-ratio 1.0/0.5/0.25 |
| Workloads | W1: 2048+256, 64 req; W2: 3840+256, 384 req, 30 QPS |
| Config | TTFT 99 | TPOT 50 | Thr. | $/h | $/Mtok |
| (s) | (ms) | (tok/s) | |||
| fp16 TP1 | 234.9 | 72.79 | 204.5 | 2 | 2.717 |
| fp16 TP2 | 133.9 | 48.85 | 356.7 | 4 | 3.115 |
| fp16 TP4 | 83.7 | 32.15 | 569.9 | 8 | 3.899 |
| fp16 TP8 | 52.4 | 21.58 | 909.2 | 16 | 4.888 |
| INT8 TP1 | 223.3 | 78.83 | 214.4 | 2 | 2.591 |
| Model | Wt. TP1 | fp16 | fp16 | INT4+k25 | INT4+k25 |
|---|---|---|---|---|---|
| (GB) | TP1 | TP4 | TP1 | TP4 | |
| Llama-2-7b | 12.1 | 29 | 137 | 479 | 2207 |
| Llama-3-8B | 13.0 | 118 | 550 | 1888 | 8800 |
| internlm-20b | 35.4 | 7 | 53 | 124 | 862 |
| CodeLlama-34b | 61.9 | 13 | 301 | 216 | 4824 |
| Llama-2-70b | 127.5 | 0 | 128 | 0 | 2054 |
| Config | Thr. | KV mem | $/h | $/Mtok |
| (tok/s) | (%) | |||
| fp16 TP1 | INFEASIBLE: 127.5 GB weights | |||
| fp16 TP2 | 53.3 | 99.1 | 4 | 20.846 |
| fp16 TP4 | 123.8 | 25.8 | 8 | 17.950 |
| fp16 TP8 | 184.5 | 9.2 | 16 | 24.089 |
| INT8 TP2 | 68.3 | 97.8 | 4 | 16.268 |
| Regime | Choose | Because |
|---|---|---|
| Weights exceed device memory ( 36B at fp16, 80 GB) | TP at ; compression cannot substitute | KV compression does not shrink weights (Table IV ) |
| runs memory-saturated | Step up one degree | throughput for price; cost falls 41% (W1) and 14% (W2), Sec. V-C |
| Weights fit; KV is binding | Compress first | capacity per dollar vs (Fig. 6 ) |
| Weights fit; KV not binding | Neither; compression is inert | Coincident points, Fig. 3 |
| Latency target unmet | TP, and pay for it | TTFT P99 cut; compression moves TPOT the wrong way ( to ) |
| Quality floor forbids compression | TP | Only remaining source of headroom |
LLM Serving
Large language model serving studies how to deliver model responses with low latency, high throughput, and efficient use of compute and memory.
See all 207 papers