Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions megatron/core/distributed/fsdp/mcore_fsdp_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
)
from megatron.core.distributed.fsdp.src.megatron_fsdp.v2 import FSDPModule
from megatron.core.distributed.fsdp.src.megatron_fsdp.v2.mixed_precision import (
FullyShardFP8Policy,
FullyShardMixedPrecisionPolicy,
)

Expand Down Expand Up @@ -251,6 +252,12 @@ def _init_with_fully_shard(
if ddp_config.grad_reduce_in_fp32
else ddp_config.megatron_fsdp_grad_comm_dtype
),
use_decoupled_grad=ddp_config.megatron_fsdp_use_decoupled_grad,
fp8=FullyShardFP8Policy(
enabled=ddp_config.fp8_param_gather,
recipe=config.fp8_recipe,
keep_transpose_cache=ddp_config.keep_fp8_transpose_cache,
),
)
kwargs = {
"mp_policy": fully_shard_mp_policy,
Expand Down
8 changes: 5 additions & 3 deletions megatron/core/distributed/fsdp/src/megatron_fsdp/v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ This directory contains the **fully_shard_v2** implementation — a PyTorch FSDP
v2/
├── README.md # This file
├── __init__.py # Public exports
├── fully_shard.py # Core fully_shard() API + FSDPModule class
├── fully_shard.py # Public fully_shard() API
├── fsdp_module.py # FSDPModule runtime state and methods
├── hooks.py # Forward/backward hook registration
├── param_group.py # ParameterGroup — groups params with shared buffers
├── dp_buffer.py # DataParallelBuffer — flat buffer management
├── allocator.py # TemporaryBucketAllocator — temp buffer reuse
├── allocator.py # BucketAllocator implementations
├── utils.py # Internal utility functions
└── design.md # Detailed design documentation (overlap, memory, sync)
```
Expand Down Expand Up @@ -123,4 +125,4 @@ torchrun --nproc_per_node=2 examples/megatron_fsdp/fsdp_toy.py \
```bash
# Run FSDP2 API tests
pytest -xvs tests/unit_tests/distributed/megatron_fsdp/test_mcore_fsdp_fully_shard_v2_api.py
```
```
Loading