Repository navigation
FSDP2 / DDP: only keep torchao weights FSDP2 cannot shard out of fully_shard and the DDP broadcast - #15373
Conversation
…fp8 weights The frozen-weight classifier from #15001 matched every torchao tensor subclass outside torchao.float8. Frozen NF4 weights were then replicated under shard_frozen (twice the packed bytes per rank) and trainable int8 mixed precision training weights were refused under FSDP2 and DDP, although both implement the hooks they need. Match only subclasses that store float8.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…tension replicated, not only float8 ones [skip ci]
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
#15001 keeps frozen
load_in_fp8weights (torchaoFloat8Tensor) out of FSDP2 sharding and out of the DDP broadcast. Its classifier matches every torchao tensor subclass outsidetorchao.float8, which catches two cases it should leave alone:NF4Tensor, QLoRA) are kept replicated underFSDP2Config(shard_frozen=True). Each rank holds the full packed weight instead of half of it.Int8MixedPrecisionTrainingLinearWeight) are refused under FSDP2 (cannot shard trainable float8 parameters) and under DDP (NotImplementedError).Both classes implement the FSDP2 all-gather hooks and the DDP flatten, and both trained before #15001.
Fix
fsdp2_native._float8_paramsnow keeps a torchao subclass out offully_shardonly when its class implements no FSDP2 all-gather extension (fsdp_pre_all_gather). That coversFloat8Tensor,AffineQuantizedTensor, and the inference int8 / int4 weights (Int8Tensor,IntxUnpackedToInt8Tensor), which implement only the ops their linear needs:fully_shard's split fails on them (NotImplementedError: Int8Tensor dispatch: ... aten.split).NF4Tensor, the int8 mixed precision training weight andtorchao.float8training weights implement the extension and go tofully_shard.Int8Tensor,AffineQuantizedTensor), so trainable int8 training weights and NF4 reach DDP as they did before Keep frozen load_in_fp8 weights out of FSDP2 sharding and the DDP broadcast #15001.Tests
tests/test_fp8_torchao_distributed_gloo.pygets four new cases; the first three run on 2 CPU gloo ranks, theInt8Tensorone in one process.shard_frozen=True: both MLP weights are DTensors holding 32768 packed bytes per rank (half of 2 x 32768)NotImplementedError)Int8Tensor(Int8WeightOnlyConfig) stays replicated; trainable is refused by FSDP2 and DDP up frontfully_shard)test_fsdp2_native_int8_gloo.py,test_float8_training_fsdp2_gloo.pyandtest_fsdp2_native_units.pystill pass (72 tests withtest_float8_training.py). The classifier was also run over the torchao weight classes on torchao 0.15 and 0.18 against whatfully_shardand DDP actually accept: 0 wrong moves.Not covered: GPU / NCCL runs, an end-to-end QLoRA training run under FSDP2, torchao versions other than 0.15 and 0.18, multi-node.