IIntroduction to AI Systems Performance EngineeringTechnical textbook
Chapter 2

Performance Measurement and Benchmarking

Build an experiment that measures completion, preserves the workload, and verifies the result

Design benchmarks that represent the target workload, account for asynchronous execution, preserve correctness, and support a specific engineering decision.

An engineer runs a text-generation program twice and sees 1,940 output tokens per second in the first run and 2,070 in the second. Neither number is useful until the experiment identifies what entered the program, which work the timer included, whether the graphics processing unit (GPU) had already compiled and cached the operations, and whether both runs produced answers of acceptable quality. A benchmark is the complete controlled experiment that supplies those conditions; a benchmark is not merely the loop that reads a clock.

Chapter 2 builds one benchmark for a 7-billion-parameter decoder service. The lesson specifies the joint distribution of prompt and output lengths, the arrival times of requests, the server and GPU software versions, and the points at which the timer starts and stops. The lesson then shows why a CPU timer can record only the submission of a GPU command even though the GPU continues working for milliseconds after the call returns.

The final measurement step checks the result as well as the time. A faster matrix or attention implementation is not an improvement when numerical changes damage the model's output or a partial GPU tile writes outside its allocation. The chapter therefore joins raw timing samples with deterministic operator tests, model-quality measurements, and a record of the exact environment. Another engineer should be able to reproduce both the observed speed and the allowed result.

Prerequisites

Learning objectives

  • Specify a reproducible benchmark before collecting results
  • Distinguish CPU submission time, GPU execution time, and request completion time
  • Reject comparisons that change workload, numerical output, or service conditions
Lessons

Study this chapter

  1. 2.1
    Benchmark requirements

    Write a benchmark contract that another engineer can reproduce without verbal context

    Begin lesson →
  2. 2.2
    Timing asynchronous systems

    Measure GPU execution without mistaking command-submission time for completed device work

    Begin lesson →
  3. 2.3
    Correctness validation

    Define and test the accepted numerical and model behavior before timing an optimized implementation

    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 a throughput claim

Select one published inference-throughput claim and reconstruct its workload, timing interval, machine state, quality condition, and latency condition. Mark every missing field as unknown rather than guessing.

Evidence: A one-page table separating quoted facts, derived values, unsupported assumptions, and the decisions the published result can and cannot support.

02
Practice

Build a timing and correctness harness

Write a harness for one CPU or GPU operation with declared warm-up, raw repeated samples, correct completion timing, a separately written reference, and adversarial inputs.

Evidence: Runnable code, machine-readable samples, environment manifest, correctness report, and an explanation of the timer endpoints.

03
Challenge

Investigate one source of variation

Change exactly one environmental condition such as cold versus warm state, power limit, competing process, or input shape. Predict the expected distribution change before running both conditions.

Evidence: Paired raw distributions, experimental control record, observed signature, and a conclusion that distinguishes direct observation from causal inference.

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. CUDA C++ Best Practices Guide
  2. NVIDIA Nsight Systems User Guide

    Official reference for capturing and reading CPU, CUDA API, GPU workload, and communication timelines.

  3. PyTorch Profiler documentation

    Official reference for recording operator activity, CPU and accelerator events, shapes, stacks, and exported traces.

  4. MLPerf Inference Rules
  5. MLPerf Training Benchmark