Manuscript Offprint

arXiv:2610.35985

Let the Gate Decide: Per-Lookup Precision for Quantized Conditional Memory in LLMs

Tianqi Chen, Xunchao Li, Linchuan Xie, Guanghua Yu, Jianchen Zhu, Peisong Wang, Jian Cheng

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

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.8×7.8\times 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.

Keywords conditional memory · Engram · quantization · residual quantization · LLM inference

1 Introduction

Recent large language models (LLMs) place part of their parameters in conditional memory: hash tables, keyed by the preceding n-gram, that sit beside the Transformer backbone, as in DeepSeek's Engram [1] and Qwen's Per-Layer Embedding (PLE) [2]. Each token retrieves a fixed number of rows, and a gate computed from the current hidden state scales the retrieved vectors before they enter the residual stream. The tables thus add many parameters at little compute cost, and they hold much of the model's factual knowledge. Zeroing them in DeepSeek-V4.1-Flash costs 36.8 points on PopQA [3], a benchmark of questions about long-tail entities, more than two thirds of its accuracy; the answers stay well formed, but the facts are wrong. The tables are also large: 203 GB (189 GiB) in FP8, 40% of the checkpoint. On a node of 8 RTX PRO 6000 GPUs, keeping them in GPU memory takes 23.6 GiB on every GPU and leaves a KV cache nine times smaller (as reported by vLLM) than when they are offloaded; offloading them instead pins all 189 GiB in host memory.

Much of what these tables contribute is long-tail knowledge: facts about rare entities, such as the author of a little-known novel, that the backbone does not recover on its own. Quantization, the natural way to shrink the tables, erases exactly these facts first (Section 3), so a compression budget should not be spread evenly across rows. Recommender systems, whose embedding tables face the same pressure, have a standard rule for deciding which rows to keep precise: the frequently accessed ones, which receive larger dimensions [4] or higher precision [5, 6]. The rule rests on an assumption: every access contributes equally to the output, so frequent rows, read most often, accumulate the most quantization error.

This assumption does not hold for conditional memory. Each retrieved row passes through a gate before it enters the residual stream, so its quantization error is paid at every lookup, scaled by that lookup's gate (Section 3.1). The gates, moreover, run against frequency: frequent n-grams are mostly function words and common phrases, which receive small gates, whereas the rare n-grams of named entities receive large ones. In the question “Who is the author of The Pianoplayers?”, the gate is smallest at the token The and largest on the three tokens of Pianoplayers (Figure 1a). Over PopQA questions, rows seen more than a thousand times serve a third of the 2-gram lookups of block 2 but, under uniform quantization, carry under 4% of the output error (Figure 1b). A frequency rule therefore spends its bits where they matter least: choosing lookups to refine by frequency does worse than choosing them at random (Sections 3.2 and 5.2).

One might hope to repair the rule instead, ranking rows by their expected gate rather than by frequency. This helps, but it still misses many important lookups, for two reasons. The rows that matter most belong to rare n-grams, which a counting corpus sees too seldom to estimate their gate; and even for common rows, the gate changes with context and can be large in one sentence and near zero in another (Section 3.2). Precision should therefore be decided per lookup, from the gate at hand. This seems to require the very precision one wants to save, since the gate is computed from the retrieved rows. It does not: the gate is insensitive to quantization, and gates computed from a 1-bit code closely match those computed from the FP8 table ( r≥0.989r \geq 0.989; Section 3.2). Whether a lookup needs higher precision can thus be decided before any high-precision data is read.

GateRQ (gate-driven residual quantization; Figure 2) combines two pieces. The first is a code whose precision can be raised after a row has been read: each row is stored as a ladder of 1-bit residual codes, with level 1 in GPU memory and deeper levels in host memory. The second is a rule that decides, per lookup, how far up the ladder to go: every lookup reads level 1 to obtain its key and gate, and under a fixed budget of bits per lookup, the lookups that the gate marks as most important fetch deeper levels, which refine only the value. Precision thus becomes a property of each access rather than of the stored row.

Our contributions are as follows:

• Analysis. We show three properties of quantization error in gated conditional memory: the gate error is negligible, so the gate can be computed accurately from a 1-bit code; importance runs against access frequency, so frequency-based allocation fails; and importance is concentrated in a few lookups whose identity depends on context, so row-level statistics cannot find them (Section 3).

• Method. We propose GateRQ, a post-training scheme that stores each row as a ladder of 1-bit residual codes and uses the gate computed from the first level to choose how many levels each lookup reads. It needs no retraining, keeps the model's gating mechanism intact, and applies to any codec that can encode residuals (Section 4).

• Evaluation. We evaluate on two models, three codecs (trellis-coded quantization, TCQ; integer, INT; product quantization, PQ), and two read budgets (12 settings). At the same number of bits read per lookup, gate-based selection beats selection by expected gate, at random, and by access frequency in all 36 paired PopQA comparisons. With TCQ [7, 8], reading 1.50 and 2.10 bits per lookup costs about 1 and 0.2 PopQA points relative to FP8 and is statistically indistinguishable from reading the full two- and three-level ladders, which take 0.63–1.20 more bits per lookup (Section 5.2).

• System. In vLLM [9] on 8 RTX PRO 6000 GPUs, GateRQ cuts the table memory from 23.6 to 3.0 GiB per GPU, which enlarges the KV cache 8.1×8.1 \times (as reported by vLLM) and raises throughput by 11%–31% over FP8 tables in GPU memory. Against FP8 host offloading, it matches throughput (within 1.5%) with 26–49 GiB of pinned host memory instead of 189 GiB (Appendix H).

References (24)