- The paper demonstrates that cache-enabled and cache-free FP16 inference produced different token sequences in 100% of 31,500 paired runs across LLaMA-2, Mistral, and Gemma.
- The study traces divergence to non-associative FP16 accumulation, with GQA models showing up to 105× first-layer drift and FP32 reducing KL divergence by more than eight orders of magnitude.
- The findings show that divergence is most consequential near model decision boundaries and cannot be repaired through residual-stream patching, making direct KV-cache interventions the key open direction.
Overview
KV caching is a foundational optimization in autoregressive transformer inference, and its numerical equivalence to cache-free (recomputation) inference is widely assumed but rarely verified. Chodavarapu and Xu demonstrate that this assumption fails under standard FP16 precision. Because the cache-ON and cache-OFF execution paths use different kernel layouts and floating-point accumulation orders, and because FP16 arithmetic is non-associative, the two paths produce deterministic, reproducibly different decoded token sequences. The paper characterizes this divergence behaviorally, traces its layer-wise propagation, falsifies competing explanations via FP32 controls, resolves an apparent contradiction in flip timing through decision boundary analysis, and localizes the causal variable to the KV cache state itself using activation patching (2604.15409).
Experimental design
The study evaluates three open-weight models spanning key architectural axes: LLaMA-2-7B (MHA), Mistral-7B-v0.3 (GQA ratio 4:1), and Gemma-2-2B (GQA ratio 2:1, head dimension 256, sliding window attention). All experiments run on a single NVIDIA H100 with deterministic settings (CUBLAS_WORKSPACE_CONFIG=:4096:8, torch.use_deterministic_algorithms(True)), ensuring bitwise reproducibility. The benchmark is GSM8K, with 700 sampled test examples evaluated under five seeds per model-strategy condition — 31,500 run pairs total across greedy, top-k (k=50, T=0.7), and top-p (p=0.95, T=0.7) decoding.
A methodological detail matters for interpretation: the authors implement a custom token-by-token generation loop rather than model.generate(), so that full-vocabulary logits are available at every step and both execution paths share identical per-step random seeds. This design ensures that observed differences reflect distributional divergence rather than sampling variance. The authors also concede that absolute accuracy under their protocol is low (max_new_tokens=128 truncates some generations; few-shot prompting induces exemplar mimicry), and they explicitly frame accuracy differences as indicators of execution-path bias rather than measures of reasoning ability.
Behavioral characterization: universal, systematic divergence
The headline result is stark: cache-ON and cache-OFF generate different token sequences in 100% of all 31,500 run pairs, across every model, strategy, and seed — including greedy decoding, which eliminates sampling randomness as a confound. Mean KL divergence between the two paths' output distributions ranges from 10.68 (LLaMA-2 greedy) to 12.83 (Gemma top-p), with narrow bootstrap confidence intervals, indicating substantial probability mass redistribution at every decode step that persists without convergence across all 128 steps. Bounded Jensen-Shannon divergence confirms these trends are not artifacts of KL's unbounded range.
| Model |
Strategy |
Div. rate |
Mean KL |
Cache acc. |
No-cache acc. |
| LLaMA-2 |
Greedy |
100% |
10.68 |
3.3% |
2.0% |
| LLaMA-2 |
Top-k |
100% |
10.70 |
3.3% |
1.2% |
| LLaMA-2 |
Top-p |
100% |
10.79 |
2.8% |
1.7% |
| Mistral |
Greedy |
100% |
11.46 |
6.6% |
2.0% |
| Mistral |
Top-k |
100% |
10.70 |
6.5% |
1.7% |
| Mistral |
Top-k=500 |
100% |
10.90 |
5.0% |
1.9% |
| Gemma |
Greedy |
100% |
12.66 |
1.9% |
2.1% |
| Gemma |
Top-k=501 |
100% |
12.80 |
3.9% |
1.1% |
| Gemma |
Top-k=502 |
100% |
12.83 |
3.3% |
1.3% |
The direction of divergence is systematic rather than random: cache-ON yields higher accuracy in 8 of 9 conditions, reaching Bonferroni-corrected significance (McNemar test, k=503) in most of them. The sole exception is Gemma greedy, where the direction inverts (2.1% vs. 1.9%, k=504). The implication is direct: any production system relying on prompt caching or KV reuse will systematically — not stochastically — produce outputs that differ from recomputed-prefix inference.
Layer-wise propagation is architecturally predictable
Per-layer hidden state drift reveals two qualitatively distinct propagation regimes. LLaMA-2 and Mistral exhibit sharp amplification at the first transformer layer: drift jumps from 3.45 to 361.96 (a k=505 single-layer amplification) for LLaMA-2, and from 25.76 to 902.36 (k=506) for Mistral. The authors attribute this to GQA's error-broadcast structure: a single FP16 rounding error in a shared KV head propagates to all k=507 attending query heads as correlated rather than independent errors, amplifying divergence relative to MHA. Cosine similarity between the two paths' hidden states collapses to near zero within the first layers (0.49 for LLaMA-2, 0.015 for Mistral at layer 0).
Gemma shows a structurally distinct flat profile, with drift confined to 1.0–1.4 across all 26 layers and no amplification event — consistent with its larger head dimension (256 vs. 128) and sliding window attention limiting global error propagation. Notably, despite having the lowest per-layer drift, Gemma exhibits the highest overall KL divergence, indicating distributed accumulation across layers rather than concentrated amplification. Statistical support is strong: 89 of 90 layer-model combinations are significant under Mann-Whitney U tests with BH-FDR correction (only Gemma layer 16 is not, k=508).
Root cause: controlled FP32 falsification
The causal claim rests on a clean falsification experiment. If FP16 non-associativity is the sole driver, switching to FP32 must eliminate divergence — and it does. Across k=509 examples per model, KL divergence collapses from roughly T=0.70 to a noise floor near T=0.71, a reduction exceeding eight orders of magnitude, and the token flip rate drops to exactly 0.0% in every model. Complementary microbenchmarks show the mean relative FP16 accumulation error is approximately 0.036%, flat across sequence lengths (16–128 tokens) and identical across models (std T=0.72), establishing that per-step error magnitude is determined by head dimension and attention structure, not input content. This means divergence magnitude is predictable from architecture alone, prior to inference.
Decision boundary analysis: resolving the flip-index contradiction
An apparent tension emerges: examples that flip earlier exhibit higher KL divergence, seemingly contradicting the accumulation hypothesis (more accumulated drift should cause earlier flips). The resolution is that both early flips and high KL are joint consequences of model uncertainty. Examples near the decision boundary have small logit margins, so any perturbation crosses the argmax threshold on the first step; the same uncertainty spreads probability mass, inflating KL. Early-flip groups show higher mean KL in 8 of 9 conditions (Welch's T=0.73-test, T=0.74), and Pearson correlations between flip index and mean KL are consistently negative (T=0.75 for LLaMA-2, T=0.76 for Mistral, T=0.77 for Gemma; all T=0.78). Partial correlations excluding boundary cases strengthen the negative relationship for the GQA models (Mistral: T=0.79; Gemma: p0) while weakening for MHA-based LLaMA-2 (p1), suggesting architecture-dependent propagation of boundary uncertainty. The behavioral takeaway: divergence matters when the model is uncertain, not when the numerical drift is large.
Causal localization: the residual stream is not the carrier
Activation patching provides the localization result. Injecting cache-ON hidden states into the cache-OFF forward pass at decode step 0 — one layer at a time, then cumulatively across all layers — fails to recover the cache-free trajectory. Median recovery across all layers and models is p2, with a mean of p3: patching perturbs rather than corrects. Cumulative patching of the entire residual stream produces negative mean recovery in all three models (LLaMA-2: p4, Mistral: p5, Gemma: p6). Gemma shows partial single-layer recovery (+5.75% median, stable across layers), consistent with its flat drift profile, but even there cumulative patching fails.
This null result carries two implications. First, it rules out attention-head or MLP-layer phenomena as the causal site and establishes that correcting divergence requires direct manipulation of KV cache tensors, not residual stream interventions — a finding that challenges the residual-stream-centric assumptions of much mechanistic interpretability work (2604.15409). Second, the authors are candid that this is an elimination argument: failure of residual-stream patching demonstrates a necessary condition, not a positive demonstration that the KV cache carries the error. Direct KV cache tensor patching is identified as the decisive missing experiment.
Relation to prior work
The paper distinguishes itself from four bodies of literature. Mixed-precision training and quantization research established that networks tolerate reduced precision but did not examine accumulation-order interactions with caching (Micikevicius et al., 2017, Bhattacharjee et al., 2022). KV cache efficiency work — FlashAttention, PagedAttention, MQA/GQA — implicitly assumes cross-path equivalence without verification [(Dao et al., 2022)v2-era kernels; (Dao, 2023, Kwon et al., 2023)]. Mechanistic interpretability methods assume interventions operate on a deterministic forward pass through the residual stream (Schobs et al., 2022, Wang et al., 2022). Prior reproducibility studies treated output variability as stochastic or configuration-dependent; the closest work, Yuan et al., showed FP16/BF16 non-associativity causes nondeterminism across batch sizes, GPU counts, and hardware, and proposed LayerCast as mitigation. The present work differs in showing divergence on identical hardware and batch size, isolating the KV cache path specifically, and connecting divergence magnitude to GQA sharing ratios.
Limitations
The authors acknowledge several constraints. The evaluation covers three models and one benchmark (GSM8K); larger models, instruction-tuned variants, and other tasks remain untested, though the effect is argued to be a property of FP16 arithmetic rather than task or scale. Absolute accuracy figures are low due to generation truncation and prompt format, so accuracy differences should be read as bias indicators only. Most substantively, causal localization rests on elimination rather than direct KV cache patching, leaving the mechanistic story formally incomplete. Two pairwise comparisons were underpowered and excluded from confirmatory claims.
Conclusion
This paper establishes that FP16 KV-cached inference is deterministically non-equivalent to cache-free inference: divergence occurs in 100% of runs, is caused by FP16 non-associativity (eliminated by FP32 to a noise floor over eight orders of magnitude smaller), propagates in architecturally predictable patterns governed by GQA sharing ratios and head dimension, becomes behaviorally relevant only near decision boundaries, and cannot be corrected by any residual-stream intervention. The practical consequence is that cached and recomputed inference paths will systematically disagree in production FP16 systems, with FP32 remaining the only validated remedy. The open questions the paper leaves — direct KV cache tensor patching, quantifying GQA amplification across sharing ratios, and interactions with cache compression schemes — define the immediate agenda for completing this mechanistic account.