Add _MXFP8GroupedMM variant with bf16 backward - #4649
andrewor14 wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/4649
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 344526e with merge base f10e69b ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
why do we need cutedsl 4.6.0? can we use 4.5.2? |
It's because vllm nightly (since 7/16/26) has 4.6.0 has a hard dependency, and I feel it's unlikely they'll downgrade. torchtitan RL is expected to work with vllm nightly |
| out_dtype: Optional[torch.dtype] = torch.bfloat16 | ||
|
|
||
| # Whether to compute the gradient of the weights in high precision (True) or use MXFP8 (False). | ||
| wgrad_with_hp: bool = False |
There was a problem hiding this comment.
@andrewor14 , i think instead of bf16_bwd you can set this flag to true and also add dgrad_with_hp to get the same effect but matching the existing code better.
|
Going to close this to reopen with ghstack |
**Summary:** Add `_MXFP8GroupedMMFwdBF16Bwd`, which does real MXFP8 forward but BF16 backward backward (straight-through), for QAT or RL trainer where a low-precision backward isn't needed. Selectable via a new `bf16_bwd` flag on `_to_mxfp8_then_scaled_grouped_mm` and `MXFP8TrainingOpConfig`. Also add KernelPreference.TRITON, which runs pure triton kernels for the forward quantization to work around an mxfp8 cutedsl issue (see #4647). Example usage: ``` from torchao.prototype.moe_training.config import MXFP8TrainingOpConfig from torchao.prototype.mx_formats.config import ScaleCalculationMode from torchao.quantization import quantize_ from torchao.quantization.quantize_.common import KernelPreference from torchtitan.models.common.moe import GroupedExperts config = MXFP8TrainingOpConfig( kernel_preference=KernelPreference.TRITON, scale_calculation_mode=ScaleCalculationMode.RCEIL, bf16_bwd=True, ) quantize_(model, config=config, filter_fn=lambda m, fqn: isinstance(m, GroupedExperts)) ``` **Test Plan:** ``` pytest test/prototype/moe_training/test_mxfp8_grouped_mm.py -k bf16_bwd_forward_matches_default pytest test/prototype/moe_training/test_mxfp8_grouped_mm.py -k bf16_bwd_triton_matches_emulated ``` Real e2e RL tests TBD.
0814732 to
344526e
Compare
Summary:
Add
_MXFP8GroupedMMFwdBF16Bwd, which does real MXFP8 forward but BF16 backward backward (straight-through), for QAT or RL trainer where a low-precision backward isn't needed. Selectable via a newbf16_bwdflag on_to_mxfp8_then_scaled_grouped_mmandMXFP8TrainingOpConfig. Also add KernelPreference.TRITON, which runs pure triton kernels for the forward quantization to work around an mxfp8 cutedsl issue (see #4647).Example usage:
Test Plan:
Real e2e RL tests TBD.