feat(grpo): add SAPO actor loss#2455
Open
taivu1998 wants to merge 1 commit into
Open
Conversation
Signed-off-by: taivu1998 <46636857+taivu1998@users.noreply.github.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.
Summary
loss_fn.actor_loss_type: "sapo".actor_loss_type: "ppo_clip".Closes #1677.
Motivation
Issue #1677 requests support for the SAPO algorithm from https://arxiv.org/pdf/2511.20347. The current GRPO loss path supports PPO-style clipped objectives and related variants, but does not expose SAPO smooth adaptive actor surrogate behavior.
Implementation
ClippedPGLossConfigwithactor_loss_type,sapo_tau_pos,sapo_tau_neg, andsapo_log_ratio_clamp_value.4 / tau * sigmoid(tau * (r - 1)), withtauselected by advantage sign.disable_ppo_ratio,force_on_policy_ratio, and dual clipping.Validation
12 passed, 43 deselectedfortests/unit/algorithms/test_loss_functions.py -k sapousing a no-project harness with managed Python, because this local machine has a broken/usr/local/bin/python3.13and the project requires>=3.13.13.ruff checkon all touched Python files.ruff format --checkon all touched Python files.python -m py_compileon all touched Python files.git diff --check.examples/andresearch/template_projectthat mentionratio_clip_c; all resolve the new SAPO config keys.Notes
The default remains
actor_loss_type: "ppo_clip", so existing configs preserve their current behavior unless SAPO is explicitly enabled.