IIntroduction to AI Systems Performance EngineeringTechnical textbook
Chapter 21

Performance Engineering Practice

Turn measurements into reproducible explanations and bounded engineering decisions

Build a versioned experiment record, follow one quantity across model and system layers, write a causal report, scope a finishable capstone, and evaluate new systems without losing workload context.

An engineer changes a normalization operation in the recurring 7-billion-parameter inference service, which runs on one 80 GiB graphics processing unit (GPU). A local CUDA-event benchmark reports a 22-microsecond improvement, but the weekly report contains no tensor shape, raw samples, correctness result, source revision, or end-to-end request measurement. Three months later, nobody can determine whether a compiler update removed the gain or whether the original comparison timed different work.

Chapter 21 turns an optimization attempt into a reproducible experiment. A laboratory record names the question, predicts a mechanism, captures the environment, stores raw timing samples, and links a separate profiler report to the ordinary benchmark. The chapter follows learned weights through general matrix multiplication (GEMM), retained attention data through the key-value (KV) cache, and host preparation on the central processing unit (CPU). High-bandwidth memory (HBM) names the large off-chip memory attached to each GPU whenever the experiment counts device-memory traffic.

The chapter also connects local results to user-visible measures. Time to first token (TTFT) runs from a declared request-entry timestamp to delivery of the first generated token. Time per output token (TPOT) measures the cadence of later generated tokens for an active request. A faster GPU program matters to the inference service only when the experiment shows how the changed interval affects TTFT, TPOT, capacity, cost, or another declared objective.

Every practice section produces artifacts that another engineer can inspect: a versioned experiment record, a cross-layer representation table, a causal report, a bounded capstone proposal, or a version-aware reproduction note. The artifacts preserve failed hypotheses and limitations as carefully as the fastest result because future decisions depend on knowing where the evidence stops.

Prerequisites

  • Chapters 0–20, or documented proficiency in their prerequisites
  • One completed correctness and performance investigation
  • Version control, command-line tools, and basic data plotting

Learning objectives

  • Create a reproducible experiment record from a prewritten prediction through archived raw evidence
  • Follow one declared quantity through model semantics, software representation, GPU execution, and an end-to-end metric
  • Write a causal performance report and a bounded capstone proposal with explicit limits and stop conditions
Lessons

Study this chapter

  1. 21.1
    Reproducible performance experiments

    Produce an experiment record that another engineer can inspect, run, and compare after a software or hardware change

    Begin lesson →
  2. 21.2
    Cross-layer performance analysis

    Trace one named quantity with stable units from model semantics to an end-to-end service or training metric

    Begin lesson →
  3. 21.3
    Performance report structure

    Write a report that labels direct measurement, causal inference, model-based extrapolation, and unresolved assumptions

    Begin lesson →
  4. 21.4
    Capstone projects

    Write and execute a capstone proposal whose evidence milestones and stop conditions fit the available hardware and schedule

    Begin lesson →
  5. 21.5
    Continued technical study

    Evaluate a new system with versioned primary sources, a fixed comparison contract, and the smallest experiment that distinguishes its claimed mechanism

    Begin lesson →
Chapter projects

Extended exercises

Complete these projects after the lesson-level practice tasks. Each project combines several mechanisms from the chapter.

01
Check

Audit one causal claim

Choose one past optimization report and label every technical claim as direct measurement, calculation, inference, extrapolation, source-supported fact, or unresolved assumption.

Evidence: A revised one-page report that links each measured claim to raw evidence and names the smallest experiment needed for every consequential gap.

02
Practice

Design a cross-layer investigation

Follow one quantity such as key-value bytes per retained token through at least four layers. Fix one recurring workload and predict the observation at each interface before measuring it.

Evidence: A representation table, staged experiment plan, unit-consistent calculations, named tools, falsifiable predictions, and explicit boundary between measured and simulated scale.

03
Challenge

Write a capstone proposal

Propose a project that adds one new integration task to a measurement workflow you have already completed. For example, add PyTorch operator registration to a verified CUDA kernel or add one collective communication operation to a measured single-GPU training step. Define decisive evidence and numerical stop conditions before implementation.

Evidence: Objective, workload, baseline, model, correctness contract, measurements, primary sources, hardware cost, milestones, stop conditions, reproducibility package, and publication plan.

References

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.

  1. The Rust Programming Language

    Structural inspiration: progressive chapters, concrete examples, and explicit learning flow.

  2. CUDA C++ Best Practices Guide
  3. Nsight Compute Profiling Guide
  4. MLPerf Inference Rules
  5. torch.compile Programming Model
  6. PagedAttention / vLLM