Skip to content

SevenNet, Mace, CHGNetへの対応 (rework of #76)#80

Draft
k-yoshimi wants to merge 8 commits into
developfrom
support-sevennet-mace-chgnet
Draft

SevenNet, Mace, CHGNetへの対応 (rework of #76)#80
k-yoshimi wants to merge 8 commits into
developfrom
support-sevennet-mace-chgnet

Conversation

@k-yoshimi

@k-yoshimi k-yoshimi commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR adds MLIP solver/trainer support for SevenNet, Mace, and CHGNet.

It is a rework of the previous PR #76 (ykonishi:develop). That PR was once merged into develop, but since it landed without any CI coverage it has been backed out of develop. This PR reintroduces the same work with review fixes applied, so it can be merged again once tests are in place.

Contents

  • New solvers: sevennet.py, mace.py, chgnet.py
  • New trainers: sevennet_trainer.py, mace_trainer.py, chgnet_trainer.py
  • Solver/trainer registration in __init__.py, and support in params.py / train.py / main_dft_latgas.py
  • Documentation updates (tutorial/other_models.rst, how_to_use/index.rst)

Review fixes applied on top of PR #76

  • params.py: fix the self.dvice typo (self.device); device was never set on the default DFTParams path
  • main_dft_latgas.py: restrict the pretrained base_input_dir creation to the sevennet/mace/chgnet solvers so existing solvers are unaffected; use makedirs(exist_ok=True)
  • Drop unused imports in the new solvers (notably the nequip imports that pulled nequip in as a hard dependency)
  • Replace the broken e.args += str exception handling in each trainer's new_baseinput with a proper RuntimeError
  • Fix the copy-pasted module docstring in chgnet.py; add a trailing newline to __init__.py

TODO before merge

  • Add integration tests for SevenNet / Mace / CHGNet (and add them to the Test_abICS.yml matrix)
  • Verify in CI that each ML package installs and how pretrained models are obtained
  • Confirm the remaining points raised in review:
    • The SevenNet trainer's xsf_to_ase feeds dummy forces generated by MorsePotential into training (need to confirm the force-loss weight is 0)
    • On relax, the energy is from the relaxed structure while the returned structure is the un-relaxed one (inconsistency)

Kept as Draft until the test coverage is ready, so it is not merged prematurely.


Co-authored-by: Yusuke Konishi konishi@academeia.co.jp

🤖 Generated with Claude Code

ykonishi and others added 8 commits June 16, 2026 17:46
- params.py: fix typo self.dvice -> self.device (device was never set
  on the default DFTParams path)
- main_dft_latgas.py: restrict the pretrained base_input_dir creation to
  the MLIP solvers (sevennet/mace/chgnet) so existing solvers are not
  affected; use makedirs(exist_ok=True)
- sevennet/mace/chgnet solvers: drop unused imports (numpy, torch, tomli
  and the nequip imports that pulled nequip in as a hard dependency)
- chgnet.py: correct copy-pasted module docstring
- *_trainer.py: replace broken 'e.args += str' handling (TypeError) in
  new_baseinput with a proper RuntimeError
- __init__.py: add trailing newline

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a lightweight integration test that runs abics_sampling with the
pretrained CHGNet solver (use_pretrained=true, relax=false) over a small
MgAl2O4 cell for a few RXMC steps, and checks that sampling produces finite,
physically plausible energies. CHGNet ships its weights, so the test needs no
network at runtime.

Wired into the CI matrix as the SamplingCHGNet testname with install_chgnet.sh.
chgnet requires Python >=3.10, so it runs only on Python 3.13 (chgnet supports
numpy 2, unlike the pinned nequip).

Verified locally (Python 3.13, chgnet 0.4.2 / torch 2.12.1): the 2-replica
sampling run completes and check.py passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the CHGNet smoke test for the MACE solver: run abics_sampling with the
pretrained MACE-MP foundation model (use_pretrained=true, relax=false) over a
small MgAl2O4 cell and check the energies are finite and physically plausible.
The MACE-MP model is downloaded on first use (no model file committed).

Wired into the CI matrix as SamplingMace with install_mace.sh, on Python 3.13.

Verified locally (mace-torch 0.3.16): the sampling run completes, check.py passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the CHGNet/MACE smoke tests for the SevenNet solver: run abics_sampling
with the pretrained 7net-0 potential (use_pretrained=true, relax=false) over a
small MgAl2O4 cell and check the energies are finite and physically plausible.
The 7net-0 potential ships with the sevenn package.

Wired into the CI matrix as SamplingSevenNet with install_sevennet.sh, on
Python 3.13.

Verified locally (sevenn 0.13.0): the sampling run completes, check.py passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The SamplingMace job hung until the 6-hour CI limit: mace_mp downloads the
foundation model on first use, and when that download failed in one of the two
MPI ranks, that rank crashed while the other deadlocked on the replica-exchange
MPI Recv. Download the model once in a single process before mpiexec so the
ranks load it from cache with no network access (and a download failure now
fails fast instead of hanging).

Verified locally with the mace-pinned e3nn==0.4.4: pre-cache succeeds and the
2-replica sampling run completes, check.py passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants