Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove tensor subclass detection logic from weights_only unpickler #127808

Conversation

mikaylagawarecki
Copy link
Contributor

@mikaylagawarecki mikaylagawarecki commented Jun 3, 2024

Remove logic to auto-detect and allow subclasses that did not override certain methods from the weights_only unpickler from #124331 for 2.4 release

Subclasses should be loadable using torch.serialization.add_safe_globals

Stack from ghstack (oldest at bottom):

cc @albanD

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Jun 3, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/127808

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (2 Unrelated Failures)

As of commit c675f31 with merge base 1b704a1 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@mikaylagawarecki mikaylagawarecki changed the title Remove default subclass detection logic from weights_only unpickler Remove tensor subclass detection logic from weights_only unpickler Jun 3, 2024
[ghstack-poisoned]
@mikaylagawarecki mikaylagawarecki requested review from albanD and malfet June 3, 2024 20:54
@mikaylagawarecki mikaylagawarecki added module: python frontend For issues relating to PyTorch's Python frontend release notes: python_frontend python frontend release notes category topic: not user facing topic category and removed module: python frontend For issues relating to PyTorch's Python frontend labels Jun 3, 2024
[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Jun 3, 2024
ghstack-source-id: 29dff9bf4e999d3ca4db4d5d74d981bfa1c2beb6
Pull Request resolved: #127808
Copy link
Contributor

@malfet malfet left a comment

Choose a reason for hiding this comment

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

LGTM, but it would be nice to have at least one test that validate subclasses work via globals. Also, perhaps worth having a safe globals context manager

for method, func in restore_methods.items():
setattr(subclass, method, func)
a = subclass(torch.randn(2, 3))

@skipIfTorchDynamo("name 'SYNTHETIC_LOCAL' is not defined")
def test_safe_globals_for_weights_only(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@malfet This tests that functionality with TwoTensor, is that what you were looking for?

@mikaylagawarecki
Copy link
Contributor Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Jun 4, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: .github/workflows/generated-linux-binary-manywheel-main.yml / manywheel-py3_8-cuda11_8-test / test

Details for Dev Infra team Raised by workflow job

[ghstack-poisoned]
[ghstack-poisoned]
@mikaylagawarecki
Copy link
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@github-actions github-actions bot deleted the gh/mikaylagawarecki/218/head branch July 6, 2024 01:54
pytorchmergebot pushed a commit that referenced this pull request Jul 12, 2024
xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: python_frontend python frontend release notes category topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants