Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves the issue with evaluation on step2 for single GPU #766

Merged
merged 10 commits into from
Oct 12, 2023
15 changes: 11 additions & 4 deletions applications/DeepSpeed-Chat/training/utils/model/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def create_critic_model(model_name_or_path,
critic_model = create_hf_model(AutoModel, model_name_or_path, tokenizer,
ds_config, rlhf_training, dropout)
end = time.time()
if torch.distributed.get_rank() == 0:
if not torch.distributed.is_initialized():
print(f"> Creating model from_config took {end - start} seconds")
elif torch.distributed.get_rank() == 0:
mrwyattii marked this conversation as resolved.
Show resolved Hide resolved
print(f"> Creating model from_config took {end - start} seconds")

critic_model = RewardModel(
Expand All @@ -152,8 +154,10 @@ def create_critic_model(model_name_or_path,
start = time.time()
model_ckpt_state_dict = torch.load(model_ckpt_path, map_location='cpu')
end = time.time()
if torch.distributed.get_rank() == 0:
print(f"> torch.load took {end - start} seconds")
if not torch.distributed.is_initialized():
print(f"> Creating model from_config took {end - start} seconds")
elif torch.distributed.get_rank() == 0:
print(f"> Creating model from_config took {end - start} seconds")

# load critic model from checkpoint with zero-stage 3 compatibility
# this functionality may be moved to DS checkpoint load API in future
Expand All @@ -163,7 +167,10 @@ def create_critic_model(model_name_or_path,
"",
zero_stage=zero_stage)
end = time.time()
if torch.distributed.get_rank() == 0:

if not torch.distributed.is_initialized():
print(f"> Creating model from_config took {end - start} seconds")
elif torch.distributed.get_rank() == 0:
print(f"> Loading model state dict took {end - start} seconds")

return critic_model
Loading