Skip to content

feat(flux): FSDP2 fp32/bf16 optimizers + fp8 all-gather#808

Merged
wenxie-amd merged 1 commit into
mainfrom
feat/flux/opt
Jul 8, 2026
Merged

feat(flux): FSDP2 fp32/bf16 optimizers + fp8 all-gather#808
wenxie-amd merged 1 commit into
mainfrom
feat/flux/opt

Conversation

@jasainio

Copy link
Copy Markdown
Contributor

Part of an 18-PR series splitting the Flux diffusion-training feature (training Flux, a DiT text-to-image diffusion model, on Primus/Megatron) out of one large branch for reviewability. Targets feat/flux/core — review after it. The diff here is only this layer.

What this changes

The FSDP2 optimization layer used by Flux training: fp32 and bf16-master-weight optimizer variants, incremental grad-norm, the FSDP2 fp8 all-gather path, and the related torch-FSDP2 / fp8-cache / optimizer-registration patches.

Dependencies

Sequenced after the CI-pins PR (feat/flux/ci-env); builds on feat/flux/core. It is the parent of the turbo layer, whose float8 extension lazily imports this layer's fp8 all-gather.

Test plan

pytest tests/unit_tests/optimizer tests/unit_tests/backends/megatron/diffusion/distributed. Validated locally on an AMD GPU container: 87 passed.

Files

14 (FSDP2 optimizers, fp8 all-gather, optimizer/FSDP2 patches + tests).

@luiza-amd luiza-amd changed the base branch from feat/flux/core to main July 7, 2026 10:01
@luiza-amd luiza-amd marked this pull request as ready for review July 7, 2026 10:04
@wenxie-amd wenxie-amd merged commit bbbcfa8 into main Jul 8, 2026
12 checks passed
botaohu001 added a commit that referenced this pull request Jul 10, 2026
…DP2 refactor (#808)

PR #808 (FSDP2 fp32/bf16 optimizers + fp8 all-gather) replaced Megatron's FSDP2
wrapper with PrimusTorchFullyShardedDataParallel (installed as
megatron.training.training.torch_FSDP). ODC still hooked the stock
megatron.core...TorchFullyShardedDataParallel.__init__, which is no longer
instantiated, so odc_init/_ensure_odc_ready never ran, reduction_service stayed
None, and odc_nopad crashed at iter2 with NoneType.clear_accumulations.

Hook the class the trainer actually uses, with an ImportError fallback to the
stock class. Verified: single-node 1.5B odc_nopad runs 100/100 (lm loss 9.970).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants