---
id: 18173
lang: en
title: "The same LLM prompt gives different answers: the KV-cache changes the generation path in 37–82% of cases"
published_at: "2026-11-25 10:30:36"
source_name: "Habr AI"
source_url: "https://habr.com/ru/companies/timeweb/articles/1101040/?utm_campaign=1101040&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/18173"
categories: ["llm", "research"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# The same LLM prompt gives different answers: the KV-cache changes the generation path in 37–82% of cases

> **Краткая суть (BLUF):** The same prompt sent to an LLM can produce different answers even at temperature = 0, when randomness is switched off. One cause is reuse of the KV-cache (the model's memory of earlier tokens): it changes the generation path in 37.4% of cases with 16-bit numbers and in 82.5% with 4-bit model compression. As a result, in agent chains a single successful run guarantees nothing; the prompt should be run many times.  • Rephrasing breaks 23% of answers that were previously correct • On MMLU, Gemini 2.0 Flash falls from 86% to 75%, and o3-mini from 87% to 80% • GPUs group requests into batches differently, and rounding changes which words get picked

You send the same prompt to a model twice. The first time the answer is fine, the second time the model gets confused or produces nonsense, even though you changed nothing. This happens even at temperature = 0, when randomness in word selection is switched off. One of the causes is the KV-cache, the model's memory of previous tokens within a single generation. If that memory is reused instead of recomputed from scratch, the generation path changes in 37.4% of cases with standard 16-bit numbers (FP16), and in 82.5% of cases when the model is heavily compressed to 4 bits. In a single chat this is annoying; in an agent chain it becomes a real problem: the first model's answer goes to the second, then a tool returns data, then a third model makes a decision, and a small divergence at the start turns into a completely different result. Habr reviewed recent research on where this variability comes from.

## Instability starts before generation

The first cause is phrasing. In the work by Faghih et al., the researchers took benchmark tasks that the model solved correctly and rewrote them while keeping all the numbers, conditions, and logic. On average across the benchmark, accuracy barely changed, which creates a false sense of reliability. But at the level of individual tasks, after the rephrasing, errors appeared in 23% of cases.

Example: a train travels at 60 km/h. What distance will it cover in 45 minutes? The model multiplies 60 by 0.75 and picks the correct option. But if you write "if a train covers 60 kilometers in one hour, how much distance will remain behind it after 45 minutes," the model may simply subtract the minutes from the hour: in texts, such phrasings more often meant a time difference. The knowledge is in the weights, but under a different wording it is retrieved unreliably.

The second problem is Prompt-Reverse Inconsistency (Ahn and Yin, 2025). If you ask "which statement is true," the model will choose option A. If you ask "which statement is false," it may again name A. For the model, the words "true" and "false" are not logical True and False but different signals, under which the word probabilities are recalculated. For the LLM-as-a-judge approach, where a neural network labels data, checks code, or evaluates other models, this is a serious blow: a judge that counts the same answer as both correct and incorrect depending on how the question is asked is worthless.

## Why temperature = 0 does not turn an LLM into a calculator

The model first produces logits, the raw scores for each candidate token. The Softmax function turns them into probabilities: the scores are exponentiated with e and divided by their total. In the author's example, "pizza" gets 73.7%, "carbonara" gets 26.3%, and "tractor" gets a negligible fraction of a percent. At t = 0 the model always takes the most probable token, so the result should be fixed. In practice it is not, and the hardware is to blame.

To keep the GPU from sitting idle, the server groups requests into batches. Your request at 10:00 may land in one group, and at 10:01 in another, alongside tasks of completely different complexity. The batch size changes, and the GPU rearranges the order of computations. In ordinary mathematics, reordering the terms of a sum does not change the result, but in floating-point arithmetic it does, because of rounding. The shift is tiny, but if "Yes" led "No" by a millionth, the choice flips, and then a domino effect sets in.

The second source of divergence is the KV-cache itself. Reusing it instead of recomputing creates a discrepancy in the calculations: 37.4% of cases in FP16 and 82.5% with 4-bit quantization. Aggressive model compression to save memory directly undermines reproducibility.

## How to measure the variability

Average accuracy hides the key point. A model with 90% correct answers may confidently solve 9 out of 10 questions, or it may be guessing based on the GPU's mood. A Frontiers article (2026) proposes a Beta-Binomial Bayesian approach and three metrics instead of a single number:

- mean accuracy, cleaned of random guesses and one-off failures;
- concentration: how consistently the model solves different tasks;
- internal noise: how much the answers diverge when the same question is asked 100 times. With low noise, the model is either right 100 times or wrong 100 times; with high noise, it answers "Yes" and "No" roughly equally often.

The comparison showed that reasoning models are more robust to rephrasing. Gemini 2.0 Flash's MMLU accuracy fell from 86% to 75%, and o3-mini's from 87% to 80%. Internal noise in the standard model rose more than 11-fold (from 0.49 to 5.58), while in the reasoning model it went from 2.79 to 4.68. Concentration for Gemini Flash jumped from 0.03 to 0.50, while for o3-mini it barely changed. The extra compute budget lets the model check several intermediate variants before giving its final answer.

## What to do in practice

This is an overview of research, not a ready-made product, but the conclusions apply immediately:

- don't trust a single successful run: run key prompts many times, including on rephrased versions;
- in LLM judges, ask the question in both direct and reversed form and compare the answers;
- if you need reproducibility, pin the stack versions and the GPU type, and keep in mind the cost of aggressive quantization;
- for critical steps in an agent chain, consider reasoning models.

temperature = 0 reduces randomness but does not eliminate it entirely, and this should be designed into the architecture rather than relying on "determinism."

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/companies/timeweb/articles/1101040/?utm_campaign=1101040&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/18173
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
