Pidoku
11Models as Computation
On this page

Models as Computation

Module 1111 lessons~12h 30m

Lessons, in order

11.a Tracing One Request Through a ModelA step-by-step account of what one request costs inside the model: every operator, in order, with the real shapes, the arithmetic it does and the bytes it moves. 1h 15m 11.b Computational Graphs and OperatorsA model is a directed acyclic graph: nodes are operators (matmul, add, softmax) and edges are tensors. Inference executes that graph in an order where every node runs after its inputs are … 1h 11.c GEMM and GEMVThe difference that matters: a GEMM reuses each number it loads many times; a GEMV uses each weight exactly once. Multiplying an M×K matrix by a K×N matrix does about 2·M·N·K FLOPs on about … 1h 30m 11.d ConvolutionsA convolution slides a small filter over an input and computes a dot product at each position. 45 min 11.e Normalization LayersAn operation that rescales each token's hidden vector so its size stays in a predictable range. 45 min 11.f Attention Computation in PracticeHow attention is actually computed on a GPU, as opposed to how it is written in a paper. 1h 30m 11.g Tensor Layouts and MemoryLayout is how a tensor's elements are placed in memory. A tensor of shape (tokens, heads, head_dim) is, physically, one long row of bytes. Which dimension changes fastest as you walk along … 1h 15m 11.h Operator FusionCombining several operations into one kernel, so that intermediate results stay in registers or shared memory instead of making a round trip through HBM. 1h 15m 11.i Graph Optimization and CompilersTaking a model's graph (11.b), rewriting it into a faster graph that computes the same thing, and generating code for it. 1h 15m 11.j Static vs Dynamic ShapesStatic shapes are known before the program runs. Dynamic shapes change per call. LLM serving is dynamic by nature: prompt lengths, the number of requests in a step and the length of every … 1h 11.k Numerical Precision and Stability in PracticeThe practical discipline of keeping an inference system numerically sound while running it in the lowest precision you can get away with, with fused kernels, across many GPUs and at whatever … 1h

About this module

A model seen as an engineer sees it: a graph of operators over tensors. A forward pass traced end to end, GEMM versus GEMV, convolutions, normalisation, the attention computation, tensor layouts, operator fusion, graph optimisation, static versus dynamic shapes, and numerical precision in practice.

Lessons#

#LessonTime
11.aTracing One Request Through a Model75 min
11.bComputational Graphs and Operators60 min
11.cGEMM and GEMV90 min
11.dConvolutions45 min
11.eNormalization Layers45 min
11.fAttention Computation in Practice90 min
11.gTensor Layouts and Memory75 min
11.hOperator Fusion75 min
11.iGraph Optimization and Compilers75 min
11.jStatic vs Dynamic Shapes60 min
11.kNumerical Precision and Stability in Practice60 min

Previous: ML Foundations · Next: LLM Inference

↑↓ navigate↵ openesc close

100% drag to pan · scroll or pinch to zoom · double-click to zoom in