Module 3
GPU Architecture and Performance Engineering
Learn to predict a bottleneck from operations, shapes and data movement—then identify the evidence needed to test it.
From equations to hardware
You already know what attention computes. Now ask: which work runs together, which bytes move, and which resource prevents it running faster? Start from one projection, trace it onto a GPU, then test a performance hypothesis.
Ready to start? Begin with 3.1 after checking the prerequisites below. You need matrix shapes, a dot product, prefill/decode and KV-cache basics. Mathematical fluency can develop alongside the course: sums · shapes. These lessons do not certify implementation mastery.
Each lesson has a few concepts, a manipulable example, optional derivations and a prediction check. No score, prerequisite gate or local CUDA install. CPU/Mac learners can study every example in a browser. NVIDIA terms are used explicitly; Apple/AMD hardware differs.
Five short lessons
- 3.1 GPU execution
Map independent outputs to threads, blocks, warps and SMs; see how resident warps hide memory waits.
Open the visual GPU walkthrough — the same example as the lesson, on an illustrated chip.
- 3.2 Memory and movement
Follow an operand through memory; distinguish capacity, traffic and coalescing.
- 3.3 Matrix multiplication and tiling
Compute one output, then reuse a tile. Count work and transferred elements.
- 3.4 Arithmetic intensity and roofline
Derive a resource lower bound; change compute and bandwidth independently.
- 3.5 Prefill, decode and evidence
Change row count, batch and context; see why attention needs fused kernels. Turn a bottleneck prediction into a falsifiable experiment.
Memory requests and tile reuse, step by step — two optional motion walkthroughs for lessons 3.2 and 3.3.
Notation
Hover, focus or tap a symbol for its meaning; Escape dismisses help. This table remains available as a reference. Subscripts spell out roles: rows, cols and inner are dimension counts; row, col and sum are indices.
| Symbol | Meaning |
|---|---|
| U | Left matrix: input rows [r × k] in the GPU examples |
| W | Right matrix: projection weights [k × c] in the GPU examples |
| Y | Matrix product U W, with shape [r × c] |
| rrows | Number of input/output rows in the GPU examples |
| ccols | Number of output columns in the GPU examples |
| kinner | Reduction width: input columns and weight rows in the GPU examples |
| irow | Output row index in the GPU matrix product (zero-based) |
| jcol | Output column index in the GPU matrix product (zero-based) |
| psum | Summation index over the reduction width (zero-based) |
| btile | Square tile side length in the GPU teaching model |
| F | Floating-point operations; multiply-add counts as two FLOPs |
| E | Bytes transferred at the explicitly chosen memory boundary |
| I | Arithmetic intensity F / E, in FLOP per byte |
| P | Compute ceiling for the chosen operation and precision, in FLOP per second |
| BW | Bandwidth ceiling at the chosen memory boundary, in bytes per second |
| TC | Tensor core: SM hardware that multiplies small matrix tiles and accumulates the result (matrix multiply-accumulate) |
Sources and boundaries
Original teaching examples derive from the following primary references. Invented resource limits and hardware ceilings are labeled in place. Calculated times are lower bounds, never benchmark results.
- NVIDIA CUDA Programming Guide: SIMT kernels — execution, memory scopes and synchronization.
- NVIDIA CUDA Best Practices Guide — coalescing, reuse and occupancy.
- NVIDIA Matrix Multiplication Background — shapes, tiling and resource limits.
- NVIDIA GPU Performance Background — throughput versus bandwidth.
- Williams, Waterman and Patterson: Roofline — resource ceilings, not a latency oracle.
- FlashAttention — attention tiling and reduced HBM traffic; deeper kernel study follows this module.
Not covered here: full CUDA implementation, profiling practice on physical hardware, tensor-core layouts, distributed inference, or a complete decoder latency model. These are next experiments, not implicit claims of this course.