Training
- Updates weights via backpropagation over batches of data
- Runs hours to weeks on multi-node clusters
- Tooling such as PyTorch, JAX, DeepSpeed, Megatron
- Only worth doing yourself when no existing model fits
What actually happens between a prompt and a response: the generation loop, the two phases that dominate latency, the hardware the work lands on, and the metrics that describe it.
Training adjusts model weights over a large dataset, typically once, on a large accelerator cluster. Inference applies the frozen weights to new inputs, continuously, for every request your product serves. Training cost is mostly a one-time investment; inference cost compounds with traffic, which is why serving efficiency decides the economics of an AI product.
A related distinction: an inference framework executes the model efficiently, while an inference server wraps it with batching, queuing, streaming, health checks, autoscaling, and an HTTP or gRPC API. Production systems need both.
The prefill/decode split explains most serving behavior: long prompts hurt time to first token, long outputs hurt total latency, and almost every optimization on the serving optimization page targets one phase or the other. Token-by-token generation is the dominant paradigm but not the only one: diffusion-based language models generate whole passages through iterative refinement instead, an active research direction with different latency behavior.
General-purpose, available everywhere, limited parallel throughput. Viable for small or heavily quantized models, prototyping, and edge boxes without accelerators.
The default for LLM serving: thousands of parallel cores and high-bandwidth memory (HBM) matched to the matrix multiplications that dominate the workload. Ecosystems: CUDA, ROCm.
Purpose-built tensor accelerators (for example TPUs with XLA/JAX) can be efficient at scale, at the price of a narrower software ecosystem and provider coupling.
Selection criteria are model size, request volume, latency targets, cost, and the infrastructure you already operate. Browser, edge, and mobile execution are covered in web inference and edge and mobile.
| Metric | Meaning | When it matters most |
|---|---|---|
| TTFT | Time to first token, dominated by queueing plus prefill | Chat and any interactive UI |
| ITL / TPOT | Latency between tokens; time per output token averages it over the response | Perceived streaming speed |
| E2EL | End-to-end request latency; TPOT is roughly (E2EL - TTFT) / (output tokens - 1) | Batch steps and tool-call chains |
| TPS / RPS | Output tokens per second and requests per second at a given concurrency | Capacity and cost planning |
| Goodput | Only the requests that met their latency objective | SLO-bound production services |