+++ Meet us at SCCON in Berlin, 13–15 October +++ Experience Kolibri, our new sovereign model, live in action for the public sector +++ Hall 26A, Booth 126 +++

Aleph Alpha
Motion-blurred streaks of pink and bright orange-red sweeping upwards from left to right, fading into grey at the lower edge
Research

Jordan Sassoon

Scaling Pre-Training in Practice: A Hierarchical Approach

Meme image about the synchronised humming of hundreds of GPUs.

MFU is good; TPS is better

TPS=ntokensΔt⋅ngpus\mathrm{TPS} = \frac{n_\text{tokens}}{\Delta t\cdot n_\text{gpus}}
MFU=Ftoken⋅TPSFpeak\mathrm{MFU} = \frac{F_{\text{token}} \cdot \mathrm{TPS}}{F_{\text{peak}}}
mem=peak reserved memorytotal device memory\mathrm{mem} = \frac{\text{peak reserved memory}}{\text{total device memory}}

Three degrees of freedom to make us compute-bound

1 – Parallelism scheme

2 – Activation checkpointing

Memory profile of a run of our 30B-A3B model on 16 GPUs. Stored activations persist from the forward pass until the backward pass of the related layer. In the backward pass, each layer recomputes the activations it was missing to compute the gradients, thus creating many small spikes in memory. After the gradient is computed, the activations and model weights are evicted from memory, while the gradients are reduced and sharded again.

3 – Local batch size

ga=gbslbs⋅ngpus,ga∈N>0ga = \frac{gbs}{lbs\cdot n_{\text{gpus}}}, \qquad ga \in \mathbb{N}_{>0}

How it all fits together

Meme image of an average distributed training enjoyer.

16 GPUs are enough to decimate our search space

Heatmap of model efficiency across different parallelism and activation checkpointing configurations, evaluated over local batch sizes up to OOM. Peak performance reaches 28.4k TPS and 37.5% MFU. Results are averaged over 20 training steps. Dark green = speedy!

A profile is worth a thousand experiments

Meme image about seeing clearly.
PyTorch trace of the forward pass of our 30B-A3B MoE model for transformer layers 25–30. We use Perfetto UI to analyse all our traces; the trace analyser reported in this post is custom-built. We group compute and communication kernels by type (all_gather, General Matrix Multiply – GEMM, Attention, Norm, and all other operations).
PyTorch trace of the backward pass of our 30B-A3B MoE model for transformer layers 30–25. Just like in the forward pass, our compute kernels are back to back. We also see the reduce_scatter operation to average and shard computed gradients.
The all_reduce operation is inserted after the reduce_scatter to average and shard computed gradients between FSDP groups.

Trace of our model with DP during the backward pass of a non-final gradient accumulation step. DP all_reduce operations are not needed and therefore removed.

From 16 to 512 GPUs, scaling cost is (nearly) free

Forward pass on 128 GPUs, FSDP=128, selective-AC.

Forward pass on 128 GPUs, FSDP=128, full-AC.

Forward pass on 512 GPUs, FSDP=128, DP=4, selective-AC.

Best configuration per GPU count.
Number of GPUs FSDP/DP TPS MFU HBM usage
1616/128.4k37.5%92%
128128/128.0k37.0%93%
512128/426.7k35.3%94%

Limitations

Conclusion

Acknowledgements

More blog posts