Model, Forward & Loss
Initialize parameters and implement the forward pass, activations, softmax, cross-entropy loss, and backprop that every worker will run locally.
Train workers locally, aggregate pseudo-gradients with an outer optimizer, and quantify communication savings.
Every source step is its own lesson with intuition, concepts, correctly rendered MathJax mathematics, implementation, tests, mistakes, and a checkpoint.
Initialize parameters and implement the forward pass, activations, softmax, cross-entropy loss, and backprop that every worker will run locally.
Build the per-worker AdamW optimizer: state init, moment updates, bias correction, the parameter step, and decoupled weight decay.
Implement the pytree-style parameter operations (clone, scale, subtract, average) that DiLoCo uses to compute pseudo-gradients and merge worker replicas.
Partition the dataset across workers (IID and non-IID), sample per-worker batches, and run local training steps that emulate a single DiLoCo inner worker.
Implement the server-side outer optimizer: state init, momentum buffer updates, Nesterov parameter updates, and computing the outer pseudo-gradient from worker deltas.
Compose everything into a full DiLoCo communication round, the outer training loop across rounds, and a synchronous SGD baseline for comparison.
Measure held-out loss, classification accuracy, and quantify DiLoCo's communication savings versus the synchronous baseline.