-
Notifications
You must be signed in to change notification settings - Fork 1.8k
🍡 Fix using reward model and DeepSpeed ZeRO 3 #3326
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
Conversation
self.reward_func_names = [] | ||
for i, reward_func in enumerate(reward_funcs): | ||
if isinstance(reward_func, str): | ||
reward_funcs[i] = AutoModelForSequenceClassification.from_pretrained( | ||
reward_func, num_labels=1, **model_init_kwargs | ||
) | ||
if isinstance(reward_funcs[i], nn.Module): # Use Module over PretrainedModel for compat w/ compiled models | ||
self.reward_func_names.append(reward_funcs[i].config._name_or_path.split("/")[-1]) | ||
else: | ||
self.reward_func_names.append(reward_funcs[i].__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get the reward name before it's wrapped with deepspeed.
if self.is_deepspeed_enabled: | ||
self.reward_funcs[i] = prepare_deepspeed(reward_func, self.accelerator) | ||
else: | ||
self.reward_funcs[i] = self.accelerator.prepare_model(reward_func, evaluation_mode=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes this issue
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Fixes #3202
Before this PR, running this with ZeRO3 would fail: