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

[Feature] Transform for Recording History Observations #1763

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

btx0424
Copy link
Contributor

@btx0424 btx0424 commented Dec 28, 2023

Description

This draft PR proposes a Transform for recording histories of observations, which is a common practice in robotic tasks. It should also address #1676: to record observation-action history, append the previous action to observation, and then transform the environment with History.

The naming, description (docstring), and tests are for the initial commit. Opinions and suggestions are wanted.

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

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • 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 Dec 28, 2023

🔗 Helpful Links

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

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

✅ You can merge normally! (16 Unrelated Failures)

As of commit 6c1109e with merge base eec9f9e (image):

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

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 Dec 28, 2023
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.

Cool stuff!
Is this the stack version of CatFrames? Do we want to have two separate transforms for that? If what we want is for CatFrames to have the option to discard the last observation or not, or use stack instead of cat, these could be passed as arguments (though I can see why one would rather have two separate classes). I can give some advice if we want to go down that route.

If we have two separate transforms, maybe we could name this one StackFrames for consistency? Is there any piece of code from CatFrames that we should recycle?

We should add the transform to the doc too.

test/test_transforms.py Outdated Show resolved Hide resolved
test/test_transforms.py Outdated Show resolved Hide resolved
self,
in_keys: Sequence[NestedKey],
out_keys: Sequence[NestedKey] = None,
steps: int = 16,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we use 16?

@btx0424
Copy link
Contributor Author

btx0424 commented Jan 6, 2024

Thanks for replying!

Yes, I think renaming it to StackFrames is a good idea. However, do you prefer it to be stateful (like CatFrames) or stateless (the current implementation)? I will make it reuse CatFrames more if we go for stateful.

I will complete the tests and doc soon.

@vmoens
Copy link
Contributor

vmoens commented Jan 9, 2024

It's good to have it stateless I agree. Let's keep it as it is!
Let's align the doc of this class and CatFrames and refer one to the other, it's likely that users will jump from one to the other.
Thanks again!

@vmoens vmoens added the enhancement New feature or request label Jan 9, 2024
@vmoens
Copy link
Contributor

vmoens commented Feb 5, 2024

@btx0424 Anything I can help you with here? I can find some time to help if needed

@vmoens vmoens changed the title Transform for Recording History Observations [Feature] Transform for Recording History Observations Feb 7, 2024
@btx0424
Copy link
Contributor Author

btx0424 commented Feb 7, 2024

@btx0424 Anything I can help you with here? I can find some time to help if needed

Hi there. I had some trouble figuring out the no-env usage while trying to align it with CatFrames. I noticed that CatFrames, when used for RBs, do not split between trajectories, i.e., some observations may contain information from the last episode. Is that the desired behavior?

@vmoens
Copy link
Contributor

vmoens commented Feb 15, 2024

Just seeing this now sorry
No definitely not!
We should fix this if it's the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants