Interactive Labs
What happens to accuracy?
Lab 01 is one instance of a pattern that every lab repeats.
Each lab asks you to test a quantitative result that is often surprising. The design rests on one observation. A student who predicts wrong and then discovers why has learned more than a student who reads a correct answer. The prediction lock makes that possible. You cannot passively watch the simulator; you have to commit first.
Every part within every lab follows the same rhythm:
Stakeholder Scenario: A fictional but realistic message from a CTO, VP of Engineering, or ML lead frames a real-world problem, of the kind engineers decide in practice.
Prediction Lock: Before seeing any data, you must commit a structured prediction (multiple choice or numeric estimate). The simulator is locked until you predict. This forces you to surface your assumptions.
Interactive Instruments: Sliders, toggles, and charts powered by the mlsysim physics engine let you explore the design space. Every number traces to a specific textbook claim, with no unexplained constants.
Prediction Reveal: The lab shows you what you predicted versus what actually happened, with specific numbers: “You predicted 2\(\times\). Actual: 50\(\times\). You were off by 25\(\times\).” This gap is the learning moment.
Math Peek: A collapsible accordion reveals the governing equation. You can always see the physics behind the simulator.
Briefing ~2 min Learning objectives, prerequisites, core question
Part A ~12 min Calibration --- correct a wrong prior with data
Part B ~12 min Deepening --- quantify the mechanism behind Part A
Part C ~12 min Cross-context --- same system, different hardware
Part D ~12 min Design challenge --- make a decision with trade-offs
Synthesis ~5 min Key takeaways, connections, self-assessment
At least one part includes a failure state: push a slider too far and the system crashes (OOM, SLA violation, thermal throttle). These failures are reversible and instructive: the point is to find the boundary, not to punish.
Your predictions and design decisions persist across labs in the Design Ledger, a browser-based save system. Lab 08’s training memory budget builds on Lab 05’s activation analysis, which builds on Lab 01’s magnitude calibration. The capstone labs (Lab 16 in Volume I and Lab 17 in Volume II) synthesize your full Design Ledger into a portfolio.
How do these labs work? A 5-minute walkthrough of the predict-discover-explain ritual every lab follows.
If a model fails for three different physical reasons on three hardware targets, how do you diagnose which axis to fix?
If you double compute power, why does latency not halve?
Why does discovering a deployment constraint late cost 16× more than finding it early?
When is moving compute to data cheaper than moving data to compute?
ReLU and Sigmoid produce similar accuracy, so why does activation memory dictate cache fit?
Why does self-attention scale quadratically O(N²) while convolutions scale linearly?
Why does compiled execution run 17× faster than eager mode without changing a single weight?
Why does a 7B parameter model need 112 GB of memory before storing a single activation?
When does curating data produce more accuracy per dollar than adding more raw data?
Can you compress a model 4× without losing accuracy? Where is the cliff?
Is your workload compute-bound or memory-bound, and why does the answer change the design?
Amdahl's Law says 5% sequential code limits speedup to 20× regardless of parallelism. Is that right?
Your server looks healthy at 50% utilization, so why does latency climb steeply at 80%?
Your model shipped Monday. By Friday it lost 3 accuracy points while your dashboard is green. Why?
Fairness costs accuracy, explanations cost latency, and all of it costs carbon. How do you budget?
Synthesize every invariant and physical constraint from the earlier labs into one deployment decision.
If you add 10× more GPUs, do you get 10× more throughput?
Why does Model FLOPs Utilization rarely exceed 50% on real datacenter hardware?
When does topology, latency, bandwidth, or bisection become the real system limit?
Can your distributed storage hierarchy feed your GPUs fast enough, or are they starving?
Which collective algorithm fits your topology, message size, and residual risk?
Data, tensor, or pipeline parallelism, and which fits your model and your cluster?
At 10,000 GPUs, what is the probability of zero failures in 24 hours?
FIFO scheduling wastes 40% of your cluster. Can gang scheduling and DRF do better?
How does FlashAttention SRAM tiling eliminate memory bandwidth bottlenecks?
How does PagedAttention virtual memory eliminate KV-cache fragmentation at scale?
When does moving inference to the edge save energy vs. trigger thermal throttling?
How do grey failures and stragglers silently amplify tail latency across a fleet?
Differential privacy adds noise. How much accuracy do you lose for how much privacy?
Adversarial training costs 8× compute. When is it worth it?
Moving your training from Iowa to Quebec cuts carbon 10×. Why?
The labs already run in your browser, so nothing needs to be installed. Users who want offline access or want to modify the simulations can install the package:
python3 -m pip install -r labs/requirements.txt
python3 -m pip install -e mlsysim
cd labs
marimo run vol1/lab_01_ml_intro.py
A four-volume open textbook on machine learning systems.
Beamer lecture decks with speaker notes for each volume and TinyML.
Interactive Marimo notebooks that measure the book's claims.
Hands-on embedded ML deployment on real devices.
Course maps, syllabi, and adoption resources for teaching.
A machine learning framework built from scratch, one module at a time.
The analytical modeling engine behind the book's quantitative figures.