Add regression tests for evaluating init-time eval datasets after training with precomputed reference log-probs#6488
Open
albertvillanova wants to merge 3 commits into
Open
Add regression tests for evaluating init-time eval datasets after training with precomputed reference log-probs#6488albertvillanova wants to merge 3 commits into
albertvillanova wants to merge 3 commits into
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. |
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.
This PR adds regression tests to DPO and KTO verifying that an eval_dataset set at initialization keeps producing correct evaluation metrics after training when precompute_ref_log_probs=True.
Motivation
Follow-up to the eval-time reference log-prob guard added for DPO and KTO:
That guard raises when a new dataset is passed to evaluate() after training in full fine-tuning setups, where the reference model is no longer available. A concern was raised that the guard might also break evaluation of datasets set at initialization. It does not: those datasets have their reference log-probs precomputed once, against the untrained reference, and stored on the dataset, so evaluation reuses the stored values instead of recomputing them against the trained policy. These tests lock in that behavior so it cannot silently regress.
Solution
Add a parametrized test to each trainer that sets an eval_dataset at initialization, covering a plain Dataset, a DatasetDict, and a dict of datasets, then trains and calls evaluate() with no arguments, asserting it returns per-split metrics without raising.
Changes
Note
Low Risk
Test-only changes with no production code; lowest risk for runtime behavior.
Overview
Adds parametrized regression tests to
test_dpo_trainer.pyandtest_kto_trainer.pyso init-timeeval_datasetstill works after training whenprecompute_ref_log_probs=True.Each test builds a trainer with
eval_datasetat construction (plainDataset,DatasetDict, ordictof datasets), runs a short train step, then callsevaluate()with no dataset argument. It asserts eval loss metrics are returned and nothing raises—complementing the existing test that does raise when a new dataset is passed toevaluate()after training in full fine-tuning without a separate reference model.No trainer or library code changes; test-only follow-up to the eval-time reference log-prob guard (#6443).
Reviewed by Cursor Bugbot for commit bf962ae. Bugbot is set up for automated code reviews on this repo. Configure here.