Course · Distributed trainingPhase 09 · Study guide

Is the distributed update still optimizing the same objective?

Systems Specialization · CPU ReferenceCPU reference; target qualification separate4 lessons (~6.3h)

Revision v0.18.1 ·

Distribution changes where arrays and computations live; it should preserve the intended global objective. Begin by drawing which rows and parameter columns each device owns. Then derive how distinct contributions and valid counts combine into one loss and update. Use logical CPU devices to make ownership and unequal partitions inspectable. The unsharded calculation gives you a numerical reference; shard indices and local byte counts give you a placement reference. Communication and recovery add separate questions about coordinated work, which require their own receipts.

Preparation: Data & checkpoint recovery · Performance diagnosis

Runtime: Logical CPU devices for sharding practice; multi-host work needs a real cluster

Check your starting point

Two devices see one and three valid examples. Should their mean gradients receive equal weight?

Compare your reasoning

No. Weight by valid example counts. Sum local gradient numerators and valid counts, then divide once. Padding and empty partitions must not silently change the denominator.

If this is unfamiliar, work through A sharded training step before attempting the project.

Build in stages

1. Verify placement and the global update

Inspect actual shard indices and compare each relevant output with an independent unpartitioned calculation, including padded and unequal partitions.

2. Connect communication and recovery

Inspect collectives without inferring network speed from payload size. Restore data position and optimizer state before comparing subsequent global steps. Continue to the 2x2 data/model mesh: predict parameter and momentum slices and per-device bytes, then compare one forward/backward/update with an unsharded NumPy oracle under uneven and empty valid counts.

Try a changed condition

Make a prediction before opening the reasoning. Keep your answer and the evidence you would collect.

Three shards have valid counts 2, 6 and 0 and local gradient sums 6, 6 and 0. Predict the global mean and the empty-shard contribution.

Compare an approach

Reduce sums and counts separately: the global mean is (6+6+0)/(2+6+0)=1.5(6+6+0)/(2+6+0)=1.5. The empty shard contributes a zero numerator and zero count; it must not compute 0/00/0. Reject a globally empty batch. Compare with an independent unsharded calculation.

Diagnose a likely failure

Symptom: The gradient grows with device count.

Check next: Check whether local means were summed without count normalization. Verify one complete update before interpreting a training curve.

Decide what is ready

Use sharded-training. Retain actual placements and collectives, independent uneven/empty-partition checks and full-state replay. Label logical CPU devices explicitly.

Where to put your project code

Write your code in: projects/sharded-training/my_model.py (copy projects/sharded-training/starter/model.py first: cp projects/sharded-training/starter/model.py projects/sharded-training/my_model.py).

Verify your implementation: python3 projects/sharded-training/tests/check.py --stage all --impl projects/sharded-training/my_model.py

Run the staged project checks on your implementation in projects/sharded-training/my_model.py and record your transfer experiment results in your portfolio.

Open A resilient sharded training experiment

What still needs further work

Real network collectives, multi-controller ingestion and host-loss recovery are unqualified. The optional launch instructions are preparation, not execution receipts.