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

  1. 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.

  2. 3.2 Memory and movement

    Follow an operand through memory; distinguish capacity, traffic and coalescing.

  3. 3.3 Matrix multiplication and tiling

    Compute one output, then reuse a tile. Count work and transferred elements.

  4. 3.4 Arithmetic intensity and roofline

    Derive a resource lower bound; change compute and bandwidth independently.

  5. 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.

One shared glossary across the collection
SymbolMeaning
ULeft matrix: input rows [r × k] in the GPU examples
WRight matrix: projection weights [k × c] in the GPU examples
YMatrix product U W, with shape [r × c]
rrowsNumber of input/output rows in the GPU examples
ccolsNumber of output columns in the GPU examples
kinnerReduction width: input columns and weight rows in the GPU examples
irowOutput row index in the GPU matrix product (zero-based)
jcolOutput column index in the GPU matrix product (zero-based)
psumSummation index over the reduction width (zero-based)
btileSquare tile side length in the GPU teaching model
FFloating-point operations; multiply-add counts as two FLOPs
EBytes transferred at the explicitly chosen memory boundary
IArithmetic intensity F / E, in FLOP per byte
PCompute ceiling for the chosen operation and precision, in FLOP per second
BWBandwidth ceiling at the chosen memory boundary, in bytes per second
TCTensor 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.

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.

Module 3 overview · Revisit KV memory