refactor(reward): centralize post-score operations - #31
Draft
leviking98z-rgb wants to merge 1 commit into
Draft
Conversation
2 tasks
leviking98z-rgb
force-pushed
the
refactor/bounded-recipe-composition
branch
from
August 2, 2026 17:28
56c9bf7 to
86d9673
Compare
leviking98z-rgb
force-pushed
the
refactor/reward-ownership
branch
from
August 2, 2026 17:28
3cdf886 to
39165d1
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
unirl.reward.opsas the single framework owner for reward-service dispatch, TensorRef materialization, scalar statistics, and lineage credit assignment.propagate_rewardsoff theSampletransport type and into the reward layer.score_and_attachor lineage-propagation paths again.This is an ownership refactor, not a LOC-reduction PR: it is 270 insertions / 148 deletions (net +122), including 49 lines of static guard. It removes seven copies of reward hydration/statistics logic and prevents the wire type from owning reward policy.
This is stacked on
refactor/bounded-recipe-composition(#30 in this fork), not onmain.Related Issue
N/A
Test Plan
pre-commit run --all-files— passed, including recipe composition, architecture, framework, and experimental-boundary guards.python -m compileall -q unirl lint— passed.python lint/check_framework_contracts.py— passed; reports one reward-operation contract in addition to the existing framework contracts.python lint/check_architecture_boundaries.py— passed (476 files / 4,279 internal import edges).torch==2.7.1+cpuexercised service dispatch, real-tensor materialization, component materialization, count/sum/mean statistics, and two-parent mean credit assignment — passed.Compatibility / Risk
Sample.propagate_rewards(...)is removed. Out-of-tree callers must useunirl.reward.ops.propagate_rewards(sample, ...).RewardOutcome.meanpreserves the previousfloat32mean and returns0.0when no reward is attached.Reviewer Notes
unirl/reward/ops.py, the PE/unified-model call sites, thencheck_reward_operationsin the framework guard.trainer/diffusion.py/types/sample.py, but not this responsibility; a textual rebase conflict is possible because both move policy out of trainer flow. No open PR was found that centralizes reward materialization and lineage credit.Checklist