SkillHack

How to become an Inference Optimization Engineer

Step by step and free: 12 phases, 88 topics and 307 graded practice questions.

Practise this roadmap free

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

  1. Phase 1 Foundations of inference performance

  2. Phase 2 GPU performance fundamentals

  3. Phase 3 Profiling and measurement

  4. Phase 4 Kernels and compilers

  5. Phase 5 Attention and the KV cache

  6. Phase 6 Batching and scheduling

  7. Phase 7 Quantisation and compression

  8. Phase 8 Speculative decoding

  9. Phase 9 Parallelism and large models

  10. Phase 10 Serving engines

  11. Phase 11 Benchmarking honestly

  12. 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.

  1. Phase 1 · Foundations of inference performance

    1. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    4. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
  2. Phase 2 · GPU performance fundamentals

    1. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    6. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    7. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    8. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  3. Phase 3 · Profiling and measurement

    1. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  4. Phase 4 · Kernels and compilers

    1. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    7. 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

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    8. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  5. Phase 5 · Attention and the KV cache

    1. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    2. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      6 graded questions · scored out of 100 with feedback · free

      Start the 6 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    7. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    8. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    9. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  6. Phase 6 · Batching and scheduling

    1. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    7. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  7. Phase 7 · Quantisation and compression

    1. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    7. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    8. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    9. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  8. Phase 8 · Speculative decoding

    1. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  9. Phase 9 · Parallelism and large models

    1. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    7. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
  10. Phase 10 · Serving engines

    1. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  11. Phase 11 · Benchmarking honestly

    1. 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

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    3. 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

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    6. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    7. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    8. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
  12. Phase 12 · Cost, capacity and production

    1. 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.

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    2. 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.

      Test yourself on this topic

      4 graded questions · scored out of 100 with feedback · free

      Start the 4 questions
    3. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    4. 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

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    5. 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

      Test yourself on this topic

      5 graded questions · scored out of 100 with feedback · free

      Start the 5 questions
    6. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    7. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    8. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions
    9. 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.

      Test yourself on this topic

      3 graded questions · scored out of 100 with feedback · free

      Start the 3 questions

Practise the Inference Optimization Engineer roadmap

307 questions, each graded on the server out of 100. Free · no card.

All career paths