Skip to content
Home/Resources/AI & ML/Inference engineering
AI explained ยท AI & ML

What Is Inference Engineering? LLM Inference and Model Serving Explained, the Main Speed and Cost Levers, a Batching Demo and How to Practise on a Laptop

Younus FardeenBy Younus FardeenUpdated 1 Dec 20269 min read
Short answer

Inference engineering is the work of running trained AI models in production efficiently. Sources define it as balancing latency, throughput, cost and quality across GPU code, serving software and cloud infrastructure. Main levers are batching, KV caching, quantisation and speculative decoding. You can practise the basics on a laptop with a small quantised model.

On this pageWhat is inference engineering?The four levers: latency, throughput, cost, qualityWhy batching raises throughput: a NumPy toyTools: vLLM, llama.cpp and OllamaHow to practise on a laptopFrequently asked questions

This page is for a developer or student who has seen inference engineering in job posts and course titles and wants a clear definition and a way to start. Queries such as inference engineering roadmap and LLM inference engineering course already appear in this hub's Search Console export of 5 November 2026, so people are searching for the term, even though most explainers are written for infrastructure teams. The learning-path parent is AI and ML.

The definitions below come from two sources opened on 1 December 2026. The levers are explained from stable technical knowledge, and the batching demo runs offline with NumPy. Related reading: what is a large language model for what is being served, and fine-tuning vs RAG for the step before serving.

What is inference engineering?

Inference engineering is the discipline of running trained AI models in production efficiently. ByteByteGo's guide, published 15 June 2026, says the work spans low-level GPU code, model serving frameworks and the cloud infrastructure that ties them together, and that engineers optimise some mix of latency, throughput, cost and quality depending on the product. Telnyx's guide puts it as making AI models run fast, reliably and cheaply in production, across three layers: the runtime that serves one model on a GPU, the infrastructure that scales it across machines, and the tooling that gives engineers an interface to both.

Training teaches a model. Inference is using the trained model to answer a request. Telnyx adds a useful contrast: prompt engineering improves the input you send, while inference engineering improves the system that serves the answer. Both sources are written from an industry viewpoint, and one is a vendor page, so treat the term as a working label rather than a formal standard. The definition is not settled by an exam body or a standard.

Why is serving hard? ByteByteGo explains that producing a response has two stages with different bottlenecks. Reading the prompt and emitting the first token is limited by compute. Producing every later token one at a time is limited by how fast data moves through memory. Most serving tricks exist because of that split.

The four levers: latency, throughput, cost, quality

Latency is how long one user waits. Throughput is how many tokens or requests the system finishes per second. Cost is money per token or per request. Quality is whether answers stay as good as before. Improving one usually costs another, which is the job.

LeverWhat it doesHelpsTrade-off
BatchingRuns many requests through the model together so each read of the weights serves several tokensThroughput and cost per tokenEach request may wait slightly longer to join a batch
KV cacheStores the attention keys and values of earlier tokens so each new token does not recompute themDecode speed and latencyUses memory that grows with context length and batch size
QuantisationStores weights in fewer bits. Hugging Face's docs give about 16 GB for an 8B model in bf16, about 8 GB at 8 bits and 4 to 5 GB at 4 bitsMemory, so smaller GPUs or laptops can run the model; often speedSome accuracy loss; methods differ in memory, speed and accuracy
Speculative decodingA small draft model proposes several tokens and the large model checks them in one passLatencyExtra model to run; gains depend on how often drafts are accepted
Prefix cachingReuses the computed cache for a prompt prefix shared across requestsTime to first token, costOnly helps when many requests share a prefix

Why batching raises throughput: a NumPy toy

At small batch sizes, producing a token means reading every weight from memory for very little arithmetic, so the processor waits on memory. A batch reuses each weight read for many requests. The toy checks that batching gives identical answers, then counts bytes read and arithmetic done per step. The timing lines are a made-up model, memory-bound at a fixed 1 GB per second, to show the shape of the effect. They are not a benchmark of any real hardware.

import numpy as np

rng = np.random.default_rng(0)
d = 512
W = rng.standard_normal((d, d)).astype(np.float32)       # one weight matrix of a toy layer
reqs = rng.standard_normal((8, d)).astype(np.float32)    # 8 requests, one new token each

one_by_one = np.stack([W @ r for r in reqs])             # 8 separate passes over W
batched = reqs @ W.T                                     # 1 pass over W for all 8
print("same answers:", np.allclose(one_by_one, batched, atol=1e-3))

weight_bytes = W.nbytes
for batch in (1, 8, 32):
    flops = 2 * d * d * batch
    print(f"batch={batch:2d} bytes of W read per step={weight_bytes:,} flops={flops:,} flops per byte={flops/weight_bytes:.2f}")

# Toy timing model: if the step is limited by memory, time = bytes / bandwidth (made-up 1 GB/s)
bw = 1e9
for batch in (1, 8, 32):
    step = weight_bytes / bw
    print(f"batch={batch:2d} step={step*1000:.2f} ms tokens/s={batch/step:,.0f}")
same answers: True
batch= 1 bytes of W read per step=1,048,576 flops=524,288 flops per byte=0.50
batch= 8 bytes of W read per step=1,048,576 flops=4,194,304 flops per byte=4.00
batch=32 bytes of W read per step=1,048,576 flops=16,777,216 flops per byte=16.00
batch= 1 step=1.05 ms tokens/s=954
batch= 8 step=1.05 ms tokens/s=7,629
batch=32 step=1.05 ms tokens/s=30,518

