File size: 5,419 Bytes
6ec9472 af754d0 6ec9472 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ---
license: other
license_name: paper-reserved-code-apache-2.0
license_link: https://huggingface.co/datasets/mkvn/quantization-cache-amplification/blob/main/LICENSE-NOTE.md
pretty_name: Trillion-Parameter Mixture-of-Experts Inference on a Commodity Laptop
tags:
- mixture-of-experts
- quantization
- llm-inference
- systems
- moe-routing
- expert-offloading
language:
- en
size_categories:
- n<1K
---
# Quantization as Cache Amplification
**Trillion-Parameter Mixture-of-Experts Inference on a Commodity Laptop**
Kavin Kumar, Neural Metrics
π **[Read the paper](paper/main.pdf)** β 11 pages
---
## What this is
Weight quantization is usually justified as footprint reduction. This work argues
that for *offloaded* mixture-of-experts inference that framing misses the leverage.
The binding resource is not storage capacity but the fraction of expert slots
resident in DRAM β and storage traffic depends on that fraction through a cache
hit rate that is both concave and, for recency-based policies, **discontinuous**.
The central measured result: a least-recently-used expert cache hits **exactly
zero** whenever its capacity falls below the `kΒ·L` expert slots a single token
touches. A token routes to `k` experts in each of `L` layers and revisits none of
them until the next token β a cyclic reference string, the classical worst case
for LRU. On real OLMoE-1B-7B traces (`k=8`, `L=16`, so 128 slots) we measure 0.0%
hit rate at 2%, 5% and 10% capacity, jumping to 25.3% the moment capacity reaches
128. Quantization is what carries a system across that threshold.
Everything here was measured on one laptop: NVIDIA RTX A500 (4 GB VRAM), 32 GB
DRAM, consumer NVMe, Windows 11.
## Headline numbers
| Result | Value |
|---|---|
| LRU hit rate below per-token working set | **0.0%** (measured, all capacities tested) |
| LRU hit rate at working set (128 slots) | 25.3% |
| Popularity-pinned hit rate at 10% capacity | 22.9% (vs 0.0% for LRU) |
| Codec @ 2.01 bits, WikiText-2 PPL | **12.17** (bf16 reference: 8.11) |
| Frequency-conditioned allocation @ 1.51 bits | 22.02 vs 25.54 uniform β **13.8% better at identical rate** |
| NVMe random read @ expert-block granularity | 6.01 GB/s (β₯ sequential) |
| GPU device bandwidth | 88.2 GB/s |
### Ablations (all at 1.51 bits, WikiText-2 PPL)
| Configuration | PPL |
|---|---|
| RVQ + RHT + LDLQ (full codec) | 25.54 |
| β without block-LDL error feedback | 7,701.98 |
| β without incoherence processing | 352.10 |
| RTN uniform @ 2.25 bits (scalar baseline) | 22,793.90 |
Both codec components are load-bearing, and error feedback matters more than
rotation.
## Contents
| Path | Contents |
|---|---|
| `paper/` | Paper PDF + full LaTeX source and figures |
| `code/codec.py` | Sub-2-bit codec: randomized Hadamard transform, residual VQ, block-LDL error feedback |
| `code/quant_model.py` | Layer-sequential quantization + perplexity for OLMoE-1B-7B |
| `code/trace_routing.py` | Captures per-token expert routing traces |
| `code/cache_policy.py` | LRU / popularity-pinned / hybrid cache simulation |
| `code/bench_io.py` | Page-cache-bypassing NVMe, PCIe and DRAM benchmarks |
| `code/project_1t.py` | 1T reference configuration and throughput roofline |
| `results/routing_trace.npy` | **Raw routing traces**: `int16[16, 49152, 8]` β the top-8 expert indices selected at every layer for 49,152 held-out tokens |
| `results/*.json` | Every measurement artefact behind the paper's numbers |
### Using the routing traces
```python
import numpy as np
T = np.load("results/routing_trace.npy") # [layers=16, tokens=49152, topk=8]
# distinct expert slots touched by one token:
print(T.shape[0] * T.shape[2]) # 128 -> the LRU threshold
```
Every number in the paper is generated programmatically from `results/` via
`code/gen_numbers.py` and `code/gen_tables.py`; nothing is transcribed by hand.
## Scope β please read
**No trillion-parameter model was executed.** No 1T checkpoint was downloaded,
quantized, or run. The 1T figures (196 GB at 1.5 bits, 1.81β3.08 tokens/s) are an
*analytical projection* composing measured host parameters with a cache model
validated against real 7B-scale routing traces. They are not benchmark results
and should not be cited as such. The paper's Limitations section states this, and
identifies the weakest assumption: that the Zipf exponent of expert popularity
(measured `s = 0.65` at 64 experts/layer) is scale-invariant up to 320
experts/layer. A full sensitivity curve across the entire hit-rate range is
included precisely because that assumption cannot be foreclosed.
The paper also reports a negative result that constrains any system in this class:
sustaining the storage stream while materializing fp16 weights would require
~116 GB/s of device bandwidth against 88.2 GB/s measured, so dequantization must
be fused into the GEMM rather than staged through VRAM. No fused kernel was
implemented here.
Quality cost is stated plainly rather than buried: sub-2-bit operation on a
1.3B-active-parameter MoE is expensive (8.11 β 22.02 PPL at 1.51 bits), which is
why the systems analysis is parameterized by rate rather than asserting a single
favourable operating point.
## Model used
[`allenai/OLMoE-1B-7B-0924`](https://huggingface.co/allenai/OLMoE-1B-7B-0924) β
6.9B total / 1.3B active, 16 layers, 64 experts/layer, top-8. Evaluation on
WikiText-2.
|