Skip to content

[jit] Add type tags to lists/dicts in pickle#33255

Closed
driazati wants to merge 2 commits intomasterfrom
driazati/pickle_tags
Closed

[jit] Add type tags to lists/dicts in pickle#33255
driazati wants to merge 2 commits intomasterfrom
driazati/pickle_tags

Conversation

@driazati
Copy link
Copy Markdown
Contributor

@driazati driazati commented Feb 12, 2020

Stacked PRs

This adds a global call to torch.jit._pickle.restore_type_tags for
lists and dicts so that we can preserve their types after serialization.

Differential Revision: D20346780

@driazati driazati requested a review from apaszke as a code owner February 12, 2020 23:51
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Feb 12, 2020
@driazati driazati requested review from iseeyuan and zdevito February 12, 2020 23:52
@iseeyuan
Copy link
Copy Markdown
Contributor

Thanks for putting this PR quickly! If the types are embedded in pickle, we may not need restoreAccurateTypeTags here:

restoreAccurateTypeTags(
? Could you remove it and let it go through all the tests?

@iseeyuan
Copy link
Copy Markdown
Contributor

LGTM. Thanks! Would be great if @zdevito could take a look before it's landed.

Copy link
Copy Markdown
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

This looks pretty good, but we have some file format versioning to fix before it can land. We need to bump kProducedFileFormatVersion, because now there will be restore_type_tags in the IR. While we are doing this, we also need to remove the list specialization functions (build_intlist, etc.) from serialization. They are no longer needed and the only reason I haven't removed them is because of breaking forward compat. Now that we are doing it anyway, we should do both at once. Also, restoreAccurateTypeTags should only be called for the older format since it is no longer needed.

Comment thread torch/csrc/jit/pickler.cpp Outdated
Comment thread torch/csrc/jit/unpickler.cpp Outdated
Comment thread torch/csrc/jit/unpickler.cpp Outdated
Copy link
Copy Markdown
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

Looks good now, but we should not call restoreAccurateTypeTags in unpickler if the container version is the current version. It should only get called for older formats now.

Also, this should land with the next PR in the stack so we don't end up in an intermediate state where some networks get generated with both build_intlist and restore_type_tags. It would be weird to have to continue to handle that case.

@mrshenli
Copy link
Copy Markdown
Contributor

mrshenli commented Mar 4, 2020

@mrshenli
Copy link
Copy Markdown
Contributor

mrshenli commented Mar 4, 2020

Fix is on the way #34180

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@driazati merged this pull request in 99e211e.

ttumiel pushed a commit to ttumiel/pytorch that referenced this pull request Mar 4, 2020
Summary:
Stacked PRs
 * pytorch#33474 - [jit] Remove list specializations from pickler
 * **pytorch#33255 - [jit] Add type tags to lists/dicts in pickle**

This adds a global call to `torch.jit._pickle.restore_type_tags` for
lists and dicts so that we can preserve their types after serialization.
](https://our.intern.facebook.com/intern/diff/19868637/)
Pull Request resolved: pytorch#33255

Pulled By: driazati

Reviewed By: xman1979, Tianshu-Bao

Differential Revision: D19868637

fbshipit-source-id: 2f1826e6679a786ca209198690269f399a542c04
@driazati driazati reopened this Mar 9, 2020
@driazati
Copy link
Copy Markdown
Contributor Author

driazati commented Mar 9, 2020

@pytorchbot retest this please

@driazati driazati force-pushed the driazati/pickle_tags branch from 2bcc6ca to cc66173 Compare March 10, 2020 17:46
facebook-github-bot pushed a commit that referenced this pull request Apr 3, 2020
Summary:
This enables the serialization part of this change (the deserialization stuff is already landed #33255)
Pull Request resolved: #35741

Pulled By: driazati

Differential Revision: D20758124

fbshipit-source-id: e2cdefa99c3bec991491e5e967e7f1661ca7ffd9
@facebook-github-bot facebook-github-bot deleted the driazati/pickle_tags branch July 13, 2020 17:55
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Stacked PRs
 * pytorch#33474 - [jit] Remove list specializations from pickler
 * **pytorch#33255 - [jit] Add type tags to lists/dicts in pickle**

This adds a global call to `torch.jit._pickle.restore_type_tags` for
lists and dicts so that we can preserve their types after serialization.
](https://our.intern.facebook.com/intern/diff/19868637/)
Pull Request resolved: pytorch#33255

Pulled By: driazati

Reviewed By: xman1979, Tianshu-Bao

Differential Revision: D19868637

fbshipit-source-id: 2f1826e6679a786ca209198690269f399a542c04
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Stacked PRs
 * pytorch#33474 - [jit] Remove list specializations from pickler
 * **pytorch#33255 - [jit] Add type tags to lists/dicts in pickle**

This adds a global call to `torch.jit._pickle.restore_type_tags` for
lists and dicts so that we can preserve their types after serialization.
](https://our.intern.facebook.com/intern/diff/20346780/)
Pull Request resolved: pytorch#33255

Pulled By: driazati

Differential Revision: D20346780

fbshipit-source-id: c8534954ef4adb2e3c880401acbee30cd284f3db
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
This enables the serialization part of this change (the deserialization stuff is already landed pytorch#33255)
Pull Request resolved: pytorch#35741

Pulled By: driazati

Differential Revision: D20758124

fbshipit-source-id: e2cdefa99c3bec991491e5e967e7f1661ca7ffd9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants