What Is Inference & Inference Engineering?

An AI model, physically, is a file of numbers. Llama 3.1 8B, an open model you can download from Hugging Face, is 8.03 billion of them: about 16 GB at two bytes each. There is no answer engine inside, no database of facts, no code that knows what Paris is. Only numbers, frozen at the moment a training run ended.

Inference is what happens when you use them.

Training and inference

A machine learning model lives in two phases. Training adjusts those billions of numbers, the model's weights, until the model behaves well. Inference runs the finished model against real inputs. Every model you have ever talked to was in its inference phase while you talked to it:

TrainingInference
What changesThe weightsNothing; weights are read-only
When it happensOnce, before releaseEvery time anyone uses the model
TimescaleWeeks to monthsMilliseconds to seconds per request
Who paysThe lab that built the modelWhoever runs it, on every request

Training is a project. It happens once, on someone's enormous budget, and it ends. Inference is a utility bill: it runs on every request, forever, and for a product with real traffic the cumulative inference spend eventually dwarfs what the model cost to train.

Common misconception. A chatbot that remembers your earlier messages is not learning from you. The application feeds the whole conversation back in as input on every turn; the model itself is a pure function.

Running a model

When a request arrives, the prompt is broken into tokens, small pieces of text. The model then produces its reply one token at a time. Each token takes a full pass through all 8 billion weights, and the chosen token joins the input for the next round. A 500-token answer means 500 of those rounds.

That loop is what the rest of this course is about. You will run your first LLM yourself, then trace how it produces a token step by step.

Inference as a field

Inference is also the name of the field that has grown around this phase: everything that stands between a trained model and a user getting an answer, at whatever speed, cost, and scale the product demands.

The field is unusually broad. Reinforcement learning names a fairly specific family of methods; inference stretches across most of a systems stack, from numerical formats and GPU kernels at the bottom, through serving engines and schedulers, up to fleets, routing, and economics.

So “inference work” means different jobs at different companies: fused GPU kernels at one, keeping thousands of accelerators busy across clouds at another, fitting an open model onto a phone at a third. All of it is the same problem at different layers, and an engineer can spend years inside one layer without exhausting it. The rest of orientation maps these layers.

The field also stopped being niche recently, for two reasons. Open-weight models pulled close to the frontier (the DeepSeek releases of late 2024 and early 2025 made the closing gap impossible to miss), so running your own inference became a serious option for ordinary engineering teams.

And reasoning models and agents multiplied the tokens spent per user action: models now think in tokens before they answer, and agents chain dozens of calls per task. The compute growth in AI has shifted to inference time, and the spend has followed it.

Four levels of inference

You now have four true answers to the lesson's question, and people in the field move between them without warning:

Level“Inference” means
LifecycleUsing a trained model rather than training it
ModelThe loop that turns a prompt into a reply, one token at a time
HardwareMoving weights and state through a GPU fast enough
FleetServing thousands of token streams at once, within latency and cost targets

When a researcher says “inference is cheap now,” they usually mean the model level. When a platform engineer says “inference is eating our budget,” they mean the fleet. Both are right, and knowing which level a claim lives at will spare you a lot of confused arguments.

Inference engineering

A working inference setup is not hard to build. Download an open model, rent a GPU, wrap model.generate() in a web server: a dozen lines of Python, and one user gets correct answers at a reasonable speed.

Find a model that fits your machine

llmfit checks your RAM, CPU, and GPU, then recommends models your hardware can actually run. Use it to replace the 8B example above with a practical local model.

Inference engineering is the discipline that begins where that server stops being enough. Its job is to make inference fast, cheap, and reliable at whatever scale a product actually demands. Pointed at real traffic, the dozen-line server fails in ways that are hard to predict from the outside, and the reason fits in one calculation.

The cost of one token

Every token of a reply is a full pass through all 8 billion weights. Those weights are 16 GB and live in GPU memory, so producing one token means streaming essentially all 16 GB through the compute units.

An H100 SXM, the NVIDIA data-center GPU this course uses throughout, moves memory at 3.35 TB/s. Divide, and one token cannot arrive from a single GPU faster than about 5 milliseconds: roughly 200 tokens per second for one user, no matter how good the software is, as long as every weight is read for every token.

The math itself takes about 16 microseconds per token against those 5 milliseconds of memory time, so the GPU waits through more than 99 percent of every step. The scarce resource in text generation is memory bandwidth. Try another model and GPU below before reading on.

Nearly every technique with a name in this course is one of three responses to that imbalance. Share one read of the weights across many users (batching). Shrink the bytes that must move (quantization). Earn more than one token per read (speculative decoding). When you meet a new optimization later, ask which of these it is doing. The lessons on inference memory develop this accounting in detail.

Batching is the first of these, and nobody serves production traffic without it: 64 requests sharing one 16 GB read can cut cost per token by an order of magnitude. Doing it well under live traffic, where requests arrive at random times and finish mid-batch, is a whole category of software, the inference engine, with vLLM, SGLang, and TensorRT-LLM as the names you will hear most.

What the discipline optimizes

Inference engineering balances five things: latency, throughput, memory, cost, and quality. Every technique improves one by spending another. Raising batch size trades each user's latency for fleet economics; quantization trades a quality risk for smaller weights that move faster.

The deliverable is a latency target met at a cost the product can survive. The work is a loop: choose the smallest model and hardware that meet the quality bar, benchmark a baseline honestly, find the bottleneck, apply the technique that spends what you can afford, and measure again. You do not need to train models to be excellent at serving them; many practitioners arrive from the systems side.

The next lesson walks the stack all of this work lives on, from the model file to the GPU to a fleet. Before it, open the calculator above and find the decode floor for the model you would run first.