Repository navigation
[BugFix] Expand ellipsis when writing into a TensorDictStore - #2652
Open
YeonwooSung wants to merge 2 commits into
Open
YeonwooSung wants to merge 2 commits into
YeonwooSung wants to merge 2 commits into
Conversation
store[..., i] = value must write the same batch slice as TensorDict, not a feature column. Cover a lazy stack at stack_dim 0 and 1 and a dense store, for a scalar and for a tensor value.
LazyStackedTensorDictStore.__setitem__ and TensorDictStore.__setitem__ passed (..., i) through to the stored tensor, so the ellipsis selected a feature dim. Expand it to the batch size first, as __getitem__ does.
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.
Fixes #2599.
store[..., i] = valueon aLazyStackedTensorDictStorepassed(..., i)straight through to the stored tensor._read_dim0does not handle a tuple longer than one element, so the fallback indexed the full leaf and the ellipsis selected a feature column instead of a batch element.__setitem__now expands the ellipsis withconvert_ellipsis_to_idx(index, self.batch_size)before the write, the same way__getitem__does. This coversstack_dim0 and 1.TensorDictStore.__setitem__had the same hole for a Python number and for a tensor value, and expands the ellipsis the same way. Nestedset_at_/update_at_already expanded an ellipsis and is unchanged.__getitem__is unchanged.#2591 also edits
tensordict/store/_lazy.py. This PR only changes__setitem__ellipsis handling, so the reviewer can rebase.