LLM pretraining uses massive effective batch sizes — millions of tokens per gradient update. Big batches stabilize gradient estimates (more samples = lower noise in the average gradient) and improve hardware utilization. The challenge: GPU memory.
Gradient accumulation
If you cannot fit your desired batch in memory, run several smaller "micro-batches," accumulate gradients across them, and update once. The effective batch size is micro-batch × accumulation steps. Memory cost is determined by the micro-batch; compute cost is identical to a single big batch.
This pattern is so universal that all modern training frameworks — PyTorch, DeepSpeed, Megatron-LM — make it the default. Production runs often use micro-batch ~1-4 sequences per GPU, accumulation ~16-128, distributed across hundreds or thousands of GPUs.