Skip to content

[WIP] Document MX FP8 recipe #1350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/mxfp8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## MXFp8 Training on (G)B200 Blackwell - Experimental but available now for testing

MXFP8 training can provide substantial training speedups for models running on Nvidia Blackwell architecture (G and B200s+). MX FP8 enables fine grained quantization, where 1 x 32 elements are quantized per a single U8ME0 scaling, and this scaling can be done via hardware.

We have tested MXFP8 training at 1856 GPU Scale (Crusoe B200 cluster) and for Llama 3 70B model, we observed ~ 19% speedup with near equal or better convergence loss relative to BF16.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better if such claim (and most of this doc) is put in https://github.com/pytorch/torchtitan/tree/main/benchmarks


Note that the 19% speedup is a baseline atm - we have work to do to immprove the performance due to bank conflicts in the current kernels.


### Usage steps

Please install latest nightly [TorchAO](https://github.com/pytorch/ao/tree/main/torchao/float8) to support mxfp8 dtype
```
USE_CPP=0 python -m pip install --pre torchao --index-url https://download.pytorch.org/whl/nightly/cu128
```

For mxfp8 with 1x32 scaling, launch training job with the following command (or alternatively set configs in toml files)
```
CONFIG_FILE="./torchtitan/models/llama3/train_configs/llama3_8b.toml" ./run_train.sh --model.converters mx --mx.recipe_name "mxfp8" --training.compile
```
* `--model.converters="mx"`: use mx section for converting the linear layers
* `--mx.recipe_name "mxfp8"`: swap nn.Linears from high precision to mxfp8 for internal computation.
* `--training.compile` (required for competitive performance): use `torch.compile` to fuse the mxfp8 scaling/casting kernels
Loading