Skip to content

Pass weights_only flag to EXIR deserialization#18588

Open
CaptnJackSparrow wants to merge 1 commit intopytorch:mainfrom
CaptnJackSparrow:export-D98258299
Open

Pass weights_only flag to EXIR deserialization#18588
CaptnJackSparrow wants to merge 1 commit intopytorch:mainfrom
CaptnJackSparrow:export-D98258299

Conversation

@CaptnJackSparrow
Copy link
Copy Markdown
Contributor

Summary:
This is a workaround to the following error during deserialization of the EXIR graph:

Weights only load failed. This file can still be loaded, to do so you have two options, �[1mdo those steps only if you trust the source of the checkpoint�[0m.
	(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
	(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
	WeightsUnpickler error: Unsupported global: GLOBAL executorch.exir.serde.export_serialize._reconstruct_fake_tensor was not an allowed global by default. Please use `torch.serialization.add_safe_globals([executorch.exir.serde.export_serialize._reconstruct_fake_tensor])` or the `torch.serialization.safe_globals([executorch.exir.serde.export_serialize._reconstruct_fake_tensor])` context manager to allowlist this global if you trust this class/function.

Differential Revision: D98258299

Summary:
This is a workaround to the following error during deserialization of the EXIR graph:

```Exception has occurred: UnpicklingError       (note: full exception trace is shown but execution is paused at: <module>)
Weights only load failed. This file can still be loaded, to do so you have two options, �[1mdo those steps only if you trust the source of the checkpoint�[0m.
	(1) In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
	(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
	WeightsUnpickler error: Unsupported global: GLOBAL executorch.exir.serde.export_serialize._reconstruct_fake_tensor was not an allowed global by default. Please use `torch.serialization.add_safe_globals([executorch.exir.serde.export_serialize._reconstruct_fake_tensor])` or the `torch.serialization.safe_globals([executorch.exir.serde.export_serialize._reconstruct_fake_tensor])` context manager to allowlist this global if you trust this class/function.
```

Differential Revision: D98258299
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Mar 30, 2026

🔗 Helpful Links

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

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

❌ 2 New Failures, 2 Unrelated Failures

As of commit ec4d230 with merge base 02cb325 (image):

NEW FAILURES - The following jobs have failed:

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

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

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

@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 Mar 30, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync bot commented Mar 30, 2026

@CaptnJackSparrow has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98258299.

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant