/atomistic-skills:ml-mace-finetunefrom Atomistic Skills
Fine-tunes MACE machine learning interatomic potentials on custom datasets. Guides data preparation, config generation, model training, and registration.
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.
To evaluate and improve the accuracy of a foundation MACE potential for a specific chemical system or physical property using the provided Python fine-tuning script and data-augmentation.
/benchmark-finetuning workflow for details.scripts/prepare_mace_data.py to convert JSON structures to .xyz data files.scripts/generate_mace_config.py using the .xyz data to produce finetune_config.yaml.mace_run_train --config /path/to/finetune_config.yaml to begin fine-tuning natively on the GPU.register_model tool to register the newly fine-tuned model checkpoint into the local registry so future research tasks can discover and reuse it.MACE fine-tuning is divided into a data preparation step, a configuration generation step, and a standard native training run. The script scripts/prepare_mace_data.py generates .xyz files, and scripts/generate_mace_config.py converts arguments into a fully-formed finetune_config.yaml configuration compatible with the MACE default parser.
| Key | Type | Default | Description |
|---|---|---|---|
--data | str | (Required) | Path to JSON file containing ASE/pymatgen structure dictionaries |
--output-dir | str | ./fine_tuning_data | Directory to save the converted .xyz data |
--val-split | float | 0.1 | Fraction of data to set aside for validation |
--seed | int | 42 | Random seed for validation splitting |
--vasp-stress-conversion | flag | - | If set, multiplies stress values by -1/160.2x to convert VASP raw kB to eV/ų |
| Key | Type | Default | Description |
|---|---|---|---|
--train-file | str | (Required) | Path to the converted train.xyz data |
--valid-file | str | None | Path to the valid.xyz data |
--model | str | MACE-MP-small | Base model name or path to a checkpoint |
--epochs | int | 100 | Number of training epochs |
--lr | float | 0.01 | Peak learning rate for training |
--batch-size | int | 2 | Training batch size |
--output-dir | str | ./fine_tuning | Directory to save the fine-tuned model and logs |
--device | str | cuda | Target compute device (cuda or cpu) |
[!NOTE] If you have created a dedicated research directory for your current workflow (e.g. using the
create_research_dirtool), you should set the--output-dirargument to a folder within that active research directory to keep all artifacts and models organized.
| Key | Type | Default | Choices | Description |
|---|---|---|---|---|
--freeze-backbone | flag | N/A | Add flag | Freeze backbone (interaction blocks); only readout heads are trained. |
--reinit-head | flag | N/A | Add flag | Re-initialize readout weights. When absent (default), pre-trained readout is preserved. |
--multiheads | flag | N/A | Add flag | Enable multi-head fine-tuning (adds new head while keeping existing ones). |
[!IMPORTANT] The following parameters govern Optimizer, Regularization, and Scheduling. They are NOT exposed via the
prepare_mace_data.pyCLI. Note thatprepare_mace_data.pyexposes--energy-weight,--forces-weight(default 10.0), and--stress-weightwhich inject cleanly into the initial YAML. For all other properties below, you must manually append the keys to the generatedfinetune_config.yamlfile prior to runningmace_run_train.
| Key | Type | Default | Choices / Range | Description |
|---|---|---|---|---|
optimizer | str | "adam" | "adam", "adamw", "schedulefree" | Optimizer type. |
weight_decay | float | 5e-7 | ≥0 | L2 weight decay. |
amsgrad | bool | True | True, False | Use AMSGrad variant of Adam. |
clip_grad | float | 10.0 | >0 or None | Maximum gradient norm for clipping. Set to None to disable. |
ema | bool | True | True, False | Enable exponential moving average of model weights. |
ema_decay | float | 0.99 | 0–1 | EMA decay rate. Higher = more smoothing. |
| Key | Type | Default | Choices / Range | Description |
|---|---|---|---|---|
scheduler | str | "ReduceLROnPlateau" | "ReduceLROnPlateau", "ExponentialLR" | LR scheduler type. |
lr_factor | float | 0.8 | 0–1 | Factor by which LR is reduced on plateau (for ReduceLROnPlateau). |
scheduler_patience | int | 50 | ≥1 | Epochs without improvement before reducing LR (for ReduceLROnPlateau). |
lr_scheduler_gamma | float | 0.9993 | 0–1 | Per-epoch multiplicative decay factor (for ExponentialLR). |
ReduceLROnPlateau (default): Monitors validation loss. When loss stops improving for scheduler_patience epochs, LR is multiplied by lr_factor.
ExponentialLR: LR decays every epoch by lr_scheduler_gamma. At epoch n: LR = learning_rate × lr_scheduler_gamma^n.
| Key | Type | Default | Choices / Range | Description |
|---|---|---|---|---|
patience | int | 2048 | ≥1 | Stop training after this many epochs without improvement. |
[!NOTE] Default
patience=2048effectively disables early stopping. Set lower (e.g., 100–200) if you want to stop early.
| Key | Type | Default | Choices | Description |
|---|---|---|---|---|
loss | str | "weighted" | "weighted", "universal", etc. | Loss function type. "universal" is auto-set by data script when stress data is detected. |
energy_weight | float | 1.0 | ≥0 | Weight for energy loss (exposed via CLI). |
forces_weight | float | 10.0 | ≥0 | Weight for forces loss (exposed via CLI). |
stress_weight | float | 1.0 | ≥0 | Weight for stress loss (exposed via CLI). |
compute_forces | bool | True | True, False | Include forces in training. |
compute_stress | bool | False | True, False | Include stress in training (auto-enabled by data script). |
[!WARNING] Stress Units: MACE expects stress in
eV/ų. Raw VASP stress obtained directly via some JSON files may be in kilo-Bar (kB), which is ~160x larger and will cause catastrophic training divergence. The Atomate2 MCP tool handles this conversion automatically whenconvert_units=True. However, if your JSON labels contain rawkBstress, you MUST pass the--vasp-stress-conversionflag toscripts/prepare_mace_data.pyto automatically scale them by-1/160.2x. For more details on unit standardization, see @[skills/general-property-units/SKILL.md].
[!WARNING] Learning rate sensitivity for MACE-OMAT: The official MACE docs recommend
lr=0.01for MACE-MP-0, but MACE-OMAT-0-small requireslr=1e-4to avoid divergence. Higher values (1e-3, 0.01) cause catastrophic forgetting even with frozen backbone + EMA.
[!IMPORTANT] The generated
finetune_config.yamlmaps exactly tomace_run_trainarguments. You can open and manually modify the YAML file before runningmace_run_trainto inject any advanced parameter.
Usage:
# 1. Prepare Data
${CLAUDE_SKILL_DIR}/../../venv/run mlip python ${CLAUDE_SKILL_DIR}/scripts/prepare_mace_data.py \
--data /path/to/training_data.json \
--output-dir ./mace_finetuned_data
# 2. Generate Configuration
${CLAUDE_SKILL_DIR}/../../venv/run mlip python ${CLAUDE_SKILL_DIR}/scripts/generate_mace_config.py \
--train-file ./mace_finetuned_data/train.xyz \
--valid-file ./mace_finetuned_data/valid.xyz \
--model MACE-OMAT-0-small \
--epochs 10 \
--lr 1e-4 \
--batch-size 2 \
--freeze-backbone \
--output-dir ./mace_finetuned
# 3. Run Training
${CLAUDE_SKILL_DIR}/../../venv/run mlip mace_run_train --config ./mace_finetuned/finetune_config.yaml
# 4. Extract Training Logs (Optional, to create standard training_history.json)
${CLAUDE_SKILL_DIR}/../../venv/run cpu python ${CLAUDE_SKILL_DIR}/scripts/extract_mace_logs.py \
--results-dir ./mace_finetuned/results
See the mace-wbm-finetune directory for a complete, runnable example of 10-epoch fine-tuning on high-energy crystal structures (WBM dataset), including exact usage of the --vasp-stress-conversion flag and diagnostic output artifacts.
freeze_backbone=True is strongly recommended.training_history.json files use meV units: energy MAE in meV/atom, force MAE in meV/Å, stress MAE in meV/ų.Author: Bowen Deng Contact: GitHub @learningmatter-mit
examples/mace-wbm-finetune/README.md (opens in a new tab)examples/mace-wbm-finetune/finetune_config.yaml (opens in a new tab)examples/mace-wbm-finetune/label_distributions.png (opens in a new tab)examples/mace-wbm-finetune/training_history.json (opens in a new tab)examples/mace-wbm-finetune/training_history.png (opens in a new tab)examples/mace-wbm-finetune/valid.xyz (opens in a new tab)scripts/extract_mace_logs.py (opens in a new tab)scripts/generate_mace_config.py (opens in a new tab)scripts/prepare_mace_data.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
133 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.npx claudepluginhub learningmatter-mit/atomisticskills --plugin atomistic-skillsOther plugins' skills for the same job