-
Notifications
You must be signed in to change notification settings - Fork 10
Wensun/apo #96
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
base: main
Are you sure you want to change the base?
Wensun/apo #96
Conversation
mean_ift = masked_mean( | ||
env_outs['ift_kl'], | ||
env_outs['action_mask'], | ||
) | ||
env_outs['advantages'] = advantages | ||
self.kl_ift.append(mean_ift.cpu()) | ||
|
||
iter_batch.update(env_outs) | ||
|
||
iter_batch.update({ | ||
'max_gen_len': | ||
torch.ones(self.iter_batch_size).to(torch.int32) * | ||
self.max_gen_len, | ||
'adv_masked_mean': | ||
torch.ones(self.iter_batch_size) * batch_adv_mean.cpu(), | ||
'adv_masked_var': | ||
torch.ones(self.iter_batch_size) * batch_adv_var.cpu(), | ||
'ift_kl_scalar': | ||
torch.ones(self.iter_batch_size) * self.kl_ctl.value, | ||
'reward_std': | ||
torch.ones(self.iter_batch_size) * | ||
env_outs['rewards'].std().to('cpu'), | ||
}) | ||
else: | ||
raise ValueError( | ||
f'Invalid loss type: {self.actor_critic.loss_type}. ' + | ||
'Valid options are: ppo, grpo.', | ||
) | ||
# APO and REBEL | ||
|
||
batch_adv_mean, batch_adv_var = dist_compute_masked_mean_and_var( | ||
env_outs['advantages'], | ||
env_outs['action_mask'], | ||
) | ||
mean_ift = masked_mean( | ||
env_outs['ift_kl'], | ||
env_outs['action_mask'], | ||
) | ||
self.kl_ift.append(mean_ift.cpu()) | ||
|
||
iter_batch.update(env_outs) | ||
|
||
iter_batch.update({ | ||
'max_gen_len': | ||
torch.ones(self.iter_batch_size).to(torch.int32) * | ||
self.max_gen_len, | ||
'adv_masked_mean': | ||
torch.ones(self.iter_batch_size), | ||
'adv_masked_var': | ||
torch.ones(self.iter_batch_size), | ||
'ift_kl_scalar': | ||
torch.ones(self.iter_batch_size) * self.kl_ctl.value, | ||
'reward_std': | ||
torch.ones(self.iter_batch_size) * | ||
env_outs['rewards'].std().to('cpu'), | ||
}) |
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.
Isn't this block of code for both algorithms very similar to each other, except for the adv_masked_mean
bit? If so can we condense it?
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.
done
Co-authored-by: bcui-db <141345999+bcui-db@users.noreply.github.com>
…into wensun/apo
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.
Looks good to me, but will wait for others to stamp it!
Implementation of the new algorithm A*PO.
An example of successful run on GSM8K on mlflow: link