Preference Variety (v0.40.0)
Five preference losses live behind one config knob. Pick a loss without renaming your task, anneal β over training, periodically refresh the frozen reference, and blend dpo, ipo, simpo and orpo terms with a multi-objective surface (since v0.77.0 a blend naming dpo or ipo trains too, with the exceptions below).
On a card that cannot hold the model: seven tasks stream at v0.78.0,
sft,dpo,orpo,simpo,kto,bcoandipo(bcoandiposince v0.78.0).task: preferencestreams with onepreference_loss(dpo,orpo,simpo,bcooripo); apreference_loss_weightsblend is refused (tracked as #2766). DPO and IPO keep a frozenrefadapter on the same streamed base, KTO and BCO compute their reference with the adapters switched off, and ORPO and SimPO have no reference, so none of them needs a second copy of the weights.grpoandppoare refused, and that refusal names no release. See Preference losses over streaming.
Row layout (v0.76.1). The examples below read
format: dpo, and since v0.76.1 its converter hands the trainer every row in one layout: all strings, or all message lists with the prompt turns inpromptonly. A row that cannot be written that way is dropped at load with a reason that names the field. On v0.76.0 a stringpromptbesidechosen/rejectedmessage lists that repeat the user turn, the shape of the bundled DPO examples, madetask: dpo,ipo,bcoandpreferencefail inside trl after the model had loaded; on v0.76.1 they train.orpoandsimpoprepare the same tokens as before. See Data formats.
BCO (Binary Classifier Optimization)
Same input format as DPO; rows are split internally to TRL's BCO unpaired schema ({prompt, completion, label}).
task: bco
data:
train: ./data/preferences.jsonl
format: dpo
training:
bco_beta: 0.1
lora: { r: 64, alpha: 16 }
quantization: 4bitbco_beta defaults to 0.1 (gt=0). New soup init --template bco ships in the box.
Unified preference dispatcher
Use task: preference + training.preference_loss to swap losses without touching task. Hyperparameter sweeps over the loss type itself become trivial.
task: preference
data:
train: ./data/preferences.jsonl
format: dpo
training:
preference_loss: dpo # or simpo, orpo, ipo, bcoLegacy task: dpo / task: simpo / etc. remain first-class — the unified surface is additive.
KL-controlled DPO variants
Anneal β over training and periodically refresh the reference model.
task: dpo # or task: preference + preference_loss: dpo, or task: ipo
training:
dpo_beta: 0.1
dpo_beta_schedule: linear # linear | cosine | exponential
dpo_beta_end: 0.01
dpo_ref_regen_epochs: 2 # every 2 epochs, copy the current LoRA adapter into the frozen ref adapter
lora: { r: 8, alpha: 16 }Both controls are gated to DPO-family tasks (dpo, ipo, or preference with preference_loss in {dpo, ipo}). Transformers backend only.
The BetaScheduleCallback resolves total_steps lazily in on_train_begin so the schedule sees the real state.max_steps populated by HF Trainer. Epoch-0 regen is suppressed (avoids copying the untrained student).
Reference regeneration needs LoRA. Under LoRA, TRL keeps a frozen ref adapter beside the trainable one and no separate reference model. Since v0.76.0, dpo_ref_regen_epochs: N copies the active .default. adapter's weights into the .ref. adapter under torch.no_grad() every N epochs, in place (#1345). Full fine-tuning (lora.r: 0) with this key is refused when the config loads: dpo_ref_regen_epochs requires LoRA (lora.r >= 1): full fine-tuning (lora.r: 0) is not supported for DPO-family reference regeneration.
(Since closed in v0.76.0: through v0.75.2 a run that set dpo_ref_regen_epochs or dpo_beta_schedule on dpo, ipo or preference stopped when training started, because the two callbacks were plain classes rather than Hugging Face TrainerCallback subclasses (dpo_beta_schedule with AttributeError: 'BetaScheduleCallback' object has no attribute 'on_epoch_begin', #1229). Neither setting ever took effect, and no finished run exists to re-run. dpo_ref_regen_epochs is wired under LoRA now (#1345, #1636).)
task: dpo with modality: vision now loads a vision-language wrapper checkpoint (AutoModelForImageTextToText plus the model's processor) for text-only preference rows; task: preference with preference_loss: dpo follows it. backend: unsloth does not read modality for DPO and is refused at config load for that combination (#1393).
Multi-objective preference loss (v0.40.1, blend added in v0.53.11, narrowed in v0.76.0)
task: preference
training:
preference_loss_weights: {simpo: 0.6, orpo: 0.4}The schema validates 2–5 entries summing to 1.0 (±1e-6). Single-entry rejected with an actionable message pointing at scalar preference_loss. Mutually exclusive with scalar preference_loss. Rejected on MLX backend.
Since v0.77.0 a blend that names dpo or ipo trains too, whichever loss has the largest weight (#1425, #1785, #1828, by @ybai08), with the exceptions below. The loss with the largest weight is the primary: its trl trainer is the one that is built, and the per-sequence log-probs the terms need are read out of that trainer's own forward pass.
| Largest weight | Where the terms come from |
|---|---|
dpo or ipo | trl's DPOTrainer. The policy log-probs come from its own forward pass and the reference log-probs from its compute_ref_log_probs; upstream: "The reference is run twice per step." |
simpo or orpo | trl's CPO (SimPO) or ORPO trainer, which return their log-probs from concatenated_forward. A dpo or ipo term needs a reference these trainers do not run, so the blend runs one: the trainer's own forward once more per step, without gradients and with the LoRA adapter switched off. A blend of only simpo and orpo runs no extra forward. |
- Which reference. Under a
dpooripoprimary it is trl's frozen copy of the adapter as it started; under asimpoororpoprimary it is the base with the adapter switched off. For a new LoRA adapter, whose update starts at zero, the two are the same model. They are not withlora.init_strategy: pissa,oloraorloftq(oruse_olora), which move part of every targeted weight into the adapter, so adpooripoterm under asimpoororpoprimary is refused with any of them when the trainer is set up, before the model loads; the config itself loads, sosoup train --dry-rundoes not catch it. Givedpooripothe largest weight instead.relora_stepsbeside a blend that namesdpo,ipoorbcois refused at config load whatever the primary (#1891). - What a term is.
dpoandipoare the lossespreference_loss: dpoandpreference_loss: ipotrain: DPO's sigmoid loss withtraining.dpo_beta, and IPO's loss withtraining.ipo_tau, each log-ratio divided by its response length as trl's IPO loss does. In a blend,simpoandorpoare their preference terms only (the margin or odds-ratio objective), without the likelihood term the standalonepreference_loss: simpoandpreference_loss: orporuns carry, so asimpoplusorpoblend is not the same number as either standalone run, andtraining.cpo_alphadoes not affect it. Each term reads its own config field (training.simpo_gammafor SimPO,training.orpo_betafor ORPO) whichever loss is the primary. - The same term is not exactly the same number under every primary. The terms are computed on the primary trainer's batch, and the CPO and ORPO batches start with the BOS token where the
DPOTrainer's need not, so adpoterm under asimpoprimary differs a little from the same term under adpoprimary. - Where a blend still stops at the first step. A
dpooripoterm under asimpoororpoprimary in a full fine-tune (lora.r: 0), which has no adapter to switch off, and a trainer that exposes no log-probs to read. The error startspreference_loss_weights: cannot compute <terms>, says why, and names what to change.dpo_beta_scheduleanddpo_ref_regen_epochsare refused with a blend when the config loads. - What was checked. Upstream's tests train blends on a tiny model and compare the captured log-probs against ones rebuilt independently. No quality or speed result is claimed for any blend.
Through v0.76.1 only a blend that named simpo and orpo alone trained: a blend naming dpo or ipo stopped at the first training step with preference_loss_weights: cannot compute <terms> on this step, because those trainers compute their log-probs inline and publish only means.
- Evaluation. With
val_splitset and asimpoororpoprimary, the eval loss is the primary trainer's own loss, not the blend's value, so training and evaluation report different numbers for the same batch. With adpooripoprimary, upstream says the eval loss is the blend's value.
bco cannot be combined with a paired loss, and the refusal arrives later than the others: the schema allowlist accepts the name, so the config loads clean and validate_weight_compat raises at trainer setup instead. BCO scores each completion on its own, the paired losses need a chosen-versus-rejected pair, and there is no shared batch shape. Use bco as a scalar preference_loss rather than as an ensemble member.
This surface shipped schema-only in v0.40.0, where training raised an actionable NotImplementedError (the same stub-then-live pattern as v0.27.0 MII / v0.37.0 multipack / v0.38.0 quant menu / v0.39.0 ReLoRA). v0.40.1 replaced that stub with a primary-loss approximation: the highest-weighted loss becomes the trainer and its term is scaled by its weight. v0.53.11 added a per-batch weighted blend on top, but the blend reads the policy log-probs from the batch the trainer receives, and TRL 0.29's trainers do not put them there. (Since closed in v0.76.0: through v0.75.2 the blend then quietly fell back to the primary-loss scaling. {dpo: 0.7, simpo: 0.3} printed Multi-objective preference loss: 0.70·dpo + 0.30·simpo at setup and then trained DPO alone, scaled by 0.7, with nothing in the output saying so. v0.76.0 refuses that instead (#1513) and trains the simpo plus orpo blend described above (#1556). A task: preference run from an earlier version that set preference_loss_weights was a single-loss run.) (Since closed in v0.77.0: blends naming dpo or ipo train too, #1785, #1828.) The NotImplementedError stub is gone.
SimPO caps the prompt since v0.77.0 (#2112, #2116). On the transformers backend TRL 0.29.1's CPO tokenizer cut only the answers, so a long prompt reached the model whole, beyond data.max_length. The prompt is now cut to data.max_length // 2 tokens, keeping its end, and the answers to the room left, as DPO and ORPO do. At v0.77.1 a prompt longer than data.max_length // 2 tokens was cut even when the whole row would fit (upstream's Known Limitation, #1185); a row whose prompt fit in that half and whose whole fit was unchanged.
History:(Since closed in v0.77.2, #1196 by @ousamabenyounes: for
simpo,kto,ipoandbcoon the transformers backend a prompt is cut only when the row does not fit indata.max_length. Such a row's prompt is cut todata.max_length // 2tokens, and the answers get the room left; a row that fits is unchanged, whatever its prompt length. This replaces the unconditional cut that #2116 introduced. KTO and BCO rebuild the completion from the untruncated answer instead of discarding it when a prompt is over length. That change is to the transformers wrappers. Onbackend: mlx, at v0.77.2,simporeused ORPO's tokenizer (trainer/mlx_orpo.py), which still cut a prompt longer thandata.max_length // 2tokens whether or not the whole row would fit (read in the code at that tag, not run); native MLX DPO, ORPO and SimPO follow the overflow-only rule since v0.78.0 (#2659, below). Per upstream, BCO, KTO and SimPO keep the end of a cut prompt, IPO followstruncation_mode(keep_startby default), and, at v0.77.2, DPO and ORPO kept theirmax_length // 2prompt cap (since closed in v0.78.0, below). Upstream's checks are CPU contract tests on trl 0.29; nothing was trained for this page. Upstream listed two open limits on trl 0.29 at v0.77.2: a KTO or BCO row whose prompt is cut tomax_length // 2loses its BOS token (#2487), and the KTO length cap reads the whole answer columns into memory (#2486).) (Since closed in v0.78.0: the BOS token survives a prompt cut in KTO, BCO, ORPO and SimPO (#2487, #2544, #2561, #2572), and the KTO length cap no longer reads whole answer columns (#2486).)
When the prompt is cut, for all six preference tasks (v0.78.0)
On the transformers backend, a row whose prompt plus longest answer fits in data.max_length reaches the trainer unchanged, however long its prompt. Since v0.78.0 that holds for all six tasks: task: dpo and task: orpo on trl 0.29 now cut a prompt longer than data.max_length // 2 only when the row does not fit in data.max_length (#1209, #2555, by @Srinivasan8888), the rule bco, ipo, kto and simpo already followed. A row that overflows has a prompt longer than data.max_length // 2 tokens cut to that many, and its answers cut to the room left. Native MLX DPO, ORPO and SimPO follow the same rule since v0.78.0 (#2199, #2659, by @nazek52); only an overflowing pair applies the half-length cap there.
| Task | When the prompt is cut | Which end is kept |
|---|---|---|
dpo | only when the row does not fit | the start (keep_start) |
ipo | only when the row does not fit | the start by default (truncation_mode, keep_start) |
orpo | only when the row does not fit | the end, with the BOS token kept in front when the prompt starts with one |
simpo | only when the row does not fit | the end, with the BOS token kept in front when the prompt starts with one |
kto | only when the row does not fit | the end, with the BOS token kept in front when the prompt starts with one |
bco | only when the row does not fit | the end, with the BOS token kept in front when the prompt starts with one |
This is upstream's table (its docs/training.md) and upstream's CPU contract tests on trl 0.29; nothing was trained for this page. Before v0.78.0, DPO and ORPO cut every prompt longer than data.max_length // 2 tokens, rows that fit included, and the BOS token was lost after an end-keeping cut in KTO, BCO, ORPO and SimPO. Upstream lists this among the changes that make a run not bit-comparable with v0.77.2: to reproduce a v0.77.2 run, shorten prompts longer than data.max_length // 2 tokens in the data first.
Re-run this
| If you trained | What was wrong | What to do |
|---|---|---|
task: preference with preference_loss_weights, through v0.75.2 | The blend printed at setup was not the loss that trained. Only the highest-weighted loss trained, scaled by its weight, with nothing saying so (#1425) | Re-run as a single loss with training.preference_loss, or as a blend (since v0.77.0 a blend naming dpo or ipo trains too; see the exceptions above) |
task: dpo, ipo, or task: preference with dpo or ipo, resumed with --resume, before v0.77.0 | Upstream: --resume "restored the optimizer and the step counter and trained a freshly initialised adapter: on a 4-step run resumed at step 2, the result was two steps from zero" (#1768, #1797). orpo, simpo, bco and kto were not affected | Upstream: "Re-run any dpo, ipo or grpo training that was resumed from a checkpoint." |
task: simpo on a pair where chosen is much longer than rejected and longer than data.max_length | On trl 0.29.x the shorter side could end with zero tokens, SimPO's length-normalised log-probability became 0/0, and the adapter went to NaN behind a logged loss of 0.0 (#1208) | Check the adapter for NaN or zero tensors and re-run after shortening the data or raising data.max_length. v0.76.0 refuses such a dataset before the first step, naming how many rows, which ones and the data.max_length involved |
Stats
- Net +118 tests (4538 → 4656 across 136 files)
- BCO trainer + dispatcher + β schedule math + ref-model regen TOCTOU + multi-objective schema bounds
See also
- DPO training guide — preference dataset format
- Trace-to-preference — harvest pairs from production logs
- Registry — track preference variants in the lineage DAG
Soup is free and Apache-2.0. If it saved you a training run, starring the repo costs nothing and helps most. You can also fund the GPU time behind the work a 4 GB laptop cannot reach.