Fix: Update torch.load to use weights_only=True to prevent security w… (#2451)

* Fix: Update torch.load to use weights_only=True to prevent security warning

* Update __init__.py

* Update __init__.py

---------

Co-authored-by: Jong Wook Kim <jongwook@openai.com>
This commit is contained in:
Dridi Yassin
2025-06-26 02:54:30 +02:00
committed by GitHub
parent 679ae1d141
commit 1f8fc975d3

View File

@@ -147,7 +147,8 @@ def load_model(
with (
io.BytesIO(checkpoint_file) if in_memory else open(checkpoint_file, "rb")
) as fp:
checkpoint = torch.load(fp, map_location=device)
kwargs = {"weights_only": True} if torch.__version__ >= "1.13" else {}
checkpoint = torch.load(fp, map_location=device, **kwargs)
del checkpoint_file
dims = ModelDimensions(**checkpoint["dims"])