Machine Learning for Programmers

Featured

Anatomy of a floating point

An interactive map of how a floating point value is calculated, how are `Inf` and `NaN` represented, what normal and subnormal modes are, and why we should care about them.

Read article →

Binary representations of integers

Different representations of binary integers are seen through a unified framework. Using mathematical objects like ring, affine map and dot product uncovers insights that are not obvious otherwise.

numbers

Solving neural ODEs from first principles

A detailed tour of what is, in my opinion, one of the least understood topics in ML. It covers the motivating problem, and solves three problems from scratch without any of the deep learning machinery.

neural odes

A simple 1D normalizing flow

Push a Gaussian through an invertible function and watch the density bend. One dimension is enough to see why the change-of-variables formula needs that derivative term.

generative models

Flash attention 1

A visual explainer of how FA1 works, focusing on data movement across HBM. It builds on the ideas behind online softmax.

flash attention

Flash attention 2

FA2 is often described as a "transposed" version of FA1. This articles makes it clear why. A visual guide to how data moves in FA2.

flash attention

Flash decoding

The often ignored cousin of Flash attention. It implements the same recurrence formula as FA but uses a different parallelization strategy that is more suitable for decoding stage.

flash attention

CUDA essentials: memory hierarchy and threads

Introduction to the foundations of GPU programming in CUDA.

cuda

CUDA essentials: warps and interleaving

A really short (and silly) animation of warp interleaving.

cuda

CUDA essentials: warp divergence

An illustrated article of what warp divergence is, and how to avoid it.

cuda

CUDA essentials: shared memory bank conflicts

Shared memory is split into banks, and what it means to have a bank conflict.

cuda

Kernel visualization: online softmax

Naive (safe) softmax takes three passes. Can we do better? This algorithm set the stage for Flash attention algorithms.

kernels

Kernel visualization: efficient matrix transpose

A visualization to understand a simple kernel for efficient matrix transpose (with no bank conflicts!).

kernels