[BugFix] Fixes to RenameTransform
Description
Addresses some of the issues documented in https://github.com/pytorch/rl/issues/2441. These are:
-
Specs are only modified if the key is in
in_keys. Keys specified inin_keys_invdon't lead to a change in the specs. -
The behavior of the
_invkeys 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 https://github.com/pytorch/rl/issues/2441
- [x] I have raised an issue to propose this change (required for new features and bug fixes)
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds core functionality)
- [x] 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!
- [x] 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.
:link: Helpful Links
:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/2442
- :page_facing_up: Preview Python docs built from this PR
Note: Links to docs will display an error until the docs builds have been completed.
:x: 2 New Failures, 12 Unrelated Failures
As of commit 48f160692997295e75b849c9f3327a5b6a1a2907 with merge base e294c68ca8ac1794b19398b07a1cc42cca586ea1 ():
NEW FAILURES - The following jobs have failed:
-
Habitat Tests on Linux / tests (3.9, 12.1) / linux-job (gh)
RuntimeError: Command docker exec -t cb781f4820258b7a971eef7577ba19c4ab7d9a5b050b53fab7d82763136fedad /exec failed with exit code 134 - Wheels / build-wheel-windows (3.10, 3.10.3) (gh)
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
- Continuous Benchmark (PR) / CPU Pytest benchmark (gh) (detected as infra flaky with no log or failing log classifier)
- Continuous Benchmark (PR) / GPU Pytest benchmark (gh) (detected as infra flaky with no log or failing log classifier)
- Continuous Benchmark / GPU Pytest benchmark (gh) (detected as infra flaky with no log or failing log classifier)
BROKEN TRUNK - The following jobs failed but were present on the merge base:
👉 Rebase onto the `viable/strict` branch to avoid these failures
- Build Windows Wheels / pytorch/rl (pytorch/rl, .github/scripts/td_script.sh, .github/scripts/version_script.bat, python ... / upload / wheel-py3_9-cpu (gh) (trunk failure)
- Build Windows Wheels / pytorch/rl (pytorch/rl, .github/scripts/td_script.sh, .github/scripts/version_script.bat, python ... / upload / wheel-py3_9-cuda11_8 (gh) (trunk failure)
- Build Windows Wheels / pytorch/rl (pytorch/rl, .github/scripts/td_script.sh, .github/scripts/version_script.bat, python ... / upload / wheel-py3_9-cuda12_1 (gh) (trunk failure)
- Build Windows Wheels / pytorch/rl (pytorch/rl, .github/scripts/td_script.sh, .github/scripts/version_script.bat, python ... / upload / wheel-py3_9-cuda12_4 (gh) (trunk failure)
-
Unit-tests on Linux / tests-olddeps (3.8, 11.6) / linux-job (gh) (trunk failure)
test/test_transforms.py::TestKLRewardTransform::test_kl_lstm -
Unit-tests on Windows / unittests-cpu / windows-job (gh) (trunk failure)
RuntimeError: Compiler: cl is not found. - Wheels / build-wheel-windows (3.11, 3.11) (gh) (trunk failure)
- Wheels / build-wheel-windows (3.12, 3.12) (gh) (trunk failure)
- Wheels / build-wheel-windows (3.9, 3.9) (gh) (trunk failure)
This comment was automatically generated by Dr. CI and updates every 15 minutes.
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!
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?
Sure having a look now Do you mind signing the CLA? Otherwise I can't merge it
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.
I edited the PR a bit, to comply with the logic of in_keys_inv and out_keys_inv as explained by this figure:
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.
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
_stepmethod. - What the original and what the renamed keys are.
Hope that this was helpful!
Yeah sure feel free to add this to the PR
Done!
Hi @vmoens, we've signed the CLA. I guess this should be ready to merge! (Together maybe with https://github.com/pytorch/rl/pull/2443)