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

Flip default on weights_only #137602

Conversation

[ghstack-poisoned]
Copy link

pytorch-bot bot commented Oct 9, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 27c7380 with merge base 73fde0d (image):
💚 Looks good so far! There are no failures yet. 💚

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

mikaylagawarecki added a commit that referenced this pull request Oct 9, 2024
ghstack-source-id: e75d4173cf10156143ade29d60b2cd8ac346a9f2
Pull Request resolved: #137602
@mikaylagawarecki mikaylagawarecki added release notes: python_frontend python frontend release notes category topic: bc breaking topic category labels Oct 9, 2024
mikaylagawarecki added a commit that referenced this pull request Oct 9, 2024
ghstack-source-id: f9d26b50df5e20dc7beaedf203e64324bf408884
Pull Request resolved: #137602
@mikaylagawarecki mikaylagawarecki requested a review from a team as a code owner October 16, 2024 16:08
@@ -1 +1 @@
2eb4a60ed14a38260b85b0c765161f0ce45be6d1
f71c02d1f457d58371e013632efb016c01bd1866
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was intentional to include pytorch/xla#8259

@kit1980
Copy link
Member

kit1980 commented Oct 16, 2024

I'm not sure if it's OK to use different default in fbcode/OSS.
cc @malfet

@kit1980
Copy link
Member

kit1980 commented Oct 16, 2024

Also this will break a lot of people.
Maybe it's time to break.

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.

Tentatively LGTM, but please change the signatures a bit further. And not IS_FBCODE feels a bit suspicious, perhaps better behavior would be to add weights_only=False to respective callsights?

@@ -1 +1 @@
2eb4a60ed14a38260b85b0c765161f0ce45be6d1
f71c02d1f457d58371e013632efb016c01bd1866
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not intended, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intended, see #137602 (comment)

