Repository navigation
[BugFix] Keep MCAdvantage and TopKRewardSelector working with tensordict 0.17 - #4576
Open
peterdsharpe wants to merge 1 commit into
Open
peterdsharpe wants to merge 1 commit into
peterdsharpe wants to merge 1 commit into
Conversation
…ict 0.17 Both read rewards with get(key, as_nested_tensor=True), also when the trajectories concatenate into a regular TensorDict. The keyword does nothing there today, but from tensordict 0.17 it returns a nested tensor for every kind of tensordict, and tensordict 0.15 already warns about it. Pass it only to lazy stacks, so both components keep today's rewards with every tensordict version from 0.14 on.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/4576
Note: Links to docs will display an error until the docs builds have been completed.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MCAdvantageandTopKRewardSelectornow passas_nested_tensor=Truetogetonly when the trajectories form a lazy stack. For a regularTensorDict, they read the rewards with a plainget.The rewards are the same as before with every tensordict version from 0.14 on: the keyword does nothing on a regular
TensorDicttoday. TheFutureWarningfrom tensordict 0.15 goes away, and nothing breaks when tensordict 0.17 makes the keyword return a nested tensor for every kind of tensordict.Tests:
test_mc_advantage_same_length_trajectoriesandtest_topk_regular_tensordictfeed regularTensorDicttrajectories, turn theFutureWarninginto an error, and check the rewards and advantages. With tensordict main, both fail before this change and pass after.TestMCAdvantageandTestTopKpass locally (26 passed; the Ray test is skipped).Motivation and Context
Fixes #4575. Details are in the issue.
Types of changes
Checklist