[BugFix] GAE shifted=True: tolerate missing next obs, non-canonical strides, docs#3757
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/rl/3757
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 4 New Failures, 1 Cancelled Job, 2 Unrelated FailuresAs of commit 8d89292 with merge base 0a01ee8 ( NEW FAILURES - The following jobs have failed:
CANCELLED JOB - The following job was cancelled. Please retry:
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. |
This was referenced May 15, 2026
This was referenced May 15, 2026
This was referenced May 17, 2026
vmoens
added a commit
that referenced
this pull request
May 18, 2026
…trides, docs
Three small improvements to shifted-GAE in ``_call_value_nets``:
- Add ``_fill_missing_next_inputs(next_data, root_data, in_keys)``. When
``compact_obs=True`` drops ``("next", obs)`` from the rollout, the
shifted-GAE bootstrap path was dereferencing a None key and writing
NaNs into the assembled batch. Fall back to the root key value at the
done position for any missing next-input key.
- Replace ``data_copy.view(-1)`` with ``data_copy.reshape(-1)``.
Replay-buffer reads and memmap-backed tensors can expose
non-canonical strides that ``view`` rejects; ``reshape`` accepts both.
Drop the ``with ... as data_copy_view`` context that was paired with
the in-place ``view`` — flattened tensors don't need write-back.
- Hoist ``ndim`` resolution out of the inner ``_call_value_net`` closure
so it's available to follow-up cleanups.
- Docstring update on ``shifted=True`` across TD0 / TD1 / TDLambda /
GAE / VTrace clarifying that the path expects long, contiguous
trajectory windows with valid boundary next states.
Tests cover: shifted-bootstrap parity between a compact rollout (no
``("next", obs)``) and a NaN-filled reference for TD0 / TD1 / TDLambda /
GAE, non-canonical strides via ``transpose(0, 1)`` through shifted-GAE,
and a vectorized-axis sweep on the recurrent shifted/non-shifted parity
test.
ghstack-source-id: 9712a4c
Pull-Request: #3757
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.
Stack from ghstack (oldest at bottom):
Three small improvements to shifted-GAE in
_call_value_nets:Add
_fill_missing_next_inputs(next_data, root_data, in_keys). Whencompact_obs=Truedrops("next", obs)from the rollout, theshifted-GAE bootstrap path was dereferencing a None key and writing
NaNs into the assembled batch. Fall back to the root key value at the
done position for any missing next-input key.
Replace
data_copy.view(-1)withdata_copy.reshape(-1).Replay-buffer reads and memmap-backed tensors can expose
non-canonical strides that
viewrejects;reshapeaccepts both.Drop the
with ... as data_copy_viewcontext that was paired withthe in-place
view— flattened tensors don't need write-back.Hoist
ndimresolution out of the inner_call_value_netclosureso it's available to follow-up cleanups.
Docstring update on
shifted=Trueacross TD0 / TD1 / TDLambda /GAE / VTrace clarifying that the path expects long, contiguous
trajectory windows with valid boundary next states.
Tests cover: shifted-bootstrap parity between a compact rollout (no
("next", obs)) and a NaN-filled reference for TD0 / TD1 / TDLambda /GAE, non-canonical strides via
transpose(0, 1)through shifted-GAE,and a vectorized-axis sweep on the recurrent shifted/non-shifted parity
test.