Distributed training practice problems
21 problems · 0 solved
Large models do not fit on one GPU, and even when they do, training on one GPU would take too long. Distributed training splits the work across many devices. Data parallelism copies the model and splits the batch, tensor parallelism splits each layer, and pipeline parallelism splits the stack of layers, like an assembly line where each worker handles one station. These problems simulate these schemes with plain arrays so you can see exactly what moves where. You will average gradients across workers, pick gradient accumulation steps for a global batch, simulate ring all-reduce step by step, shard flattened parameters across ranks, estimate per-GPU memory under ZeRO stages, estimate communication for DP, ZeRO and TP, split an MLP with tensor parallelism, compute the pipeline bubble fraction, and generate GPipe and 1F1B schedules. Start with the Easy problems on gradient averaging and accumulation. Then do all-reduce, sharding and ZeRO memory, and finish with tensor parallelism and pipeline schedules. LLM infrastructure roles expect you to reason about memory and communication cost, and these questions come up often in systems interviews.
Easy 7
- Average gradients across data-parallel workers
- Compute the idle bubble fraction of a pipeline-parallel schedule
- Pick gradient accumulation steps for a global batch
- Compare ring and tree all-reduce with a latency-bandwidth model
- Estimate peak parameter memory for fully sharded training with prefetch
- Apply an outer momentum step after local SGD rounds
- Choose a checkpoint interval that minimizes activation memory
Medium 7
- Simulate ring all-reduce step by stepPro
- Estimate per-GPU memory under ZeRO stages 0 to 3Pro
- Estimate per-step communication for DP, ZeRO and TPPro
- Shard flattened parameters across ranksPro
- Group gradients into all-reduce buckets in backward orderPro
- Build the all-to-all send matrix for expert parallelismPro
- Simulate a dynamic loss scaler for mixed-precision trainingPro
Hard 7
- Split an MLP across GPUs with tensor parallelismPro
- Simulate a GPipe-style schedule with uneven stage timesPro
- Generate a 1F1B pipeline schedulePro
- Split attention heads across GPUs with tensor parallelismPro
- Compute cross-entropy when the vocabulary is split across GPUsPro
- Simulate a two-level hierarchical all-reducePro
- Compress gradients with top-k and error feedbackPro