mattergen-finetune
Finetune MatterGen models and produce a reusable finetuned checkpoint for downstream crystal generation.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Finetune MatterGen models and produce a reusable finetuned checkpoint for downstream crystal generation.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Generate VASP inputs (INCAR/POSCAR/POTCAR/KPOINTS) via pymatgen.io.vasp.sets for DFT calculations: MPRelaxSet (geometry relaxation), MPStaticSet (SCF), MPNonSCFSet (band structure), MatPESStaticSet (MLFF energy/force labeling). INCAR is driven by pymatgen defaults; the agent only supplies user_incar_settings overrides. Use when the user asks to prepare VASP calculations, run DFT, or generate MLFF training data from structures. Do NOT use for VASP result post-processing / analysis, non-VASP DFT codes, or molecular dynamics — this skill only generates input files and submits jobs.
Deep potential models finetuning and testing using the DeePMD-kit. Use this skill whenever finetuning a Deep Potential (DPA-1 / DPA-2 / DPA-3 / DPA-4) model or running model tests on a dataset. The oldest DP descriptors such as se_e2_a, se_e2_r, and se_e3 are no longer supported. Training from scratch is NEVER advised unless distilling a student model from a teacher model. Multitask fine-tuning is NOT supported.
Skill for running ASE calculations, including energy/force/stress evaluation, molecular dynamics (MD) and structure optimization. Now only use machine-learned force fields (MLFFs) as calculators.
Concept skill for Machine Learning Force Fields (MLFFs). Describes what MLFFs are, the distinction between fine-tuning and distillation, and which tool skills to use. Load this before selecting a specific MLFF framework (DeePMD, MatterSim, etc.).
Concept skill for Molecular Dynamics (MD) simulation. Describes MD ensembles, key parameters, and which tool skills to invoke for MD runs. Use this to understand MD concepts before selecting a specific simulation tool.
Equation-of-State (EOS) benchmark skill — compare DFT, pretrained, and finetuned model E(V) curves to evaluate force-field quality for bulk crystals and simple systems.
| name | mattergen-finetune |
| description | Finetune MatterGen models and produce a reusable finetuned checkpoint for downstream crystal generation. |
| tags | ["MatterGen","training","finetuning"] |
| tools | ["run_bash"] |
| dependent_skills | [] |
Use this skill to train or finetune MatterGen models through the official CLI. Prefer direct shell commands.
Common upstream checkpoint names include the following model-name to property-name mappings:
mattergen_basemp_20_basechemical_system -> chemical_systemspace_group -> space_groupdft_mag_density -> dft_mag_densitydft_band_gap -> dft_band_gapml_bulk_modulus -> ml_bulk_modulusdft_mag_density_hhi_score -> dft_mag_density, hhi_scorechemical_system_energy_above_hull -> chemical_system, energy_above_hullThe current MatCreator workflow supports:
mattergen-finetune.For local runs, MatterGen is installed in a virtual environment, so you should use ${MATTERGEN_ENV}/bin/mattergen-finetune. On Bohrium, use mattergen-finetune directly.
The official MatterGen README also documents:
csv-to-datasetReference:
MatterGen training expects a preprocessed dataset cache. The official README uses:
Cached dataset directory referenced by data_module.root_dir. In practice, this means the remote task must receive the cache contents needed for all splits used by MatterGen, including train, val, and test. Do not upload only the top-level command script while leaving the cache behind locally.
If you already have numbered CIF files and a CSV with id,0,property, first build MatterGen-ready CSV files with inline CIF contents:
python skills/mattergen/build_cif_property_csv.py \
/abs/path/to/cif_dir \
/abs/path/to/id_prop.csv \
dft_band_gap \
--split-dir /abs/path/to/my_csvs \
--test-ratio 0.1
The split step is expected to create three non-empty files:
train.csvval.csvtest.csvIf the dataset is too small, or the requested ratios would make any split empty, the script should fail instead of writing an empty split.
This writes:
/abs/path/to/cif_dir/mattergen_property.csv/abs/path/to/my_csvs//abs/path/to/my_csvs/train.csv/abs/path/to/my_csvs/val.csv/abs/path/to/my_csvs/test.csvEach split CSV contains:
material_idcifThen transform csv file to cache for mattergen:
"${MATTERGEN_ENV}/bin/csv-to-dataset" \
--csv-folder /abs/path/to/my_csvs \
--dataset-name my_csvs \
--cache-folder /abs/path/to/datasets/cache
In most cases, start from mattergen_base and finetune on the target property data. If the target property is already covered by an existing pretrained property model, you can also finetune from that pretrained property model. The local pretrained model path can be obtained from the environment variable mattergen_model, with one folder per pretrained model name, such as mattergen_base
For custom property finetuning, follow this workflow:
csv-to-dataset.mattergen-finetune on the cached dataset.If the target property is not one of the built-in MatterGen properties from the official README, also follow the official custom-property setup:
PROPERTY_SOURCE_IDS in MatterGencsv-to-datasetmattergen/conf/lightning_module/diffusion_module/model/property_embeddings/Example:
ts=$(date +"%Y%m%d%H%M%S")
outdir="mattergen/${ts}.mattergen_finetune"
mkdir -p "$outdir"
cd "$workdir"
"${MATTERGEN_ENV}/bin/mattergen-finetune" \
adapter.model_path=/abs/path/mattergen_base \
data_module=mp_20 \
data_module.root_dir=/abs/path/to/datasets/cache/mp_20 \
+lightning_module/diffusion_module/model/property_embeddings@adapter.adapter.property_embeddings_adapt.$PROPERTY1=$PROPERTY1 \
+lightning_module/diffusion_module/model/property_embeddings@adapter.adapter.property_embeddings_adapt.$PROPERTY2=$PROPERTY2 \
~trainer.logger \
data_module.properties="[\"$PROPERTY1\",\"$PROPERTY2\"]" \
hydra.run.dir=results
adapter.model_path=MODEL_NAME: MODEL_NAME should be a reaaly path.data_module.root_dir=data_path: data_path should be a reaaly absolute path.PROPERTY1 and PROPERTY2 must be replaced with the actual property names used by the dataset and configuration. If only one property is used, include only one property in the command.When submitting MatterGen jobs to Bohrium through the bohrium skill, Bohrium-specific submission settings, including authentication, project, image, and machine type, can be read from environment variables such as BOHRIUM_MAT_IMAGE and BOHRIUM_MAT_MACHINE.
forward_files should include the pretrained model directory. The local pretrained model path can be obtained from the environment variable mattergen_model, with one folder per pretrained model name, such as mattergen_base. If the target property is already covered by an existing pretrained property model, you can also finetune from that pretrained property model.Prepare a writable local job directory first:
ts=$(date +"%Y%m%d%H%M%S")
workdir="matg/${ts}.mattergen_finetune"
mkdir -p "$workdir"
cd "$workdir"
Then copy the dataset cache produced by csv-to-dataset into "$workdir".
Then copy the model into "$workdir".
In submission.json:
forward_files to include two entries: the pretrained model directory, such as mattergen_base, and the specific dataset directory, for example my_bandgap_datasetbackward_files to the generation output directory, for example resultscommand to a generation command such as:mattergen-finetune adapter.model_path=MODEL_NAME data_module=mp_20 data_module.root_dir=data_path +lightning_module/diffusion_module/model/property_embeddings@adapter.adapter.property_embeddings_adapt.$PROPERTY1=$PROPERTY1 +lightning_module/diffusion_module/model/property_embeddings@adapter.adapter.property_embeddings_adapt.$PROPERTY2=$PROPERTY2 ~trainer.logger data_module.properties=["$PROPERTY1","$PROPERTY2"] hydra.run.dir=results
adapter.model_path=MODEL_NAME: MODEL_NAME can be a relativate path, such as 'mattergen_base'.data_module.root_dir=data_path: Because the Bohrium remote root is ${REMOTE_ROOT}, so data_path should be an absolute path start with ${REMOTE_ROOT}. It should usually be an absolute path such as ${REMOTE_ROOT}/my_dataset.PROPERTY1 and PROPERTY2 must be replaced with the actual property names used by the dataset and configuration. If only one property is used, include only one property in the command.An example for single-property finetune command:
mattergen-finetune adapter.model_path=${REMOTE_ROOT}/home/zdj/softutils/mattergen/checkpoints/mattergen_base data_module=mp_20 data_module.root_dir=${REMOTE_ROOT}/my_dataset +lightning_module/diffusion_module/model/property_embeddings@adapter.adapter.property_embeddings_adapt.$PROPERTY1=$PROPERTY1 ~trainer.logger data_module.properties=["$PROPERTY1"] hydra.run.dir=results
Hydra finetuning runs typically write outputs under the hydra.run.dir in the command, including:
.hydra/config.yamllightning_logs/version_0/metrics.csvlightning_logs/version_0/checkpoints/last.ckptAfter finetuning completes, package the trained result into a standard reusable model directory using the files under the results directory. The target layout should be:
~/model/new_model/
config.yaml
checkpoints/
last.ckpt
Use:
results/config.yaml as my_new_model/config.yamlresults/lightning_logs/version_0/checkpoints/last.ckpt as my_new_model/checkpoints/last.ckptExample:
ts=$(date +"%Y%m%d%H%M%S")
modeldir="~/model/${ts}"
mkdir -p "$workdir"
cp results/config.yaml $modeldir/config.yaml
cp results/lightning_logs/version_0/checkpoints/last.ckpt $modeldir/checkpoints/last.ckpt
Report at minimum:
mattergen_base unless the user requested another basecheckpoints/last.ckptmetrics.csv, if available