Skip to content

[Feature] Restructure torchrl/objectives #580

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

Merged
merged 5 commits into from
Oct 18, 2022

Conversation

sgrigory
Copy link
Contributor

Description

Closes #117

Restructures torchrl/objectives folder in line with #152 (comment). Tests, examples, notebooks, and markdown docs which import torchrl.objectives are also changed accordingly.

Motivation and Context

Context: TorchRL comes with a set of stateful loss modules that use helper functions to compute returns and advantages. The current structure does not reflect the dependency of the losses on the helper functions.

This PR moves files:

  • from torchrl/objectives/costs to torchrl/objectives
  • from torchrl/objectives/returns to torchrl/objectives/value

It also eliminates __all__ = [...] constructions in imported files in torchrl/objectives, instead explicitly listing imported objects in places where imports happen

Types of changes

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

  • 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

  • I have read the CONTRIBUTION guide
  • My change requires a change to the documentation.
  • I have updated the tests accordingly.
  • I have updated the documentation accordingly.

Testing plan

  • pytest passes locally

Screenshot 2022-10-17 at 23 27 31

  • Example scripts in examples/ run

@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 Oct 17, 2022
@codecov
Copy link

codecov bot commented Oct 17, 2022

Codecov Report

Merging #580 (4304553) into main (685c08e) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #580      +/-   ##
==========================================
- Coverage   86.96%   86.96%   -0.01%     
==========================================
  Files         121      120       -1     
  Lines       21820    21811       -9     
==========================================
- Hits        18976    18967       -9     
  Misses       2844     2844              
Flag Coverage Δ
linux-cpu 85.29% <100.00%> (-0.01%) ⬇️
linux-gpu 86.74% <100.00%> (-0.01%) ⬇️
linux-outdeps-gpu 75.39% <100.00%> (-0.02%) ⬇️
linux-stable-cpu 85.27% <100.00%> (-0.01%) ⬇️
linux-stable-gpu 86.74% <100.00%> (-0.01%) ⬇️
macos-cpu 85.05% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
torchrl/objectives/common.py 88.37% <ø> (ø)
torchrl/objectives/utils.py 85.10% <ø> (ø)
torchrl/objectives/value/returns.py 44.44% <ø> (ø)
torchrl/objectives/value/utils.py 84.61% <ø> (ø)
torchrl/objectives/value/vtrace.py 26.08% <ø> (ø)
test/smoke_test.py 100.00% <100.00%> (ø)
test/test_cost.py 96.41% <100.00%> (ø)
torchrl/objectives/__init__.py 100.00% <100.00%> (ø)
torchrl/objectives/ddpg.py 97.87% <100.00%> (ø)
torchrl/objectives/deprecated.py 92.92% <100.00%> (ø)
... and 11 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@vmoens vmoens added enhancement New feature or request bc breaking backward compatibility breaking change labels Oct 18, 2022
@sgrigory sgrigory changed the title [WIP] Restructure torchrl/objectives Restructure torchrl/objectives Oct 18, 2022
@sgrigory sgrigory marked this pull request as ready for review October 18, 2022 07:51
@vmoens vmoens changed the title Restructure torchrl/objectives [Feature] Restructure torchrl/objectives Oct 18, 2022
Copy link
Collaborator

@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.

Great work thanks for this!

@vmoens vmoens merged commit 002e1e9 into pytorch:main Oct 18, 2022
@sgrigory sgrigory deleted the restructure_objectives branch October 18, 2022 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bc breaking backward compatibility breaking change 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.

[Feature Request] Objectives modules refactoring
3 participants