Open-source handbooks · every example verified automatically

AI Infra Handbooks

From Python, LLM internals and CUDA to inference systems: one path to an LLM inference role

Fourteen interlinked handbooks, 327 chapters, with self-tests, runnable code, exercises and answers. The English translation is in progress; pages not translated yet show the Chinese original.

The library

Fourteen handbooks, plus interview questions, exercises, a learning roadmap and a job-hunting sprint plan

Advanced Python

For people who already write Python: from code that works to code that is idiomatic and solid

Data modelType hintspytestasyncio
22 chapters · verified on Python 3.14Read →

Advanced C++

Modern C++ for AI infrastructure: read inference libraries and write correct, efficient systems code that survives the sanitizers

RAII and ownershipTemplate dispatchMemory orderpybind11
15 chapters · g++ with ASan / UBSan / TSanRead →

CS Fundamentals

The operating systems, architecture, networking, distributed systems and algorithms an inference engineer needs, each chapter starting from something real in an inference system

Processes and schedulingVirtual memoryepoll / io_uringCPU and GPU architectureTCP and streamingConsistent hashingAlgorithm interviews
24 chapters · Python and C programs run on LinuxRead →

Math Fundamentals

The math behind models and inference systems, in its own book to look up when you need it; every result is measured on a real Qwen3-0.6B

SVD and low rankRejection samplingKL divergenceGPTQFloating-point errorQueueing
7 chapters · measured on a real modelRead →

LLM Internals

The groundwork for inference optimization: from language models and the Transformer all the way to inference serving

LLaMA from scratchGQA / MLAMoEKV cacheQuantizationSpeculative decoding
24 chapters · checked against the HF implementationRead →

PyTorch in a Hurry

Eight chapters to get fluent with PyTorch: tensors and shapes, autograd, models and the training loop, debugging and speed

Broadcasting & einsumgather / masksautogradnn.Moduleprofiler
8 chapters · seconds on a CPU; even the errors reproduceRead →

Advanced CUDA

From GPU architecture to hand-written high-performance kernels, for AI infrastructure and inference optimization roles

GEMMFlashAttentionTensor CoresTriton
32 chapters · compiled with nvcc 12.9 / 13.4, PyTorch examples runRead →

Train a Small Model

Start from an empty directory on your own computer and train a small language model that writes in the style of a classical novel

BPE tokenizerSmall GPTTraining loopGradient accumulationOne consumer GPU
6 chapters · six chapters run as a relay on CPURead →

Distributed Training

The training-side parallelism inference engineers need too: starting from the memory budget, implement DDP, ZeRO, and tensor, pipeline, context and expert parallelism from scratch, each matched against a single GPU

ZeRO / FSDPMegatron TP1F1BRing AttentionRL training
16 chapters · multi-process (gloo) on CPURead →

Inference Systems

Build an inference engine from scratch, read vLLM and SGLang, and master distributed inference and performance engineering

Continuous batchingPD disaggregationDeepEPRDMALoad testing
66 chapters · based on vLLM 0.30 / SGLang 0.5.20Read →

Transformer by Hand

Start from one main.py and write Qwen3.5's hybrid architecture one file per chapter, matching Hugging Face at every step

Gated DeltaNetGated attentionKV cache vs. memory stateMTP speculative decodingMoE
18 chapters · one part and one experiment per chapter, whole model within 1e-5 of HFRead →

mini-sglang from Scratch

Start from a 126-line minimal engine and build a complete inference engine one file per chapter in the official module layout; every step runs, and the output matches HF token by token

Radix CacheOverlap schedulingCUDA GraphTensor parallelism
30 chapters · 63 tests, verifiable on CPURead →

Image & Video Generation

Inference and serving for diffusion and flow-matching models: pipeline anatomy, compute and memory budgets, few-step sampling, caching, quantization, multi-GPU parallelism, video inference and scheduling for generation services

DiTFlow matchingTeaCacheSequence parallelism
20 chapters · no model weights needed, runs on CPURead →

SGLang Design Evolution

More than 19,000 commits as primary sources: the problem behind each design, the commit that introduced it, what it replaced and how it evolved, from the paper and the first commit to today

git archaeologyRadixAttentionZero-overhead schedulingPD disaggregation
27 chapters · commands and quoted code re-run on a cloneRead →

Reading SGLang-Omni

The multi-stage inference runtime for omni, TTS and ASR models: the Coordinator, stages and schedulers, how SGLang is embedded, how data moves between stages; three case studies, then finding problems and submitting a PR

Multi-stage pipelineStreamingComposing SGLangRust router
12 chapters · experiments run the real omni runtime on CPURead →

Inference interview questions

Answer outlines for 85 frequent questions, coding questions, full reference answers to 10 system design questions and 4 mock interviews; the LLM and CUDA books have their own question banks

EstimationCodingSystem design
85 questions + 10 system design answers + 4 mock interviewsPractice →

Exercises (Chinese)

292 coding exercises for the fifteen books: write code and run the tests in your browser; CUDA exercises run on a GPU emulator that checks coalescing and bank conflicts, and everything can be judged locally on macOS or WSL2

Judged in the browserGPU emulatorCUDA C++ / Triton
292 exercises · easy / medium / hardStart →

Playground

Write Python in the browser and run it right away, no exercise needed: numpy, matplotlib, plus the CUDA and Triton emulators; with code completion and shareable links

Runs in the browserCode completionTemplates
Write and runOpen →

Flashcards

2082 flashcards drawn from the self-tests, exercises and interview banks of the fifteen books, scheduled by spaced repetition; filter by book or export to Anki

Spaced repetitionInterview questionsAnki
2082 cards · 20 new cards a dayReview →

Learning roadmap

The 327 chapters of the fifteen books laid out over 17 weeks, matching the sprint plan week by week: core, recommended and optional chapters at a glance, key chapters for framework, optimization and platform roles, and progress tracking

17 weeksRole focusDependencies
17 weeks · matches the sprint planView →

17-week sprint plan

A job-hunting plan for inference systems roles: the skill model, what the three kinds of roles emphasize, weekly study and exercises, frontier topics, portfolio and open-source work, system design and the interview schedule

Weekly checklistsMilestonesPortfolioInterview prep
17 weeks · 4 phasesView →

Where to start

Each stop prepares the next, and the books link to each other; the interview questions and a portfolio wrap it up

Chapter-by-chapter roadmap → · Exercises for every chapter → · 17-week sprint plan → · Learning on a Mac: setup →