Read the last column: with the weights read once per step, 32 requests deliver 32 tokens in the time one request delivers one. Real servers cannot batch without limit: the KV cache of every request has to fit in memory, and requests arrive and finish at different times. vLLM's documentation links to a post on continuous batching, which adds new requests to a running batch as others finish, instead of waiting for the whole batch.

Tools: vLLM, llama.cpp and Ollama

Descriptions below are from each project's own page, read on 1 December 2026.

ToolWhat its page says it isBest forNeeds
vLLMA fast and easy-to-use library for LLM inference and serving, originally from UC Berkeley's Sky Computing Lab. The repo is Apache-2.0 licensedServing many users; features include PagedAttention, automatic prefix caching, speculative decoding and an OpenAI-compatible API serverQuickstart lists Python 3.11 to 3.14; docs list NVIDIA and AMD GPUs and x86, ARM and PowerPC CPUs
llama.cppLLM inference in C/C++ with a stated goal of minimal setup and state-of-the-art performance on a wide range of hardware. MIT licensedRunning quantised models on a laptop or small machineA downloaded model file; install options on its README
OllamaA tool to run open models locally or in the cloud through a simple command line and API; its README shows macOS download and a Linux install scriptThe easiest first local setupA computer with enough memory for the model you pick

A rule of thumb for beginners: start with Ollama or llama.cpp to feel the numbers on your own machine, then read vLLM's docs and design pages to see how a multi-user server differs. For hosted models you call over an API instead of running them, see free LLM APIs for developers.

How to practise on a laptop

  1. Run a small model locally. Install Ollama from its docs, pull a small model and ask it a question. Note the memory use in your system monitor.
  2. Measure, do not guess. Record time to first token and tokens per second for a short and a long prompt. The snippet below computes both from timestamps, so you can reuse it on real streaming output.
  3. Change one thing at a time. Try a smaller or more heavily quantised version of the same model and compare speed and answer quality on five fixed questions.
  4. Write down the trade-off. One page: what got faster, what got worse, what it would cost to serve 100 users.
  5. Read one serving design page. vLLM's documentation covers paged attention and prefix caching in its design section.
# Latency metrics from token timestamps (seconds since the request was sent).
stamps = [0.42, 0.47, 0.52, 0.57, 0.62, 0.67, 0.72, 0.77]   # 8 tokens streamed back

ttft = stamps[0]                                    # time to first token
decode_time = stamps[-1] - stamps[0]
tps = (len(stamps) - 1) / decode_time               # tokens per second after the first
print(f"time to first token: {ttft:.2f} s")
print(f"decode speed: {tps:.1f} tokens/s")
print(f"total for {len(stamps)} tokens: {stamps[-1]:.2f} s")
time to first token: 0.42 s
decode speed: 20.0 tokens/s
total for 8 tokens: 0.77 s

The timestamps above are invented to show the arithmetic. Your real numbers will vary with hardware, model and prompt length, so always quote your machine when you share them. Good portfolio projects: a benchmark table of three quantisation levels with your own quality checks, or a small API that adds request logging and a rate limit in front of a local model. More project ideas sit in AI and ML projects for beginners, and a study plan in how to learn AI in 2027.

Frequently asked questions

What is inference engineering?

Inference engineering is making trained AI models run efficiently in production. The aim is to balance latency, throughput, cost and quality using techniques such as batching, caching, quantisation and speculative decoding, and by choosing serving software and infrastructure. It is distinct from training a model and from prompt engineering.

What does an inference engineer do?

An inference engineer profiles how a model runs, finds the bottleneck, and fixes it with kernels, a serving framework, caching, quantisation or scaling across machines. They set targets for latency and cost, monitor them in production and check that speed-ups do not hurt answer quality.

What is LLM inference?

LLM inference is running a trained language model to produce output for an input. The model reads the prompt, then generates tokens one at a time, each depending on the previous ones. Unlike training, the weights do not change; the work is repeated for every request.

What is model serving?

Model serving is the software that exposes a trained model to users or applications, usually through an API, and handles requests, batching, memory, scaling and monitoring. Examples named in vendor and project docs include vLLM for multi-user serving and Ollama or llama.cpp for local use.

What is the KV cache?

In a transformer, each new token needs the attention keys and values of all earlier tokens. The KV cache stores them so they are computed once. It speeds up generation but uses memory that grows with context length and the number of simultaneous requests.

Do I need a GPU to learn inference engineering?

Not to start. You can run small quantised models on a laptop CPU with Ollama or llama.cpp and measure latency and tokens per second. A GPU matters when you study large-batch serving, but the concepts and the measurements carry over.

Is there an inference engineering course?

Course titles with this phrase exist, and people search for them. This page did not review or rate any. A free route is to read the serving docs, run local models, and build the measured project described above before paying for anything.

Continue learning

Concept

What is an LLM?

LLMs in plain English: a table of terms, a Python toy, costs and limits.

10 min read
AI explained

Fine-tuning vs RAG

Fine-tuning vs RAG: what each changes, decision table, runnable demo

6 min read
Roadmap

AI engineer roadmap

LLM APIs, RAG, agents and evals: the 2026 role of building on models

7 min read