/atomistic-skills:ml-mlip-nvalchemifrom Atomistic Skills
Enables optional GPU-accelerated batched inference for MACE, MatGL (TensorNet/CHGNet), and FairChem MLIPs via NValchemi, supporting parallel static, relax, and MD workflows across multiple structures. Experimental and disabled by default.
Ships in Atomistic Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Run optional GPU-parallel static predictions, relaxation and MD across multiple
structures with NValchemi. This backend is experimental and disabled by
default in AtomisticSkills 2.0.0. List and directory inputs normally run each
structure through the model's native calculator and ASE/MatCalc. Installing
nvalchemi-toolkit or selecting a GPU does not enable the batch engine.
[!WARNING] The locked toolkit 0.2.0 has confirmed batch-dynamics correctness defects. Same-size refills and variable-cell changes can omit periodic neighbors; AtomisticSkills guards this cache defect for 0.2.x, with measurable overhead. A separate defect can leave live energies inconsistent with frozen geometry after convergence; preserving the first converged snapshot reduces exposure but does not repair the upstream live batch. MatGL inflight remains disabled. Native NPT currently falls back to ASE because initial stress is missing. Static predictions do not reuse the defective dynamics cache, but this does not establish correctness for every model or structure. Historical speedups are workload-specific and do not certify the release's dynamics paths.
Explicit selection: pass use_nvalchemi=True on each batch call to
static_calculation, relax_structure or run_md. MCP tools expose the same
flag on predict_structure, relax_structure and run_md. The default is
False; the choice does not persist into later calls. Runtime logs identify
experimental use, and batch results report the actual backend.
When offering this option, explain these limitations. Do not enable it merely
because batching could be faster. Validate a small representative case against
the default path before a larger run, and check backend for any fallback.
Single-structure calls continue using their normal calculator.
NValchemi provides batched dynamics integrators (FIRE, NVT Nose-Hoover, NPT, etc.) and a BaseModelMixin interface. AtomisticSkills wraps each MLIP in a BaseModelMixin-compatible class:
| MLIP | NValchemi wrapper | Location |
|---|---|---|
| MACE | nvalchemi.models.mace.MACEWrapper | upstream (nvalchemi-toolkit) |
| MatGL TensorNet | matgl.ext._alchmtk.TensorNetWrapper | matgl package |
| MatGL CHGNet | CHGNetWrapper | src/utils/mlips/nvalchemi/matgl_wrappers.py |
| MatGL QET | QETWrapper | matgl package |
| FairChem UMA | FairChemWrapper | src/utils/mlips/nvalchemi/fairchem_nv.py |
With use_nvalchemi=True, src/utils/mlips/base.py dispatches as follows:
static_calculation(list, use_nvalchemi=True) → _batch_static_nvalchemi() → single batched forwardrelax_structure(list, use_nvalchemi=True) → _batch_relax_nvalchemi() → batched FIRErun_md(list, use_nvalchemi=True) → _batch_md_nvalchemi() → batched NVT/NVE/NPT integratorAfter explicit opt-in, relaxation can choose fixed-batch or inflight execution:
_batch_relax()
├─ use_nvalchemi=True AND nvalchemi available AND model loads?
│ YES → _batch_relax_nvalchemi()
│ └─ sum(atoms) > max_batch_atoms AND model._nvalchemi_supports_inflight?
│ YES → _batch_relax_nvalchemi_inflight() ← rolling GPU window
│ NO → fixed-batch NValchemi ← all structures at once
│ NO → _batch_relax_sequential() ← plain ASE FIRE, one by one
Note: All MatGL wrappers (
TensorNetWrapper,CHGNetWrapper) set_nvalchemi_supports_inflight=Falseand use fixed-batch NValchemi regardless of structure count, because after graduation, energies are wrong (TensorNet Cu −83.70 vs −86.57 eV fixed-batch; CHGNet 0.26 eV), MACE inflight is available after opt-in with the cache guard.
Inflight batching keeps only max_batch_atoms atoms on the GPU at once. As each structure converges or exhausts its step budget it is evicted and a new one is loaded. This is necessary when the full set of structures would exceed GPU memory.
max_batch_atoms — how it is set:
| How | Behaviour |
|---|---|
max_batch_atoms=None (default) | Auto-estimated: free_VRAM × 0.5 / bytes_per_atom using per-architecture calibration (FairChem 0.15 B/param/atom, MACE 0.5, TensorNet 1.5, CHGNet 3.0, fallback 5 MB/atom) |
Explicit integer (e.g. 500) | Forces inflight for almost any real dataset; recommended on shared GPUs |
| Very large integer | Forces fixed-batch (all structures in one GPU call) |
Every batch result dict carries a "backend" key:
"backend" value | Meaning |
|---|---|
"nvalchemi_inflight" | Inflight rolling-window (large datasets / shared GPU) |
"nvalchemi" | Fixed-batch NValchemi (entire set fits in one GPU pass) |
"sequential" | Plain ASE FIRE, one structure at a time |
result = wrapper.relax_structure(structures, fmax=0.05, steps=500, use_nvalchemi=True)
print(result["backend"]) # "nvalchemi_inflight" / "nvalchemi" / "sequential"
Logger messages (written to stderr / MCP server log) also signal transitions:
"Total atoms (N) exceeds batch limit (M); switching to inflight batching.""NValchemi inflight relax: N structures, live batch ≤M atoms, ≤S steps/structure."Variable-cell relaxation uses upstream FIRE2VariableCell with dt=0.05,
tmax=0.5, delaystep=5, and maxstep=0.2. Its cell force is already normalized
by system size; AtomisticSkills no longer applies an additional atom-count
scaling. Standard-form cell preparation is retained.
All three relaxation modes report success only on convergence,
not_converged at the step limit, and failed for execution errors. Results
include converged and per-structure steps, with separate aggregate counts.
For variable-cell runs, convergence includes the per-atom virial row norm as
well as atomic forces. This is the small-strain counterpart of ASE's
FrechetCellFilter criterion, not exact equality at finite strain.
Neighbor-cache handling in 2.0.0: NValchemi 0.2.x can omit neighbors after same-size refills or gradual cell changes. AtomisticSkills uses a version-gated guard for every neighbor hook in fixed relaxation, inflight relaxation and batch MD. Changes to cell, PBC or atom partition trigger a complete allocation refresh; ordinary fixed-cell steps retain their buffers. Installed packages are unchanged. MACE inflight stays available after opt-in, and FairChem builds its own graph without this hook. See the exposure and timing report.
The separate upstream inactive-output defect can still return live energies inconsistent with frozen coordinates after convergence. MatGL inflight remains disabled pending validation of that repair. Trajectory extraction preserves the first converged snapshot; turning extraction off exposes the live-batch output limitation. A corrected upstream release is still needed to retire the compatibility guard.
The former variable-cell speedup tables used force-only convergence and are withdrawn. New speedups remain pending a supported upstream release containing the neighbor-cache and inactive-output repairs. A source-checkout validation run must not be presented as performance of the committed dependency locks. Static-inference and MD tables below measure different operations.
Speedup comparison for a 100-step MD simulation under the nvt_nose_hoover ensemble at 300 K on 20 strained Cu FCC structures, each expanded to a fixed 108-atom cubic supercell ($\ge 10\text{ \AA}$ sides). Sequential = NValchemi disabled, structures run one at a time; Batched = all 20 driven through NValchemi integrators in a single GPU batch. Best-of-2 wall time, measured serially (one environment at a time to avoid GPU contention).
mlip)mlip)fairchem)When does batched MD help? Batched MD gives modest speedups for launch-latency-bound models at small system sizes (MACE 1.40x in the latest re-run, TensorNet 1.8x in the earlier record), at a much larger memory cost than static inference (≈20 GB GPU for 20 × 108-atom MACE structures; a TensorNet re-run of the same benchmark exceeded 37 GB and was stopped). Estimate memory before batching MD. For heavy models like FairChem uma-s-1p2 whose single-system path is already compute-bound, batching provides no speedup and MD is routed to sequential. The wrappers still accept a list of structures (and batch static/relax remain available); only FairChem's MD path is gated. Measured on NVIDIA GB10 (aarch64, CUDA 13, Warp 1.14).
FairChem batched MD disabled (
_nvalchemi_supports_batch_md = False): uma-s-1p2's forward scales superlinearly per atom — ≈1.57 ms/atom at batch=1 (108 atoms) rising to ≈2.43 ms/atom at batch=20 (2160 atoms), 1.55x worse — so a single large batched step is slower than running the structures one at a time through the model's optimized single-system path (batched 0.64x). Two facts pin this down: (1) the cost is intrinsic to the eSCN/MoE forward, not the neighbor list — correcting the wrapper cutoff (12 A → the model's true 6 A) cutadapt_inputedges from 530 to 78 per atom but left the per-step time unchanged at ~5.25 s; (2) uma-s-1p2 runs withexternal_graph_gen=False, so it rebuilds its own graph internally and ignores the edgesadapt_inputprovides (energies are identical for any cutoff we pass, including a 0-edge 2 A list). Batched MD is therefore correct (energies match sequential to 0.00 meV/atom) but never a speedup, sorun_mdfalls back to sequential.
TensorNet batched MD enabled with stream fix: TensorNet batch MD is re-enabled. The
NeighborListHook"race" it was previously disabled for was a CUDA stream mismatch, now fixed bywarp_on_torch_streaminsrc/utils/mlips/nvalchemi/nvalchemi_utils.py. Batch NVE energy drift equals sequential (max 0.02 meV/atom), and batch MD is 1.8× faster than sequential for 16 structures × 200 steps on GB10.
# (or venv/fairchem for FairChem models)
from src.utils.mlips.nvalchemi.nvalchemi_utils import NVALCHEMI_AVAILABLE
print(NVALCHEMI_AVAILABLE) # must be True
from src.utils.mlips.mace.mace_wrapper import MACEWrapper
wrapper = MACEWrapper(model_name="MACE-OMAT-0-small", device="cuda")
wrapper.load()
nv = wrapper._get_nvalchemi_model()
print(nv) # should be non-None MACEWrapper(nvalchemi)
Pass a list of ASE Atoms objects to static_calculation. The result dict includes a "backend": "nvalchemi" key when the batch path was used:
from ase.build import bulk
import numpy as np
structures = [bulk("Cu", "fcc", a=3.6 * s) for s in np.linspace(0.96, 1.04, 10)]
result = wrapper.static_calculation(structures, use_nvalchemi=True)
# result["backend"] == "nvalchemi"
# result["total_structures"] == 10
# result["results"][i] == {"energy": ..., "forces": ..., "stress": ...}
Identical API for MatGL and FairChem wrappers:
from src.utils.mlips.matgl.matgl_wrapper import MatGLWrapper
wrapper = MatGLWrapper(model_name="TensorNet-PES-MatPES-PBE-2025.2", device="cuda")
wrapper.load()
result = wrapper.static_calculation(structures, use_nvalchemi=True)
from src.utils.mlips.fairchem.fairchem_wrapper import FAIRCHEMWrapper
wrapper = FAIRCHEMWrapper(model_name="uma-s-1p2", device="cuda")
wrapper.load()
result = wrapper.static_calculation(structures, use_nvalchemi=True)
result = wrapper.relax_structure(
structure_data=structures, # list of ASE Atoms
use_nvalchemi=True, # explicit experimental-backend selection
fmax=0.05, # eV/Å convergence
steps=500,
output_dir="/path/to/output",
# relax_cell=True, # optional: variable-cell relaxation
# max_batch_atoms=500, # optional: set explicitly on shared GPUs to force
# # inflight mode and avoid OOM; None = auto from VRAM
)
print(result["backend"]) # "nvalchemi_inflight", "nvalchemi", or "sequential"
Variable-cell batch relaxation (relax_cell=True) converges only when the per-atom virial row norm is also below fmax (the small-strain counterpart of ASE's FrechetCellFilter). Per-structure relax.log files (ASE FIRE format) are written incrementally to {output_dir}/{structure_name}/relax.log during inflight runs, so partial results survive an OOM abort.
result = wrapper.run_md(
structure_data=structures,
use_nvalchemi=True,
temperature=1000,
steps=1000,
timestep=2.0, # fs
ensemble="nvt_nose_hoover",
output_dir="/path/to/output"
)
Validated fixed-cell batch families: nve, nvt_nose_hoover, nvt_langevin.
NPT aliases select a NValchemi integrator but currently fall back to ASE because
the integration does not publish initial stress; native NPT is not validated.
Unsupported (Berendsen, Andersen, inhomogeneous NPT) fall back to sequential automatically.
Omit the flag, or set it to False; no module patching is needed:
result = wrapper.static_calculation(structures)
assert result["backend"] == "sequential"
result = wrapper.relax_structure(structures, use_nvalchemi=False)
MCP/CLI example of an explicit experimental request (two structure files):
${CLAUDE_SKILL_DIR}/../../venv/run mlip python -m src.mcp_server.cli mace \
load_model model_name=MACE-OMAT-0-small device=cuda \
predict_structure 'structure_data=["first.cif","second.cif"]' use_nvalchemi=true
To re-run the full accuracy and speed benchmark for any environment:
${CLAUDE_SKILL_DIR}/../../venv/run mlip python ${CLAUDE_SKILL_DIR}/scripts/run_nvalchemi_benchmark.py \
--env mace \
--n-repeat 3 \
--output results_mace.json
${CLAUDE_SKILL_DIR}/../../venv/run mlip python ${CLAUDE_SKILL_DIR}/scripts/run_nvalchemi_benchmark.py \
--env matgl \
--n-repeat 3 \
--output results_matgl.json
${CLAUDE_SKILL_DIR}/../../venv/run fairchem python ${CLAUDE_SKILL_DIR}/scripts/run_nvalchemi_benchmark.py \
--env fairchem \
--n-repeat 3 \
--output results_fairchem.json
The script tests N=2, 5, 10, 20 structures and prints a speedup/accuracy table.
See resources/benchmark_results.md for the full results table.
| Model | Speedup (N=5) | Speedup (N=20) | ΔE max (eV) |
|---|---|---|---|
| MACE-OMAT-0-small | 21.7× | 68× | 9.5e-07 |
| MACE-OMAT-0-medium | 22.9× | 72× | 9.5e-07 |
| MACE-MH-1/omat_pbe | 14.3× | 34× | 1.6e-07 |
| MACE-MH-1/matpes_r2scan | 14.4× | 34× | 1.2e-07 |
| MACE-MP-medium-0b3 | 22.9× | 76× | 1.4e-06 |
| MACE-MATPES-PBE-0 | 23.6× | 77× | 7.2e-07 |
| MACE-MATPES-R2SCAN-0 | 24.2× | 76× | 1.9e-06 |
| TensorNet-PES-MatPES-PBE-2025.2 | 3.6× | 11× | 1.4e-07 |
| TensorNet-PES-MatPES-r2SCAN-2025.2 | 3.8× | 12× | 8.0e-07 |
| CHGNet-PES-MatPES-PBE-1M-2026.9 | 3.4× | 11× | 2.4e-07 |
| CHGNet-PES-MatPES-r2SCAN-1M-2026.9 | 3.4× | 11× | 9.5e-07 |
| QET-PES-MatPES-PBE-2025.2 | 4.2× | 13× | 7.2e-07 |
| QET-PES-MatPES-r2SCAN-2025.2 | 3.9× | 14× | 9.5e-07 |
| FairChem uma-s-1p2 (omat) | 3.0× | 2.9× | 1.6e-07 |
| FairChem uma-m-1p1 (omat) | 2.9× | 3.5× | 1.7e-07 |
| FairChem uma-s-1p1 (omat) | 3.4× | 5.5× | 2.5e-07 |
run_nvalchemi_benchmark.py for MACE-OMAT-0-small and TensorNet-PES-MatPES-PBE-2025.2 (N = 2–20). Batched and sequential results agree to float32 round-off (ΔF = 0, ΔE ≤ 1.9e-6 eV), with speedups reported next to the stored table. A batched-MD re-run gives 1.4× for MACE (stored 4.9×; now bound by the model forward) and peaks at 20 GB GPU, while TensorNet batched MD exceeded 37 GB.use_nvalchemi=True for each batch request.nvalchemi-toolkit must be installed. Check NVALCHEMI_AVAILABLE flag. Falls back to sequential if unavailable.mlip — MACE models and MatGL (TensorNet, CHGNet)fairchem — FairChem UMA_extract_static() in tests handles the conversion.dataset (e.g., "omat") passed to FCAtomicData. This is handled automatically by FairChemWrapper; defaults to "omat" when task_name=None.device="cuda" for batch workloads._nvalchemi_supports_inflight=False; when the total atom count exceeds the batch budget, they fall through to fixed-batch NValchemi (all structures in one GPU pass) rather than inflight. For large MatGL sets, split inputs into smaller calls or retain default sequential execution. max_batch_atoms does not cap the fixed-batch allocation when inflight is disabled.nvt_berendsen, nvt_andersen, nvt_bussi, npt_berendsen, and npt_inhomogeneous have no NValchemi equivalent and always run sequentially.https://pypi.nvidia.com)Author: Bowen Deng Contact: github.com/bowen-bd
examples/cu_batch_static_accuracy/README.md (opens in a new tab)examples/cu_batch_static_accuracy/results_mace.json (opens in a new tab)examples/cu_batch_static_accuracy/results_matgl.json (opens in a new tab)resources/benchmark_results.md (opens in a new tab)scripts/run_md_benchmark.py (opens in a new tab)scripts/run_nvalchemi_benchmark.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub learningmatter-mit/atomisticskills --plugin atomistic-skills133 skills in this plugin
/chem-bond-dissociationCalculate homolytic and heterolytic bond dissociation energies (BDEs) for all single bonds in a molecule using MLIPs with RDKit fragmentation./chem-conformer-searchGenerate molecular conformers with RDKit ETKDG, relax with MLIPs, and rank by energy with Boltzmann weighting./chem-db-mofQuery multiple MOF databases (QMOF via MPContribs; ARC-MOF DB7/Majumdar et al. via Materials Cloud) and download CIF structures with optional element or identifier filters.Other plugins' skills for the same job