Define LLM inference and explain how it differs from training.
Inference is the forward-only pass that turns a prompt into tokens with frozen weights; training is the backward pass that updates weights on labeled data.
Picture a chef who studied for years at culinary school. The studying part is training. They read recipes, made mistakes, got corrected, and slowly learned what works. Once they leave the school, the cookbook in their head is locked. Now when you order a meal, they cook it without going back to study. That is inference: using the recipes they already learned to make one specific dish. Training happens once and is enormously expensive because they had to learn from millions of examples. Inference happens every time a customer walks in and is cheap per meal, but the restaurant serves thousands of meals a day, so the total tab adds up fast.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: forward-only vs forward plus backward, memory footprint comparison, the prefill/decode split inside inference, and why inference cost dominates the lifetime bill of any deployed model.
| Aspect | Training | Inference |
|---|---|---|
| Weight updates | Yes, every step | No, frozen |
| Gradients | Computed in backward pass | Never computed |
| Memory footprint | ~4x parameter count | ~2x parameter count + KV cache |
| Frequency | Once per model release | Every user request |
| Dominant bottleneck | All-reduce bandwidth across cluster | HBM bandwidth on single GPU (decode) |
Real products, models, and research that use this idea.
- GPT-5.5 and Claude Opus 4.7 are trained once on massive clusters and then serve billions of inference requests per day from fleets of H100 and B200 GPUs.
- vLLM, SGLang, and TensorRT-LLM are inference-only serving stacks; they hold weights, run forward passes, and never touch a backward pass.
- PyTorch's `torch.no_grad()` context manager and `model.eval()` flag are the standard way to disable gradient tracking during inference in custom serving code.
- Llama 4 Maverick's open weights can be loaded into either a training framework (FSDP, DeepSpeed) for fine-tuning or an inference framework (vLLM, llama.cpp) for serving.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does inference memory grow with the KV cache while training memory grows with activations?
QIf inference dominates lifetime cost, why does training still get headline attention?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Saying inference is 'just a smaller training run'. It is structurally different: no gradients, no optimizer state, no labels, and weights are read-only the entire time.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.