@@ -1159,7 +1160,7 @@ def load(
map_location: MAP_LOCATION = None,
pickle_module: Any = None,
*,
weights_only: Optional[bool] = None,
weights_only: Optional[bool] = not IS_FBCODE,
Copy link
Contributor

Choose a reason for hiding this comment

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

if you are changing it to hard boolean, please remove Optional and delete the logic associated with opt-in checks

Suggested change
weights_only: Optional[bool] = not IS_FBCODE,
weights_only: bool = not IS_FBCODE,

@kit1980
Copy link
Member

kit1980 commented Oct 16, 2024

And just FYI users can use TorchFix to find and update call sites where weights_only is not explicitly set: https://github.com/pytorch-labs/torchfix?tab=readme-ov-file#tor102-torchload-without-weights_only-parameter-is-unsafe

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

A couple more pieces need to be added to the CI and we should announce this one as a bc-breaking change broadly for sure!
But yes let's do it!

@mikaylagawarecki mikaylagawarecki added ciflow/trunk Trigger trunk jobs on your pull request ci-no-td Do not run TD on this PR labels Oct 17, 2024
mikaylagawarecki added a commit to mikaylagawarecki/benchmark that referenced this pull request Oct 21, 2024
Summary:
Some fixes for pytorch/pytorch#137602


Reviewed By: xuzhao9

Differential Revision: D64628614

Pulled By: mikaylagawarecki
mikaylagawarecki added a commit to mikaylagawarecki/benchmark that referenced this pull request Oct 21, 2024
Summary:
Some fixes for pytorch/pytorch#137602


Reviewed By: xuzhao9

Differential Revision: D64628614

Pulled By: mikaylagawarecki
mikaylagawarecki added a commit to mikaylagawarecki/benchmark that referenced this pull request Oct 21, 2024
Summary:
Some fixes for pytorch/pytorch#137602


Reviewed By: xuzhao9

Differential Revision: D64628614

Pulled By: mikaylagawarecki
facebook-github-bot pushed a commit to pytorch/benchmark that referenced this pull request Oct 22, 2024
Summary:
Some fixes for pytorch/pytorch#137602

Pull Request resolved: #2514

Reviewed By: xuzhao9

Differential Revision: D64628614

Pulled By: mikaylagawarecki

fbshipit-source-id: edebf25cc6648919d5673a3baeaffdac26e5b91f
mikaylagawarecki added a commit that referenced this pull request Oct 22, 2024
ghstack-source-id: 97e14307bf0b69477e818622d05d436e9a160934
Pull Request resolved: #137602
pytorchmergebot pushed a commit that referenced this pull request Nov 6, 2024
After #137602, the default `weights_only` has been set to True.  This test is failing in trunk slow jobs atm

benchmark_utils/test_benchmark_utils.py::TestBenchmarkUtils::test_collect_callgrind [GH job link](https://github.com/pytorch/pytorch/actions/runs/11672436111/job/32502454946) [HUD commit link](https://hud.pytorch.org/pytorch/pytorch/commit/1aa71be56c39908893273bd9558b127159e1ef3a)
Pull Request resolved: #139810
Approved by: https://github.com/kit1980
atalman pushed a commit to atalman/pytorch that referenced this pull request Nov 11, 2024
Prevent same global from being added multiple times

Pull Request resolved: pytorch#139303
Approved by: https://github.com/janeyx99
ghstack dependencies: pytorch#138936, pytorch#139221, pytorch#139433, pytorch#139541, pytorch#137602
atalman pushed a commit to atalman/pytorch that referenced this pull request Nov 11, 2024
…139810)

After pytorch#137602, the default `weights_only` has been set to True.  This test is failing in trunk slow jobs atm

benchmark_utils/test_benchmark_utils.py::TestBenchmarkUtils::test_collect_callgrind [GH job link](https://github.com/pytorch/pytorch/actions/runs/11672436111/job/32502454946) [HUD commit link](https://hud.pytorch.org/pytorch/pytorch/commit/1aa71be56c39908893273bd9558b127159e1ef3a)
Pull Request resolved: pytorch#139810
Approved by: https://github.com/kit1980
vmoens added a commit to pytorch/rl that referenced this pull request Nov 13, 2024
cc mikaylagawarecki albanD

ghstack-source-id: 6fc7434a259f92b0fca8875b20ac22624ecf1a03
Pull Request resolved: #2558
vmoens added a commit to pytorch/rl that referenced this pull request Nov 13, 2024
cc mikaylagawarecki albanD

ghstack-source-id: 6fc7434a259f92b0fca8875b20ac22624ecf1a03
Pull Request resolved: #2558
zero000064 pushed a commit to zero000064/pytorch that referenced this pull request Nov 14, 2024
…139810)

After pytorch#137602, the default `weights_only` has been set to True.  This test is failing in trunk slow jobs atm

benchmark_utils/test_benchmark_utils.py::TestBenchmarkUtils::test_collect_callgrind [GH job link](https://github.com/pytorch/pytorch/actions/runs/11672436111/job/32502454946) [HUD commit link](https://hud.pytorch.org/pytorch/pytorch/commit/1aa71be56c39908893273bd9558b127159e1ef3a)
Pull Request resolved: pytorch#139810
Approved by: https://github.com/kit1980
vmoens added a commit to pytorch/rl that referenced this pull request Nov 14, 2024
cc mikaylagawarecki albanD

ghstack-source-id: 6fc7434a259f92b0fca8875b20ac22624ecf1a03
Pull Request resolved: #2558

(cherry picked from commit 165163a)
dvrogozh added a commit to dvrogozh/transformers that referenced this pull request Nov 22, 2024
Starting from version 2.4 PyTorch introduces a stricter check for the objects which
can be loaded with torch.load(). Starting from version 2.6 loading with weights_only=True
requires allowlisting of such objects.

This commit adds allowlist of some numpy objects used to load model checkpoints.
Usage is restricted by context manager. User can still additionally call
torch.serialization.add_safe_globals() to add other objects into the safe globals list.

Accelerate library also stepped into same problem and addressed it with PR-3036.

Fixes: huggingface#34631
See: pytorch/pytorch#137602
See: https://pytorch.org/docs/stable/notes/serialization.html#torch.serialization.add_safe_globals
See: huggingface/accelerate#3036
Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
ArthurZucker pushed a commit to huggingface/transformers that referenced this pull request Nov 25, 2024
Starting from version 2.4 PyTorch introduces a stricter check for the objects which
can be loaded with torch.load(). Starting from version 2.6 loading with weights_only=True
requires allowlisting of such objects.

This commit adds allowlist of some numpy objects used to load model checkpoints.
Usage is restricted by context manager. User can still additionally call
torch.serialization.add_safe_globals() to add other objects into the safe globals list.

Accelerate library also stepped into same problem and addressed it with PR-3036.

Fixes: #34631
See: pytorch/pytorch#137602
See: https://pytorch.org/docs/stable/notes/serialization.html#torch.serialization.add_safe_globals
See: huggingface/accelerate#3036

Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Ryo-not-rio pushed a commit to Ryo-not-rio/pytorch that referenced this pull request Dec 2, 2024
Ryo-not-rio pushed a commit to Ryo-not-rio/pytorch that referenced this pull request Dec 2, 2024
Prevent same global from being added multiple times

Pull Request resolved: pytorch#139303
Approved by: https://github.com/janeyx99
ghstack dependencies: pytorch#138936, pytorch#139221, pytorch#139433, pytorch#139541, pytorch#137602
Ryo-not-rio pushed a commit to Ryo-not-rio/pytorch that referenced this pull request Dec 2, 2024
…139810)

After pytorch#137602, the default `weights_only` has been set to True.  This test is failing in trunk slow jobs atm

benchmark_utils/test_benchmark_utils.py::TestBenchmarkUtils::test_collect_callgrind [GH job link](https://github.com/pytorch/pytorch/actions/runs/11672436111/job/32502454946) [HUD commit link](https://hud.pytorch.org/pytorch/pytorch/commit/1aa71be56c39908893273bd9558b127159e1ef3a)
Pull Request resolved: pytorch#139810
Approved by: https://github.com/kit1980
@github-actions github-actions bot deleted the gh/mikaylagawarecki/269/head branch December 5, 2024 02:14
pobin6 pushed a commit to pobin6/pytorch that referenced this pull request Dec 5, 2024
…139810)

After pytorch#137602, the default `weights_only` has been set to True.  This test is failing in trunk slow jobs atm

benchmark_utils/test_benchmark_utils.py::TestBenchmarkUtils::test_collect_callgrind [GH job link](https://github.com/pytorch/pytorch/actions/runs/11672436111/job/32502454946) [HUD commit link](https://hud.pytorch.org/pytorch/pytorch/commit/1aa71be56c39908893273bd9558b127159e1ef3a)
Pull Request resolved: pytorch#139810
Approved by: https://github.com/kit1980
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
Starting from version 2.4 PyTorch introduces a stricter check for the objects which
can be loaded with torch.load(). Starting from version 2.6 loading with weights_only=True
requires allowlisting of such objects.

This commit adds allowlist of some numpy objects used to load model checkpoints.
Usage is restricted by context manager. User can still additionally call
torch.serialization.add_safe_globals() to add other objects into the safe globals list.

Accelerate library also stepped into same problem and addressed it with PR-3036.

Fixes: huggingface#34631
See: pytorch/pytorch#137602
See: https://pytorch.org/docs/stable/notes/serialization.html#torch.serialization.add_safe_globals
See: huggingface/accelerate#3036

Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-no-td Do not run TD on this PR ciflow/inductor ciflow/mps Run MPS tests (subset of trunk) ciflow/trunk Trigger trunk jobs on your pull request Merged module: dynamo oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: python_frontend python frontend release notes category topic: bc breaking topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants