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] Add reduction parameter to Off-Policy losses. #1956

Merged
merged 26 commits into from
Feb 26, 2024

Conversation

albertbou92
Copy link
Contributor

Description

Same as #1890, but for Off-Policy losses.

Motivation and Context

Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax close #15213 if this solves the issue #15213

  • 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 Feb 23, 2024

🔗 Helpful Links

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

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

❌ 6 New Failures, 21 Unrelated Failures

As of commit 65c6399 with merge base 492091a (image):

NEW FAILURES - The following jobs have failed:

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 Feb 23, 2024
@vmoens vmoens added the enhancement New feature or request label Feb 23, 2024
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.

Thanks so much this is an amazing feature!

We should also do the deprecated REDQ because i'll de-deprecate it soon (it runs faster than the other lol)

test/test_cost.py Outdated Show resolved Hide resolved
test/test_cost.py Outdated Show resolved Hide resolved
test/test_cost.py Outdated Show resolved Hide resolved
test/test_cost.py Outdated Show resolved Hide resolved
test/test_cost.py Outdated Show resolved Hide resolved
test/test_cost.py Outdated Show resolved Hide resolved
@albertbou92
Copy link
Contributor Author

I have changed the test so each loss has a dedicated test for the reduction parameter. Also added the reduction parameter to deprecated REDQ.

For on-policy losses we did not have dedicated tests for reduction, we added them to the general test (e.g. test_ppo()). Should we change that too? And if so, in this PR? maybe cleaner to do it in a separate PR.

@albertbou92 albertbou92 requested a review from vmoens February 26, 2024 14:56
@vmoens
Copy link
Contributor

vmoens commented Feb 26, 2024

Another PR seems appropriate! Thanks!

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.

Looks awesome thanks!
Approving it but can you quickly simplify the DQN case? I think we can avoid the call to apply in this case (which will make the loss faster to execute)

torchrl/objectives/dqn.py Outdated Show resolved Hide resolved
@albertbou92 albertbou92 requested a review from vmoens February 26, 2024 16:34
@vmoens vmoens merged commit 6274b27 into pytorch:main Feb 26, 2024
25 of 51 checks passed
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