lenatriestounderstand

Section 9 of 9

ML Systems

How machine-learning algorithms actually run on hardware: GPUs, CUDA and C++, memory and parallelism, kernels, numerical computing, LLM inference and serving, distributed systems, and performance engineering.

9 items in this section.

Long reads

01
Lab inside

How GPUs Actually Run Machine Learning

Why the same GPU is nineteen times faster than the CPU at one operation, eleven times at the next, and slower at a third — worked out on a real Tesla T4, from two numbers per machine: how fast it computes and how fast it moves bytes. Along the way: warps and SIMT, latency hiding, the memory hierarchy, arithmetic intensity, the roofline, and a power limit that moves the ceiling.

  • gpu
  • cuda
  • roofline
  • memory-bandwidth
  • +2
Read
02
Lab inside

Matrix Multiplication: The Operation Behind Modern AI

Most of the arithmetic in a neural network is matrix multiplication. Written the obvious way it is correct, and fifty times slower than torch.mm on the same GPU. Where that difference comes from, one change at a time on a Tesla T4: coalescing, tiles, shared memory, registers, tensor cores and precision — and why almost all of it is about where the numbers are kept rather than how they are multiplied.

  • matrix-multiplication
  • cuda
  • tiling
  • shared-memory
  • +3
Read
03
Lab inside

How LLM Inference Actually Works: Where the Time Goes on a Real GPU

What a GPU is actually doing while a language model answers: the generation loop, the prefill pass that reads the prompt and the decode steps that write the answer, the two waits a user feels — time to first token and time per output token — and why the second is limited by moving the model's weights through memory. Measured end to end on a Tesla T4, including why a token costs nine times what its bytes say, what a real kernel trace shows instead, and how latency and throughput pull apart when many people share one card.

  • llm
  • inference
  • prefill
  • decode
  • +6
Read
04
Lab inside

From Python Call to GPU Kernel: The C++ Underneath ML Libraries

One line of Python — index.search(query, k=10) — taken apart layer by layer, with a small nearest-neighbour library written in C++ and CUDA to take it apart with. Where numbers live and who frees them, what a copy of a gigabyte costs, why the order of additions changes both the speed and the answer, when an abstraction is free and when it is ruinous, what a template costs to compile, what happens between the call returning and the GPU finishing — and why the same search runs 25 times faster after eight rewrites that change nothing about what it computes. Measured end to end on a Kaggle T4.

  • c++
  • cuda
  • pybind11
  • memory
  • +6
Read
05

PagedAttention: Treating KV Memory Like Virtual Memory

A conversation's key/value cache grows one token at a time and nobody knows how long it will get. Give every request a contiguous buffer sized for the worst case and one Tesla T4 holds 573 of them, most of that memory reserved for answers that never arrive. Hand the same card out in blocks of 16 tokens and it holds several thousand. Measured on vLLM 0.29: what the block table costs the attention kernel, how the engine decides that two requests hold the same block, how much of the card the cache actually gets, and how many sequences all of it makes room for.

  • llm
  • inference
  • kv-cache
  • memory
  • +4
Read
Updated Oct 26, 2026
06

Where Your Prompt Goes: Inside a Modern AI GPU

Follow one message into a 2026 AI server: through CPU memory, HBM4, compute dies, matrix units and the links between GPUs, then back out as an answer. Original interactive diagrams show where weights already live, what a request creates, and what the hardware waits for. Based on NVIDIA Rubin and AMD CDNA 5.

  • gpu
  • rubin
  • vera
  • cdna-5
  • +4
Read
Updated Oct 26, 2026
07
Lab inside

Isotonic Regression on GPU

torchisotonic and the paper behind it, in plain words. A curve that may only go up is a ten-line walk on a CPU, and a walk is the one thing a GPU cannot share out: on ten million numbers a far bigger GPU can be even slower. The way out is to stop walking and draw instead, since the fit is a string pulled tight under the running totals, and then to stop copying the pieces of that string that never change.

  • gpu
  • cuda
  • isotonic-regression
  • calibration
  • +4
Read
Updated Oct 27, 2026

Shorts