feat: reward shaping layer with success-gated length penalty - #3376
Draft
hallerite wants to merge 1 commit into
Draft
feat: reward shaping layer with success-gated length penalty#3376hallerite wants to merge 1 commit into
hallerite wants to merge 1 commit into
Conversation
Pull the length penalty out of GRPOAlgorithm into a RewardShaper layer that runs before credit assignment, gate it on success (success_threshold, default 1.0), and score every reward-consuming algorithm against training_reward. Bump deps/verifiers to the Trace.reward_shaping companion commit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
hallerite
force-pushed
the
feat/reward-shaping
branch
from
August 24, 2026 23:13
e09bce1 to
d1c84bc
Compare
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
Pulls the length penalty out of
GRPOAlgorithminto a reward-shaping layer that runs before credit assignment, and gates it on success.Why
The penalty modifies the reward; the algorithm decides what to do with the reward afterwards. Hacked into GRPO it was unavailable to
max_rl(a one-line variant of GRPO),raeandhierarchical_grpo. And it penalized every rollout in a group — a wrong long answer paid the same as a right long answer, so among failures shorter-wrong out-ranked longer-wrong: "if you're going to fail, fail fast", the opposite of what you want on hard problems.What
[[orchestrator.reward_shaping]]— a list of shapers (type = "length_penalty"is the first), inheriting to each[[orchestrator.train.source]]likealgodoes (unset inherits,[]disables).GRPOAlgoConfig.length_penaltyis removed.RewardShaper.shape_group(orchestrator/reward_shaping.py) runs inTrainSink.process_groupright beforealgorithm.finalize_group. Each shaper records an additive term on every trainable trace intrace.reward_shaping[<type>](new verifiers field, companion PR below).training_reward(trace)=trace.reward + sum(trace.reward_shaping.values())is whatgrpo,echo,max_rl,raeandhierarchical_grponow score against.trace.rewardstays the env's verdict, sosolved_*, pass@k gating, curriculum pools and evals are unaffected.penalty_i = 1[r_i ≥ success_threshold] · mean(r) · frac_i,success_threshold = 1.0by default (lower it for partial-credit envs).mean(r)stays as the difficulty scaler.reward_shaping/<type>.configs/debug/concurrency.toml,examples/advanced/{glm-4.5-air/*,nemotron-3-super/swe}.toml) are migrated with the same weights — note they now gate on success by default.docs/algorithms.md;docs/training.mdandskills/configsupdated.Companion
Depends on PrimeIntellect-ai/verifiers#2436 (
Trace.reward_shaping); thedeps/verifierssubmodule is bumped to that branch's commit (based on the currently pinnedd4f3d5a8c, so no other verifiers changes ride along).Tests
tests/unit/orchestrator: 87 passed. Length-penalty tests now driveLengthPenalty.shape_group→GRPOAlgorithm; one new test covers the success gate and threshold override.test_env_algo_overrides_top_levelextended to cover thereward_shapinginherit /[]rule.🤖 Generated with Claude Code