Skip to content

Commit 836379b

Browse files
shyuepclaude
andcommitted
fix: repair stale post-DGL-removal refs in LAMMPS export + CI
The LAMMPS export wrapper and its test predated the DGL-backend removal and module renames, breaking the Lint and Test CI jobs: - _lammps.py imported the removed `_pyg`-suffixed modules (graph._compute_pyg, apps._pes_pyg, models._m3gnet_pyg/_tensornet_pyg); repoint to graph._compute, apps.pes, models._m3gnet/_tensornet. - test_lammps_export.py guarded on the removed `matgl.config.BACKEND` and imported the same dead modules; drop the guard and import from the public APIs. - cli.py: cover the `attr-defined` code in the create-lammps-model type-ignore so mypy passes. Also correct the READMEs: M3GNet (not just TensorNet) is supported by the LAMMPS export / Kokkos path, and drop the outdated AdvancedSoft third-party reference. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 438038d commit 836379b

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ pip install matgl[jax] # JAX/XLA inference for TensorNet/QET (CPU / CUDA / Ap
118118

119119
## LAMMPS support
120120

121-
MatGL ships a native LAMMPS `pair_style matgl` that evaluates a TorchScript-compiled MatGL **TensorNet** PES
122-
(energies, forces, and virials) on every timestep via LibTorch, with both a CPU/serial pair style and a Kokkos
123-
GPU/host variant (`pair_style matgl/kk`). Export a LAMMPS-loadable model from any pre-trained TensorNet with
124-
`mgl create-lammps-model`. Build and usage instructions, the input-deck syntax, and current limitations are in
125-
[`lammps/README.md`](lammps/README.md).
121+
MatGL ships a native LAMMPS `pair_style matgl` that evaluates a TorchScript-compiled MatGL **TensorNet** or
122+
**M3GNet** PES (energies, forces, and virials) on every timestep via LibTorch, with both a CPU/serial pair style
123+
and a Kokkos GPU/host variant (`pair_style matgl/kk`). Export a LAMMPS-loadable model from a pre-trained TensorNet
124+
or M3GNet with `mgl create-lammps-model`. Build and usage instructions, the input-deck syntax, and current
125+
limitations are in [`lammps/README.md`](lammps/README.md).
126126

127127
## Docker images
128128

lammps/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# MatGL → LAMMPS pair_style
22

33
`pair_matgl` is a LAMMPS pair style that loads a TorchScript-compiled
4-
**MatGL TensorNet** PES (PyG backend, no-Warp, extensive head) and uses
4+
**MatGL TensorNet or M3GNet** PES (PyG backend, extensive head) and uses
55
LibTorch to evaluate energies, forces, and the virial tensor on every
66
timestep.
77

@@ -144,9 +144,14 @@ Currently a no-op.
144144
proportionally to the number of ranks.
145145
- **No restart support.** The model lives on disk; `restart` files don't
146146
capture the path. Re-issue `pair_style` / `pair_coeff` after a restart.
147-
- **TensorNet only.** The pair style loads a TorchScript-compiled
148-
TensorNet PES. Other architectures (M3GNet, CHGNet, MEGNet, SO3Net,
149-
QET) are not yet wired into the LAMMPS export path.
147+
- **TensorNet and M3GNet only.** The export path (`mgl
148+
create-lammps-model` / `LAMMPSMatGLModel`) supports the PyG TensorNet
149+
and M3GNet PES models with an extensive head (TensorNet must be
150+
no-Warp; both require `use_smooth=True`, and M3GNet requires
151+
`use_phi=False`). For M3GNet the three-body line graph is built inside
152+
the TorchScript module, so both the CPU and Kokkos pair styles run it
153+
with no extra handling. CHGNet, MEGNet, SO3Net, and QET are not yet
154+
wired into the LAMMPS export path.
150155

151156
## Continuous integration
152157

src/matgl/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def create_lammps_model(args: argparse.Namespace) -> int:
241241
print(" r_max :", wrapper.r_max)
242242
print(" n_species :", wrapper.n_species)
243243
print(" dtype :", args.dtype)
244-
species = list(potential.model.element_types) # type:ignore[union-attr,arg-type]
244+
species = list(potential.model.element_types) # type:ignore[union-attr,arg-type,attr-defined]
245245
print(" species :", species[: wrapper.n_species])
246246
return 0
247247

src/matgl/ext/_lammps.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from torch import Tensor, nn
2525
from torch.autograd import grad
2626

27-
from matgl.graph._compute_pyg import (
27+
from matgl.graph._compute import (
2828
compute_pair_vector_and_distance,
2929
compute_theta_and_phi,
3030
create_line_graph_torch,
@@ -34,7 +34,7 @@
3434
from matgl.utils.maths import decompose_tensor, tensor_norm
3535

3636
if TYPE_CHECKING:
37-
from matgl.apps._pes_pyg import Potential
37+
from matgl.apps.pes import Potential
3838

3939
logger = logging.getLogger(__name__)
4040

@@ -343,8 +343,8 @@ def __init__(
343343

344344
# Imports kept local so the public ``matgl.ext`` namespace doesn't
345345
# hard-require these submodules at import time.
346-
from matgl.models._m3gnet_pyg import M3GNet
347-
from matgl.models._tensornet_pyg import TensorNet
346+
from matgl.models._m3gnet import M3GNet
347+
from matgl.models._tensornet import TensorNet
348348

349349
model = potential.model
350350

tests/ext/test_lammps_export.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,14 @@
1111
import numpy as np
1212
import pytest
1313
import torch
14-
15-
import matgl
16-
17-
if matgl.config.BACKEND != "PYG":
18-
pytest.skip("LAMMPS export only supports PyG backend", allow_module_level=True)
19-
2014
from pymatgen.core import Lattice, Structure
2115
from pymatgen.optimization.neighbors import find_points_in_spheres
2216

23-
from matgl.apps._pes_pyg import Potential
24-
from matgl.ext._lammps import LAMMPSMatGLModel
25-
from matgl.ext._pymatgen_pyg import Structure2Graph
26-
from matgl.models._m3gnet_pyg import M3GNet
27-
from matgl.models._tensornet_pyg import TensorNet
17+
import matgl
18+
from matgl.apps.pes import Potential
19+
from matgl.ext.lammps import LAMMPSMatGLModel
20+
from matgl.ext.pymatgen import Structure2Graph
21+
from matgl.models import M3GNet, TensorNet
2822

2923

3024
def _build_lammps_inputs(structure: Structure, element_types: tuple[str, ...], cutoff: float, dtype: torch.dtype):

0 commit comments

Comments
 (0)