Configuration for FSDP (Fully Sharded Data Parallel). The inheritance from BaseConfig provides omegaconf.DictConfig-like interface for a dataclass config. Args: wrap_policy (Dict[str, Any]): Configuration for FSDP wrap policy. param_offload (bool): Whether to offload parame
| 137 | |
| 138 | @dataclass |
| 139 | class FSDPEngineConfig(EngineConfig): |
| 140 | """Configuration for FSDP (Fully Sharded Data Parallel). |
| 141 | |
| 142 | The inheritance from BaseConfig provides omegaconf.DictConfig-like interface for a dataclass config. |
| 143 | |
| 144 | Args: |
| 145 | wrap_policy (Dict[str, Any]): Configuration for FSDP wrap policy. |
| 146 | param_offload (bool): Whether to offload parameters to CPU, default False |
| 147 | optimizer_offload (bool): Whether to offload optimizer states to CPU, default False |
| 148 | offload_policy (bool): Whether to offload policy model parameters, default False |
| 149 | reshard_after_forward (bool): Whether to reshard parameters after forward pass, default True |
| 150 | fsdp_size (int): FSDP group size. -1 means use all available GPUs. |
| 151 | forward_prefetch (bool): Whether to prefetch parameters for next forward pass, default False |
| 152 | model_dtype (str): Model data type used to initialize the transformers model. default "fp32" |
| 153 | use_orig_params (bool): Whether to use original parameters when initialize FSDP1, default False |
| 154 | seed (int): Random seed for reproducibility. |
| 155 | full_determinism (bool): If true, enable_full_determinism is called to ensure reproducible results |
| 156 | in distributed training. Important: this will negatively impact performance, so only use it for |
| 157 | debugging. |
| 158 | mixed_precision (Optional[dict[str, Any]]): Mixed precision configuration for FSDP, default None |
| 159 | dtype (str): Mixed precision training param dtype, default "bfloat16" |
| 160 | """ |
| 161 | |
| 162 | # ulysses_sequence_parallel_size is mutable for backward compatibility |
| 163 | _mutable_fields = EngineConfig._mutable_fields | {"ulysses_sequence_parallel_size"} |
| 164 | |
| 165 | # fsdp specific flags |
| 166 | wrap_policy: dict[str, Any] = field(default_factory=dict) |
| 167 | offload_policy: bool = False |
| 168 | reshard_after_forward: bool = True |
| 169 | fsdp_size: int = -1 |
| 170 | forward_prefetch: bool = False |
| 171 | model_dtype: str = "fp32" |
| 172 | use_orig_params: bool = False |
| 173 | mixed_precision: Optional[dict[str, Any]] = None |
| 174 | ulysses_sequence_parallel_size: int = 1 |
| 175 | entropy_from_logits_with_chunking: bool = False |
| 176 | use_torch_compile: bool = True |
| 177 | entropy_checkpointing: bool = False |
| 178 | strategy: str = "fsdp" |
| 179 | |
| 180 | def __post_init__(self): |
| 181 | super().__post_init__() |
| 182 | assert self.strategy in ["fsdp", "fsdp2"], f"strategy {self.strategy} not supported" |
| 183 | |
| 184 | |
| 185 | @dataclass |
no outgoing calls