Skip to content

[BugFix] fix ragged_idx of consolidated tensor#1675

Merged
vmoens merged 3 commits intopytorch:mainfrom
vermouth1992:chi/fix/ragged_idx
Apr 20, 2026
Merged

[BugFix] fix ragged_idx of consolidated tensor#1675
vmoens merged 3 commits intopytorch:mainfrom
vermouth1992:chi/fix/ragged_idx

Conversation

@vermouth1992
Copy link
Copy Markdown
Contributor

@vermouth1992 vermouth1992 commented Apr 16, 2026

Description

  • The _ragged_idx of a nested tensor is lost after consolidation and reset to the default value of 1 after unpickling. This causes numerical incorrectness when the nested tensor has more than 2 dimensions and the ragged_idx is not 1.

Motivation and Context

close #1676

Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax close #15213 if this solves the issue #15213

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

What types of changes does your code introduce? Remove all that do not apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)
  • Example (update in the folder of examples)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.

Signed-off-by: Chi Zhang <czhangseu@gmail.com>
Signed-off-by: Chi Zhang <czhangseu@gmail.com>
@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 Apr 16, 2026
@github-actions github-actions Bot added bug Something isn't working Test and removed bug Something isn't working labels Apr 16, 2026
@vermouth1992
Copy link
Copy Markdown
Contributor Author

@vmoens Could you help release a minor version for this fix as it affects the correctness of 3d position ids used in VLM training. Thanks!

Copy link
Copy Markdown
Collaborator

@vmoens vmoens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a couple of nits
I'll make a minor with it asap

Comment thread test/test_tensordict.py Outdated
Comment thread test/test_tensordict.py
…test

- Move `io` and `pickle` to top-level imports in test/test_tensordict.py
- Extract the ragged_idx-after-consolidation check into a dedicated
  `test_consolidate_njt_ragged_idx` test method.

Made-with: Cursor
@vmoens vmoens merged commit 9792dff into pytorch:main Apr 20, 2026
32 of 46 checks passed
@vmoens
Copy link
Copy Markdown
Collaborator

vmoens commented Apr 20, 2026

@vermouth1992

I've just published 0.12.2

@vermouth1992
Copy link
Copy Markdown
Contributor Author

@vermouth1992

I've just published 0.12.2

Great thanks!

@vermouth1992 vermouth1992 deleted the chi/fix/ragged_idx branch April 20, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] The ragged_idx is lost after consolidate

2 participants