-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update performance and loss converging results
ghstack-source-id: ec5512945a3f156a989111b8226d274650eed4d2 Pull Request resolved: #800
- Loading branch information
Showing
6 changed files
with
71 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,72 @@ | ||
To demonstrate the effectiveness of PyTorch distributed training techniques used in torchtitan, we report both the infra metrics and loss curves of Llama 3 (8B and 70B) training on 64 A100 (80GB memory) GPUs and Llama 3.1 (405B) on 128 H100 (94GB memory). | ||
We report infra metrics achieved by [FSDP2](fsdp.md) (1D parallelism) under various configurations, and loss curves for both 1D parallelism (FSDP2) and 2D parallelism (FSDP2 + Tensor Parallel) training. (We only report 2D for 405B) | ||
We demonstrate the effectiveness of elastic distributed training using torchtitan, via experiments on Llama 3.1 8B, 70B, and 405B models, from 1D parallelism to 4D parallelism, at the scale from 8 GPUs to 512 GPUs. | ||
|
||
We ran our performance benchmarks on the [Grand Teton platform](https://engineering.fb.com/2022/10/18/open-source/ocp-summit-2022-grand-teton/), where | ||
- Each host has 8 NVIDIA H100 GPUs fully connected with NVLink. | ||
- Each H100 GPU is equipped with 96GB HBM2e with 2.4 TB/sec peak memory bandwidth. | ||
- Hosts are inter-connected with backend RDMA network with 400 Gb/s per GPU. | ||
- We used the default 500W power limit, although tuning it up to 700W TDP can potentially provide further speedups. | ||
|
||
## Llama 3.1 performance numbers | ||
We note that, throughout our experimentation, memory readings are stable across the whole training process[^1], whereas throughput numbers (TPS/GPU) are calculated and logged every 10 iterations, and always read at the (arbitrarily determined) 90th iteration. | ||
|
||
Below are the WPS (word per second, or more accurately, token per second) and MFU (model FLOPS utilization) results which torchtitan achieves on the 405B model released in [Llama 3.1](https://llama.meta.com/docs/model-cards-and-prompt-formats/llama3_1). The way we compute WPS and MFU can be found in `train.py`. Because the model now is larger, we run on 128 H100 GPUs to test both performance and loss curves. Below is the performance result of 405B model with optimizations we have developed. We do see OOM for 1D parallelism (FSDP2), so we only tested 2D parallelism (FSDP2 + Tensor Parallel). | ||
We do not report Model FLOPS Utilization (MFU) because when Float8 is enabled (on `nn.Linear` modules), both BFLOAT16 Tensor Core and FP8 Tensor Core are involved in model training, but they have different peak FLOPS and the definition of MFU under such scenario is not well-defined. We note that the 1D Llama 3.1 8B model training on 8 or 128 H100 GPUs without Float8 achieves 33% to 39% MFU[^2] (with or without torch.compile, respectively). | ||
|
||
| Model size | Batch size | Activation checkpointing | WPS | MFU | Optimizations | | ||
| ----- | ----- | ----- | ----- | ----- | ----- | | ||
| 405B | 2 | full | 109 | 29.0%[^1] | None | ||
| 405B | 2 | full | 177 | 23.46%[^2] | Float8 | ||
| 405B | 2 | full | 185 | 24.52% | Float8 + Async TP | ||
**Table 1** 1D Parallelism (FSDP). Llama 3.1 8B model. 8 GPUs. Local batch size 2, global batch size 16. Selective activation checkpointing. | ||
|
||
Here, we use local batch size 2 (global batch size = local batch size 2 * number of FSDP ranks 16 = 32). | ||
| Techniques | TPS/GPU | Memory(GiB) | | ||
| ----- | ----: | ----: | | ||
| FSDP | 5,762 | 82.4 | | ||
| FSDP + torch.compile | 6,667 | 77.0 | | ||
| FSDP + torch.compile + Float8 | 8,532 | 76.8 | | ||
|
||
Next, we show the loss curves, all models are trained 3000 steps on the [C4 dataset](https://huggingface.co/datasets/allenai/c4), with global batch size 32. We have to use full AC to save memory usage. The results are shown in the picture (a TensorBoard screenshot) below. | ||
**Table 2** FSDP + CP + torch.compile + Float8. Llama 3.1 8B model. 8 GPUs. Local batch size 1. Full activation checkpointing. | ||
|
||
![image](../assets/images/llama3_1_405B_loss_curves.png) | ||
| Parallelism | Sequence Length | TPS/GPU | Memory(GiB) | | ||
| ----- | ----: | ----: | ----: | | ||
| FSDP 8, CP 1 | 32768 | 3,890 | 83.9 | | ||
| FSDP 4, CP 2 | 65536 | 2,540 | 84.2 | | ||
| FSDP 2, CP 4 | 131072 | 1,071 | 84.0 | | ||
| FSDP 1, CP 8 | 262144 | 548 | 84.5 | | ||
|
||
## Llama 3 performance numbers | ||
**Table 3** 1D Parallelism (FSDP). Llama 3.1 8B model. 128 GPUs. Local batch size 2, global batch size 256. Selective activation checkpointing. | ||
|
||
Below are the WPS and MFU results which torchtitan achieves on Llama 3 models with FSDP2 on 64 A100 (80GB) GPUs. | ||
| Techniques | TPS/GPU | Memory(GiB) | | ||
| ----- | ----: | ----: | | ||
| FSDP | 5,605 | 67.0 | | ||
| FSDP + torch.compile | 6,514 | 62.0 | | ||
| FSDP + torch.compile + Float8 | 8,380 | 61.8 | | ||
|
||
| Model size | Batch size | Activation checkpointing | WPS | MFU | | ||
| ----- | ----- | ----- | ----- | ----- | | ||
| 8B | 1 | selective layer | 2904 | 56.8% | | ||
| 8B | 1 | selective op | 2973 | 58.2% | | ||
| 70B | 1 | full | 331 | 51.7% | | ||
**Table 4** 2D parallelism (FSDP + TP) + torch.compile + Float8. Llama 3.1 70B model. 256 GPUs (FSDP 32, TP 8). Local batch size 16, global batch size 512. Full activation checkpointing. | ||
|
||
We use local batch size 1 (global batch size = local batch size 1 * number of FSDP ranks 64 = 64), because it mimics the small local batch size in large scaled training, and moreoever allows us to compare 1D (FSDP) and 2D (FSDP + TP) training under the same global batch size on both 8B and 70B Llama 3 models, without the out-of-memory (OOM) issue. | ||
| Techniques | TPS/GPU | Memory(GiB) | | ||
| ----- | ----: | ----: | | ||
| 2D | 829 | 71.9 | | ||
| 2D + AsyncTP | 876 | 67.6 | | ||
|
||
Next we show the loss curves for Llama 3 8B and Llama 3 70B training with both 1D parallelism (FSDP2) and 2D parallelism (FSDP2 + Tensor Parallel). All four models are trained the same way as mentioned above with global batch size 64. In terms of activation checkpointing (AC) configs, the Llama 3 8B training jobs use selective op AC, whereas the Llama 3 70B training jobs use full AC. The results are shown in the picture (a TensorBoard screenshot) below. | ||
**Table 5** 3D parallelism (FSDP + TP + PP) + torch.compile + Float8 + AsyncTP. Llama 3.1 405B model. 512 GPUs (FSDP 8, TP 8, PP8). Local batch size 32, global batch size 256. Full activation checkpointing. | ||
|
||
![image](../assets/images/llama3_loss_curves.png) | ||
| Schedule | TPS/GPU | Memory(GiB) | | ||
| ----- | ----: | ----: | | ||
| 1F1B | 100 | 82.5 | | ||
| Interleaved 1F1B | 128 | 72.7 | | ||
|
||
[^1]: We used HBM2e based lower TDP SXM H100(95GB) for our test, the actual peak TFLOPs number is between SXM and NVL, and we don't know its exact value. So this MFU number is lower than actual MFU because we use the peak number of SXM directly. | ||
**Table 6** 4D parallelism (FSDP + TP + PP + CP) + torch.compile + Float8 + AsyncTP + 1F1B. Llama 3.1 405B model. 512 GPUs (TP 8, PP8). Local batch size 8. Full activation checkpointing. | ||
|
||
[^2]: Since for Float8, we are not converting all the matmuls to Float8 because our fused attention implementation is not done in Float8, so this number is lower than expected. | ||
| Parallelism | Sequence Length | TPS/GPU | Memory(GiB) | | ||
| ----- | ----: | ----: | ----: | | ||
| FSDP 8, CP 1 | 32768 | 76 | 75.3 | | ||
| FSDP 4, CP 2 | 65536 | 47 | 75.9 | | ||
| FSDP 2, CP 4 | 131072 | 31 | 77.1 | | ||
| FSDP 1, CP 8 | 262144 | 16 | 84.9 | | ||
|
||
|
||
#### Versions | ||
| repo | commit | date | | ||
| --- | --- | --- | | ||
| torch | [1963fc8](https://github.com/pytorch/pytorch/commit/1963fc83a1c32e162162e2414f78b043f0674bae) | 2024/12/23 | | ||
| torchao | [eab345c](https://github.com/pytorch/ao/commit/eab345c2268a7506355d506ebfc27b5d28e5e7d0) | 2024/12/23 | | ||
| torchtitan | [9dec370](https://github.com/pytorch/torchtitan/commit/9dec370ad26b5f8e9a7333a0e36165018262644b) | 2024/12/26 | | ||
|
||
|
||
[^1]: Different PP ranks can have different peak memory usages. We take the maximum across all GPUs. | ||
|
||
[^2]: In our test we used HBM2e-based SXM H100 with lower TDP, the actual peak TFLOPs number is between SXM and NVL, and we don't know its exact value. So this MFU number is lower than actual MFU because we use the peak number of SXM directly. |