Ollama Bug Inflates Prefill Speed by 318x When KV Cache Is Warm
A developer discovered that Ollama's API reports wildly inflated token prefill speeds when the KV cache is active, because it divides the full prompt token count by the time taken to process only the uncached tokens. In one test on Ollama 0.34.0 with a 318-token prompt, the reported rate jumped from 2,272 tokens/sec on a cold run to a false 13,826 tokens/sec on a warm run, when the true rate was just 43 tokens/sec. The root cause is a mismatch between two fields: prompt_eval_count includes all tokens in the prompt, while prompt_eval_duration only covers tokens actually computed, making the error proportional to the cache hit ratio. The correct approach is to subtract the cached token count before calculating the rate, which is what Ollama's own internal Metrics.Summary() method already does. The issue affects all three of Ollama's API surfaces and is especially misleading in older daemon versions prior to 0.33.3, which omit the cached token count field entirely.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in