Commit c31418c
committed
fix(metrics): correct four RL trainer diagnostics
Two of the four are padding problems and two are not. No loss or gradient path
changes in any of them.
Online DPO summed raw `(B, T)` logprobs for `objective/kl`, `objective/entropy`
and, through `non_score_reward`, `objective/rlhf_reward`, two lines below a loss
that already multiplies by `~cr_padding_mask`. PPO masked `pg_loss` and
`pg_clipfrac` but left `policy/approxkl_avg`, `policy/entropy_avg` and
`policy/ratio_avg` on a bare `.mean()`. Both now use the mask already in scope.
The padded positions hold `log p(pad | context)`: `_forward` returns
`selective_log_softmax` over the full padded width and nothing zeroes it before
the stat sites. That value rises toward zero as the policy learns to emit pad
after EOS, so the contamination shrinks during training instead of sitting at a
fixed offset. Holding the true masked entropy fixed and moving only `p(pad|ctx)`
from 0.01 to 0.99 slides the reported value from 48.99 to 37.51, a downward
trend that nothing real is producing.
XPO logged `logps/chosen` and `logps/rejected` as policy plus reference logps.
Online DPO logs the policy term alone and Nash-MD logs the two separately, so
the sum matches neither and has no interpretation. Now the policy term.
GRPO computed `policy_loss` on every loss branch but appended it only inside the
entropy-bonus block, so the metric vanished for standard runs. The append moves
out. Its value is unchanged: it is captured after the KL term is folded in, so
with `beta != 0` it carries that too, and excludes only the entropy bonus and
the MoE auxiliary loss.
Resolves #68091 parent 6d484ba commit c31418c
4 files changed
Lines changed: 18 additions & 9 deletions
File tree
- trl
- experimental
- online_dpo
- ppo
- xpo
- trainer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1249 | 1249 | | |
1250 | 1250 | | |
1251 | 1251 | | |
1252 | | - | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
1253 | 1255 | | |
1254 | 1256 | | |
1255 | 1257 | | |
| |||
1262 | 1264 | | |
1263 | 1265 | | |
1264 | 1266 | | |
1265 | | - | |
| 1267 | + | |
1266 | 1268 | | |
1267 | 1269 | | |
1268 | 1270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
857 | | - | |
| 857 | + | |
858 | 858 | | |
859 | 859 | | |
860 | 860 | | |
| |||
864 | 864 | | |
865 | 865 | | |
866 | 866 | | |
867 | | - | |
868 | | - | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
869 | 873 | | |
870 | 874 | | |
871 | 875 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
388 | | - | |
| 387 | + | |
| 388 | + | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3272 | 3272 | | |
3273 | 3273 | | |
3274 | 3274 | | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
3275 | 3280 | | |
3276 | 3281 | | |
3277 | 3282 | | |
| |||
3299 | 3304 | | |
3300 | 3305 | | |
3301 | 3306 | | |
3302 | | - | |
3303 | | - | |
3304 | 3307 | | |
3305 | 3308 | | |
3306 | 3309 | | |
| |||
0 commit comments