mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Mention version of flip in weights_only error message (#141304)
Fixes https://github.com/pytorch/pytorch/issues/141139 How the 3 versions of the error message now look ### Version 1 Old error message: ``` _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. (1) 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 __main__._rebuild_class_that_uses_build_instruction was not an allowed global by default. Please use `torch.serialization.add_safe_globals([_rebuild_class_that_uses_build_instruction])` or the `torch.serialization.safe_globals([_rebuild_class_that_uses_build_instruction])` context manager to allowlist this global if you trust this class/function. Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html. ``` New error message: ``` _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. (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 __main__._rebuild_class_that_uses_build_instruction was not an allowed global by default. Please use `torch.serialization.add_safe_globals([_rebuild_class_that_uses_build_instruction])` or the `torch.serialization.safe_globals([_rebuild_class_that_uses_build_instruction])` context manager to allowlist this global if you trust this class/function. Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html. ```` ### Version 2 Old error message: ``` _pickle.UnpicklingError: Weights only load failed. ``torch.nested`` and ``torch._dynamo`` must be imported to load nested jagged tensors (NJTs) ``` New error message: ``` _pickle.UnpicklingError: Weights only load failed. ``torch.nested`` and ``torch._dynamo`` must be imported to load nested jagged tensors (NJTs) 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. ``` ### Version 3 Old error message ``` _pickle.UnpicklingError: Weights only load failed. 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. Trying to load unsupported GLOBAL posix.execv whose module posix is blocked. Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html. ``` New error message ``` _pickle.UnpicklingError: Weights only load failed. 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. Trying to load unsupported GLOBAL posix.execv whose module posix is blocked. Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html. ```` Pull Request resolved: https://github.com/pytorch/pytorch/pull/141304 Approved by: https://github.com/zou3519
This commit is contained in:
committed by
PyTorch MergeBot
parent
4cbb3b4bd2
commit
ecbb8a8800
@ -1317,7 +1317,8 @@ def load(
|
||||
"""
|
||||
torch._C._log_api_usage_once("torch.load")
|
||||
UNSAFE_MESSAGE = (
|
||||
"Re-running `torch.load` with `weights_only` set to `False` will likely succeed, "
|
||||
"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."
|
||||
)
|
||||
@ -1343,7 +1344,7 @@ def load(
|
||||
)
|
||||
else:
|
||||
if has_import:
|
||||
return f"Weights only load failed. {message}"
|
||||
return f"Weights only load failed. {message}\n {UNSAFE_MESSAGE}\n"
|
||||
else:
|
||||
updated_message = f"Weights only load failed. {UNSAFE_MESSAGE}\n"
|
||||
if not has_blocklist:
|
||||
|
Reference in New Issue
Block a user