Skip to content

Commit

Permalink
make sure plugins are not none
Browse files Browse the repository at this point in the history
  • Loading branch information
kashif committed May 13, 2024
1 parent 3b63bdd commit 247a88b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion trl/trainer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ def _sync_target_model(model, target_model, alpha):

@classmethod
def sync_target_model(cls, model, target_model, alpha):
if AcceleratorState().deepspeed_plugin.zero_stage == 3:
deepspeed_plugin = AcceleratorState().deepspeed_plugin
if deepspeed_plugin is not None and deepspeed_plugin.zero_stage == 3:
with deepspeed.zero.GatheredParameters(list(model.parameters()), modifier_rank=0):
if deepspeed.comm.get_rank() == 0:
cls._sync_target_model(model, target_model, alpha)
Expand Down

0 comments on commit 247a88b

Please sign in to comment.