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] Fixes to RenameTransform #2442

Merged
merged 4 commits into from
Sep 30, 2024

Conversation

thomasbbrunner
Copy link
Contributor

Description

Addresses some of the issues documented in #2441. These are:

  1. Specs are only modified if the key is in in_keys. Keys specified in in_keys_inv don't lead to a change in the specs.
  2. The behavior of the _inv keys is different to the documented behavior.

This MR does not target the remaining bug (Only the full_action_spec is modified in the transform, but not the action_spec.), as I'm not sure if this is a bug or intended behavior.

Motivation and Context

close #2441

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

Copy link

pytorch-bot bot commented Sep 19, 2024

🔗 Helpful Links

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

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

❌ 2 New Failures, 12 Unrelated Failures

As of commit 48f1606 with merge base e294c68 (image):

NEW FAILURES - The following jobs have failed:

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
Copy link

Hi @thomasbbrunner!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@thomasbbrunner
Copy link
Contributor Author

The tests are currently failing. Before I dive into them, could you take a look at the changes @vmoens and let me know if my assumptions are correct?

@vmoens vmoens changed the title Fixes to RenameTransform [BugFix] Fixes to RenameTransform Sep 19, 2024
@vmoens
Copy link
Contributor

vmoens commented Sep 19, 2024

Sure having a look now
Do you mind signing the CLA? Otherwise I can't merge it

@thomasbbrunner
Copy link
Contributor Author

Thanks!

Do you mind signing the CLA? Otherwise I can't merge it

Currently clarifying this with my employer. Should not be a blocker, but could take a couple of days.

@vmoens
Copy link
Contributor

vmoens commented Sep 19, 2024

I edited the PR a bit, to comply with the logic of in_keys_inv and out_keys_inv as explained by this figure:
image
Hope that makes sense. Happy to provide a version of this in the docstrings in that helps understanding what the transform is doing.
LMK if in its current form you still see issues with the transform.

@thomasbbrunner
Copy link
Contributor Author

Hope that makes sense.

Yes, it does! And thanks for the diagram. Really useful to understand.

LMK if in its current form you still see issues with the transform.

IMO there's some room for improvement in the docstrings:

    A transform to rename entries in the output tensordict.

    Args:
        in_keys (sequence of NestedKey): the entries to rename
        out_keys (sequence of NestedKey): the name of the entries after renaming.
        in_keys_inv (sequence of NestedKey, optional): the entries to rename before
            passing the input tensordict to :meth:`EnvBase._step`.
        out_keys_inv (sequence of NestedKey, optional): the names of the renamed
            entries passed to :meth:`EnvBase._step`.
        create_copy (bool, optional): if ``True``, the entries will be copied
            with a different name rather than being renamed. This allows for
            renaming immutable entries such as ``"reward"`` and ``"done"``.

Can I suggest something along the lines of (unformatted):

   A transform to rename entries in the output tensordict (or input tensordict via the inverse keys).

    Args:
        in_keys (sequence of NestedKey): the entries to rename.
        out_keys (sequence of NestedKey): the name of the entries after renaming.
        in_keys_inv (sequence of NestedKey, optional): the entries to rename
            in the input tensordict, which will be passed to :meth:`EnvBase._step`.
        out_keys_inv (sequence of NestedKey, optional): the names of the entries in the
            input tensordict after renaming.

This way it is clear:

  • Which name is going to ultimately going to be passed to the _step method.
  • What the original and what the renamed keys are.

Hope that this was helpful!

@vmoens
Copy link
Contributor

vmoens commented Sep 19, 2024

Yeah sure feel free to add this to the PR

@thomasbbrunner
Copy link
Contributor Author

Done!

@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 Sep 26, 2024
@thomasbbrunner
Copy link
Contributor Author

Hi @vmoens, we've signed the CLA. I guess this should be ready to merge! (Together maybe with #2443)

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

@vmoens vmoens merged commit a0dfddc into pytorch:main Sep 30, 2024
62 of 76 checks passed
@vmoens vmoens added the bug Something isn't working label Sep 30, 2024
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.

[BUG] Inconsistent behavior in RenameTransform
3 participants