Skip to content

Commit 94ea40c

Browse files
zhaiwenxiclaude
andcommitted
Guard descriptor extraction grad requirement
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f6f75d0 commit 94ea40c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

deepmd/dpa_tools/_backend.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ def _run_forward(self, coord, atype, box):
158158
torch.Tensor
159159
(n_frames, n_atoms, feat_dim), detached.
160160
"""
161+
if not coord.requires_grad:
162+
raise RuntimeError("forward_common requires coord to have requires_grad=True")
161163
self._clear_accumulator()
162164
self._inner_model.forward_common(coord, atype, box)
163165
return self._atomic_model.eval_descriptor().detach()

0 commit comments

Comments
 (0)