Add ORPOTrainer tests to align coverage with DPO#6229
Open
DaoyuanLi2816 wants to merge 1 commit into
Open
Conversation
ORPOTrainer had thin test coverage (5 tests) vs DPO (~40). Port DPO's generic trainer tests: test_train_model_dtype, test_train_with_eval, test_train_with_gradient_checkpointing, test_tag_added, test_tag_added_peft. All pass on a single GPU. (IterableDataset and dict eval_dataset tests were intentionally not ported: ORPOTrainer.__init__ doesn't yet support those, unlike DPO -- left as a possible follow-up.)
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.
ORPOTrainerhas thin test coverage (5 tests) compared toDPOTrainer(~40). This ports a set of DPO's generic trainer tests to ORPO, in the spirit of the maintainers' "Align KTO with DPO: Add tests" work (e.g. #6034, #6160):test_train_model_dtype— training withmodel_init_kwargs={"dtype": torch.float16}keeps the trained params in fp16.test_train_with_eval— witheval_strategy="steps", aneval_lossis logged.test_train_with_gradient_checkpointing— regression guard for the (default-on) gradient-checkpointing path.test_tag_added/test_tag_added_peft— the["orpo", "trl"]model-card tags are set (plain and with PEFT).All pass on a single GPU (RTX 4080);
ruff check/ruff format --checkclean.Note: while porting I found two DPO tests that don't apply yet because
ORPOTrainerdoesn't support the feature — training on anIterableDataset(__init__calls.map(num_proc=...), whichIterableDatasetdoesn't accept) and a dicteval_dataset(__init__calls.map()on the dict). I left those out; aligning those two would need small__init__changes and could be a separate follow-up.Note
Low Risk
Test-only changes in the experimental ORPO test module; no runtime or training logic modified.
Overview
Expands
ORPOTrainerintegration tests intests/experimental/test_orpo_trainer.pyso coverage matches the pattern used for DPO / KTO (e.g. prior “align KTO with DPO” work). No trainer or library behavior is changed—only new regression tests.Added cases cover fp16 training via
model_init_kwargs, step-based eval (eval_lossin logs), gradient checkpointing (params still update), and model-card tagsorpoandtrlfor full finetune and PEFT setups. Iterable-dataset and dicteval_datasetDPO-style tests were intentionally omitted becauseORPOTrainer.__init__does not support those paths yet.Reviewed by Cursor Bugbot for commit 0c26e90. Bugbot is set up for automated code reviews on this repo. Configure here.