Skip to content
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

[BugFix] RewardSum key check #1718

Merged
merged 4 commits into from
Nov 29, 2023
Merged

Conversation

matteobettini
Copy link
Contributor

In the RewardSum transform, reset keys where checked to be valid only when not directly provided by the user.

if len(reset_keys) != len(self.in_keys) or not _check_match(

This led to silent errors when the users provides reset keys manually but there are not as many as the in_keys gathered automatically from the reward_spec.

This PR runs the key check in both the case of user provided or autoimatically gathered reset keys, making the function more resilient.

Copy link

pytorch-bot bot commented Nov 28, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/1718

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (8 Unrelated Failures)

As of commit 290ba1e with merge base 07fcfb1 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 28, 2023
@vmoens vmoens added the bug Something isn't working label Nov 28, 2023
@vmoens
Copy link
Contributor

vmoens commented Nov 28, 2023

Is this needed?

If we look at the message in the error, we specifically tell the user that we cannot retrieve them automatically and hence the user should pass them.
If we pass them manually, the check should be different, e.g., we could just test that there are as many in_keys as reset_keys.

@matteobettini
Copy link
Contributor Author

I think having both checks is useful and at worst it cannot hurt.
The second part of the check will help preventing the user to pass "("smth","_reset") when the in_key is "reward"

The checks are run just once

@vmoens
Copy link
Contributor

vmoens commented Nov 28, 2023

The current check makes sure that the root of in_keys has a similar root for resets. If resets are passed manually, they could be located anywhere IMO, not at the sample place as in_keys. I guess we want manual resets to be as flexible as possible. If we restrict them as we do for automatically gathered reset entries, what do we gain with the manual version?

@matteobettini
Copy link
Contributor Author

matteobettini commented Nov 28, 2023

I thought the manual version was just for when the auto does not work, but i see the point.
I ll update to just check the length of the key list in both cases as what to i want to avoid is the zip silently failing due to diff lenghts (which just happened to me)

@vmoens
Copy link
Contributor

vmoens commented Nov 29, 2023

At this point we need a better set of tests for these error messages! It isn't easy to make sure we get them right just by looking at the code

@matteobettini
Copy link
Contributor Author

matteobettini commented Nov 29, 2023

I have added a test that would fail on main that checks all the errors related to the length of keys in rewardsum

@vmoens
Copy link
Contributor

vmoens commented Nov 29, 2023

What do you mean "that would fail on main"? In the sense that they test the new feature or that the feature is bc breaking?

Copy link
Contributor

@vmoens vmoens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@matteobettini
Copy link
Contributor Author

matteobettini commented Nov 29, 2023

What do you mean "that would fail on main"? In the sense that they test the new feature or that the feature is bc breaking?

They test that where before there was a silent error, now there is an explicit exeption.

@vmoens vmoens merged commit 2e7f574 into pytorch:main Nov 29, 2023
53 of 61 checks passed
@matteobettini matteobettini deleted the error_reward_sum branch December 4, 2023 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants