Repository navigation
Adds reward groups to the reward manager - #729
Dhoeller19 wants to merge 2 commits into
Conversation
|
Thanks for porting and cleaning this up. |
| """ | ||
|
|
||
|
|
There was a problem hiding this comment.
| """ | |
| """ | |
| pass | |
|
|
||
| For backwards compatibility, the reward manager also supports the old configuration format without | ||
| groups. | ||
|
|
There was a problem hiding this comment.
Better to keep the note in a separate directive.
| For backwards compatibility, the reward manager also supports the old configuration format without | |
| groups. | |
| .. note:: | |
| For backwards compatibility, the reward manager also supports the old configuration format without | |
| groups. In this case, the :meth:`compute` returns a tensor instead of a dictionary of tensors. | |
|
|
||
| Returns: | ||
| The net reward signal of shape (num_envs,). | ||
| A dictionary containing the net reward signal of shape (num_envs,) for each group. |
There was a problem hiding this comment.
We return a tensor when user doesn't set things up. We should throw proper deprecation warnings to the user so that they adapt.
Both the docstring here in the return and also in the class docs need to be fixed.
| def set_term_cfg(self, term_name: str, cfg: RewardTermCfg, group_name: str = DEFAULT_GROUP_NAME): | ||
| """Sets the configuration of the specified term into the manager. | ||
|
|
||
| Args: | ||
| group_name: The name of the reward group. | ||
| term_name: The name of the reward term. | ||
| cfg: The configuration for the reward term. | ||
|
|
There was a problem hiding this comment.
Ordering of the args don't match.
Mayankm96
left a comment
There was a problem hiding this comment.
Minor comments related to breaking changes. Also need to adapt the unit tests.
| group_name: The name of the reward group. | ||
| term_name: The name of the reward term. |
| def active_terms(self) -> list[str]: | ||
| """Name of active reward terms.""" | ||
| return self._term_names | ||
| def active_terms(self) -> dict[str, list[str]]: |
There was a problem hiding this comment.
Breaking? This should return a list if it is only one group?
| from omni.isaac.lab.envs import ManagerBasedRLEnv | ||
|
|
||
|
|
||
| DEFAULT_GROUP_NAME = "reward" |
There was a problem hiding this comment.
If this is only for internal usage in the class then I suggest marking it with an underscore.
|
@lorenwel @Mayankm96 @jsmith-bdai I appreciate the effort in implementing this feature. I’ve been using it for my manager-based multi-agent setup, and it has been quite helpful. I have a suggestion: it might be beneficial to extend this to the termination manager as well. Specifically, accessing This change would enable computing returns more accurately. Currently, a single tensor indicates termination for all agents, even if only one agent has terminated, introducing potential bias in return calculations. However, this wouldn’t require modifying the logic for computing done in the manager-based RL environment, it would still be true if at least one agent has been terminated. Overall, this feature would be particularly useful for correctly computing returns in multi-agent scenarios. Let me know your thoughts! |
There was a problem hiding this comment.
Re-review after force push (583a264)
Previous bot review (4380685018) was lost during force push. Posting fresh findings that complement @Mayankm96's existing feedback.
Issues Found
-
Variable shadowing in
_prepare_terms— The inner loop reusesgroup_cfg_itemsas a variable name (line ~302), which shadows the outerfor group_name, group_cfg in group_cfg_items:loop iterator. While Python'sforsemantics mean this won't cause a runtime bug (the iterator is already captured), it's confusing and a maintenance hazard. Consider renaming the inner variable toterm_cfg_itemsorinner_cfg_items. -
has_groupsdetection may include dunder/internal attrs —all(isinstance(cfg, RewardGroupCfg) for _, cfg in cfg_items)iterates over__dict__.items()which forconfigclassobjects could include internal attributes. If any non-RewardGroupCfginternal attr is present,has_groupswill beFalseeven when the user intended groups. Consider filtering to exclude items starting with_. -
Logging key change is a silent breaking change —
"Episode Reward/"→"Episode_Reward/"(underscore vs space). This will break downstream dashboards/plotting scripts that key on the old format. Either keep the old format for the non-grouped case, or document this explicitly as a breaking change.
Minor Nits (non-blocking)
- The
compute()return type annotationdict[str, torch.Tensor] | torch.Tensoris correct but consider a@overloadpair for better type-checker support. - Nice work on the backwards compatibility path — the
has_groupstoggle is a clean approach.
Update (583a264): No new commits since last review. PR is now closed. Previous concerns (variable shadowing, has_groups detection, logging key change) remain as noted above — no further action needed from the bot.
Update (2026-06-08): Re-review triggered for commit 3e67c1cb but the PR HEAD is still at 583a264 (the previously reviewed SHA). The PR remains closed. No new changes to review.
Update (2026-06-08, commit 6699cf71): Re-review triggered but the referenced commit (6699cf71) does not exist in this repository. PR HEAD remains at 583a264 and the PR is still closed (not merged). No new changes to review.
Update (2026-06-08, commit 5447928b): Re-review triggered but the referenced commit (5447928b) does not exist on this PR. PR HEAD remains at 583a264 and the PR is still closed. No new changes to review.
Update (2026-06-08, commit 9eea5fc2): Re-review triggered but the referenced commit (9eea5fc2) does not exist on this PR. PR HEAD remains at 583a264 and the PR is still closed (not merged). No new changes to review.
Update (2026-06-08, commit 36b993c4): Re-review triggered but the referenced commit (36b993c45b0e6133a90b1dfd404ab119ddf54947) does not exist in this repository. PR HEAD remains at 583a264 and the PR is still closed (not merged). No new changes to review.
Update (2026-06-10, commit 89cdc1be): Re-review triggered but the referenced commit (89cdc1be6d3d3d3b7dcc7ec8f5d5139e7d0c8500) does not exist in this repository. PR HEAD remains at 583a264 and the PR is still closed (not merged). No new changes to review.
Description
This MR ports the code from @lorenwel and adds the concept of reward groups to the code. In the manager-based workflow, the reward terms can now be grouped together, where the computations for different groups can be done independently. This is useful in multi-agents scenarios, where you have to compute different rewards for different agents.
The reward manager still supports the previous case where no groups are defined.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there