Skip to content

[BugFix] Expand ellipsis when writing into a TensorDictStore - #2652

Open
YeonwooSung wants to merge 2 commits into
pytorch:mainfrom
YeonwooSung:fix/store-ellipsis-setitem
Open

YeonwooSung wants to merge 2 commits into
pytorch:mainfrom
YeonwooSung:fix/store-ellipsis-setitem

Conversation

@YeonwooSung

Copy link
Copy Markdown

Fixes #2599.

store[..., i] = value on a LazyStackedTensorDictStore passed (..., i) straight through to the stored tensor. _read_dim0 does 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 with convert_ellipsis_to_idx(index, self.batch_size) before the write, the same way __getitem__ does. This covers stack_dim 0 and 1. TensorDictStore.__setitem__ had the same hole for a Python number and for a tensor value, and expands the ellipsis the same way. Nested set_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.

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.
@meta-cla meta-cla 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 14, 2026
@github-actions github-actions Bot added bug Something isn't working Test store tensordict.store module and removed bug Something isn't working labels Oct 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. store tensordict.store module Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] store[..., i] = value on a LazyStackedTensorDictStore writes into a feature dim instead of a batch dim

1 participant