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

[BugFix] Call contiguous on rollout results in TestMultiStepTransform #2025

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10208,11 +10208,11 @@ def test_multistep_transform(self):
t = MultiStepTransform(3, 0.98)

outs_2 = []
td = env.reset()
td = env.reset().contiguous()
for _ in range(1):
rollout = env.rollout(
250, auto_reset=False, tensordict=td, break_when_any_done=False
)
).contiguous()
out = t._inv_call(rollout)
td = rollout[..., -1]
outs_2.append(out)
Expand All @@ -10225,15 +10225,15 @@ def test_multistep_transform(self):
torch.manual_seed(0)

outs = []
td = env.reset()
td = env.reset().contiguous()
for i in range(5):
rollout = env.rollout(
50, auto_reset=False, tensordict=td, break_when_any_done=False
)
).contiguous()
out = t._inv_call(rollout)
# tests that the data is insensitive to the collection schedule
assert_allclose_td(out, outs_2[i])
td = rollout[..., -1]["next"]
td = rollout[..., -1]["next"].exclude("reward")
outs.append(out)

outs = torch.cat(outs, -1)
Expand All @@ -10245,11 +10245,11 @@ def test_multistep_transform(self):
torch.manual_seed(0)

outs_3 = []
td = env.reset()
td = env.reset().contiguous()
for _ in range(125):
rollout = env.rollout(
2, auto_reset=False, tensordict=td, break_when_any_done=False
)
).contiguous()
out = t._inv_call(rollout)
td = rollout[..., -1]["next"]
if out is not None:
Expand Down
Loading