Skip to content

Commit bc90a20

Browse files
author
Han Wang
committed
style(pt_expt): explicit device on the graph_lower_disabled buffer init
Satisfies the project pylint no-explicit-device rule (pre-commit.ci); the buffer follows the module on .to(device) as before.
1 parent 41bbd49 commit bc90a20

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

deepmd/pt_expt/descriptor/dpa1.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
284284
# equation and gradients without warning. A persistent buffer rides
285285
# every pt_expt state_dict, so save/restart round-trips it.
286286
torch.nn.Module.register_buffer(
287-
self, "graph_lower_disabled", torch.zeros((), dtype=torch.bool)
287+
self,
288+
"graph_lower_disabled",
289+
torch.zeros((), dtype=torch.bool, device="cpu"),
288290
)
289291

290292
def disable_graph_lower(self) -> None:

deepmd/pt_expt/descriptor/dpa2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
4444
# equation and gradients without warning. A persistent buffer rides
4545
# every pt_expt state_dict, so save/restart round-trips it.
4646
torch.nn.Module.register_buffer(
47-
self, "graph_lower_disabled", torch.zeros((), dtype=torch.bool)
47+
self,
48+
"graph_lower_disabled",
49+
torch.zeros((), dtype=torch.bool, device="cpu"),
4850
)
4951

5052
def disable_graph_lower(self) -> None:

0 commit comments

Comments
 (0)