Inference

Authors 7 articles 73 min total read
Definition
The process of running a trained machine learning model on new input data to produce a prediction or output. For large language models, inference uses autoregressive decoding — generating text one token at a time, with each token conditioned on all preceding tokens.
Also called: model inference, AI inference, LLM inference

What inference is

Every AI model goes through two distinct stages in its lifecycle: training and inference. Training is the expensive, time-consuming part where the model learns patterns from massive datasets. Inference is what happens after — the moment you actually use the model to get a result. When you type a question into ChatGPT, Claude, or any AI assistant, the model runs inference to produce your answer.

Think of it like learning to cook versus actually cooking dinner. Training is reading cookbooks, studying techniques, and practicing for months. Inference is walking into the kitchen and making a meal for someone. How good the meal tastes depends on your training, but how fast and cheaply you can serve it depends on your inference setup.

For large language models, inference works through autoregressive decoding. The model doesn’t produce an entire response at once. Instead, it predicts one token (roughly a word or word fragment) at a time, feeding each prediction back as input to generate the next one. This is why you see text appearing word by word in AI chat interfaces — that’s autoregressive inference happening in real time.

According to BentoML Handbook, LLM inference has two distinct phases: prefill, where the model processes your entire prompt, and decode, where it generates tokens one at a time. The prefill phase is compute-intensive because it processes everything you sent in parallel. The decode phase is memory-intensive because it needs to store and access the attention history — called the KV cache — for every token generated so far.

That KV cache is one of the biggest bottlenecks in inference. As conversations grow longer, the cache grows with them, consuming GPU memory that could serve more users. According to the PagedAttention paper, traditional KV cache management wastes substantial memory through fragmentation, but PagedAttention reduces that waste to near zero by borrowing memory management ideas from operating systems.

Each token waits on the one before it, so more GPUs serve more requests rather than one response faster. · More AI cheat sheets
  • Inference is bound by memory movement, not raw compute, and generation is sequential — one token depends on the last, which is why more GPUs multiply capacity, not the speed of a single response.
  • Serving-framework choice (vLLM, TensorRT-LLM, SGLang) is a constraint match, not a popularity contest — profile the workload before picking one.
  • Custom silicon like Cerebras and Groq is repricing inference speed, but GPU clouds still own the flexibility floor — the right architecture depends on the workload, not a universal winner.
  • Inference runs around the clock, so its environmental and access cost scales with usage — a recurring draw, not a one-time line item.

How inference is used in practice

The most common place you encounter inference is every time you interact with an AI assistant. When you ask Claude to draft an email, write code, or answer a question, the application sends your prompt to a server running the model. The model runs inference to generate a response, and you see the result stream back token by token. That streaming effect isn’t a visual trick — it reflects the actual autoregressive generation happening on the server.

Behind the scenes, production systems run inference for thousands of users at once. Techniques like continuous batching group multiple requests together so the GPU stays busy instead of sitting idle between generations. This is why AI services can handle millions of conversations without needing a separate GPU for each user.

When evaluating AI tools, pay attention to Time to First Token (TTFT) — the delay between sending your prompt and seeing the first word appear. According to NVIDIA Blog, TTFT includes both scheduling delay and prefill compute. A tool that feels sluggish often has a TTFT problem, not a generation speed problem.

Reading the inference stack: mechanism first, market last

Start with what model inference is and how LLMs generate text through autoregressive decoding — it establishes the one fact everything else in this topic assumes: generation happens one token at a time, each conditioned on every token before it. From there, KV-cache, PagedAttention, and the building blocks every inference pipeline needs names the machinery that makes that loop fast enough to serve, and memory walls, quadratic context costs, and the hard engineering limits of LLM inference is the honest read on where that machinery stops helping.

Once the mechanism is solid, the vLLM, TensorRT-LLM, and SGLang deployment guide turns it into a running server, with the framework-selection logic a benchmark table alone won’t give you. For where the hardware market is moving underneath that choice, Cerebras vs. Groq vs. GPU clouds maps the custom-silicon bet reshaping inference economics. Close with the environmental price and access inequality of large-scale inference — once inference runs continuously in production, this is the cost the cloud bill doesn’t show.

MAX asks: 'My cluster has more GPUs than ever — why can't I just throw them at one slow response to speed it up?' MONA answers: 'Because each token waits on the one before it. More GPUs serve more requests, not one faster.' — comic dialog.
Inference is sequential by construction — parallel hardware buys throughput, not speed for a single response.

How inference differs from training, and from the levers that shape it

Inference and training share the same weights but sit on opposite sides of the cost equation. Training happens once, offline, in a controlled batch job. Inference runs continuously, on live traffic, and its cost compounds with every request instead of every model version — a distinction that usage-based billing makes concrete and always-on deployment makes expensive.

A second confusion sits one level down: inference is the process, not the technique. Quantization, continuous batching, and temperature and sampling are levers applied to inference, not different names for it — quantization changes what the weights weigh, continuous batching changes how requests share the GPU, sampling changes which token gets picked. None of them replace understanding the loop itself; they tune it.

When inference fits — and when it doesn't

ScenarioUseAvoid
Generating text responses in an AI chat assistant✅
Classifying incoming support tickets automatically✅
Training a model from scratch on new data❌
Real-time translation during a live video call✅
Fine-tuning a model’s weights on domain-specific data❌
Batch-processing documents overnight for summaries✅

Common questions about inference

Q: Is LLM inference actually more expensive than training the model, over its lifetime? A: Usually, yes — training is a one-time job, but inference reruns on every single request for as long as the product is live, and at scale that recurring draw includes real electricity, water, and carbon, not just a per-token charge. The environmental price of always-on inference traces where that bill actually lands.

Q: Will adding more GPU memory alone fix slow inference at long context lengths? A: Only partially — more memory buys headroom for a bigger KV-cache, but the attention computation itself still grows worse than linearly with context length, so the wall moves rather than disappears. The hard engineering limits of LLM inference covers where teams hit it anyway.

Q: Does the custom-silicon race between Groq and Cerebras matter if I’m just calling a hosted API? A: Indirectly, yes — the speed and cost gains custom silicon delivers show up as pricing and latency changes at the API layer even if you never touch the hardware, and hyperscalers are already buying in rather than competing. Cerebras vs. Groq vs. GPU clouds tracks who’s adopting what.

Q: Do I need to understand the inference mechanism before picking a serving framework? A: Yes, in practice — framework choice sits on top of the mechanism, not in place of it. Read how KV-cache and PagedAttention work first, then let the deployment guide match a framework to your constraints.

Part of inference optimization · closest neighbour: continuous batching. New to inference from a software background? Start with the story: Inference Optimization for Developers: What Transfers and What Breaks.

Sources

1

Understand the Fundamentals

Inference is where training meets reality, converting static model weights into dynamic output one token at a time. These articles unpack the mechanisms that make generation possible and the constraints that shape it.

2

Build with Inference

Deploying inference at scale means choosing the right serving framework, configuring batching strategies, and managing GPU memory under load. These guides walk through the practical decisions that determine cost and speed.

4

Risks and Considerations

Running inference at scale raises questions about energy consumption, equitable access, and the hidden costs of always-available AI. These articles examine what responsible deployment looks like beyond raw performance.