Compute the effective batch from per-device batch, accum steps, and GPU count
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Effective batch is per_device_train_batch_size times gradient_accumulation_steps times world_size. With 2, 8, and 4 GPUs that is 64 examples per optimizer update.
Imagine four bakery teams each baking trays of cookies. Each team's oven only fits two trays at a time, so they bake two trays per oven round. They keep collecting cookies into a shared pile and only deliver the pile to the storefront after eight oven rounds. That means each team contributes 2 trays per round times 8 rounds equals 16 trays before delivery. Four teams doing this in parallel deliver 4 times 16 equals 64 trays per delivery cycle. The optimizer is the storefront and one delivery cycle is one update. The accumulation steps are the oven rounds, and the GPUs are the bakery teams.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: state the three-factor formula, walk through the worked example, then cover the loss-reduction trap and the LR-scaling implication that catch most teams.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Forgetting to multiply by world_size when computing effective batch. The optimizer sees the combined gradient from all data-parallel ranks, not just one rank's contribution.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.