Add blockwise FP8 training recipe for linears and MoE grouped experts#3891
Draft
iamzainhuda wants to merge 1 commit into
Draft
Add blockwise FP8 training recipe for linears and MoE grouped experts#3891iamzainhuda wants to merge 1 commit into
iamzainhuda wants to merge 1 commit into
Conversation
- Add Float8BlockwiseLinear wrapper backed by
torchao.prototype.blockwise_fp8_training.linear, selectable via
Float8LinearConverter recipe_name='blockwise'.
- Add recipe_name to Float8GroupedExpertsConverter ('fp8_rowwise' |
'fp8_blockwise'); the blockwise recipe routes routed-expert grouped
GEMMs through torchao's blockwise FP8 grouped MM via
Float8TrainingRecipe.FP8_BLOCKWISE.
- Add deepseek_v3_16b_fp8_blockwise and
deepseek_v3_debugmodel_fp8_blockwise configs applying blockwise FP8
to both linears and MoE experts.
- Add an 8-GPU BF16 vs blockwise FP8 loss-convergence comparison script
for DeepSeek V3 16B.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
8c54a40 to
19ec248
Compare
|
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #3228 (rebased onto latest main, and extended to cover MoE expert grouped GEMMs in addition to linears).
Float8BlockwiseLinearwrapper backed bytorchao.prototype.blockwise_fp8_training.linear, selectable viaFloat8LinearConverter.Config(recipe_name="blockwise"). Blockwise linears require bias-free layers with in/out features divisible byblock_size(128) and SM90+.recipe_nametoFloat8GroupedExpertsConverter.Config("fp8_rowwise"default,"fp8_blockwise"new). The blockwise recipe routes routed-expert grouped GEMMs through torchao's blockwise FP8 grouped MM (1x128 activation / 128x128 weight scaling, DeepSeek V3 style) viaFloat8TrainingRecipe.FP8_BLOCKWISE. Token-group padding to the 128 scaling block happens inside the torchao op, so no dispatcher-level padding swap is needed.deepseek_v3_16b_fp8_blockwiseanddeepseek_v3_debugmodel_fp8_blockwiseconfigs that apply blockwise FP8 to both dense/MoE-adjacent linears and routed experts (lm_headandrouter.gatefiltered).scripts/fp8_blockwise/compare_deepseek_v3_16b.shfor the 8-GPU BF16 vs blockwise FP8 loss-convergence comparison.Requires a torchao build with
torchao.prototype.moe_trainingblockwise FP8 support (Float8TrainingRecipe.FP8_BLOCKWISE), which is stacked on top of pytorch/ao#4551.Test Plan
pytest tests/unit_tests/test_quantization.py(newtest_fp8_blockwise_applied_by_model_registry)DeepSeek V3 16B loss convergence: 8x H100, 1000 steps, seed 42
STEPS=1000 NGPU=8 SEED=42 ./scripts/fp8_blockwise/compare_deepseek_v3_16b.sh-- defaultdeepseek_v3_16bparallelism (EP=8, Interleaved1F1B PP), C4 dataset, blockwise FP8 applied to all 159 eligible linears plus routed-expert grouped GEMMs (DeepGEMM backend).Blockwise FP8 tracks BF16 within noise for the entire run (final delta 0.0002, FP8 slightly ahead at most checkpoints).
Throughput note: this run was ~7.4k tps for FP8 vs ~9.5k tps for BF16. The 16B config only compiles the loss, so quantization ops run eager; grouped-GEMM performance work is tracked separately in torchao (native blockwise grouped GEMM kernels).
DeepSeek V3 debugmodel: 1 GPU, 30 steps, seed 42