Add ORPOTrainer tests to align coverage with DPO
ORPOTrainer has thin test coverage (5 tests) compared to DPOTrainer (~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 --check clean.
Note: while porting I found two DPO tests that don't apply yet because ORPOTrainer doesn't support the feature — training on an IterableDataset (__init__ calls .map(num_proc=...), which IterableDataset doesn't accept) and a dict eval_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 0c26e90523656741fa6f30d91ed883d0b40d04fe. Bugbot is set up for automated code reviews on this repo. Configure here.