Skip to content

Commit

Permalink
offload fsdp state dict to cpu and rank 0 only
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiscode committed Jun 27, 2024
1 parent c633811 commit 04f3be1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python/text_utils/api/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,16 @@ def __init__(
# later, because FSDP handles mixed precision itself
self.mixed_precision = None

offload_state_dict = self.info.world_size > 1
FSDP.set_state_dict_type(
self.model,
StateDictType.FULL_STATE_DICT,
FullStateDictConfig(
offload_to_cpu=offload_state_dict,
rank0_only=offload_state_dict
offload_to_cpu=True,
rank0_only=True
),
FullOptimStateDictConfig(
offload_to_cpu=offload_state_dict,
rank0_only=offload_state_dict
offload_to_cpu=True,
rank0_only=True
)
)

Expand Down

0 comments on commit 04f3be1

Please sign in to comment.