KV Cache Local Affine Quantization: How Shared Ranges Inflate Prediction Error

Study reveals 4-bit KV cache quantization collapse stems from key-channel fixed offsets perturbed by rounding; bias subtraction repairs it.
This study analyzes why 4-bit KV cache quantization performs so differently across models, using eight models. Core finding: group-wise affine quantization shares scale and zero-point across channels, and persistent key-channel offsets encroach on the group's dynamic range; fixed offsets that should cancel in exact softmax become position-dependent prediction error due to rounding. Rotated key projection bias explains nearly all first-layer offset, so subtracting it before quantization and adding it back repairs severe 4-bit degradation; StableLM also needs positional-trajectory tracking. Coordinate substitution shows shifted-coordinate outputs recover almost all 4-bit loss on Qwen2.5, while at 2 bits adjacent outputs matter. Practically, check and center key bias for 4-bit, and prioritize grouping strategy at 2 bits.
During LLM inference, the KV cache accounts for the bulk of memory usage, and low-bit quantization is a key means of compressing that cache. But a puzzling phenomenon persists: 4-bit KV cache quantization is nearly lossless on some models, yet on others it causes severe collapse in language model quality. Where does this huge disparity between models come from? A study spanning eight models offers a clue: persistent offsets in key channels encroach on the shared key quantization range, and quantization rounding then converts this fixed offset into position-dependent prediction error.

