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.
PPO trainer currently separately calculates the KL that's reported in the stats and to wandb, and always uses the estimated KL for this. That's fine when the estimated KL is also used for training (
kl_penalty = 'kl'
), but leads to a mismatch when usingkl_penalty = 'abs'
,kl_penalty = 'mse'
, orkl_penalty = 'full'
. Additionally, this can lead to a warning about negative KL being triggered even in cases where the KL used in training is not and cannot be negative.This PR changes it so that instead the KL that is calculated during training is kept and used for stats and reporting.
Tested using the PPO example script in both single-GPU and Deepspeed stage 2 training, leading to identical results in the
kl_penalty = 'kl'
case. Verified also thatkl_penalty = 'abs'
now does not trigger the negative KL warning anymore.Closes #1161.