Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modelopt/torch/opt/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ def load_modelopt_state(modelopt_state_path: str | os.PathLike, **kwargs) -> dic
Returns:
A modelopt state dictionary describing the modifications to the model.
"""
# Security NOTE: weights_only=False is used here on ModelOpt-generated state_dict, not on untrusted user input
kwargs.setdefault("weights_only", False)
# Security NOTE: weights_only=True is used here on ModelOpt-generated state_dict
kwargs.setdefault("weights_only", True)
kwargs.setdefault("map_location", "cpu")
# TODO: Add some validation to ensure the file is a valid modelopt state file.
modelopt_state = torch.load(modelopt_state_path, **kwargs)
Expand Down Expand Up @@ -628,7 +628,7 @@ def restore(model: ModelLike, f: str | os.PathLike | BinaryIO, **kwargs) -> nn.M

# load checkpoint
kwargs.setdefault("map_location", "cpu")
kwargs.setdefault("weights_only", False)
kwargs.setdefault("weights_only", True)
objs = torch.load(f, **kwargs)

# restore model architecture
Expand Down