Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load with weights_only=True #68

Merged
merged 5 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/tad_dftd3/data/radii.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from typing import Optional

import torch
from tad_mctc._version import __tversion__
from tad_mctc.data.radii import COV_D3

from ..typing import Tensor
Expand All @@ -51,8 +52,12 @@ def _load_vdw_rad_d3(
Tensor
VDW radii.
"""
kwargs: dict = {"map_location": device}
if __tversion__ > (1, 12, 1): # pragma: no cover
kwargs["weights_only"] = True

path = op.join(op.dirname(__file__), "vdw-d3.pt")
return torch.load(path).type(dtype).to(device)
return torch.load(path, **kwargs).type(dtype=dtype)


VDW_D3 = _load_vdw_rad_d3()
7 changes: 6 additions & 1 deletion src/tad_dftd3/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from typing import Optional

import torch
from tad_mctc._version import __tversion__

from .typing import Any, NoReturn, Tensor, get_default_device, get_default_dtype

Expand Down Expand Up @@ -177,8 +178,12 @@ def _load_c6(
Tensor
Reference C6 coefficients.
"""
kwargs: dict = {"map_location": device}
if __tversion__ > (1, 12, 1): # pragma: no cover
kwargs["weights_only"] = True

path = op.join(op.dirname(__file__), "reference-c6.pt")
return torch.load(path).type(dtype).to(device)
return torch.load(path, **kwargs).type(dtype=dtype)


class Reference:
Expand Down
Loading