-
Notifications
You must be signed in to change notification settings - Fork 174
Add Rubric system for reward computation (RFC 004) #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Darktex
wants to merge
1
commit into
main
Choose a base branch
from
feat/rubrics-core
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
Implements the Rubric abstraction for reward computation as specified in RFC 004: - Base Rubric class with forward hooks, child registration, and serialization - Container rubrics: Sequential, Gate, WeightedSum, RubricList, RubricDict - Trajectory rubrics: TrajectoryRubric, ExponentialDiscountingTrajectoryRubric - Environment integration: rubric attribute, _apply_rubric(), _reset_rubric() This provides a composable, PyTorch-like API for defining reward signals that can be introspected by training infrastructure. 86 tests covering all rubric functionality.
3 tasks
Greptile OverviewGreptile SummaryThis PR implements RFC 004's Rubric system for composable reward computation in OpenEnv environments. The implementation provides a PyTorch-inspired API where environment authors define rubrics that compute rewards from actions and observations. Key additions:
Design alignment:
Test coverage:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Env as Environment
participant Rubric as Rubric System
participant Agent as Agent/Infrastructure
Note over Env,Agent: Episode Initialization
Agent->>Env: reset(seed, episode_id)
Env->>Rubric: _reset_rubric()
Rubric->>Rubric: Clear trajectory state
Env-->>Agent: Initial Observation
Note over Env,Agent: Step Loop
Agent->>Env: step(action)
Env->>Env: Execute action logic
Env->>Env: Create observation
Env->>Rubric: _apply_rubric(action, obs)
alt Immediate Reward (Base Rubric)
Rubric->>Rubric: forward(action, obs)
Rubric->>Rubric: Run pre-forward hooks
Rubric->>Rubric: Compute reward
Rubric->>Rubric: Update last_score
Rubric->>Rubric: Run post-forward hooks
Rubric-->>Env: Return reward score
else Trajectory-Based Reward
Rubric->>Rubric: Accumulate (action, obs)
alt Not done
Rubric-->>Env: Return intermediate_reward (0.0)
else Done
Rubric->>Rubric: score_trajectory()
Rubric-->>Env: Return final score
end
end
Env->>Env: observation.reward = score
Env-->>Agent: Observation with reward
opt Infrastructure Introspection
Agent->>Env: env.rubric.named_rubrics()
Env-->>Agent: Iterator of (name, rubric)
loop For each rubric
Agent->>Rubric: rubric.last_score
Rubric-->>Agent: Component score
end
end
opt Training with Trajectory Rubrics
Agent->>Rubric: compute_step_rewards()
Rubric->>Rubric: Apply credit assignment
Rubric-->>Agent: Per-step rewards list
end
|
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
Implements the Rubric abstraction for reward computation as specified in RFC 004:
Sequential,Gate,WeightedSum,RubricList,RubricDictTrajectoryRubric,ExponentialDiscountingTrajectoryRubricfor delayed rewardsrubricattribute,_apply_rubric(),_reset_rubric()helpersThis provides a composable, PyTorch-like API for defining reward signals that can be introspected by training infrastructure.
Changes
New files
src/openenv/core/rubrics/base.py- BaseRubricclasssrc/openenv/core/rubrics/containers.py- Container rubrics (Sequential, Gate, WeightedSum, etc.)src/openenv/core/rubrics/trajectory.py- Trajectory-based rubrics for delayed rewardssrc/openenv/core/rubrics/__init__.py- Package exportsModified files
src/openenv/core/env_server/interfaces.py- Added optionalrubricattribute and helper methodsTests
tests/core/test_rubrics/- 86 comprehensive tests covering all rubric functionalityTest plan
Follow-up PRs