Conversation
…target margin - Add 'simpo' loss_type and configurable simpo_gamma margin to DPOEngineConfig - Support SimPO reference-free loss with length-normalized logits in dpo_preference_loss - Integrate SimPO length-normalized implicit reward scoring and stats reporting into compute_dpo_loss - Update bilingual CLI reference documentation (en/zh) - Add comprehensive unit tests in tests/test_simpo_loss.py
hsusul
requested review from
Le8r0nJames,
fishcrap,
garrett4wade,
nuzant,
rchardx and
sitabulaixizawaluduo
as code owners
September 10, 2026 16:17
Le8r0nJames
reviewed
Sep 16, 2026
| device = logprobs.device | ||
| cu_seqlens = input_["cu_seqlens"].to(device=device, dtype=torch.long) | ||
| loss_mask = input_["loss_mask"].bool().to(device=device) | ||
| ref_logprobs = input_["ref_logprobs"].to(device) |
Collaborator
There was a problem hiding this comment.
Could we skip reference-model initialization and log-prob computation for SimPO, and add a test without ref_logprobs? The loss is reference-free, but the training and evaluation paths still require the reference model.
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.
Description
Direct Preference Optimization (DPO) and its variants are core alignment techniques in post-training. Standard DPO requires loading a separate reference model alongside the policy model throughout training, substantially increasing GPU memory consumption and inference overhead. Furthermore, DPO without length normalization frequently suffers from length exploitation (favoring longer responses merely due to cumulative token log-probabilities).
SimPO (Simple Preference Optimization with a Reference-Free Objective, Meng et al., NeurIPS 2024, https://arxiv.org/abs/2405.14734) directly solves these issues:
$$\mathcal{L}{\text{SimPO}} = -\mathbb{E}{(x, y_w, y_l)} \left[ \log \sigma \left( \frac{\beta}{|y_w|} \log \pi_\theta(y_w \mid x) - \frac{\beta}{|y_l|} \log \pi_\theta(y_l \mid x) - \gamma \right) \right]$$
This PR introduces SimPO support into AReaL's preference learning engine:
"simpo"toloss_typeinDPOEngineConfig(["sigmoid", "ipo", "simpo"]).simpo_gamma: float = 0.5with non-negative validation (--dpo.actor.simpo_gammaand--dpo.ref.simpo_gamma).dpo_preference_lossinareal.utils.functionalwithloss_type="simpo"andsimpo_gammamargin.compute_dpo_lossinareal.trainer.dpo.dpo_engineto compute length-normalized policy log-probabilities and margin-adjusted logits.stats_tracker.docs/en/cli_reference.mdanddocs/zh/cli_reference.md).tests/test_simpo_loss.pycovering mathematical correctness, margin sensitivity, length normalization, autograd backward pass, and configuration validation.Related Issue
N/A
Type of Change
Checklist
pre-commit run --all-files)./docs/build_all.sh)main/review-prcommand/create-prAdditional Context
uv run pytest -q tests/test_simpo_loss.py(5/5 passed).uv run pytest -q tests/test_dpo.py(26/26 passed).