Repository navigation
[mxfp8 moe training] add MX MoE model converter using torchao mxfp8 moe training; refactor quantization APIs to use unified API - #1701
Conversation
960840d to
90582f1
Compare
| # TODO: add warning in torchao when this happens, or find a better way to avoid this. | ||
| if self.moe_fqns: | ||
| self._convert_moe_layers(model) | ||
|
|
There was a problem hiding this comment.
it feels like the converter registered for self.config should handle this case specifically
There was a problem hiding this comment.
as in having separate converters registered for mxfp8 moe, fp8 moe etc? If so, I kind of agree actually, the converters are becoming a bit of a mess, and having separate converters would also allow users to convert just dense or just MoE (or both), rather than the current state of having to convert dense in order to convert MoE.
There was a problem hiding this comment.
Yeah that is one way, another thing I was thinking is that https://github.com/pytorch/ao/blob/93030e750186ace1c1c2ee7a849e2818a9f0ffde/torchao/prototype/moe_training/conversion_utils.py#L50 should be able to gracefully handle the case where the module has already be converted
There was a problem hiding this comment.
Separated the dense and MoE converters
tianyu-l
left a comment
There was a problem hiding this comment.
In the log
Swapped w1.weight to ScaledGroupedMMTensor
it's hard to tell which w1 is converted. Can we include full fqn?
(eager only currently - compile support in progress)
Does it mean we shouldn't care too much about performance with this PR?
How about numerics?
I'll try to find some time to look into #1651
902b922 to
4643915
Compare
d674008 to
5c45908
Compare
8533644 to
0032b6a
Compare
5d6046b to
7e1caa0
Compare
|
@tianyu-l tests are failing with a weird CI issue, it cannot |
|
|
||
|
|
||
| register_model_converter(Float8Converter, "float8") | ||
| register_model_converter(Float8DenseConverter, "quantize.float8.dense") |
There was a problem hiding this comment.
IMO ideally the order would be quantize.dense|moe.float8|mx
There was a problem hiding this comment.
hmm I agree... updated and retested on h100 + b200
|
|
||
|
|
||
| class MXConverter(ModelConverter): | ||
| class MXDenseConverter(ModelConverter): |
|
|
||
|
|
||
| register_model_converter(MXConverter, "mx") | ||
| class MXMoEConverter(ModelConverter): |
There was a problem hiding this comment.
MXGroupedGemmConverter? the more specific the better
b550f4a to
c8ca3c5
Compare
c8ca3c5 to
a7d6c8c
Compare
daac1f7 to
588966a
Compare
588966a to
d77a194
Compare
…oe training; refactor quantization APIs to use unified API (pytorch#1701) ## Context - We've recently landed prototype mxfp8 MoE training support in torchao, with **~1.3x speedup** over bf16 in single node. fsdp2 only, llama4 e2e training with seq_len 8192, 2 experts per device: pytorch/ao#3037. - This PR integrates this feature into torchtitan and refactors the quantized training APIs to use a unified `"quantize.[mx|float8].[dense|moe]"` API ## Changes - Replace "float8" and "mx" model converters with the following set of converters, unified under the `quantize` namespace: - `quantize.dense.mx` - `quantize.dense.float8` - `quantize.moe.mx` - `quantize.moe.float8` - This clean separation allows users more flexibility/control, to use mxfp8 for dense layers, MoE layers, or both. ## Test plan - float8 dense and moe: `NGPU=4 CONFIG_FILE="./torchtitan/experiments/llama4/train_conf igs/debug_model.toml" sanitize ./run_train.sh --parallelism.data_parallel_shard_degree=4 --parallelism.expert_parallel_degree=4 --parallelism.tensor_parallel_degree=1 --model.print-after-conversion --metrics.log_freq=10 --training.steps=30 --model.converters="quantize.dense.mx,quantize.moe.mx" --quantize.dense.mx.recipe_n ame="mxfp8_cublas" --quantize.moe.mx.fqns="experts"` - mxfp8 dense and moe: `NGPU=4 CONFIG_FILE="./torchtitan/experiments/llama4/train_configs/debug_model.toml" ./run_train.sh --parallelism.data_parallel_shard_degree=4 --parallelism.tensor_parallel_degree=1 --model.print-after-conversion --metrics.log_freq=10 --training.steps=30 --compile.enable --model.converters="quantize.dense.float8,quantize.moe.float8"`
In pytorch#1701 we split out the `Float8` job config to `Float8Dense` and `Float8MoE`. This forge config was inadvertently not updated. cc @tianyu-l
…oe training; refactor quantization APIs to use unified API (pytorch#1701) ## Context - We've recently landed prototype mxfp8 MoE training support in torchao, with **~1.3x speedup** over bf16 in single node. fsdp2 only, llama4 e2e training with seq_len 8192, 2 experts per device: pytorch/ao#3037. - This PR integrates this feature into torchtitan and refactors the quantized training APIs to use a unified `"quantize.[mx|float8].[dense|moe]"` API ## Changes - Replace "float8" and "mx" model converters with the following set of converters, unified under the `quantize` namespace: - `quantize.dense.mx` - `quantize.dense.float8` - `quantize.moe.mx` - `quantize.moe.float8` - This clean separation allows users more flexibility/control, to use mxfp8 for dense layers, MoE layers, or both. ## Test plan - float8 dense and moe: `NGPU=4 CONFIG_FILE="./torchtitan/experiments/llama4/train_conf igs/debug_model.toml" sanitize ./run_train.sh --parallelism.data_parallel_shard_degree=4 --parallelism.expert_parallel_degree=4 --parallelism.tensor_parallel_degree=1 --model.print-after-conversion --metrics.log_freq=10 --training.steps=30 --model.converters="quantize.dense.mx,quantize.moe.mx" --quantize.dense.mx.recipe_n ame="mxfp8_cublas" --quantize.moe.mx.fqns="experts"` - mxfp8 dense and moe: `NGPU=4 CONFIG_FILE="./torchtitan/experiments/llama4/train_configs/debug_model.toml" ./run_train.sh --parallelism.data_parallel_shard_degree=4 --parallelism.tensor_parallel_degree=1 --model.print-after-conversion --metrics.log_freq=10 --training.steps=30 --compile.enable --model.converters="quantize.dense.float8,quantize.moe.float8"`
In pytorch#1701 we split out the `Float8` job config to `Float8Dense` and `Float8MoE`. This forge config was inadvertently not updated. cc @tianyu-l
Context
"quantize.[mx|float8].[dense|moe]"APIChanges
quantizenamespace:quantize.dense.mxquantize.dense.float8quantize.moe.mxquantize.moe.float8Test plan
NGPU=4 CONFIG_FILE="./torchtitan/experiments/llama4/train_conf igs/debug_model.toml" sanitize ./run_train.sh --parallelism.data_parallel_shard_degree=4 --parallelism.expert_parallel_degree=4 --parallelism.tensor_parallel_degree=1 --model.print-after-conversion --metrics.log_freq=10 --training.steps=30 --model.converters="quantize.dense.mx,quantize.moe.mx" --quantize.dense.mx.recipe_n ame="mxfp8_cublas" --quantize.moe.mx.fqns="experts"NGPU=4 CONFIG_FILE="./torchtitan/experiments/llama4/train_configs/debug_model.toml" ./run_train.sh --parallelism.data_parallel_shard_degree=4 --parallelism.tensor_parallel_degree=1 --model.print-after-conversion --metrics.log_freq=10 --training.steps=30 --compile.enable --model.converters="quantize.dense.float8,quantize.moe.float8"