Series
Deep dives into specific topics.
Online softmax, flash attention and flash decoding
How attention kernels avoid trips to GPU memory. This series starts with online softmax, builds Flash Attention 1 and 2 on it, and ends with flash decoding, with each CUDA kernel stepped through as tiles move between HBM and SRAM.
Integer and floating point representations
How computers turn bits into numbers. This series starts with four ways to represent integers, seen through one formula, and then takes a floating point number apart bit by bit.
- Binary representations of integers
- Anatomy of a floating point number
- Block scaling in MXFP4 and NVFP4
- Adding two floating point numbers
- Why floating point addition isn't associative
- Exponentiation by squaring
From Permutations to Sinkhorn
Explore the journey from the spectral properties of permutations to the geometry of doubly stochastic matrices, Birkhoff’s polytope, and how it all leads to Sinkhorn distances in optimization and machine learning.
- Overview and permutation cycles
- Permutation spectra
- Circulant matrices
- Birkhoff polytope
- Doubly stochastic matrices
- Birkhoff-von-Neumann algorithm
- Matrix scaling
- Sinkhorn distance
Matrix calculus and autodiff
Starting from the idea of a small change in output given a small change in input, this series builds the concepts of linear operators, gradients and Jacobians, and covers the foundational ideas behind autodiff alongwith links to implementations in PyTorch and JAX.
- Linear operator
- Gradient of a function
- Jacobian of a function
- Key matrix derivatives
- Function is a DAG
- Autodiff on a DAG
- VJP and JVP
- Hessian of a function
Rotations, quaternions and Lie algebras
This series starts from 2D rotation matrices and takes us through the developments we have made to understand and describe rotations - it covers imaginary numbers, intrinsic and extrinsic rotations, Euler angles, quaternions, geometric algebra and Lie theory.