Open any LLM pricing page (OpenAI, Anthropic, or Gemini) and you will notice the exact same pattern: output tokens cost 3× to 5× more than input tokens — and cached input tokens cost up to 90% less.

That pricing gap is not arbitrary marketing. It comes directly from two completely different hardware phases inside a Transformer forward pass.

Phase 1: Prefill (Input Tokens Run in Parallel)

When you send a 4,000-token system prompt + RAG context, the GPU already knows all 4,000 tokens upfront.

PHASE 1: PREFILL (COMPUTE-BOUND · PARALLEL MATRIX-MATRIX MULTIPLY) ┌──────────────────────────────────────────────────────────┐ │ [Token 1, Token 2, ..., Token 4000] ──► 1 GPU Pass! │ │ Saves Key (K) & Value (V) tensors into GPU VRAM Cache │ └──────────────────────────────────────────────────────────┘ Determines: Time-to-First-Token (TTFT) 

Because matrix-matrix multiplication (GEMM) saturates GPU Tensor Cores efficiently in one parallel pass, processing 4,000 input tokens is cheap per token.

Phase 2: Decode (Output Tokens Run Sequentially 1-by-1!)

Generating the response is autoregressive: the model cannot compute Token #2 until Token #1 has been sampled!

PHASE 2: DECODE (MEMORY-BANDWIDTH-BOUND · 1 TOKEN PER LOOP) Loop 1: Reload 140GB model weights from VRAM -> emit "Here" Loop 2: Reload 140GB model weights from VRAM -> emit "is" Loop 3: Reload 140GB model weights from VRAM -> emit "the" ... 

For every single output token, the GPU has to stream billions of model parameters from HBM memory onto compute cores just to produce one vector. GPU compute sits mostly idle waiting on memory bandwidth — making each output token 3×–5× more expensive in GPU-seconds!

How Production Engineers Cut LLM Bills by 60%+ With Prefix KV Caching

If 1,000 users hit your endpoint with the same system instructions, tool schemas, and few-shot examples, recomputing K and V tensors for that static prefix 1,000 times wastes money and latency.

Rule #1 of Prompt Ordering for KV Cache Hits: Put 100% static content FIRST, and dynamic per-request variables LAST!

# ❌ BAD: Dynamic timestamp at line 1 busts 100% of the prefix KV cache! bad_system = f"Current UTC time: {now_iso()}\n\n{FIVE_THOUSAND_TOKEN_RUBRIC}" # ✅ GOOD: Static prefix stays byte-identical across calls -> 50%-90% cache discount! messages = [ {"role": "system", "content": FIVE_THOUSAND_TOKEN_RUBRIC}, # <-- Cached in VRAM! {"role": "user", "content": f"[Time: {now_iso()}]\nQuery: {user_question}"} ] 

Interactive Wire-Level KV Cache & Tokenizer Labs

Want to step through Prefill vs Decode telemetry and test live BPE token budgets in your browser (zero API keys)?

👉 Try the Free Interactive Context Window & KV Cache Lesson on BigOSlate