11# dpa_tools
22
3- Fine-tuning, descriptor extraction, cross-validation, and data utilities for
4- DPA-3 pretrained models. Lives as a self-contained subpackage of ` deepmd-kit `
5- at ` deepmd.dpa_tools ` .
3+ Property-prediction tools built on top of DPA-3 pretrained models. ` dpa_tools `
4+ turns molecular or atomistic structure data into ` deepmd/npy ` datasets, extracts
5+ DPA descriptors, and trains lightweight or fine-tuned property predictors for
6+ small- to medium-sized datasets. It lives as a self-contained subpackage of
7+ ` deepmd-kit ` at ` deepmd.dpa_tools ` .
68
79## Relationship with deepmd-kit
810
@@ -16,7 +18,7 @@ at `deepmd.dpa_tools`.
1618 ` dp --pt test ` , auto-generating ` input.json ` config files.
1719- ** Inference** : deepmd-kit's built-in ` DeepProperty ` handles neural-network
1820 models; dpa_tools adds a lightweight frozen-descriptor + sklearn-head path.
19- - ** SMILES pipeline** : ` data/smiles.py ` converts CSV ( SMILES or MOL files) +
21+ - ** SMILES pipeline** : ` data/smiles.py ` converts CSV with SMILES columns +
2022 property labels into ` deepmd/npy ` format via RDKit 3D conformer generation.
2123- ** CLI** : registered as ` dp dpa ` subcommand group via ` deepmd/main.py ` .
2224 Torch and all DPA dependencies are loaded lazily — only when a ` dp dpa ... `
@@ -30,15 +32,16 @@ at `deepmd.dpa_tools`.
3032pip install deepmd-kit[dpa-tools]
3133```
3234
33- The ` dpa-tools ` extra brings in ` scikit-learn ` . ` torch ` and ` dpdata ` are
34- already provided by deepmd-kit's core dependencies. For SMILES→3D conversion
35- install RDKit (` conda install -c conda-forge rdkit ` ).
35+ The ` dpa-tools ` extra installs the Python dependencies used by this package,
36+ including ` scikit-learn ` , ` dpdata ` , ` torch ` , ` rdkit ` , and ` e3nn ` . For
37+ CUDA/GPU-specific PyTorch builds, install the desired PyTorch variant first or
38+ follow the PyTorch installation instructions for your platform.
3639
3740## Python API
3841
3942``` python
4043from deepmd.dpa_tools import (
41- DPAFineTuner, # train (all strategies: frozen_sklearn, linear_probe, finetune, mft, scratch )
44+ DPAFineTuner, # train (strategies: frozen_sklearn, linear_probe, finetune, mft)
4245 DPAPredictor, # read-only inference from frozen bundles
4346 extract_descriptors, # standalone descriptor extraction
4447 cross_validate, # leak-proof cross-validation
@@ -56,15 +59,14 @@ from deepmd.dpa_tools import (
5659
5760### DPAFineTuner
5861
59- Four training strategies:
62+ Training strategies:
6063
6164| Strategy | Description | Best for |
6265| ----------| ------------| ----------|
6366| ` frozen_sklearn ` | Freeze descriptor, extract once, fit sklearn head (RF/Ridge/MLP) | Small data (<1k samples), CPU inference |
6467| ` linear_probe ` | Freeze backbone, train property fitting net only | Medium data, GPU |
6568| ` finetune ` | Full-network fine-tuning | Larger data, GPU |
6669| ` mft ` | Multi-task: property head + force-field head | Prevents representation collapse |
67- | ` scratch ` | Train from random init (experimental) | Large-scale data only |
6870
6971``` python
7072model = DPAFineTuner(
@@ -120,7 +122,14 @@ from deepmd.dpa_tools import auto_convert
120122
121123# CSV with SMILES → auto-detected, RDKit generates 3D coords
122124result = auto_convert(" data.csv" , " ./npy" , property_name = " homo" , property_col = " HOMO" )
123- # → {"method": "smiles", "train_systems": [...], "valid_systems": [...], ...}
125+ # prints: RDKit converted samples: ... / RDKit failed rows : ...
126+ # → {"method": "smiles", "train_systems": [...], "valid_systems": [...],
127+ # "samples_used": ..., "failed_rows": [...], "skipped_zero": ...,
128+ # "skipped_overlap": ...}
129+
130+ # To force the SMILES pipeline, pass fmt="smiles"; the value is case-insensitive
131+ # ("SMILES" and "Smiles" also work).
132+ result = auto_convert(" data.csv" , " ./npy" , fmt = " SMILES" , property_name = " homo" , property_col = " HOMO" )
124133
125134# Structure file → auto-detected by dpdata
126135result = auto_convert(" POSCAR" , " ./npy" )
@@ -130,8 +139,6 @@ result = auto_convert("POSCAR", "./npy")
130139Supports ` .csv ` , ` .xlsx ` , ` .xls ` for SMILES inputs and any format dpdata
131140recognises for structure files (POSCAR, extxyz, cif, OUTCAR, …).
132141
133- A demo CSV and MOL files are included in ` demo/ ` .
134-
135142### Cross-validation
136143
137144Formula-grouped to prevent same-molecule leakage:
@@ -163,7 +170,7 @@ All commands live under `dp dpa` with two-level nesting:
163170dp dpa
164171 extract-descriptors extract pooled DPA descriptors to .npy
165172 fit train a model (any strategy)
166- --strategy {frozen-sklearn|linear-probe |finetune|mft|scratch }
173+ --strategy {frozen_sklearn|linear_probe |finetune|mft}
167174 cv cross-validate (metric estimation, no model output)
168175 predict predict with a frozen .pth bundle
169176 evaluate evaluate a frozen .pth against stored labels
@@ -214,7 +221,6 @@ deepmd/dpa_tools/
214221├── trainer.py # DPATrainer (dp --pt train subprocess wrapper)
215222├── cv.py # cross-validation + data splitting
216223├── conditions.py # scalar condition manager (T, P)
217- ├── demo/ # demo CSV + MOL files for the SMILES pipeline
218224├── config/
219225│ └── manager.py # MFT input.json generation
220226├── data/
0 commit comments