Let the Gate Decide: Per-Lookup Precision for Quantized Conditional Memory in LLMs
Organizations: C2DL, Institute of Automation, Chinese Academy of Sciences · School of Artificial Intelligence, University of Chinese Academy of Sciences · Tencent
Abstract
Conditional memory layers, such as DeepSeek's Engram, attach large hashed n-gram tables to a language model, and removing them from DeepSeek-V4.1-Flash costs 36.8 PopQA points. Low-bit quantization loses long-tail facts first, and the standard remedy, giving more bits to frequently accessed rows, backfires: refining lookups by access frequency is worse than refining them at random. We trace this to the gate that scales each retrieved row. A lookup's quantization error is weighted by its gate, which is small for frequent n-grams, large for the rare n-grams of long-tail entities, and computable from a 1-bit code. GateRQ therefore stores each row as a ladder of 1-bit residual codes, keeps level 1 in GPU memory to compute the gate, and reads deeper levels only for the lookups the gate ranks highest. Without retraining, GateRQ cuts GPU table memory by 7.8x on DeepSeek-V4.1-Flash, which raises vLLM throughput by 11%-31% over FP8 tables, while losing about 1 PopQA point at 1.50 bits read per lookup and 0.2 points at 2.10 bits across two models.
Figures & tables
| Quantized | |||
|---|---|---|---|
| Bits | Gates | Values | Both |
| 1.06 | |||
| 2.13 | |||
| 3.19 | |||
| Method | Read | PopQA | TriviaQA | CMMLU | NQ-open | Avg. |
|---|---|---|---|---|---|---|
| DeepSeek-V4.1-Flash | ||||||
| FP8 | 8.25 | 52.39 | 82.78 | 89.48 | 32.71 | 64.34 |
| Uniform, level 1 | 1.06 | 48.52 | 82.92 | 88.83 | 32.96 | 63.31 |
| Uniform, levels 1–2 | 2.13 | 51.50 | 82.97 | 89.26 | 32.74 | 64.12 |
| Uniform, levels 1–3 | 3.19 | 52.24 | 82.87 | 89.52 | 33.13 | 64.44 |
| bits per lookup | ||||||
Appendix figures & tables21 assets
Supplementary material from the paper’s appendix.
Appendix
| DeepSeek-V4.1-Flash | Qwen3.8-Flash-Next | |
| Memory layers | Engram, blocks 2 and 15 | PLE, block 2 |
| Hash heads per layer | 24 (eight each of 2-, 3-, 4-grams) | 16 (eight each of 2-, 3-grams) |
| Row dimension | 256 | 160 |
| Rows, all layers | ||
| FP8 table | GB, bits per element | GB, bits per element |
| Share of the checkpoint | of GB | of GB |
| PopQA | TriviaQA | CMMLU | NQ-open | |
|---|---|---|---|---|
| DeepSeek-V4.1-Flash | ||||
| Qwen3.8-Flash-Next |
| DeepSeek-V4.1-Flash | Qwen3.8-Flash-Next | |||||||
|---|---|---|---|---|---|---|---|---|
| Quartile | Page views | Questions | FP8 | Level 1 | 95% interval | FP8 | Level 1 | 95% interval |
| Rarest | 2–235 | 3,559 | 42.23 | 29.53 | ||||
| Second | 235–975 | 3,572 | 44.15 | 26.85 | ||||
| Third | 975–5,784 | 3,569 | 51.67 | 36.34 | ||||
| Most popular | 3,567 | 71.49 | 65.49 | |||||
| Block | Order | Value rank | Key rank | Key top-10 energy (%) | |
|---|---|---|---|---|---|
| 2 | 2 | 2.87 | 244 | 1.56 | 99.7 |
| 3 | 1.48 | 243 | 1.24 | 99.7 | |
| 4 | 1.25 | 242 | 1.24 | 99.9 | |
| 15 | 2 | 3.60 | 252 | 2.35 | 98.5 |
| 3 | 1.85 | 241 | 1.36 | 98.2 | |
| 4 | 1.26 | 230 | 1.25 | 97.8 |
| DeepSeek, block 2 | DeepSeek, block 15 | Qwen | ||||
|---|---|---|---|---|---|---|
| Text | Correlation | Ratio | Correlation | Ratio | Correlation | Overlap (%) |
| English | 0.9998 | 1.025 | 0.9893 | 1.017 | 0.9896 | 95.9 |
| Chinese | 0.9996 | 1.026 | 0.9899 | 1.029 | 0.9925 | 95.9 |
| Code | 0.9998 | 1.022 | 0.9901 | 1.049 | 0.9947 | 98.0 |
| Top | Top | Top | |
|---|---|---|---|
| Block 2 | 98.1 | 98.8 | 99.3 |
| Block 15 | 92.8 | 94.6 | 96.2 |
| Bits | Gates only | Values only | Both | Predicted (values) |
|---|---|---|---|---|
| 1.06 | ||||
| 2.13 | ||||
| 3.19 |
| English, block 2 | English, block 15 | PopQA, block 2 | ||||
|---|---|---|---|---|---|---|
| Access count | Lookups | Importance | Lookups | Importance | Lookups | Importance |
| never seen | 4.2 | 15.0 | 4.2 | 19.5 | 14.2 | 22.7 |
| 1 | 3.1 | 9.3 | 3.2 | 12.1 | 9.1 | 12.3 |
| 2–10 | 11.6 | 25.1 | 11.5 | 29.5 | 13.7 | 22.9 |
| 11–100 | 23.0 | 30.0 | 23.0 | 26.6 | 15.9 | 24.3 |
| 101–1,000 | 26.1 | 16.1 | 26.1 | 10.4 | 15.2 | 13.9 |
| Text | Block | -gram | -gram | -gram |
|---|---|---|---|---|
| English | 2 | |||
| 15 | ||||
| Chinese | 2 | |||
| 15 | ||||
| Code | 2 | |||
| 15 |
| Text | Block | Top 1% | Top 5% | Top 10% | Top 20% | p90/p10 | |
|---|---|---|---|---|---|---|---|
| Held-out English | 2 | 11 | 32 | 48 | 69 | 0.92 | 2.1 (1.6–2.7) |
| 15 | 25 | 53 | 69 | 84 | 0.67 | 8.8 (4.6–15.3) | |
| RACE passages | 2 | 12 | 34 | 50 | 69 | 0.92 | 2.0 (1.7–2.4) |
| 15 | 12 | 32 | 47 | 66 | 0.71 | 4.3 (3.1–6.4) | |
| PopQA prompts | 2 | 10 | 30 | 45 | 65 | 0.98 | 1.2 (1.1–1.4) |
| 15 | 54 | 74 | 84 | 92 | 0.95 | 2.0 (1.5–2.8) |
| Bits per level | DeepSeek | Qwen | ||||||
|---|---|---|---|---|---|---|---|---|
| Code | DeepSeek | Qwen | Level 1 | Level 2 | Level 3 | Level 1 | Level 2 | Level 3 |
| TCQ | 1.0625 | 1.10 | 26.9 | 7.2 | 1.9 | 27.2 | 7.4 | 2.0 |
| PQ | 1.0625 | 1.10 | 32.2 | 10.6 | 3.7 | 32.1 | 10.4 | 3.5 |
| INT | 1.25 | 1.25 | 35.6 | 12.3 | 5.6 | 35.6 | 12.2 | 5.4 |
| DeepSeek | Qwen | |||
|---|---|---|---|---|
| Code | ||||
| TCQ | 5.4 | 20.1 | 5.6 | 20.4 |
| PQ | 4.9 | 15.4 | 5.1 | 16.0 |
| INT | 5.4 | 18.6 | 5.4 | 18.2 |
| Fractions | Bits per lookup | |||||
|---|---|---|---|---|---|---|
| Model | Setting | TCQ | PQ | INT | ||
| DeepSeek | bits | |||||
| bits | ||||||
| Qwen | bits | |||||
| bits | ||||||
| Tokens per forward pass | |||
| Table configuration | |||
| FP8 in GPU memory | 414 | 1,565 | 3,144 |
| FP8 in host memory | 498 | 1,918 | 3,854 |
| Uniform, level 1 | 104 | 207 | 350 |
| Uniform, levels 1–2 | 113 | 325 | 603 |
| Uniform, levels 1–3 | 150 | 461 | 884 |
| Benchmark | Questions | Score | Shots |
|---|---|---|---|
| PopQA [ 3 ] | a possible answer occurs in the first line of the reply | 15 | |
| TriviaQA [ 14 ] | exact match | 5 | |
| NQ-open [ 15 ] | exact match | 5 | |
| CMMLU [ 16 ] | accuracy of the answer letter, by log-likelihood | 5 |
| INT | PQ | |||||
| Method | Read | PopQA | Avg. | Read | PopQA | Avg. |
| DeepSeek-V4.1-Flash | ||||||
| FP8 | 8.25 | 52.39 | 64.34 | 8.25 | 52.39 | 64.34 |
| Uniform, level 1 | 1.25 | 46.79 | 62.35 | 1.06 | 46.81 | 62.17 |
| Uniform, levels 1–2 | 2.50 | 50.56 | 63.58 | 2.13 | 51.39 | 63.88 |
| Uniform, levels 1–3 | 3.75 | 51.85 | 64.12 | 3.19 | 51.87 | 64.36 |
| Setting | Bits | Prior | Random | Frequency | Uniform | Saved |
|---|---|---|---|---|---|---|
| DeepSeek TCQ | 1.50 | 0.63 | ||||
| DeepSeek TCQ | 2.10 | 1.09 | ||||
| DeepSeek INT | 1.50 | 0.74 | ||||
| DeepSeek INT | 2.10 | 1.28 | ||||
| DeepSeek PQ | 1.50 | 0.63 | ||||
| DeepSeek PQ | 2.10 | 1.09 |
| Task | Prior | Random | Frequency | All | Mean |
|---|---|---|---|---|---|
| PopQA | 12/0/0 | 12/0/0 | 12/0/0 | 36/0/0 | |
| TriviaQA | 5/7/0 | 8/4/0 | 7/4/1 | 20/15/1 | |
| CMMLU | 1/11/0 | 8/4/0 | 12/0/0 | 21/15/0 | |
| NQ-open | 0/12/0 | 0/12/0 | 1/11/0 | 1/35/0 |
| TCQ | INT | PQ | ||||
| Configuration | Predicted | Measured | Predicted | Measured | Predicted | Measured |
| DeepSeek-V4.1-Flash | ||||||
| Uniform, level 1 | ||||||
| Uniform, levels 1–2 | ||||||
| Uniform, levels 1–3 | ||||||
| 1.50 bits per lookup | ||||||
| Throughput | ||||
|---|---|---|---|---|
| Table configuration | GPU | Host | 64 requests | 128 requests |
| FP8 in GPU memory | 23.6 | 0 | 228.3 | 349.6 |
| FP8 host offloading | 0 | 188.7 | 253.3 | 460.1 |
| Uniform, level 1 | 3.04 | 0 | 256.0 | 464.5 |
| Uniform, levels 1–2 | 6.1 | 0 | 256.8 | 464.0 |
| Uniform, levels 1–3 | 9.1 | 0 | 256.4 | 465.0 |
Memory-Augmented Language Models
Memory-augmented language models combine persistent or temporary memory with neural computation to retain, retrieve, and use information beyond the active context.
See all 291 papers