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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -147,7 +147,8 @@ def load_model(
with ( with (
io.BytesIO(checkpoint_file) if in_memory else open(checkpoint_file, "rb") io.BytesIO(checkpoint_file) if in_memory else open(checkpoint_file, "rb")
) as fp: ) 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 del checkpoint_file
dims = ModelDimensions(**checkpoint["dims"]) dims = ModelDimensions(**checkpoint["dims"])