[Draft] Add reference-free SimPO loss - #2986
Draft
marcusacosta wants to merge 1 commit into
Draft
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Draft - design feedback requested
This PR adds native support for SimPO (Simple Preference Optimization) using
Torchtune's existing paired-preference DPO pipeline.
I am opening this as a draft because SimPO requires response-token-average log
probabilities, while existing DPO and RSO losses consume summed response log
probabilities. The PR preserves existing DPO/RSO behavior and requests review
of the loss-level aggregation contract.
Feedback is especially welcome on:
PreferenceLoss.return_average_logprobsis the preferred interfacefor losses that require averaged rather than summed sequence log
probabilities.
torchtune.rlhf.lossAPI or undertorchtune.dev.Summary
SimPOLoss(beta=2.0, gamma_beta_ratio=0.25).PreferenceLoss.return_average_logprobsproperty.llama3_1/8B_lora_simpo_single_device.and summed-versus-averaged log-probability aggregation.
SimPO compatibility
SimPO is a reference-free paired-preference objective that uses the average
log probability over unmasked response tokens. Existing Torchtune DPO recipes
currently provide summed sequence log probabilities to preference losses.
Torchtune already supports the required masked averaging through:
This PR exposes that selection through the loss contract while retaining
existing summed-log-probability behavior for DPO and RSO.
Scope
forward through the existing reference-free path.
Testing
The new GPU/S3-backed integration test was not run locally because a GPU and
the required test checkpoint artifacts are unavailable. It is collected with
the existing integration and one-GPU markers for the applicable upstream CI
workflow.
References