Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
The most common failure mode in ML systems work is optimization folklore: someone reads that fused kernels, bigger batches, or a specific flag fixed a colleague's job, applies it blind, and is confused when nothing changes. The discipline that actually works is a loop — measure, name the bottleneck, apply the one fix that addresses that specific bottleneck, then measure again — and it never skips a step. A profile that shows 60% of step time as NCCL communication tells you to look at Module 8's overlap and bucketing techniques, not Module 4's kernel fusion; a profile that shows 70% compute-bound matmul time tells you the opposite. This task is a checkpoint, not new material: it turns the vocabulary from the first five tasks (compute-bound, memory-bound, arithmetic intensity) into an actual decision procedure you'll run for real, on a real trace, starting in Module 3.
The demo encodes the decision procedure as a small router: given a rough profile split (fractions of step time in compute, memory-stall, communication, and idle), it recommends which module's toolkit to reach for next.
max(), which one wins — then argue whether that's the right default.dataloader_pct, that should win over idle_pct when both are present, and wire it into the function.def recommend_next_step(compute_pct, memory_pct, comm_pct, idle_pct):
dominant = max(
[("compute", compute_pct), ("memory", memory_pct),
("comm", comm_pct), ("idle", idle_pct)],
key=lambda kv: kv[1],
)
name, pct = dominant
if name == "compute":
return f"compute-bound ({pct:.0%}) -> write/use a fused kernel or lower precision (Module 4/5)"
if name == "memory":
return f"memory-bound ({pct:.0%}) -> fuse ops, cut activation memory, or shrink dtype (Module 4/5)"
if name == "comm":
return f"comm-bound ({pct:.0%}) -> overlap all-reduce, bucket gradients, or check topology (Module 6/8)"
return f"idle ({pct:.0%}) -> data-loader stall or host-device sync gap, check the trace timeline (Module 3)"
profiles = [
dict(compute_pct=0.72, memory_pct=0.15, comm_pct=0.05, idle_pct=0.08),
dict(compute_pct=0.20, memory_pct=0.55, comm_pct=0.10, idle_pct=0.15),
dict(compute_pct=0.30, memory_pct=0.10, comm_pct=0.50, idle_pct=0.10),
dict(compute_pct=0.35, memory_pct=0.15, comm_pct=0.10, idle_pct=0.40),
]
for p in profiles:
print(recommend_next_step(**p))python3 main.py