fsdp.py 770 B

1234567891011121314151617181920
  1. # Copyright (c) Meta Platforms, Inc. and affiliates.
  2. # This software may be used and distributed according to the terms of the Llama 2 Community License Agreement.
  3. from dataclasses import dataclass
  4. from torch.distributed.fsdp import ShardingStrategy
  5. from torch.distributed.fsdp.fully_sharded_data_parallel import StateDictType
  6. @dataclass
  7. class fsdp_config:
  8. mixed_precision: bool=True
  9. use_fp16: bool=False
  10. sharding_strategy: ShardingStrategy = ShardingStrategy.FULL_SHARD
  11. checkpoint_type: StateDictType = StateDictType.SHARDED_STATE_DICT # alternatively can use SHARDED_STATE_DICT save one file per rank, and can resize the world-size.
  12. fsdp_activation_checkpointing: bool=True
  13. pure_bf16: bool = False
  14. optimizer: str= "AdamW"