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] patch rand_action in TransformedEnv to read the base_env method #2699

Open
wants to merge 2 commits into
base: gh/vmoens/68/base
Choose a base branch
from

Conversation

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Jan 17, 2025

🔗 Helpful Links

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

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

❌ 4 New Failures, 7 Pending, 3 Unrelated Failures

As of commit 2794f70 with merge base 256a700 (image):

NEW FAILURES - The following jobs have failed:

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 Jan 17, 2025
@vmoens vmoens added the bug Something isn't working label Jan 17, 2025
@vmoens vmoens requested a review from kurtamohler January 17, 2025 15:20
@vmoens
Copy link
Contributor Author

vmoens commented Jan 17, 2025

@kurtamohler I'm not super happy with this, as the comment says it's far from accounting for transforms that do some kind of inverse mapping but the point is that without that, a transformed chess env cannot generate random actions (because the rand_action is not the same as the one in EnvBase that would otherwise be used by TransformedEnv).

[ghstack-poisoned]
# env = PendulumEnv().append_transform(ActionDiscretizer(num_intervals=4))
# env.rand_action will NOT have a discrete action!
# Getting a discrete action would require coding the inverse transform of an action within
# ActionDiscretizer (ie, float->int, not int->float).
Copy link
Collaborator

@kurtamohler kurtamohler Jan 17, 2025

Choose a reason for hiding this comment

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

Is there a reason we couldn't use self.action_spec.rand()?

>>> import torchrl
>>> env = torchrl.envs.PendulumEnv().append_transform(torchrl.envs.ActionDiscretizer(num_intervals=4))
>>> env.action_spec.rand()
tensor([3])
>>> env.action_spec.rand().dtype
torch.int64

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.

3 participants