Skip to content

Commit bf7e284

Browse files
committed
default to weights_only=False for torch.hub.load_state_dict_from_url
1 parent 170fbe0 commit bf7e284

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/lightning/fabric/utilities/cloud_io.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from fsspec.implementations.local import AbstractFileSystem
2727
from lightning_utilities.core.imports import module_available
2828

29-
from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_6
3029
from lightning.fabric.utilities.types import _MAP_LOCATION_TYPE, _PATH
3130

3231
log = logging.getLogger(__name__)
@@ -58,12 +57,11 @@ def _load(
5857
)
5958
if str(path_or_url).startswith("http"):
6059
if weights_only is None:
61-
if _TORCH_GREATER_EQUAL_2_6:
62-
weights_only = True
63-
log.debug(f"Default to `weights_only=True` for remote checkpoint for torch>=2.6: {path_or_url}")
64-
else:
65-
weights_only = False
66-
log.debug(f"Default to `weights_only=False` for remote checkpoint for torch<2.6: {path_or_url}")
60+
weights_only = False
61+
log.debug(
62+
f"Defaulting to `weights_only=False` for remote checkpoint: {path_or_url}."
63+
f" If loading a checkpoint from an untrustted source, we recommend using `weights_only=True`."
64+
)
6765

6866
return torch.hub.load_state_dict_from_url(
6967
str(path_or_url),

0 commit comments

Comments
 (0)