Skip to content

Commit ebfc72a

Browse files
author
Han Wang
committed
test(lmp): load build-test custom op lib in the native-spin reference subprocess
1 parent 5994a5c commit ebfc72a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

source/lmp/tests/test_lammps_dpa4_spin_graph_pt2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,24 @@ def _compute_expected() -> None:
159159
cell = _cell_from_lammps_box(box)
160160
atype = (type_NiO - 1).tolist() # LAMMPS 1-based -> deepmd 0-based (Ni=0, O=1)
161161

162+
# ``deeppot_dpa4_spin_graph.pt2`` lives in ``source/tests/infer`` next to
163+
# ``gen_common.py``, whose ``load_custom_ops()`` loads the build-tree
164+
# ``libdeepmd_op_pt.so`` (registering ``deepmd::edge_force_virial``, which
165+
# the graph ``.pt2`` inference needs). ``import deepmd.pt`` alone only loads
166+
# the op library from SHARED_LIB_DIR, which the build-test env does not
167+
# populate -- so the subprocess reuses that fallback (after importing
168+
# ``deepmd.pt``, per its docstring) before constructing ``DeepPot``.
169+
infer_dir = str(pb_file.resolve().parent)
162170
script = textwrap.dedent(f"""\
163171
import json
172+
import sys
164173
import numpy as np
174+
175+
sys.path.insert(0, {infer_dir!r})
176+
import deepmd.pt # noqa: F401 (triggers the base op-library load)
177+
from gen_common import load_custom_ops
178+
179+
load_custom_ops()
165180
from deepmd.infer import DeepPot
166181
167182
dp = DeepPot({str(pb_file.resolve())!r})

0 commit comments

Comments
 (0)