Prefill vs Decode

Prefill vs Decode

Operational split in LLM serving between processing a block of input tokens in parallel and generating output tokens sequentially one at a time.

Key points

  • Decode processes one next token per sequence and is heavily exposed to memory bandwidth because the model repeatedly fetches weights and prior KV-cache data [src-042].
  • Prefill processes many input tokens in a pass, so memory costs can be divided over more tokens and the operation is more likely to be compute-limited [src-042].
  • The common API pattern where output tokens cost several times more than input tokens is consistent with decode being more memory-bandwidth constrained than prefill [src-042].
  • Tool calls, user messages, and file reads create new prefill segments inside a chat or agent session [src-042].
  • Understanding this split helps explain why prompt caching and cache hits can reduce price and latency: they avoid rematerializing already processed context [src-042].

Related concepts

Source references

  • [src-042] Dwarkesh Patel — “How GPT, Claude, and Gemini are actually trained and served – Reiner Pope” (2026-04-29)

Robin Cartier perspective

This page is part of Robin Cartier's working AI knowledge graph: a practical research layer for production AI, recommendation systems, experimentation, GEO, and agentic web readiness.

The useful next step is to connect this concept back to applied product leadership and operating models.

Recommended next

Keep reading from this thread

From 491 indexed pages and articles.

  1. Wiki concept LLM Inference Economics The cost and latency structure of serving large language models, driven by compute throughput, memory bandwidth, batch size, context length, KV-cache storage, and Related by decode
  2. Wiki concept Prompt Caching for Agents The practice of arranging stable instructions, policies, and tool schemas so providers can reuse repeated prompt prefixes Related by input
  3. Insight AI Measurement and Experimentation How to measure AI product impact with evals, adoption metrics, online experiments, guardrails, and cost tracking Readers have engaged with this next