Ability to store generation logits and vals for training #1535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using the PPO trainer, a user will generally generate responses with
PPOTrainer.generate()
. The input queries and resulting responses are then passed toPPOTrainer.step()
to train. At the start of training, the initial logits and values of the these input sequences are again calculated inPPOTrainer.step()
(line 1129 in this branch). The majority of this computation is a repeat of what was computed during the call toPPOTrainer.generate()
, which leaves an opportunity to save the computation cost of one forward pass per training batch. This optimization was previous requested in ticket #848.This change adds the ability to return the values and logits during generation, so that they can be fed back to
PPOTrainer.step()
, and reused to save on computation. Example usage:This is an easy addition to anyone who wants to save compute. The
return_values_and_logits
andvalues_and_logits
arguments of these functions are optional, so using these functions without change is also not an issue.