Zenaique

Each decode step loads ___ from HBM, regardless of how many tokens have already been generated

Fill in blank·Easy·4.0 · 0·~1 min·Asked atMeeshoRobust IntelligenceTata Digital·Relevant atNVIDIA
Attempt it
Each autoregressive decode step reads from HBM (constant per step) plus (which grows linearly with the live sequence length). This second term is why long context decode gets slower as generation progresses.
TL;DR

Each decode step reads the full model weights (constant) plus the live KV cache (grows linearly with context length). Decode is bandwidth-bound, and the KV term is what makes long-context decode slow.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine the model is a chef cooking one dish at a time. Every dish, the chef has to grab the entire recipe book from a shelf, that is the model weights, and it is always the same weight no matter what dish. The chef also has to read every note they wrote down from earlier dishes in the meal, that is the KV cache, and after twenty dishes the stack of notes is twenty pages. After two hundred dishes it is two hundred pages. The recipe-book trip is constant per dish, but the notes-reading trip grows. By dish number two hundred, reading the notes takes longer than reading the recipe. That is why long stories get slower to write as they get longer.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Decode is two bytes-moved streams per step, not one. Internalizing both is the foundation for understanding every long-context optimization and every batching decision in production serving. The first is the model weights, fixed in size by the architecture and dtype, loaded in full on every step. The second is the KV cache, growing linearly with the live sequence length, also loaded in full on every step. The kernel is memory-bound, so per-token latency is essentially the sum of those bytes divided by HBM bandwidth.

This deep dive quantifies both terms on a realistic 70B model, derives the crossover where the KV term overtakes the weight term, explains why batching helps one term and not the other, and connects the math to the long-context optimization stack.

Why decode loads the full weights on every step

An autoregressive decoder produces one token at a time. To produce token t, the model runs a full forward pass with t-1 tokens of cached attention state and one new query at position t. Every layer's matmul has to operate on the current activation against the layer's weight matrix, and the weight matrix has to be in compute scope during that matmul.

The weight matrix lives in HBM. To bring it into compute (the tensor cores in shared memory and registers), the kernel issues memory operations that read the entire weight tensor. That happens on every layer of every step. There is no caching of weights across steps that avoids the HBM read; HBM is the cache, in this hierarchy.

The total weight bytes per step is roughly the parameter count times the bytes per parameter. For Llama 3.1 70B in FP16 that is 140 GB per step per GPU. In FP8 it is 70 GB. In FP4 (Blackwell-class) it is 35 GB. Tensor parallelism shards the weights across N GPUs, so the per-GPU read drops to weight_bytes / N. None of this changes step to step. Whether the model has produced 10 tokens or 10,000, the weight read is the same.

Why the KV cache grows and how big it actually is
Per-token latency on bandwidth-bound hardware
Why batching helps the weight term but not the KV term
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
TermPer-step bytesScalingOptimizations
Model weightsParam count * bytes-per-paramConstant per stepLower-precision dtype (FP8/FP4), tensor parallelism
KV cache2 * L * H_kv * d_h * b * TLinear in T (and in batch)GQA / MQA / MLA, FP8/FP4 KV, sliding-window, paged attention

Real products, models, and research that use this idea.

  • Llama 3.1 70B with GQA-8 in FP8 loads roughly 70 GB of weights and about 32 GB of KV at 200k context per decode step on a single GPU, dominated by weight bandwidth at short context and by KV bandwidth at long context.
  • DeepSeek V4 ships Multi-head Latent Attention specifically to compress the KV term, replacing per-head K and V with a low-rank latent that streams far fewer bytes per token at long context.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy does the KV cache load per step include both K and V even though the new token only adds one K and one V?
A

Attention at step t computes softmax(Q_t * K_1..t-1^T) * V_1..t-1, so the kernel must touch every prior K and every prior V to compute the attention output. The new K and V are added to the cache, but the full cache is read every step.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Saying decode only re-reads what it needs for that one new token. Wrong: each decode step reloads the entire weight matrix plus the entire current KV cache from HBM, because every output token must be computed against the full parameter set and the full attention history.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Name the two HBM byte streams per decode step.

  • Describe the structure of the weight term.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
What is the KV cache in transformer inference?
Flashcard·Easy