feat(trainer): IPO+KL — double-sided mask, KL only on kept tokens#2423
Draft
feat(trainer): IPO+KL — double-sided mask, KL only on kept tokens#2423
Conversation
Two modifications to the default IPO+KL loss: 1. Replace advantage-conditioned probability-difference masking with IcePop-style double-sided importance-ratio masking: tokens whose ratio π_train/π_infer falls outside [α, β] are dropped. 2. Apply the KL penalty only to unmasked (kept) tokens. Previously, `kl_loss = loss_mask * log_ratio**2` accumulated KL for tokens that contributed nothing to the PG term — now it's gated by `keep_mask`. Breaking config changes (`trainer.loss`): - removed: `dppo_mask_low`, `dppo_mask_high` (probability-diff thresholds) - added: `ipo_ratio_low` (default: 0.2, α), `ipo_ratio_high` (default: 5.0, β) — importance-ratio bounds - unchanged: `kl_tau`, `adv_tau`, `teacher_tau` Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per review: don't rename the fields. The semantics changed (prob-diff threshold → importance-ratio bound), but reusing the existing field names keeps the diff against main minimal. `dppo_mask_high` default goes 0.2 → 5.0 to match the new ratio semantic; `dppo_mask_low` stays at 0.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per review: this isn't modified IPO. The DPPO probs-diff mask is fully gone; what's left is IcePop's ratio mask plus a Kimi-K2.5 KL term gated by the same mask. Update docstring and CHANGELOG entry to reflect that. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per review: this is IPO — DPPO+KL with two mods (double-sided mask + KL on kept tokens only). Not IcePop; IcePop is the no-KL sibling PR. Restore IPO+KL framing in docstring and CHANGELOG. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Two modifications to the existing IPO+KL default loss (DPPO-Binary TV PG term + Kimi-K2.5 KL term):
kl_loss = loss_mask * log_ratio**2— KL was paid even on tokens excluded from the PG term. Now it's gated bykeep_mask, so masked tokens contribute nothing to either term.The PG-term shape (DPPO-Binary TV) and the KL form (Kimi-K2.5,$(\log r_t)^2$ ) are unchanged.
adv_tau/teacher_tau(on-policy distillation) are also unchanged.Breaking config changes (
trainer.loss)dppo_mask_low(default0.2)dppo_mask_high(default0.2→5.0)kl_tau(1e-3),adv_tau(1.0),teacher_tau(0.0) untouched.Notes
feat/icepop-loss) is pure IcePop, no KL term at all. This PR keeps the existing KL — useful if the KL signal turns out to add stability on top of the double-sided mask alone.dppo_mask_*) to keep the diff against main minimal; only the semantic and one default change.dppo_mask_high=10.0as a kwarg, which still resolves to a valid (now ratio-based) value.🤖 Generated with Claude Code