Companion code: run the course's algorithms yourself

The DMXSF companion repository provides 61 Python labs for a laptop CPU, covering all 66 wiki articles with runnable material and checking their core formulas and mechanisms.

dmxsf/dmxsf offers 61 CPU labs, from tensor shapes and GPU rooflines to local inference, agents, training, evaluation, and safety. Every lab has Chinese and English instructions, a run command, and recorded output. The default runs need no GPU, model API, or external weights.

Quick start

git clone https://github.com/dmxsf/dmxsf.git
cd dmxsf
uv sync                      # Python 3.10 or newer; pip install -e . works too
uv run dmxsf list            # every lab
uv run dmxsf run foundations/tensors-and-shapes
uv run dmxsf roadmap weekend # labs for the weekend crash course

Dependencies are managed with uv. Without uv, run pip install -e . and drop uv run from the commands.

How the code relates to the course

  • All 66 articles with runnable material have a lab. The directory labs/<section>/<page>/ follows the path of the primary article. Closely related articles such as information theory and next-token prediction can share a lab. The “Companion code” card gives the full command, source location, and README in the selected language.
  • Labs check core formulas and mechanisms. Parameter counts, memory and probabilities can be recomputed directly. Some performance and scaling experiments use smaller CPU examples. A failing check prints [FAIL] and exits with a nonzero status. Use --seed N to change the random seed.
  • The README states the scope of each experiment. It identifies teaching examples, results that can be reproduced with --hf or --bge, and measurements that require the full experiment in the wiki article.
  • Library, labs and tests are separate. src/dmxsf/ is an importable library, labs/ holds scripts written to be read like a tutorial, and tests/ tests the library. CI runs all of the tests on every commit and runs each lab once with --quick.

How to use it

  1. Read a wiki page and note the formulas or tables you would like to verify.
  2. Run its lab and read the source next to the output; the docstring at the top of each lab says which parts of the page it checks.
  3. Change a parameter and run it again, then try the exercises in the lab’s write-up.

Environment and run time

  • A CPU is enough. The first lab that needs a pretrained model trains a very small byte-level model on your machine (a few minutes) and caches it in ~/.cache/dmxsf.
  • The full run time of each lab is listed below; --quick is a smoke version for checking that your setup works.
  • Timings in milliseconds or throughput depend on the machine: read the ratios in a lab, not the absolute numbers.

All labs 61 labs

Each lab covers one or two wiki pages and lives in the directory that mirrors the wiki path; its output checks the numbers on the page.

Getting Started

Foundations

Model Architecture

Compute and Systems

Pre-training

Post-training and Alignment

Inference and Serving

Applications

Multimodal

Evaluation

Safety and Alignment Risks

Frontier

Follow a study route

These are the roadmap's own routes: the labs behind the pages you read in a week or step are the ones to run in it. The LLM algorithms wiki →

Route 0: Weekend crash course (about 10 hours)

Route 1: AI application developer (8 weeks)

Route 2: LLM engineer (14 weeks)

Week 1
Week 2
Week 3
Week 4
Week 5
Week 6
Week 7
Week 8
Week 9
Week 10
Week 11
Week 12
Week 13
Week 14

Route 3: LLM researcher (16 weeks)

Repository

View dmxsf/dmxsf on GitHub ↗ Report a problem ↗

Updated