OS fundamentals · for AI systems
A three-weekend course · AI systems notes

The machine and the kernel under your GPUs

Six modules on the host side of distributed training and inference. Part I covers one machine: how the box is wired, what virtual memory does to your bytes, how the kernel schedules the threads that feed the GPU, and how I/O, networks and containers fail. Part II scales that up to coherent CPU–GPU superchips and rack-sized NVLink domains: GB200/GB300 NVL72 and Vera Rubin. Each module takes ≈35–45 minutes to read, has interactive diagrams you can step through, and ends with a drill you can run on any NVIDIA machine, from an RTX 4090 workstation or a DGX Spark to an 8×H100 node or a GB200 tray.

0 of 6 modules complete

IOne machine

todo
MODULE 1 · WEEKEND 1

How the machine is built

Cores and cache lines, latency orders of magnitude, NUMA, PCIe topology, NVLink and NVLink-C2C, DMA and pinned memory, interrupts vs polling.

≈35 min · latency explorer · pageable-vs-pinned stepper · data-path stepper
todo
MODULE 2 · WEEKEND 1

Virtual memory

Page tables and TLBs, minor/major faults, THP, mmap and the page cache, COW, pinning and the IOMMU, CUDA VMM, expandable segments, SymmetricMemory, UVM/HMM/ATS.

≈45 min · page-walk stepper · fault-handler stepper · fork+COW visualizer
todo
MODULE 3 · WEEKEND 2

The CPU side: processes, threads, scheduling

Syscalls and context switches, futexes, fork vs spawn (and CUDA), EEVDF, affinity, isolcpus, IRQs, launch jitter, CUDA graphs.

≈35 min · syscall/register stepper · launch-jitter timeline
todo
MODULE 4 · WEEKEND 2

I/O, networking, containers, observability

Page cache vs O_DIRECT, io_uring, GPUDirect Storage, TCP vs RDMA, memory registration, cgroups and namespaces, container outages, perf/eBPF/nsys.

≈40 min · TCP vs RDMA stepper · "debug this container" quiz · final self-check

IIRack scale

todo
MODULE 5 · WEEKEND 3

Rack-scale: GB200 and GB300 NVL72

18 kernels and one NVLink domain, coherent NVLink-C2C, GPU memory as NUMA nodes vs CDMM, ATS and why page size matters to the GPU, the Grace tuning checklist, IMEX and fabric handles, NVLS, failure domains.

≈45 min · allocation-placement stepper · cross-tray sharing stepper · all-reduce calculator
todo
MODULE 6 · WEEKEND 3

Vera Rubin, and reading any new machine

Six machines on the same four axes. Vera's 176-thread CPU, C2C at 1.8 TB/s and offload math, NVLink 6 and MoE all-to-all, ConnectX-9/BlueField-4 KV-cache tiers, Rubin CPX, and a day-one checklist.

≈35 min · generation explorer · offload calculator · MoE all-to-all calculator

✓What you should be able to explain afterwards

  1. Why pageable-memory copies are slower and can't be truly async.
  2. What happens step by step on a page fault, and what a TLB miss costs.
  3. Why GPU and NIC NUMA placement matters for NCCL.
  4. Why DataLoader workers seem to "leak" memory.
  5. What mmap buys you for checkpoint loading.
  6. Why RDMA needs pinned, registered memory.
  7. What usually breaks distributed training inside containers.

The final self-check at the end of Module 4 asks all seven.

DDrills

All drills are in drills/. They need Python 3 with PyTorch (CUDA), nvidia-smi, and optionally sudo apt install hwloc numactl sysstat. Run each one on both machines and keep the output: the pages compare the two.

ModuleCommandWhat it shows
1bash drills/m1_machine.shtopology, NUMA, PCIe links, GPU/NIC affinity; pinned vs pageable bandwidth; big vs small core (or cross-NUMA)
2bash drills/m2_vm.shpage size, THP, CUDA unified-memory attributes; read vs mmap faults, cold vs warm; THP fault counts
3bash drills/m3_cpu.shstrace of a training step; DataLoader COW growth (list vs numpy); launch jitter quiet / noisy / pinned / CUDA graph
4bash drills/m4_io.sh
docker run … sh /d/m4_container_check.sh
bash drills/m4_60s.sh PID
page cache and O_DIRECT; container limits that break training; the 60-second checklist
5bash drills/m5_rack.shcoherence class (ATS, NUMA config, fabric handles), copy engine vs SMs reading CPU memory, Grace tuning checklist, fabric/IMEX state, NUMA placement
6bash drills/report.shone-page profile of any machine, written to results/<host>.md: the four questions plus headline numbers

Get the drills with git clone https://github.com/kapilsh/ai-systems-notes, or download single files from the links in each module. m5_coherent.cu needs a CUDA toolkit (nvcc).

Every "x86 + RTX 4090" result in the pages was measured on an i9-13900K + RTX 4090 workstation. The DGX Spark, 8×H100, GB200/GB300 and Vera Rubin columns are predictions from NVIDIA's documentation, marked as such until measured.

↺Suggested schedule

Weekend 1

Module 1 + drill on both boxes (≈1 h). Module 2, the longest and most important, + drill (≈1.25 h). Re-do the page-walk and COW steppers until you can narrate them without looking.

Weekend 2

Module 3 + drill (≈1 h). Module 4 + drill (≈1.25 h). Finish with the final self-check, out loud, without notes.

Weekend 3

Module 5 (≈1 h), then Module 6 (≈45 min). Run drills/report.sh on every machine you can reach and compare the reports against Module 6's table.

Part of kapilsharma.dev · source and drills on GitHub.