Introduction to AI Systems Performance Engineering
Follow one model request, measure its stages, and test one performance explanation
Follow a 2,048-token request through browser, server, scheduler, model worker, GPU programs, and response delivery before defining latency, throughput, resource use, or optimization.
A user opens a coding assistant, enters a 2,048-token question, and presses Send. The browser sends an HTTP request to a server. The server's central processing unit (CPU) converts the text into numbered vocabulary entries called tokens, places the request in a waiting queue, and eventually assigns the request to a graphics processing unit (GPU). The GPU runs many small parallel programs over arrays of numbers that represent the text and the model's learned parameters. The service returns one generated token at a time until the answer ends. A delay can arise before the GPU starts, while the GPU moves numbers through memory, between GPU operations, or after the GPU produces an output.
Chapter 0 follows that request before asking you to use performance terminology. The model worker stores its numeric arrays in GPU memory. Engineers call a multidimensional numeric array a tensor. The framework asks the GPU to process those tensors by launching small parallel programs called CUDA kernels.
Measurement software records another concrete object. NVIDIA Nsight Systems can observe selected CPU calls, CUDA commands, data transfers, and GPU kernels while the request runs. The resulting timestamped event record is a profiler trace. A timeline view draws each recorded event as an interval between its start and end times.
The model combines activation tensors with learned-weight tensors through general matrix multiplication (GEMM). During output generation, the worker also retains attention history in a key-value (KV) cache so the next iteration does not recompute every earlier result. Later lessons derive both mechanisms from concrete tensor shapes.
The chapter then introduces the investigation method used throughout the book. An engineer records the result that users need, observes where time and resources are spent, proposes a physical or software cause, changes one relevant condition, and checks the prediction. Diagnostic reports can count arithmetic as floating-point operations (FLOP), but a FLOP rate is useful only after the engineer connects it to the requested result. The exercises produce inspectable artifacts—a request timeline, raw timing samples, a correctness comparison, and a written conclusion—because an optimization claim must be reproducible by someone who did not watch the original experiment.
Prerequisites
- Ability to read a short program
- Comfort reading timestamps and command-line output
- No prior GPU or machine-learning systems knowledge
Learning objectives
- Draw the path of one inference request and name which software or hardware owns each stage
- Define latency and throughput from declared events, completed work, elapsed time, and workload conditions
- Use a recorded observation, causal prediction, controlled change, and correctness check to investigate one delay
Study this chapter
- 0.1Performance objectives and constraintsBegin lesson →
Describe one request path and define a measurable objective from named timestamps and completed results
- 0.2Performance optimization processBegin lesson →
Write and run an investigation whose predicted observation can be rejected by measurement
- 0.3Study method and evidenceBegin lesson →
Produce a versioned experiment record with calculations, raw observations, correctness results, and a bounded conclusion
Extended exercises
Complete these projects after the lesson-level practice tasks. Each project combines several mechanisms from the chapter.
Draw a request path
Draw the recurring inference request from browser submission through server processing, scheduler admission, GPU execution, and token delivery. Label the owner and observable timestamp at every handoff.
Evidence: A diagram whose arrows name the transferred object and whose stages cite browser, server, scheduler, framework, or GPU evidence.
Reproduce a baseline
Benchmark a familiar CPU or GPU operation at least 100 times after a declared warm-up. State exactly where the timer begins and ends.
Evidence: A machine-readable sample file, sample count, median, empirical p95, environment manifest, and plot of the observed distribution.
Complete one investigation record
Change one input size or implementation choice, predict the timing effect before running it, verify output, and compare the result with the baseline.
Evidence: A versioned record containing the question, setup, prediction, raw measurements, correctness result, conclusion, and one unresolved alternative.
Sources and further reading
The lesson explanations synthesize primary papers and official references. Follow the originals for proofs, exact APIs, architecture details, and version-sensitive behavior.
- The Rust Programming Language↗
Structural inspiration: progressive chapters, concrete examples, and explicit learning flow.
- NVIDIA Nsight Systems User Guide↗
Official reference for capturing and reading CPU, CUDA API, GPU workload, and communication timelines.
- PyTorch Profiler documentation↗
Official reference for recording operator activity, CPU and accelerator events, shapes, stacks, and exported traces.
- MLPerf Inference Rules↗
- MLPerf Training Benchmark↗