The 4-Bit Dilemma Under a Shared Quantization Range
In group-wise affine quantization, multiple channels share the same scale and zero-point. This is done to reduce metadata overhead, but it also means that the value distribution of an individual channel can "hijack" the usable dynamic range of the entire group. After measuring eight models, the study found that the quantization penalty on the value cache is generally small, whereas sensitivity on the key cache varies enormously. In other words, the root cause of collapse is not that values get crushed—it's that key quantization error gets amplified by the attention mechanism.
The paper's core observation is this: certain channels carry a persistent offset. In exact softmax attention, an offset that is constant across all positions is added to both the numerator and the denominator, so it cancels out in theory and does not change attention weights. But quantization rounding turns this "should-be-canceled" offset into a position-dependent error—rounding codes differ across positions, the offset can no longer cancel consistently, and relative logits end up being perturbed.
Group-wise affine quantization is a common scheme for low-bit KV cache compression: channels are partitioned into groups, each group shares a single scale and a single zero-point, and the integer values of channels within the group are reconstructed via x ≈ scale * (q - zero_point). Its advantage is that metadata overhead is amortized over group size—if the group size is 128, only 2 floating-point parameters need to be stored per 128 values. The cost is that the dynamic range within a group is jointly constrained: if one channel's value distribution deviates significantly from the others in the group, it either squeezes the quantization precision of the rest or gets clipped itself.
Offset cancellation in softmax attention refers to the following: attention weights are softmax(QK^T/√d). If a constant vector c is added to every dimension of the key vector, logits become Q(K+c)^T = QK^T + Qc^T. Since Qc^T is identical for all key positions, it appears in both the numerator and denominator of the softmax and cancels out, leaving attention weights unchanged. This property is the theoretical basis for "fixed offsets should be harmless," and it is also the starting point from which the paper argues that quantization rounding breaks this cancellation.
Why Fixed Offsets Become Dangerous After Rounding
To verify this mechanism, the researchers directly examined the numerical behavior of the native keys. They found that rare but critical rounding-code changes contribute a considerable share of the temporal error energy: that is, on most time steps the rounding error is small, but on a few time steps the rounding result jumps, and these jumps land precisely at positions that affect attention ordering, so the cost is significantly amplified.
This finding explains why the same quantization bit-width performs so differently across models. Models whose key channels show more pronounced offsets and more asymmetric distributions are more prone to severe degradation at 4 bits. Conversely, models with smaller offsets pass through 4-bit quantization relatively smoothly.
The "Contribution" of Rotated Key Projection Bias
In two architectures that contain bias, the rotated key projection bias accounts for nearly all of the offset component measured in first-layer key energy. This means the problem is not mysterious: the offset has a clear source—the projection bias term. That being the case, a direct fix follows—subtract the bias before quantization and add it back after dequantization.
Experiments show that this simple operation repairs severe 4-bit degradation. The case of StableLM goes further: removing the fixed mean alone is not enough; only by tracking its positional trajectory rather than subtracting just a constant can a better repair be achieved. This suggests that removing the fixed offset and reconstructing the positional component are two separable problems.
Rotary position embedding (RoPE) injects positional information by applying a position-dependent rotation matrix to query and key vectors. In architectures using RoPE, the key projection is typically written as k = W_k x + b_k, followed by rotation. If the bias b_k is nonzero, after rotation it becomes a vector that rotates with position, but its magnitude and directional structure still retain an identifiable fixed component. The paper's "rotated key projection bias" refers to the term RoPE(b_k).
Centering before quantization works as follows: before quantization, subtract an estimated constant vector (such as the rotated result of the bias or the channel mean) from the key vectors, so that channel distributions are centered at zero and the dynamic range narrows; after dequantization, add it back. This is equivalent to liberating the "group shared range" from a state where it is hijacked by the offset, allowing effective bits to be spent more on representing position-dependent variation. StableLM requires tracking a positional trajectory, indicating that its offset is not strictly constant but drifts slowly with position, so simply subtracting the mean leaves residual error.
Locating the Prediction Effect: Coordinate Substitution Experiments
The repair works, but at exactly which step is the prediction loss affected? The researchers designed an elaborate set of substitution experiments: first fit the full baseline and the centered grid, then substitute reconstructed outputs on shifted coordinates or their block neighbors, and observe the impact on predictions.
On Qwen2.5, outputs using only shifted coordinates are enough to recover almost all of the 4-bit performance loss. This indicates that in the 4-bit setting, the error mainly comes from the single pathway of fixed offsets being perturbed by rounding, while reconstruction of positional neighborhoods is relatively secondary. But at 2 bits, the situation changes: adjacent outputs become pivotal, and attribution results also depend on the chosen coordinates. A counterintuitive finding is that local reconstruction error and attention divergence can improve while prediction loss worsens—showing that these local metrics do not always represent final language modeling quality.
Coordinate substitution is a causal attribution method: first fit two sets of quantized reconstructions—the "full baseline" and the "centered grid"—then at inference time replace the output of a certain set of keys with the reconstruction from the other set and observe the change in prediction loss. If replacing a certain coordinate substantially recovers the loss, that coordinate carries the main error. Here, "shifted coordinates" refer to outputs under the centered coordinate system, and "block neighbors" refer to key positions adjacent to the target position.
Attention divergence is usually measured by KL divergence or total variation between the attention weight distributions before and after quantization. It is cheap to compute and interpretable, but it is not directly equivalent to language modeling loss: a slight rearrangement of attention weights may be absorbed by subsequent layers, or may happen to change the ordering of critical tokens. The paper's counterexample—where local reconstruction error and attention divergence improve while prediction loss worsens—is precisely a reminder of the limitations of such proxy metrics.
Full-Model Comparison and Practical Implications
The full-model comparison yields a practical boundary: centering repair is effective when the channel grouping layout is preserved; and on the tested model panel, 2-bit keys using token grouping achieve lower loss. This conclusion connects the mechanism of "shared ranges causing prediction error" with engineering trade-offs.
From a broader perspective, this study does two valuable things. First, it establishes a causal chain from the implementation detail of shared quantization ranges to the final metric of prediction error, rather than stopping at the empirical description that "some models just aren't suited to low bits." Second, it clearly distinguishes fixed-offset removal from positional-component reconstruction: the former can be accomplished by subtracting and adding back the bias, while the latter requires tracking a positional trajectory—the two must not be conflated.
For engineers actually deploying low-bit KV caches, the actionable takeaways are: if your model exhibits abnormal degradation under 4-bit key quantization, first check whether the key projection bias has a significant fixed offset and try centering before quantization; if the target is 2 bits, the choice of grouping strategy may be more critical than offset repair, with token grouping performing better on the tested panel. At the same time, do not judge quantization quality solely by attention divergence or local reconstruction error—prediction loss is the final arbiter.
Research Boundaries and Open Questions
The study's conclusions rest on a panel of eight models, with limited coverage of model architectures; extrapolating the conclusions to larger models or hybrid architectures requires caution. In addition, at 2 bits the attribution depends on the chosen coordinates, indicating that error pathways become more complex at extremely low bit-widths and a single repair method may not suffice. How to adaptively identify and handle high-offset channels without significantly increasing metadata overhead remains a direction worth exploring.
One-line Summary
Study reveals that 4-bit KV cache quantization collapse stems from key-channel fixed offsets perturbed by rounding; bias subtraction repairs it.
Paragraph Summary
This study investigates why 4-bit KV cache quantization performs so differently across models, conducting a mechanistic analysis on eight models. The core finding: group-wise affine quantization makes multiple channels share a scale and zero-point, and persistent offsets in key channels encroach on the group's dynamic range; a fixed offset that should cancel in exact softmax becomes position-dependent prediction error because quantization rounding produces different rounding codes at different positions, perturbing relative logits. Rotated key projection bias accounts for nearly all of the first-layer offset component, so subtracting the bias before quantization and adding it back after dequantization repairs severe 4-bit degradation; StableLM additionally requires tracking a positional trajectory rather than just removing the mean. Coordinate substitution experiments show that on Qwen2.5, shifted-coordinate outputs suffice to recover almost all 4-bit loss, while at 2 bits adjacent outputs matter significantly. In practice, 4-bit degradation should first be checked for and centered on key bias, whereas at 2 bits grouping strategy is more critical.
Related articles

Nearly Breaking eMudhra's Encryption Key: A Deep Retrospective on a Failed Attempt
Security researcher Hanno Böck discloses an attempted attack on eMudhra CA's private key: a search around the d=4 parameter weakness stopped just short of success. This article reviews the technical path, community reaction, and implications for the PKI trust model.

OpenAI Independent Evaluation Pilot Hits Snag: Apollo Research Says Access Is Restricted
OpenAI's pilot allowing independent evaluators into its lab faces criticism as Apollo Research says access is restricted. We analyze the independence dilemma and its implications for AI safety governance.

India Clarifies Tax Treaty Rules, Offering Clearer Tax Guidance for Global VCs
India clarifies application rules for foreign investors seeking tax treaty benefits. After months of lobbying, overseas VCs have a clearer tax compliance path in India, following Tiger Global's tax setback.