Skip to content

Commit 4eaf45e

Browse files
Longyun Shenclaude
andcommitted
Address review: scripted registration block in README, old-layout import fallback in the checkpoint exporter
- README: steps 1-3 of the build are now also a copy-paste block (symlink + sed into STANDARD_PACKAGES + append include), verified end-to-end on a pristine stable_22Jul2025_update5 tree (configure + style_pair.h carries the pair style). - export_matgl_checkpoint.py: try the matgl 4.0.3 layout first (matgl.ext.lammps), fall back to the pre-4.0.3 layout with the create_line_graph_torch shim -- the fallback branch is the code this PR previously replaced, kept verbatim. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent c403b03 commit 4eaf45e

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

lammps/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ cmake -B build -S <lammps>/cmake \
7878
cmake --build build -j 8
7979
```
8080

81+
Steps 1–3 as a copy-paste block (GNU sed; the `set(STANDARD_PACKAGES`
82+
opener has kept this exact form across recent LAMMPS releases, and the
83+
list is not order-sensitive):
84+
85+
```bash
86+
MATGL=/path/to/matgl
87+
LMP=/path/to/lammps
88+
ln -s "$MATGL/lammps/src/ML-MATGL" "$LMP/src/ML-MATGL"
89+
sed -i '/^set(STANDARD_PACKAGES$/a\ ML-MATGL' "$LMP/cmake/CMakeLists.txt"
90+
echo "include($MATGL/lammps/cmake/ML-MATGL.cmake)" >> "$LMP/cmake/CMakeLists.txt"
91+
grep -c ML-MATGL "$LMP/cmake/CMakeLists.txt" # expect 2: package list + include
92+
```
93+
8194
Check the registration before running anything:
8295

8396
```bash

lammps/src/ML-MATGL/export_matgl_checkpoint.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@
2020
# (matgl.graph._compute_pyg, matgl.ext._lammps) predate that layout; the first
2121
# no longer exists, so the import raised ModuleNotFoundError and made the
2222
# "point pair_coeff at a checkpoint directory" path unusable.
23-
# _compute exports create_line_graph_torch directly,
24-
# so the in-memory shim that used to sit here is no longer needed either.
25-
from matgl.ext.lammps import export_lammps_model
23+
# The except branch keeps the script usable on the older layout, where
24+
# matgl.ext._lammps needs create_line_graph_torch shimmed in first.
25+
try:
26+
from matgl.ext.lammps import export_lammps_model
27+
except ModuleNotFoundError:
28+
import matgl.graph._compute_pyg as _cpyg
29+
30+
if not hasattr(_cpyg, "create_line_graph_torch"):
31+
_cpyg.create_line_graph_torch = _cpyg.create_line_graph
32+
from matgl.ext._lammps import export_lammps_model
2633

2734
checkpoint_dir, out_path = sys.argv[1], sys.argv[2]
2835
potential = matgl.load_model(checkpoint_dir)

0 commit comments

Comments
 (0)