How to become an Inference Optimization Engineer
Step by step and free: 12 phases, 88 topics and 307 graded practice questions.
Open any topic and mark it Learning, Done or Skip to track your progress. Sign in to save it to your account.
0 of 88 done · 0 learning · 0 skipped · Start with the first topic
Saved on this device only. Sign up free or sign in to keep your progress everywhere.
It's saved on this device only. Sign up free to keep it everywhere; your marks move into your account.
What is an Inference Optimization Engineer?
An Inference Optimization Engineer makes trained models answer faster and more cheaply without making them worse. They profile where a forward pass spends its time, write or tune kernels, size batches and the KV cache, apply quantisation and speculative decoding, and choose serving engines and GPUs. Every change is benchmarked against a latency target and a quality check. They work with serving, infrastructure and research teams.
Who this roadmap is for
Machine learning engineers who already serve models, systems and GPU programmers, and backend engineers who own model-serving costs. You should know Python, the transformer architecture and basic linear algebra; C++ or CUDA experience helps. If you only call hosted model APIs and never run your own, start with a different roadmap.
What you will be able to do
You will be able to read a profiler trace and say whether a workload is compute, memory or overhead bound, write and test fused kernels, tune continuous batching and the KV cache, quantise a model and measure the damage, deploy speculative decoding, choose a parallelism layout, and report cost per million tokens honestly.
The Inference Optimization Engineer roadmap
Inference Optimization Engineer
-
Phase 1 Foundations of inference performance
-
Phase 2 GPU performance fundamentals
-
Phase 3 Profiling and measurement
-
Phase 4 Kernels and compilers
-
Phase 5 Attention and the KV cache
-
Phase 6 Batching and scheduling
-
Phase 7 Quantisation and compression
-
Phase 8 Speculative decoding
-
Phase 9 Parallelism and large models
-
Phase 10 Serving engines
-
Phase 11 Benchmarking honestly
-
Phase 12 Cost, capacity and production
All topics, in order
Mark each topic Learning, Done or Skip, and sign in to save your place to your account. Done is your own word, not passing: a topic is passed when you score 50 or more on its questions. This order is the study plan.
-
Phase 1 · Foundations of inference performance
-
What an inference optimisation engineer does
You take a model someone else trained, on hardware someone else bought, and make every token faster and cheaper without changing what the model says. The work runs from kernels and number formats up to batching policy and engine flags, and every claim ends in a measurement. Platform engineers keep the fleet running; you decide why one replica serves twice the traffic of another, and prove it.
Reading
- NVIDIA: Mastering LLM techniques, inference optimization developer.nvidia.com
- How to Scale Your Model (Google DeepMind): Transformer inference jax-ml.github.io
- Databricks: LLM inference performance engineering best practices databricks.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Where a forward pass spends its time
A transformer layer is a few large matrix multiplies (the QKV and output projections, the MLP or expert layers) plus attention and a scatter of small ops: norms, rotary embeddings, activations, residual adds. The matmuls hold almost all the FLOPs; the small ops do little math but each one reads and writes whole tensors. Know which ops are which before you optimise, because fusing small ops and speeding up matmuls are different jobs.
Reading
- How to Scale Your Model: All the transformer math you need jax-ml.github.io
- kipply: Transformer inference arithmetic kipp.ly
- arXiv: Attention Is All You Need arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Prefill and decode
Generation runs in two phases. Prefill pushes the whole prompt through the model at once: big matrix multiplies, compute-bound, and it sets time to first token. Decode then emits one token per step, rereading every weight and the growing KV cache for very little math, so it is bound by memory bandwidth and sets inter-token latency. Ask which phase dominates your traffic before choosing a technique, because most optimisations help one phase and not the other.
Reading
- NVIDIA: Mastering LLM techniques, inference optimization developer.nvidia.com
- Hugging Face: LLM inference optimization huggingface.co
- arXiv: Efficiently Scaling Transformer Inference arxiv.org
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Latency versus throughput
Latency is how long one request waits; throughput is how many tokens the whole server produces per second. Batching more sequences together reuses each weight read across them, so throughput climbs, but every step does more work and each user's tokens arrive more slowly. Decide which one the workload pays for: a chat product defends tail latency, an overnight batch job buys throughput, and the right batch size follows from that choice.
Reading
- vLLM: Optimization and tuning docs.vllm.ai
- Databricks: LLM inference performance engineering best practices databricks.com
- Anyscale: How continuous batching enables 23x throughput anyscale.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
TTFT, inter-token latency and goodput
Time to first token runs from request arrival to the first streamed token, so it includes queueing as well as prefill. Inter-token latency (often reported as time per output token) is the gap between later tokens. End-to-end latency is both together. Goodput counts only requests that met their latency targets, which stops a server looking fast by finishing many requests late. Always state which definition and which percentile you mean.
Reading
- NVIDIA NIM: LLM benchmarking metrics docs.nvidia.com
- arXiv: DistServe, goodput-optimized LLM serving arxiv.org
- Anyscale: Reproducible performance metrics for LLM inference anyscale.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Inference arithmetic on paper
A dense model costs about 2 FLOPs per parameter per token, and each decode step must read every weight once. So an 8B model in BF16 (16 GB) on a GPU with about 3.35 TB/s of bandwidth cannot decode faster than roughly 200 tokens per second for one sequence, whatever the software. Work out this ceiling before profiling: it tells you how far from the hardware limit you are and which resource to attack.
Reading
- kipply: Transformer inference arithmetic kipp.ly
- How to Scale Your Model: Transformer inference jax-ml.github.io
- Baseten: A guide to LLM inference and performance baseten.co
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
-
Phase 2 · GPU performance fundamentals
-
Reading an accelerator for inference
Four numbers decide what an accelerator does for inference: memory bandwidth (decode speed), memory capacity (weights plus KV cache, so concurrency), peak FLOPs at the precisions you will actually run (prefill speed), and interconnect bandwidth (how well it splits a model). A newer chip with more FLOPs and the same bandwidth may decode no faster. Match the chip's strongest axis to your workload's bottleneck, then confirm with your own benchmark.
Reading
- NVIDIA: GPU performance background user's guide docs.nvidia.com
- How to Scale Your Model: How to think about GPUs jax-ml.github.io
- Hugging Face: GPU inference huggingface.co
- NVIDIA: Tensor Core GPU resources resources.nvidia.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
How a GPU executes a kernel
A kernel launches a grid of thread blocks; each block runs on one streaming multiprocessor, and its threads execute in warps of 32 that issue the same instruction together. The SM hides memory latency by switching between resident warps, so it needs enough of them (occupancy) and threads in a warp that take the same branch. Small grids that cannot fill every SM, a common shape in decode, leave most of the chip idle.
Reading
- NVIDIA: CUDA C++ programming guide docs.nvidia.com
- Modal GPU glossary: Streaming multiprocessor modal.com
- Modal GPU glossary: Occupancy modal.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The GPU memory hierarchy
Data lives in layers that get smaller and faster as they get closer to the math: HBM (tens of gigabytes), a shared L2 cache, per-SM shared memory and L1, then registers. A fast kernel loads each byte from HBM once, keeps it in shared memory or registers while it is reused, and writes results once. Most inference speedups, FlashAttention included, are really about moving fewer bytes between these layers.
Reading
- NVIDIA: CUDA C++ best practices guide, memory optimizations docs.nvidia.com
- Modal GPU glossary modal.com
- Horace He: Making deep learning go brrrr from first principles horace.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Tensor cores and precision
Tensor cores are the units that do small matrix multiplies in one instruction, and they supply nearly all of a GPU's advertised FLOPs. Each step down in precision (BF16 to FP8, FP8 to FP4 on chips that support it) roughly doubles peak math and halves bytes moved. Work that does not run on tensor cores, such as softmax or elementwise ops, gets a small fraction of that peak, which is why it must be fused or kept small.
Reading
- Modal GPU glossary: Tensor core modal.com
- NVIDIA: Matrix multiplication background user's guide docs.nvidia.com
- arXiv: FP8 formats for deep learning arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The roofline and arithmetic intensity
Arithmetic intensity is the FLOPs an operation does per byte it moves. Divide a chip's peak FLOPs by its bandwidth to get its ridge point: for an H100 SXM in BF16 that is roughly 300 FLOPs per byte. Below the ridge you are memory-bound and only fewer bytes help; above it you are compute-bound and only fewer or cheaper FLOPs help. Decode at small batch sits far below the ridge, which is why batching raises throughput.
Reading
- How to Scale Your Model: All about rooflines jax-ml.github.io
- Modal GPU glossary: Roofline model modal.com
- Modal GPU glossary: Arithmetic intensity modal.com
- NVIDIA: GPU performance background user's guide docs.nvidia.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Compute, memory or overhead bound
Every slow step is limited by one of three things: math throughput, memory bandwidth, or overhead (time the GPU spends idle waiting for launches, Python or the CPU). The cures do not transfer: lower precision helps memory-bound work, a better matmul kernel helps compute-bound work, and neither helps an overhead-bound loop that needs CUDA graphs or fewer launches. Name the regime from a profile first, then pick the cure.
Reading
- Horace He: Making deep learning go brrrr from first principles horace.io
- How to Scale Your Model: All about rooflines jax-ml.github.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
When the GPU waits on the host
In decode each step may launch hundreds of small kernels, and if the CPU cannot queue them faster than the GPU runs them, the GPU sits idle between kernels. Python dispatch, a stray .item() or print that forces synchronisation, tokenisation, sampling and scheduling all add host time per step. The sign is gaps on the GPU timeline. Fixes are fewer launches, CUDA graphs, and overlapping the next step's CPU work with the current step's GPU work.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Optimising beyond NVIDIA
AMD Instinct GPUs (ROCm, HIP kernels), Google TPUs (JAX and XLA) and AWS Trainium and Inferentia (Neuron) can cost less per token, and the reasoning carries over: rooflines, memory hierarchy, batching and quantisation all still apply. What does not carry over is the kernel library. Check that your engine, attention kernels and quantised formats are supported and fast on the target before you promise a saving, and benchmark on it yourself.
Reading
- AMD ROCm documentation rocm.docs.amd.com
- Google Cloud: TPU system architecture cloud.google.com
- AWS Neuron documentation awsdocs-neuron.readthedocs-hosted.com
- vLLM blog: EAGLE-3 speculative decoding on AMD Instinct GPUs vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 3 · Profiling and measurement
-
A method for performance work
Performance work goes wrong when you optimise what you guessed was slow. Work in a loop: fix a workload and a metric, compute the hardware ceiling, profile to find the biggest gap, form one hypothesis, change one thing, and measure again on the same setup. Keep a log of every run and its configuration. A two percent gain on a kernel that takes one percent of the step is not worth the review.
Reading
- Brendan Gregg: Performance analysis methodology brendangregg.com
- Brendan Gregg: The USE method brendangregg.com
- NVIDIA: CUDA C++ best practices guide (assess, parallelise, optimise, deploy) docs.nvidia.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Timing GPU code correctly
GPU work is queued asynchronously, so a CPU timer around a kernel call measures only how long it took to enqueue it. Synchronise before reading the clock, or record CUDA events on the stream, and run warmup iterations first so compilation, autotuning and caches do not pollute the number. Report a median over many runs, and flush or account for the L2 cache when timing small kernels that would otherwise run from cache.
Reading
- NVIDIA: How to implement performance metrics in CUDA C/C++ developer.nvidia.com
- PyTorch: CUDA semantics and asynchronous execution docs.pytorch.org
- Triton: triton.testing.do_bench triton-lang.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The PyTorch profiler
The PyTorch profiler records which operators ran, how long each spent on CPU and GPU, and which kernels they launched, and exports a trace you can open as a timeline. Start with the table sorted by GPU time to find the few ops that dominate a decode step, then open the trace to see gaps and synchronisation. Profile a handful of steady-state steps with a schedule, not the first step, which is full of one-off setup.
Reading
- PyTorch: torch.profiler docs.pytorch.org
- PyTorch: Profiler recipe docs.pytorch.org
- vLLM: Profiling vLLM docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Timelines with Nsight Systems
Nsight Systems puts CPU threads, CUDA API calls, kernels, memory copies and NCCL collectives on one timeline for the whole process. Use it to answer system questions: is the GPU idle between kernels, are copies overlapping compute, is one rank waiting on another, where does the scheduler spend its time. NVTX ranges you add around steps and phases make the timeline readable. Reach for kernel-level tools only after this view says which kernel matters.
Reading
- NVIDIA: Nsight Systems user guide docs.nvidia.com
- NVIDIA: Nsight Systems developer.nvidia.com
- vLLM: Profiling vLLM docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Kernel analysis with Nsight Compute
Nsight Compute replays one kernel and reports how close it came to the hardware limits: speed of light for memory and compute, achieved occupancy, cache hit rates, warp stall reasons and a roofline chart. A memory-bound kernel at 90 percent of peak bandwidth has little left to give; one at 40 percent has a fixable access pattern. Profile with realistic shapes, because the same kernel behaves very differently at batch 1 and batch 256.
Reading
- NVIDIA: Nsight Compute profiling guide docs.nvidia.com
- NVIDIA: Nsight Compute developer.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Bandwidth and FLOPs utilisation
Model bandwidth utilisation (MBU) is the bytes a decode step must read (weights plus KV cache) divided by step time, as a share of peak bandwidth. Model FLOPs utilisation (MFU) is achieved model FLOPs over peak FLOPs, and suits compute-bound prefill. Use MBU for decode and MFU for prefill: together they say how much headroom is left. A decode loop at 30 percent MBU has real gains to find; one at 80 percent is near the wall.
Reading
- Databricks: LLM inference performance engineering (defines MBU) databricks.com
- arXiv: PaLM (defines model FLOPs utilisation) arxiv.org
- How to Scale Your Model: Transformer inference jax-ml.github.io
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 4 · Kernels and compilers
-
Kernel fusion
Each unfused op reads its input from HBM and writes its output back, so a chain of small elementwise ops (bias, activation, residual add, norm) spends its time moving the same tensor in and out. Fusion runs the chain as one kernel that keeps intermediate values in registers, cutting both bytes and launches. Fuse memory-bound neighbours, and fold small ops into a matmul's epilogue where the library allows it.
Reading
- Horace He: Making deep learning go brrrr from first principles horace.io
- Triton tutorial: Fused softmax triton-lang.org
- arXiv: FlashAttention arxiv.org
- NVIDIA: Getting started with CUDA graphs developer.nvidia.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Writing CUDA kernels for inference
A hand-written CUDA kernel earns its maintenance cost only where libraries and compilers fall short: an unusual fused op, a new quantised format, a shape the library handles badly. The basics decide most of the speed: coalesced global loads so a warp reads contiguous bytes, shared memory tiles for reuse, vectorised loads, and enough blocks to fill every SM. Write it last, after a profile proves the op matters.
Reading
- NVIDIA: CUDA C++ programming guide docs.nvidia.com
- NVIDIA: CUDA C++ best practices guide docs.nvidia.com
- GPU MODE lectures github.com
- PyTorch: Custom C++ and CUDA operators docs.pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Kernels in Triton
Triton lets you write a GPU kernel in Python at the level of blocks rather than threads: you load a tile, compute on it and store it, and the compiler handles thread mapping, shared memory and much of the scheduling. Autotuning tries block sizes and warp counts for each shape. It gets close to hand-tuned CUDA for fused and memory-bound kernels in far less code, which is why compilers and engines generate or ship many Triton kernels.
Reading
- Triton tutorials triton-lang.org
- Triton tutorial: Matrix multiplication triton-lang.org
- Liger Kernel: Triton kernels for LLMs github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Fast matrix multiplies
Matrix multiplies carry most of the FLOPs, and libraries such as cuBLAS and CUTLASS get them near peak by tiling: each block loads tiles of both inputs into shared memory and feeds tensor cores from registers. Shapes matter: dimensions that are not multiples of the tile size, or a decode batch so small that the matmul is really a matrix-vector product, waste the hardware. Fusing work into the epilogue saves a pass over the output.
Reading
- NVIDIA: Matrix multiplication background user's guide docs.nvidia.com
- NVIDIA CUTLASS documentation docs.nvidia.com
- NVIDIA cuBLAS documentation docs.nvidia.com
- Simon Boehm: How to optimise a CUDA matmul kernel siboehm.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
torch.compile for inference
torch.compile traces your PyTorch code into a graph and generates fused kernels for it, often in Triton, so you get fusion without writing kernels. It pays most on memory-bound decode code full of small ops. Watch for graph breaks (code it cannot trace, which splits the graph) and recompiles (new shapes or Python values that trigger a fresh compile mid-serving). Mark dynamic dimensions and warm up every shape bucket before taking traffic.
Reading
- PyTorch: torch.compiler docs.pytorch.org
- PyTorch tutorial: Introduction to torch.compile docs.pytorch.org
- PyTorch blog: Accelerating generative AI, part 2 (gpt-fast) pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
CUDA graphs
A CUDA graph records a sequence of kernel launches once and replays the whole sequence with a single launch, removing per-kernel CPU overhead from an overhead-bound decode step. The price is rigidity: shapes, memory addresses and control flow are frozen at capture. Engines therefore capture one graph per batch-size bucket and pad batches up to the nearest bucket. Too many buckets cost memory and startup time; too few waste compute on padding.
Reading
- NVIDIA: Getting started with CUDA graphs developer.nvidia.com
- PyTorch: CUDA graphs in CUDA semantics docs.pytorch.org
- vLLM: CUDA graphs design docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Ahead-of-time engines
TensorRT and ONNX Runtime take a model graph and build an engine for specific hardware, precision and shape ranges, choosing the fastest kernel for each layer and fusing where they can. Ahead-of-time building can beat eager PyTorch, especially for encoders and vision models with fixed shapes. The cost is a build step per GPU type and version, shape profiles you must declare, and less flexibility when the model changes.
Reading
- NVIDIA TensorRT documentation docs.nvidia.com
- ONNX Runtime: Performance onnxruntime.ai
- Hugging Face Optimum huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Testing a kernel's numbers
A faster kernel that is subtly wrong is worse than a slow one, because the damage shows up later as worse answers. Test every kernel against a simple reference implementation, in higher precision where you can, over realistic and awkward shapes (odd lengths, a batch of one, padding). Set tolerances that fit the precision, since BF16 and FP8 never match FP32 bit for bit, and add an end-to-end output check before shipping.
Reading
- PyTorch: torch.testing.assert_close docs.pytorch.org
- NVIDIA: Floating point and IEEE 754 compliance for GPUs docs.nvidia.com
- Thinking Machines: Defeating nondeterminism in LLM inference thinkingmachines.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 5 · Attention and the KV cache
-
What attention costs
In prefill, attention compares every prompt token with every earlier one, so its compute and naive memory grow with the square of the prompt length and come to dominate past a few thousand tokens. In decode each new token reads the keys and values of every earlier token, so the cost per step grows linearly with context and is pure memory traffic. Short chats are matmul-bound; long documents and long reasoning traces are attention-bound.
Reading
- arXiv: Attention Is All You Need arxiv.org
- How to Scale Your Model: All the transformer math you need jax-ml.github.io
- kipply: Transformer inference arithmetic kipp.ly
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
FlashAttention
Standard attention writes the full score matrix to HBM, softmaxes it and reads it back. FlashAttention instead loads blocks of queries, keys and values into shared memory and computes the softmax incrementally (online softmax, rescaling a running maximum and sum), so the score matrix never leaves the chip. The result is exact, not approximate, and memory grows linearly with length. Later versions add better work partitioning and use newer hardware features such as asynchronous copies and FP8.
Reading
- arXiv: FlashAttention arxiv.org
- arXiv: FlashAttention-2 arxiv.org
- arXiv: FlashAttention-3 arxiv.org
- arXiv: Online normaliser calculation for softmax arxiv.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Attention kernels for decode
At decode a sequence has a single query token, so a kernel that parallelises over queries and heads launches too few blocks to fill the GPU. Split-KV decoding (Flash-Decoding) splits the cached keys and values along the sequence, lets many blocks work on one request, then merges their partial softmax results. Serving libraries such as FlashInfer add kernels for paged caches, shared prefixes and mixed prefill and decode batches; engines choose among them per batch shape.
Reading
- Stanford CRFM: Flash-Decoding for long-context inference crfm.stanford.edu
- arXiv: FlashInfer, attention engine for LLM serving arxiv.org
- FlashInfer on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Paged KV cache
Reserving one contiguous KV buffer per request at its maximum length wastes most of the memory, because few requests reach that length. Paged KV cache splits the cache into fixed-size blocks allocated as tokens arrive and tracked by a block table, like virtual memory pages. Waste drops to the last partly filled block, more sequences fit, and blocks can be shared between requests with a common prefix. Attention kernels must then read through the block table.
Reading
- arXiv: Efficient memory management for LLM serving with PagedAttention arxiv.org
- vLLM: Paged attention design docs.vllm.ai
- Hugging Face: KV cache strategies huggingface.co
Start the 6 questionsTest yourself on this topic
6 graded questions · scored out of 100 with feedback · free
-
MQA, GQA and MLA
KV cache per token is 2 times layers times KV heads times head dimension times bytes per value, so the number of KV heads is a direct multiplier. Multi-query attention shares one KV head across all query heads; grouped-query attention shares each KV head across a group (Llama 3 70B keeps 8 KV heads for 64 query heads, an eighth of the cache). Multi-head latent attention, from DeepSeek, caches a small compressed latent instead and needs its own kernels.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The serving memory budget
GPU memory holds the weights, a working set for activations and CUDA graphs, and everything left over becomes KV cache, which sets how many tokens can be in flight. A 70B model with GQA costs about 320 KB of BF16 KV per token, so 100 concurrent 8K-token requests need about 270 GB of cache alone. Levers on the budget: quantise weights or KV, cap context length or concurrency, add GPUs, or offload cold blocks to host memory.
Reading
- vLLM: Optimization and tuning docs.vllm.ai
- Hugging Face: KV cache strategies huggingface.co
- LMCache documentation (KV offload and sharing) docs.lmcache.ai
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Quantising the KV cache
Storing keys and values in FP8 instead of BF16 halves the cache, so twice the tokens fit and each decode step reads half the attention bytes. Lower bit widths (4 or 2 bits with per-channel key scales and per-token value scales) go further at more risk. The damage concentrates on long contexts and retrieval of exact details, so evaluate on long inputs, not short chat, and check that the attention kernel supports the format natively.
Reading
- vLLM: Quantized KV cache docs.vllm.ai
- arXiv: KIVI, 2-bit asymmetric KV cache quantisation arxiv.org
- Hugging Face: KV cache strategies huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Prefix caching
Many requests start with the same tokens: a system prompt, a tool list, a shared document, the earlier turns of a chat. Prefix caching keeps the KV blocks for those tokens and reuses them, so prefill only runs on the new suffix and time to first token falls sharply. Hits need an exact token match from the start, so put stable content first and variable content last, and route repeat users to the replica that holds their cache.
Reading
- vLLM: Automatic prefix caching design docs.vllm.ai
- arXiv: SGLang (RadixAttention) arxiv.org
- arXiv: Hydragen, inference with shared prefixes arxiv.org
- Anthropic: Prompt caching docs.anthropic.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Long context: windows, sparsity and eviction
When context runs to hundreds of thousands of tokens, full attention and a full KV cache become the cost. Models built with sliding-window layers keep only recent tokens in those layers; sparse attention reads a chosen subset of blocks; eviction methods drop tokens judged unimportant, keeping a few initial attention sink tokens. Only the first is free, because the model was trained that way. The others change outputs, so test them on real long-context tasks.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 6 · Batching and scheduling
-
Continuous batching
Static batching runs a group of requests until the longest one finishes, leaving slots idle as shorter ones end. Continuous batching schedules at every decode step instead: finished sequences leave, waiting ones join, and the batch stays full. Combined with paged KV memory it is what lets one GPU serve many users at once. The scheduler now decides latency, so its admission rules and limits are as important as the kernels.
Reading
- USENIX OSDI 2022: Orca, iteration-level scheduling usenix.org
- Anyscale: Continuous batching for LLM inference anyscale.com
- vLLM documentation docs.vllm.ai
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Chunked prefill
A long prompt's prefill can take hundreds of milliseconds, and in a mixed batch every decoding user waits through it, which shows up as inter-token latency spikes. Chunked prefill splits the prompt into pieces of a set token budget and schedules each piece alongside ongoing decodes, so steps stay short and the GPU mixes compute-heavy and memory-heavy work. Smaller chunks protect inter-token latency; larger ones finish prefill sooner and favour time to first token.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Sizing the batch and token budget
Engines cap each step with two limits: how many sequences can run at once and how many tokens a single step may process. Raising them lifts throughput until KV memory runs out or steps grow long enough to break the inter-token latency target. Tune them by sweeping on your real traffic and reading tail latency, not by maximising both. Watch preemption counts: a budget that admits more than memory can hold buys restarts, not throughput.
Reading
- vLLM: Engine arguments docs.vllm.ai
- vLLM: Optimization and tuning docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Scheduling and preemption
The scheduler decides who runs next: first come first served is simple, priorities protect interactive traffic from batch jobs, and fairness rules stop one tenant's long prompts starving everyone. When KV memory runs out mid-generation it must preempt a sequence, either dropping its cache and recomputing it later or swapping it to host memory. Recompute costs GPU time, swap costs PCIe bandwidth; frequent preemption means admission is too generous.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Disaggregating prefill and decode
Prefill wants compute and decode wants bandwidth, and on one GPU they interfere. Disaggregated serving runs them on separate pools and ships each request's KV cache from the prefill GPU to a decode GPU, so each pool is tuned and sized for its own latency target. It raises goodput when prompts are long and targets are tight, but adds a KV transfer on every request and a ratio of pools to tune. Measure it against chunked prefill on one pool first.
Reading
- arXiv: DistServe, disaggregating prefill and decoding arxiv.org
- arXiv: Splitwise, phase splitting for LLM inference arxiv.org
- vLLM: Disaggregated prefilling docs.vllm.ai
- NVIDIA Dynamo on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
The cost of structured output
Constrained decoding forces output to match a JSON schema or grammar by masking invalid tokens before sampling. The mask is computed on the CPU each step, and if it is slow the GPU waits, so a naive grammar can halve decode speed. Fast backends precompile the grammar, cache masks for context-independent tokens and compute the mask while the GPU runs the forward pass. Measure throughput with and without constraints on your own schemas.
Reading
- arXiv: XGrammar, structured generation for LLMs arxiv.org
- vLLM: Structured outputs docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Batching many LoRA adapters
When many fine-tunes share one base model as LoRA adapters, a batch can mix requests for different adapters. The base weights run as one matmul for everyone, and a specialised kernel applies each request's small low-rank update, so a mixed batch costs only a little more than a plain one. Throughput drops as adapter count and rank rise, and swapping adapters into GPU memory adds latency, so cap the resident set and benchmark at your real adapter mix.
Reading
- arXiv: Punica, multi-tenant LoRA serving arxiv.org
- arXiv: S-LoRA, serving thousands of concurrent adapters arxiv.org
- vLLM: LoRA adapters docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 7 · Quantisation and compression
-
What quantisation buys
Quantisation stores weights, and sometimes activations or KV, in fewer bits. Fewer bytes per weight make bandwidth-bound decode faster and free memory for KV cache, so more requests fit. Faster math is a separate gain that only appears when the GPU has native support for the format, such as FP8 tensor cores; otherwise values are converted back to BF16 before the multiply. Treat every quantised model as a new model and prove its quality on your evals.
Reading
- Hugging Face: Quantization overview huggingface.co
- vLLM: Quantization docs.vllm.ai
- arXiv: GPTQ post-training quantisation arxiv.org
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Low-precision number formats
INT8 and INT4 are evenly spaced integers with a scale; FP8 (E4M3 for inference) keeps an exponent, so it handles a wide range of values better. Four-bit floating formats use small blocks that share a scale: MXFP4 has 32 values per power-of-two scale, NVFP4 has 16 values per FP8 scale plus a tensor-level scale. Scale granularity (per tensor, channel, group or block) trades accuracy against overhead. Check which formats your GPU runs natively.
Reading
- arXiv: FP8 formats for deep learning arxiv.org
- arXiv: Microscaling data formats for deep learning arxiv.org
- NVIDIA: Introducing NVFP4 for low-precision inference developer.nvidia.com
- OCP: Microscaling formats (MX) v1.0 specification opencompute.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Weight-only quantisation
Weight-only schemes such as W4A16 store weights in 4 bits and keep activations in 16, so a decode step reads about a quarter of the weight bytes. GPTQ quantises layer by layer and adjusts remaining weights to cancel the error; AWQ scales the channels that matter most to large activations before rounding. It is the best fit for small-batch, bandwidth-bound decode; at large batch the dequantise step costs compute and the gain shrinks.
Reading
- arXiv: GPTQ post-training quantisation arxiv.org
- arXiv: AWQ, activation-aware weight quantisation arxiv.org
- vLLM: Quantization docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Quantising weights and activations
To use low-precision tensor cores for the multiply itself, activations must be quantised too, which is harder because a few channels carry outliers far larger than the rest. SmoothQuant moves that difficulty into the weights with a per-channel rescale; rotation methods such as QuaRot spread outliers across channels before rounding. FP8 for both (W8A8) is usually the safest compute-bound win; 4-bit activations need careful method choice and evaluation.
Reading
- arXiv: SmoothQuant arxiv.org
- arXiv: LLM.int8(), outlier features at scale arxiv.org
- arXiv: QuaRot, outlier-free 4-bit inference arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Calibration
Most post-training methods run a small calibration set through the model to choose scales and measure the error each layer introduces. The set should look like production traffic: a quantiser calibrated on generic web text can hurt a code or multilingual model on exactly the inputs that matter. A few hundred representative samples is typical. Static activation scales are cheaper at runtime but fragile to new distributions; dynamic scales cost a little more and adapt.
Reading
- LLM Compressor documentation docs.vllm.ai
- arXiv: GPTQ post-training quantisation arxiv.org
- NVIDIA TensorRT Model Optimizer on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Measuring quantisation damage
Perplexity on a generic corpus can barely move while a quantised model loses ground on reasoning, code, long context or a minority language. Evaluate the tasks your product depends on, compare against the original model under identical settings, and look at the KL divergence between the two models' token distributions to catch drift that accuracy averages hide. Run enough samples that the difference you report is larger than the noise.
Reading
- arXiv: Give me BF16 or give me death? Quantisation trade-offs arxiv.org
- EleutherAI: lm-evaluation-harness github.com
- Hugging Face: Quantization overview huggingface.co
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Quantisation toolchains and checkpoints
A quantised checkpoint is only useful if your engine has fast kernels for its exact format on your GPU. Toolchains such as LLM Compressor, NVIDIA's TensorRT Model Optimizer and torchao apply a recipe (method, bit widths, which layers to skip) and save a checkpoint with its scales in a format engines load. Keep sensitive layers such as embeddings and the output head in higher precision, record the recipe with the model, and benchmark the loaded result.
Reading
- LLM Compressor on GitHub github.com
- NVIDIA TensorRT Model Optimizer on GitHub github.com
- PyTorch torchao documentation docs.pytorch.org
- vLLM: Quantization docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Pruning and distillation
Pruning removes parts of a model; distillation trains a smaller student to imitate a larger teacher's outputs. Structured pruning that drops whole layers, heads or MLP channels gives a genuinely smaller dense model that every kernel runs faster, and it usually needs some distillation afterwards to recover quality. Both are training jobs, not flags, so they pay off for a model you will serve at volume for months. Re-run the full eval suite on the result.
Reading
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Structured sparsity on hardware
Setting half the weights to zero at random saves nothing on a GPU, because dense kernels still read and multiply the zeros. NVIDIA's 2:4 pattern, two nonzeros in every group of four, is supported by sparse tensor cores from Ampere on and can double matmul math while halving weight storage. The gain arrives only in compute-bound matmuls and needs pruning methods that keep accuracy, so measure both the speedup and the quality loss.
Reading
- arXiv: Accelerating sparse deep neural networks (2:4) arxiv.org
- NVIDIA: Accelerating inference with sparsity on Ampere and TensorRT developer.nvidia.com
- arXiv: SparseGPT, one-shot pruning arxiv.org
- arXiv: Wanda, pruning by weights and activations arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 8 · Speculative decoding
-
Speculative decoding
Decode is bandwidth-bound, so checking several tokens in one forward pass costs about the same as generating one. Speculative decoding exploits this: a cheap drafter proposes a few tokens, the target model scores them all in one pass, and a rejection-sampling rule keeps the longest acceptable run plus one token of its own. Done correctly the output distribution is exactly the target's, so it is a pure latency win whenever drafts are accepted often enough.
Reading
- arXiv: Fast inference from transformers via speculative decoding arxiv.org
- arXiv: Accelerating LLM decoding with speculative sampling arxiv.org
- Hugging Face: Assisted generation huggingface.co
- vLLM: Speculative decoding docs.vllm.ai
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Acceptance rate and expected speedup
If each draft token is accepted with probability a and you draft k tokens, a verification step yields on average (1 minus a to the power k+1) divided by (1 minus a) tokens. At a = 0.8 and k = 4 that is about 3.4 tokens per target pass; at a = 0.5 it is under 2. Subtract the drafter's own cost and the extra verify work to get the real speedup. Measure acceptance on your traffic, because it varies widely by task and temperature.
Reading
- arXiv: Fast inference from transformers via speculative decoding arxiv.org
- vLLM: Speculative decoding docs.vllm.ai
- PyTorch blog: A hitchhiker's guide to speculative decoding pytorch.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Draft heads: Medusa, EAGLE and MTP
Instead of a separate small model, a draft head reads the target's own hidden states and predicts the next few tokens, so it is cheap and already knows the context. Medusa adds parallel heads and verifies a tree of candidates; EAGLE drafts at the feature level, and its later versions draw on several layers for higher acceptance. Some models ship multi-token prediction modules from training, as DeepSeek-V3 does, that can serve as the drafter directly.
Reading
- arXiv: Medusa, multiple decoding heads arxiv.org
- arXiv: EAGLE, speculative sampling at the feature level arxiv.org
- arXiv: EAGLE-3 arxiv.org
- arXiv: DeepSeek-V3 technical report (multi-token prediction) arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Speculation without a draft model
When output repeats text already in the context, as in code edits, document rewrites, extraction or RAG answers that quote sources, you can draft by matching the last few generated tokens against the prompt and proposing what followed them there. N-gram or prompt lookup drafting needs no extra model or memory and costs almost nothing when it misses. It shines on copy-heavy traffic and does little for open-ended writing, so check acceptance per workload.
Reading
- Prompt lookup decoding on GitHub github.com
- arXiv: Lookahead decoding arxiv.org
- vLLM: Speculative decoding (n-gram) docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Training a draft for your traffic
A drafter trained on generic chat accepts poorly on your domain, your chat template or a fine-tuned target. Train or fine-tune it on outputs the target itself generates for prompts like yours, so it learns the target's habits, and retrain whenever the target changes. Open tooling such as vLLM's Speculators and SGLang's SpecForge packages this training. Track acceptance length in production as the health metric for the drafter.
Reading
- vLLM Speculators on GitHub github.com
- SGLang SpecForge on GitHub github.com
- arXiv: EAGLE-3 arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Speculation under load
Speculation spends spare compute to save memory-bound steps. At low batch there is plenty spare; as batches grow, decode moves toward compute-bound, and verifying several draft tokens for every sequence starts to cost real throughput. A setting that halves latency at quiet hours can lower capacity at peak. Benchmark across load levels, and prefer engines that shorten or disable drafting as the batch fills.
Reading
- arXiv: TurboSpec, closed-loop speculation control for goodput arxiv.org
- vLLM: Speculative decoding docs.vllm.ai
- Hugging Face TGI: Speculation huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 9 · Parallelism and large models
-
Tensor and pipeline parallelism
Tensor parallelism splits each layer's weight matrices across GPUs, so every GPU works on every token and the shards combine their results with collectives in every layer; it cuts per-token latency but needs a fast link. Pipeline parallelism gives each GPU a run of whole layers and passes activations along, which needs little bandwidth but leaves stages idle unless many micro-batches keep the pipe full. Inside one NVLink node use tensor parallelism; across nodes add pipeline stages.
Reading
- arXiv: Megatron-LM, tensor model parallelism arxiv.org
- NVIDIA Megatron-LM on GitHub github.com
- vLLM: Parallelism and scaling docs.vllm.ai
- How to Scale Your Model: Sharded matrices jax-ml.github.io
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
The cost of tensor-parallel communication
In the usual tensor-parallel layout each transformer layer ends its attention and its MLP with an all-reduce, so communication grows with layers and batch while each GPU's matmuls shrink as you add GPUs. On NVLink that cost stays small up to the size of one node; over PCIe or between nodes it can dominate a decode step. Add tensor-parallel degree only while measured latency keeps falling, and compare against more replicas at a lower degree.
Reading
- arXiv: Megatron-LM, tensor model parallelism arxiv.org
- NVIDIA: NCCL user guide docs.nvidia.com
- arXiv: Efficiently scaling transformer inference arxiv.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Overlapping communication with compute
A collective that runs while the GPU computes costs nothing; one that runs between compute steps adds straight to latency. Overlap techniques split a batch or a matmul into chunks so one chunk's communication proceeds while the next chunk computes, or run two micro-batches in alternation so each hides the other's exchange. Check the timeline: if collectives sit in gaps with idle compute around them, overlap is the next win.
Reading
- Hugging Face: The ultra-scale playbook huggingface.co
- DeepSeek DeepEP on GitHub github.com
- NVIDIA: Nsight Systems user guide docs.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Mixture-of-experts inference
A mixture-of-experts model routes each token to a few experts out of many, so it does the math of a much smaller dense model: DeepSeek-V3 has 671B parameters but about 37B active per token. Memory does not shrink, because every expert must stay resident, and a decode batch touches many different experts, so weight reads grow with batch. MoE is cheap per FLOP and expensive per byte of memory, and it needs grouped matmul kernels that handle uneven expert loads.
Reading
- arXiv: DeepSeek-V3 technical report arxiv.org
- arXiv: Mixtral of experts arxiv.org
- arXiv: Switch transformers arxiv.org
- DeepSeek DeepGEMM on GitHub github.com
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Expert parallelism and all-to-all
Expert parallelism places different experts on different GPUs and sends each token to wherever its chosen experts live, with an all-to-all exchange before and after every MoE layer. It lets very large MoE models run with big batches per expert, but popular experts become hot spots and the whole step waits for the busiest GPU. Dispatch kernels built for this traffic, redundant copies of hot experts, and load-aware placement keep the GPUs even.
Reading
- vLLM: Expert parallel deployment docs.vllm.ai
- DeepSeek DeepEP on GitHub github.com
- LMSYS: Large-scale expert parallelism in SGLang lmsys.org
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Context parallelism for long prompts
When a single prompt runs to hundreds of thousands of tokens, prefill on one GPU takes too long even with FlashAttention. Context parallelism splits that sequence across GPUs: each holds a slice of the tokens and their KV, and the GPUs pass key and value blocks around a ring so every query still sees every earlier token. It cuts time to first token for very long prompts at the price of communication, and it rarely helps short ones.
Reading
- arXiv: Ring attention with blockwise transformers arxiv.org
- Hugging Face: The ultra-scale playbook huggingface.co
- vLLM: Parallelism and scaling docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Replicas or shards
Sharding a model across GPUs answers one question: does it fit, with enough room left for KV cache? Replicas answer another: how much traffic can the fleet take? If the model fits on one GPU with room for cache, several independent replicas usually give more throughput per GPU than one sharded copy, and a failure takes out only one of them. Shard to the smallest degree that fits and meets latency, then scale out with replicas.
Reading
- vLLM: Parallelism and scaling docs.vllm.ai
- Ray Serve documentation docs.ray.io
- Databricks: LLM inference performance engineering best practices databricks.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
-
Phase 10 · Serving engines
-
Choosing a serving engine
vLLM, SGLang and TensorRT-LLM all ship continuous batching, paged KV, quantised kernels, speculation and parallelism, so the choice turns on specifics: does it support your model and GPU well today, what goodput does it reach on your workload at your latency target, and how quickly does it adopt new models and techniques. Benchmark two candidates on your own traffic rather than trusting launch charts, and keep the API in front of the engine standard so you can switch.
Reading
- vLLM documentation docs.vllm.ai
- SGLang documentation docs.sglang.ai
- NVIDIA TensorRT-LLM documentation nvidia.github.io
- Hugging Face: Text Generation Inference huggingface.co
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Inside vLLM
vLLM separates an API server from an engine core that runs the scheduling loop: each step the scheduler picks which requests get how many tokens, the KV cache manager hands out paged blocks and finds prefix hits, and workers run the model with attention backends and CUDA graphs. Knowing the parts tells you where a setting acts: memory utilisation sizes the KV pool, batched token limits shape the scheduler, and compilation options change the kernels.
Reading
- vLLM: Architecture overview docs.vllm.ai
- vLLM blog: vLLM V1, a major upgrade to the core architecture blog.vllm.ai
- vLLM: Engine arguments docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Inside SGLang
SGLang stores the KV cache in a radix tree keyed by token prefixes (RadixAttention), so any request that shares a prefix with an earlier one reuses its cache automatically, which suits agents, few-shot prompts and multi-turn chat. Its scheduler prepares the next batch on the CPU while the GPU runs the current one, hiding host overhead. It also ships a frontend language for multi-call programs and a cache-aware router for replicas.
Reading
- arXiv: SGLang, efficient execution of structured LM programs arxiv.org
- LMSYS: SGLang v0.4, zero-overhead batch scheduler lmsys.org
- SGLang on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
TensorRT-LLM
TensorRT-LLM is NVIDIA's inference library for its own GPUs: in-flight batching, paged KV cache, speculative decoding, parallelism and the fastest kernels for new NVIDIA formats such as FP8 and FP4, often first. It pairs with NVIDIA's Model Optimizer for quantisation and with Triton Inference Server or Dynamo for serving. Choose it when you run NVIDIA only and need peak per-GPU numbers, and budget for its tighter coupling to specific GPU and software versions.
Reading
- NVIDIA TensorRT-LLM documentation nvidia.github.io
- NVIDIA TensorRT-LLM on GitHub github.com
- NVIDIA TensorRT Model Optimizer on GitHub github.com
- NVIDIA Triton Inference Server user guide docs.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Optimising embedding, vision and diffusion models
The same method applies beyond chat models, with different bottlenecks. Embedding models and rerankers are encoders with no decode loop: they are compute-bound, gain most from batching by similar length, FP8 or INT8 and compiled engines. Diffusion models run the same network for many denoising steps, so cutting steps, compiling the network and caching repeated work dominate. Profile first; the regime decides the technique, not the model family.
Reading
- Hugging Face: Text Embeddings Inference github.com
- Hugging Face Diffusers: Speed and memory optimisations huggingface.co
- NVIDIA TensorRT documentation docs.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 11 · Benchmarking honestly
-
Benchmarking inference
An inference benchmark is only evidence if it matches production: the same model and precision, realistic prompt and output lengths, the concurrency you expect, and the metrics users feel (time to first token, inter-token latency and end-to-end latency at p50, p95 and p99) alongside throughput. Keep the benchmark as a script in the repo and run it on every engine, kernel or config change, then watch the same metrics live to catch regressions it missed.
Reading
- vLLM: Benchmark suites docs.vllm.ai
- vLLM: bench serve docs.vllm.ai
- NVIDIA NIM: LLM benchmarking metrics docs.nvidia.com
- vLLM: Metrics docs.vllm.ai
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Modelling the real workload
Fixed 512 in, 128 out tells you little about a product whose prompts range from 200 tokens to 30,000 and whose outputs depend on the task. Build the benchmark workload from production logs: the distributions of input and output length, the share of requests that share a prefix, the arrival pattern and its bursts, the sampling settings. A change that wins on uniform short prompts can lose on a long tail of long ones.
Reading
- Kubernetes SIG: inference-perf github.com
- NVIDIA AIPerf on GitHub github.com
- vLLM: Benchmark suites docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Load generators and sweeps
A closed-loop load test holds a fixed number of users who each wait for a reply before sending again, so a slow server simply receives less load. An open-loop test sends requests at a set rate regardless, which exposes queueing the way real traffic does. Sweep the load from idle to past saturation and plot latency against throughput; a single point at one load level hides where the knee is and how badly the tail degrades.
Reading
- vLLM: bench serve docs.vllm.ai
- NVIDIA AIPerf on GitHub github.com
- Ray LLMPerf on GitHub github.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Throughput at the latency target
Peak tokens per second is reached at a batch so large that no user would wait for it, so it says little about what a GPU can sell. Report the highest throughput, or request rate, at which a stated share of requests still meets the time to first token and inter-token targets: goodput at the SLO. Compare configurations on that number, and show the latency against throughput curve so a reader can pick a different target.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Noise, repeats and fair comparisons
GPU results vary run to run with clocks, temperature, power limits, other tenants on the node and which kernels the autotuner picked. Warm up, run each configuration several times, report the spread as well as the median, and treat any gain smaller than the spread as no gain. Change one variable at a time on the same machine and software versions, and give each side its best settings, because a tuned candidate against a default baseline proves nothing.
Reading
- Brendan Gregg: Active benchmarking brendangregg.com
- Triton: triton.testing.do_bench triton-lang.org
- NVIDIA: How to implement performance metrics in CUDA C/C++ developer.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Quality checks for every speedup
Every optimisation that touches numbers, whether a new kernel, a lower precision, a KV format, an attention shortcut or a compiler change, can shift outputs, and a speed benchmark will never notice. Gate each change on a fixed accuracy suite that covers your product's tasks plus long-context and edge cases, compared against the reference configuration with a threshold agreed in advance. Lossless techniques such as correct speculative decoding still get the check, because bugs are not lossless.
Reading
- EleutherAI: lm-evaluation-harness github.com
- arXiv: Give me BF16 or give me death? Quantisation trade-offs arxiv.org
- PyTorch: torch.testing.assert_close docs.pytorch.org
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Nondeterminism and batch invariance
The same prompt at temperature zero can return different text on a busy server, mainly because kernels choose different reduction orders for different batch sizes, and floating-point addition is not associative. Results then depend on who else was in the batch. For most products that is acceptable, but it breaks bitwise evals, reproducible debugging and some RL training loops. Batch-invariant kernels fix it at some speed cost; decide whether you need them.
Reading
- Thinking Machines: Defeating nondeterminism in LLM inference thinkingmachines.ai
- NVIDIA: Floating point and IEEE 754 compliance for GPUs docs.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Reading public benchmarks and vendor claims
MLPerf Inference publishes audited results under fixed rules, with a closed division that holds the model and accuracy target constant and scenarios with latency limits, which makes it the most comparable public source. Leaderboards of API providers and vendor launch charts are useful but each picks its own workload. Before trusting any number, ask what model and precision, which input and output lengths, what concurrency and latency target, and whether quality was checked.
Reading
- MLCommons: MLPerf Inference datacenter mlcommons.org
- Artificial Analysis: Methodology artificialanalysis.ai
- Brendan Gregg: Active benchmarking brendangregg.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
-
Phase 12 · Cost, capacity and production
-
Cost and latency trade-offs
Production tuning is one constrained problem: the lowest cost per token that still meets the latency target at the traffic you expect. Bigger batches, lower precision, smaller models, fewer GPUs per replica and speculation each move cost and latency, sometimes in opposite directions. Write the constraint down first, measure each lever's effect on both sides under realistic load, and stop when the next lever costs more in latency or quality than it saves.
Reading
- NVIDIA: Mastering LLM techniques, inference optimization developer.nvidia.com
- vLLM: Optimization and tuning docs.vllm.ai
- Databricks: LLM inference performance engineering best practices databricks.com
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Cost per million tokens
Unit cost comes from two numbers: what the GPU costs per hour and how many tokens it produces per hour at your latency target. A GPU at, say, 3 dollars an hour serving 1,500 tokens per second of goodput costs about 56 cents per million tokens. Input and output tokens cost very differently (prefill is cheap per token, decode is not), so price them separately, and use goodput rather than peak throughput or the figure will be too low.
Reading
- Google Cloud: GPU pricing cloud.google.com
- Databricks: LLM inference performance engineering best practices databricks.com
- Artificial Analysis: Methodology artificialanalysis.ai
Start the 4 questionsTest yourself on this topic
4 graded questions · scored out of 100 with feedback · free
-
Right-sizing model, GPU and precision
Model size, GPU type and precision are one decision, not three. A smaller or quantised model may fit on one cheaper GPU with room for cache and beat a larger model sharded across four, or a newer GPU with native FP8 may halve the fleet. List candidate combinations that meet the quality bar, benchmark each at your latency target, and pick on cost per million tokens. Revisit whenever a new model or GPU arrives.
Reading
- NVIDIA: Mastering LLM techniques, inference optimization developer.nvidia.com
- arXiv: Give me BF16 or give me death? Quantisation trade-offs arxiv.org
- Hugging Face: GPU inference huggingface.co
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Changing the workload, not the engine
The cheapest token is one you never process. Trim system prompts and retrieved context that the model does not use, cap output length where the product allows, put shared content first so prefix caching hits, and send work that can wait through a batch path at lower priority. These changes need agreement from product teams, but they often save more than a month of kernel work. Measure the quality effect of each before it ships.
Reading
- vLLM: Automatic prefix caching design docs.vllm.ai
- OpenAI: Prompt caching platform.openai.com
- Anthropic: Prompt caching docs.anthropic.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Autoscaling with slow starts
A new LLM replica may take minutes to pull an image, load weights, compile and capture graphs, so a scaler that reacts to requests per second adds capacity after the burst has already hurt users. Scale on signals that rise before saturation, such as queue depth, KV cache usage or running batch size, keep warm headroom for spikes, and shorten startup itself with cached weights and stored compile artifacts. Add cooldowns so the scaler does not oscillate.
Reading
- KServe: Inference autoscaling kserve.github.io
- Ray Serve: Autoscaling guide docs.ray.io
- vLLM: Metrics docs.vllm.ai
Start the 5 questionsTest yourself on this topic
5 graded questions · scored out of 100 with feedback · free
-
Shipping an optimisation safely
An optimisation is a release like any other: it can regress latency under traffic the benchmark missed, or quality on inputs the eval missed. Ship behind a flag, mirror a slice of real traffic to the new configuration and compare outputs and latency, then canary to a small share of users with rollback criteria written in advance. Keep the old configuration deployable until the new one has run through a full traffic cycle, including the peak.
Reading
- Google SRE workbook: Canarying releases sre.google
- vLLM: Metrics docs.vllm.ai
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Reasoning and agent workloads
Reasoning models spend thousands of tokens thinking before they answer, so decode, not prefill, dominates their cost and latency; speculation, KV quantisation and decode-attention kernels matter more. Agents call the model many times in a loop, each call repeating a long and growing context, so prefix caching and cache-aware routing decide the bill. Rebuild the benchmark workload from these traces, because chat-shaped benchmarks misjudge both.
Reading
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Energy per token
Energy per token is average power draw times time, divided by tokens produced, and it is becoming a cost and a capacity limit in its own right as datacenters run short of power. Read GPU power through NVML or DCGM during a steady benchmark and report joules per token at your latency target. Higher batch usually lowers energy per token; lowering a GPU's power cap often costs little speed on memory-bound decode, so test it.
Reading
- arXiv: The ML.ENERGY benchmark arxiv.org
- ML.ENERGY leaderboard ml.energy
- NVIDIA: NVML API reference docs.nvidia.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Writing up a performance result
A performance claim is only as good as the reader's ability to check it. State the question, the workload, model, precision, hardware, software versions and exact configuration; show before and after with spread, at the latency target, plus the quality check; and say what did not improve or got worse. Attach the script that reproduces it. A short honest report gets an optimisation shipped; a single headline number gets it doubted.
Reading
- Brendan Gregg: Active benchmarking brendangregg.com
- MLCommons: MLPerf Inference datacenter mlcommons.org
- Brendan Gregg: Performance analysis methodology brendangregg.com
Start the 3 questionsTest yourself on this topic
3 graded questions · scored out of 100 with feedback · free
-
Practise the Inference Optimization Engineer roadmap
307 questions, each graded on the server out of 100. Free · no card.
Other AI careers
- Agent Engineer
- AI Alignment Researcher
- AI Data Engineer
- AI Engineer
- AI Evals Engineer
- AI Governance Analyst
- AI Infrastructure Engineer
- AI Integration Engineer
- AI Product Manager
- AI Red Team Specialist
- AI Reliability Engineer
- AI Research Engineer
- AI Safety Engineer
- AI Security Engineer
- AI Solutions Architect
- AI Strategist
- Computer Vision Engineer
- Context Engineer
- Conversational AI Designer
- Forward-Deployed Engineer
- ML Engineer
- Multimodal AI Engineer
- Post-Training Engineer