Machine Learning Systems: GPU Computing, AI Compilers and Efficient Inference
Where the FLOPs actually go, from tensor layout to attention kernels
About this course
Machine-learning systems from measurement — latency, throughput and memory — through tensor layout and autodiff, GPU execution and memory access, tiled matrix multiplication, numerically stable reductions, compiler intermediate representations, fusion and scheduling, and attention kernels that avoid materialising intermediates.
What you will be able to do
- Measure correctness, latency, throughput and memory before optimising anything
- Reason about tensors, strides and views as data layout, not notation
- Explain GPU execution in threads, warps and memory access patterns
- Tile a matrix multiplication for data reuse, and keep reductions numerically stable
- Lower tensor programs to a compiler IR and prove a fusion preserves behaviour
What this course covers
- Reproducible reporting and experimental integrity
- Workload specification and correctness verification
- Latency, throughput, and timing-boundary discipline
- Arithmetic and memory traffic counting
- Roofline model and Amdahl's Law as performance bounds
- Standard attention operator and materialized storage
- Numerical stability via score shifting
- Online running summary (max, denominator, numerator)
- Block merge algorithm (rescale-then-add)
- Tiled blocked attention implementation
- Mask semantics and causal attention convention
- Storage model, exactness, and performance scope
- Warp memory access patterns and segment counting
- Thread indexing: global index, block, and warp/lane decomposition
- Bounds guarding and active masks
- Stride, alignment, and layout effects on segment traffic
- Broadcast and same-address access accounting
- SIMT divergence: serialized path schedule and lane utilization
- Shared memory, barriers, and producer-consumer ordering
- Model scope, occupancy, and hardware claims
- Running example and motivation for an IR
- Tensor IR structure and value semantics
- Type rules and program validation
- Floating-point ordering as part of the IR contract
- Lowering to a structured loop IR
- Correctness argument and negative-control testing
- Language boundaries and extension discipline
- Executable correctness contract for tensor fusion
- Materialized baseline: three-stage reference computation
- Fusion correctness: value proof and index proof
- Broadcasting as an explicit index map
- Logical traffic cost model and its boundaries
- Purity, numerical order, and limits of fusion legality
- Traversal schedules and iteration coverage
- Task scheduling and peak live-buffer analysis
- Alias dependence and the overlapping-shift counter-example
- Tiled matrix multiplication algorithm
- Arithmetic operation count and its invariance under tiling
- Naive traffic model and its declared boundary
- Tiled traffic formula and reduction-depth invariance
- Ragged-edge (incomplete tile) correctness
- Arithmetic intensity and roofline reasoning
- Correctness validation, negative controls, and numerical precision
- Tensor descriptor: shape, strides, offset, storage
- Address formula and coordinate validation
- Row-major (C-order) stride construction
- Reachable-bounds validation for arbitrary strides
- Transpose and axis permutation as metadata-only views
- Slicing, axis reversal, and zero/negative strides
- Contiguity, reshape, and contiguous copy
- Separating address evidence from performance claims
- Parallel reduction: work, span, and tree structure
- Identity values and tail-carrying in reductions
- Reduction tree ownership and in-place race hazards
- Floating-point rounding and reassociation
- Floating-point reproducibility and determinism
- Stable softmax via active-maximum shift
- Masked softmax, log-sum-exp, and the softmax gradient
- Testing strategy: oracles, negative controls, and benchmarking
- Computation graph construction and node identity
- Local derivative rules for primitive operations
- Reverse-mode chain rule and adjoint accumulation
- Topological ordering for correct reverse traversal
- Shared-node accumulation and the overwrite failure mode
- Numerical verification and finite-difference checking
- Parameter-sharing gradient accumulation in a training step
Syllabus
Measure First
- L1 · Measure First Correctness Latency Throughput and Memory
- L2 · Tensors Strides Views and Data Layout
- L3 · Computation Graphs and Automatic Differentiation
The GPU Execution Model
- L4 · GPU Execution Threads Warps and Memory Access
- L5 · Matrix Multiplication Tiling and Data Reuse
- L6 · Parallel Reductions Softmax and Numerical Stability
Compilers for Tensor Programs
- L7 · From Tensor Programs to Compiler Intermediate Representations
- L8 · Fusion Scheduling and Correctness of Transformations
Attention and Efficient Inference
- L9 · Attention Kernels and Avoiding Intermediate Materialization