Align KTO with DPO: Align precompute_ref_logps#5850
Merged
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
qgallouedec
approved these changes
May 26, 2026
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.
Align KTO with DPO: Align
precompute_ref_logps.Part of:
Changes
Variable renaming for clarity:
precompute_ref_log_probstoprecompute_ref_logpsinKTOTrainerinit.if "reference_logps" in batchwith if self.precompute_ref_logps in_compute_loss.Note
Low Risk
Small refactor in KTO loss path; behavior change only when batches lack precompute but still carry
reference_logps, which should match enabled precompute mode.Overview
Aligns KTO with DPO by using a trainer flag
self.precompute_ref_logps(fromargs.precompute_ref_log_probs) instead of the oldself.precompute_ref_log_probsname everywhere that path is checked—including Liger validation and dataset precomputation.In
_compute_loss, reference log-probs are taken from the batch only whenself.precompute_ref_logpsis true, replacing the previous"reference_logps" in batchcheck so precomputed references are tied to the config, not accidental batch keys.Reviewed by Cursor Bugbot for commit 34b8124. Bugbot is set up for automated code reviews on this repo. Configure here.