This package is a Python implementation of potential energy surface (PES) fitting with permutational invariant polynomials neural network (PIP-NN).
If CQPES helps your work, please cite correctly.
Li, J.; Song, K.; Li, J. CQPES: A GPU-Aided Software Package for Developing Full-Dimensional Accurate Potential Energy Surfaces by Permutation-Invariant-Polynomial Neural Network. Chemistry (Basel) 2025, 7 (6), 201. https://doi.org/10.3390/chemistry7060201.
We provide pre-packaged installers including all dependencies (TensorFlow, CUDA, etc.). This is the most stable way to use CQPES.
Download the installer from Releases.
Run the installer:
# cpu version
$ bash ./cqpes-cpu-2.3.0-Linux-x86_64.sh
# cuda version
$ cat cqpes-cu129-2.3.0-Linux-x86_64.sh.part* > cqpes-cu129-2.3.0-Linux-x86_64.sh
$ bash ./cqpes-cu129-2.3.0-Linux-x86_64.shActivate your environment first:
$ conda activate /path/to/cqpes-env
For standard users, simply install via pip:
(cqpes-env)$ pip install cqpesFor beginners and developers, or offline environments, clone the repository and install from source:
(cqpes-env)$ git clone https://github.com/CQPES/cqpes-legacy.git
(cqpes-env)$ cd cqpes-legacy
# For users
(cqpes-env)$ pip install .
# For developers
(cqpes-env)$ pip install -e .(cqpes-env)$ cqpes -h
usage: cqpes [-h] [-v] {prepare,train,test,export,predict,run} ...
CQPES: GPU-Aided Potential Energy Surface Development Toolkit
positional arguments:
{prepare,train,test,export,predict,run}
Sub-commands
prepare Prepare dataset from raw files
train Train PIP-NN model via Keras & TensorFlow
test Evaluate model performance and plot errors
export Export trained model for dynamics interfaces
predict Predict energies for a given XYZ trajectory
run Run tasks (Opt, TS, Freq, MD) using trained PES via ASE
options:
-h, --help show this help message and exit
-v, --version show program's version number and exitCQPES provides a unified Command Line Interface (CLI) for the entire PES development lifecycle: from data preparation and training, to model evaluation and dynamic simulations.
You can try the following steps in directory examples/CH4!
CQPES now supports two powerful backends to balance compatibility and performance:
| Feature | MSA (Legacy) | JaxPIP (Modern) |
|---|---|---|
| Core Engine | TensorFlow + Keras | JAX + Equinox |
| PIP Logic | f2py Dynamic Linking Library (wrapper for MSA-2.0) |
Native JaxPIP Implementation |
| Derivatives | Analytical (Hybrid Fortran-based & Tensorflow) | Automatic Differentiation |
| Performance | Baseline | Extreme (XLA Optimized) |
We provide a wrapper for MSA-2.0 to generate the PIP basis. Clone the builder repository:
(cqpes-env)$ git clone https://github.com/CQPES/PyMSA-Builder.git
(cqpes-env)$ cd PyMSA-Builder
(cqpes-env)$ python3 build.pyFollow the interactive prompts to configure your molecular system (e.g., 4 1 for an A4B system like CH4). Once built, copy the generated .so library into your working directory.
- Basis Conversion: Convert your existing PIP definitions to JaxPIP JSON format using the cli tool
jaxpip bas2json. - Library: You can also find pre-computed basis sets in the JaxPIP Basis Library.
Two input formats are supported for the raw data:
Legacy plain-text - a standard xyz file plus a plain-text file of absolute electronic energies (one per frame, in Hartree). A reference energy is subtracted (ref_energy in the config, default: the dataset minimum) and the dataset stores V = (E - E_ref) in eV together with the reference:
{
"xyz": "rawdata/CH4.xyz",
"energy": "rawdata/CH4_CCSD-T.dat",
"ref_energy": null,
"alpha": 1.0,
"output": "data"
}extxyz - a single self-describing extxyz file; point xyz and energy at the same file and the embedded energies (in eV, ASE convention) are used as-is: they are V, the quantity the PES reproduces verbatim - no reference is subtracted and ref_energy is ignored:
{
"xyz": "rawdata/CH4.extxyz",
"energy": "rawdata/CH4.extxyz",
"alpha": 1.0,
"output": "data"
}Pack them into efficient NumPy arrays using the prepare command:
MSA:
(cqpes-env)$ cqpes prepare config/prepare.json --msa msa.cpython-310-x86_64-linux-gnu.soJaxPIP:
(cqpes-env)$ cqpes prepare config/prepare.json --jaxpip MOL_x_y_z_k.jsonThis handles the Morse-like variable transformations and structural unpacking automatically based on your JSON configuration.
Train the PIP-NN model using Levenberg-Marquardt (LM) or other optimizers defined in your configuration file:
(cqpes-env)$ cqpes train config/train.jsonThe trained models and training logs will be saved in a timestamped output path for model, e.g., model_20260315_123751.
The training log reports physical-unit errors alongside the scaled LM loss: E_MAE/E_RMSE in meV and, for force-aided fits, F_MAE/F_RMSE in meV/Angstrom.
By default, all samples are weighted equally. To emphasize specific energy regions (e.g., near the potential well), provide a custom weighting function via the -w / --weighting flag:
(cqpes-env)$ cqpes train config/train.json -w weighting.pyIf the flag is omitted, CQPES reports that uniform weighting is active.
CQPES can fit energies and forces simultaneously. Force-aided fitting uses a single extxyz file: point xyz, energy and force at the same file in your prepare.json:
{
"xyz": "rawdata/CH4.extxyz",
"energy": "rawdata/CH4.extxyz",
"force": "rawdata/CH4.extxyz",
"alpha": 1.0,
"output": "data"
}Coordinates, energies and forces are extracted from the file, following ASE conventions: energies in eV, forces in eV/Angstrom. The energy values are used as-is (they are V, the quantity the PES reproduces verbatim - no reference is subtracted, and ref_energy is ignored in this mode). Structures with a periodic boundary are rejected unless the cell is a vacuum box much larger than the molecule (a warning is printed).
Any tool that writes extxyz works - for a DeePMD-kit dataset, four lines of dpdata produce it:
import dpdata
from ase.io import write
frames = [dpdata.LabeledSystem(d, fmt="deepmd/npy").to_ase_structure()
for d in ["00.data/training_data", "00.data/validation_data"]]
write("dataset.extxyz", [a for split in frames for a in split])During prepare, the PIP Jacobian dp/dxyz is stored in the dataset (dbemsav for the MSA backend, forward-mode AD for JaxPIP). During training, the force residuals
F = -dV/dxyz = -(dV/dy · dX/dp · dp/dxyz) · (dy/dX)
are assembled per sample — dy/dX via an analytic matmul chain, the constant factors folded into a scale vector — and appended to the LM residual vector, so tf_levenberg_marquardt fits energies and forces in one shot (fully FP64).
Both residual blocks are normalized to O(1) before fitting: energies via the min-max scaling to [-1, 1], forces by their dataset RMS (DeePMD-style sigma_F), so the loss is
loss = MSE(ΔE / s_E) + force_weight · MSE(ΔF / F_rms)
and fit.force_weight in train.json is a dataset-independent relative weight (1 balances the two relative errors). The "physical" balance where a 1 meV/Å force error counts the same as a 1 meV energy error corresponds to force_weight = (F_rms / s_E)² with s_E = (V_max - V_min) / 2 — about 98 for the CH₄ example below.
See examples/CH4-with-forces (DeePMD data) and examples/CH4-MSA-2.0 (MSA-2.0 geom.inp data) for complete runs.
The train.json config selects the LM engine by top-level config key. The two keys are mutually exclusive (specifying both raises a ValueError); if neither is present, the legacy lm defaults are used, so every pre-2.4 config runs exactly as before.
"lm"-- the upstreamtf_levenberg_marquardtpackage, unchanged: classic damped LM with retry."rnc-lm"-- the bundled RNC-LM engine (Ref. (6)): trust-ratio step control with curve-length backtracking and ρ-driven damping, second-order geodesic curvature correction, and two safety valves (soft geodesic trust gatealpha_ga, damping floorlambda_min). Reuses a single Cholesky factorization per direction for all coefficient solves.
The selected engine is declared at the top of the training log ([ENGINE] tf_levenberg_marquardt or [ENGINE] cqpes.lm).
Example rnc-lm section (validated production defaults; fields not listed take these values):
{
"network": { "layers": [32, 64], "activation": "tanh" },
"fit": { "lr": 0.5, "epoch": 1000, "batch_size": -1 },
"rnc-lm": {
"adaptive_scaling": true,
"fletcher": false,
"solve_method": "solve",
"jacobian_max_num_rows": 1000,
"step_control": "trust_ratio",
"eta_acc": 0.1,
"max_t_retries": 3,
"rnc_order": 2,
"fd_h_rel": 1e-5,
"alpha_ga": 0.75,
"lambda_min": 1e-8
}
}Field notes:
step_control--"trust_ratio"(default): the accepted LM direction is realized as a curved path θ(t) = θ + t·d1 + t²/2·d2 with curve length t ∈ (0, 1]; on overshoot the length is shortened by quadratic interpolation (three retries at most) before the damping factor is touched."classic"restores the upstream strict-decrease + damping-retry behavior verbatim.rnc_order--1= straight-line update;2(default) adds the second-order geodesic correction c2 = G⁻¹(−JᵀR2) (R2 estimated by an FP64 central difference, JᵀR2 by one frozen-cotangent VJP; both reuse the same Cholesky factor).lambda_min-- floor for the λ/3 damping branch. Response sweep on H + H₂S: 1e-10 overfits (validation detaches, MaxErr spikes), 1e-7 caps the fit depth; 1e-8 is the validated sweet spot and the default.alpha_ga-- soft gate capping ‖d2/2‖ atalpha_ga·‖d1‖, guarding null-space overshoot of the curvature term in sparsely sampled directions.
Evaluate the accuracy of your trained PES against the test set:
(cqpes-env)$ cqpes test model_20260315_123751/This will automatically compute MAE, MSE, and RMSE for your training, validation, and test subsets. Additionally, fitting error scatter plots and histograms will be generated and saved in the model path for visual diagnostics.
For datasets with forces, a second table reports force MAE/RMSE/MaxErr (meV/Angstrom) together with the per-frame force-norm error and the cosine similarity between predicted and reference force vectors.
CQPES can be exported in 2 formats:
- Standard Keras
h5format, required bypredictandruncommands ifMSAbackend used. - Experimental
JaxPIPformat, required bypredictandruncommands ifJaxPIPbackend used. - Legacy
potfitplain text format, compatible with fortran interface for software like Polyrate, VENUS96C, or Caracal.
(cqpes-env)$ cqpes export -t h5 model_20260315_123751/
(cqpes-env)$ cqpes export -t jaxpip model_20260315_123751/
(cqpes-env)$ cqpes export -t potfit model_20260315_123751/The exported files will be stored in model path.
(cqpes-env)$ cqpes predict model_20260315_123751 new_trajectory.xyz --output predictions.xyzCQPES is fully integrated with the Atomic Simulation Environment (ASE). You can perform high-level computational chemistry tasks directly via the CLI:
# Geometry optimization followed by analytical frequency analysis
(cqpes-env)$ cqpes run model_20260315_123751 ch4.xyz --opt min --freq
# Transition State (TS) search (requires Sella)
(cqpes-env)$ cqpes run model_20260315_123751 guess_ts.xyz --opt ts --freq
# Molecular Dynamics (NVT ensemble at 300K)
(cqpes-env)$ cqpes run model_20260315_123751 input.xyz --md nvt --temp 300.0 --dt 1.0 --steps 5000 -o md.xyzfrom cqpes import CQPESPot, CQPESCalculatorexamples/CH4/interface/Fortran
examples/CH4/interface/Gaussian
examples/CH4/interface/VENUS96C
- (1) Xie, Z.; Bowman, J. M. Permutationally Invariant Polynomial Basis for Molecular Energy Surface Fitting via Monomial Symmetrization. J. Chem. Theory Comput. 2010, 6 (1), 26–34. https://doi.org/10.1021/ct9004917.
- (2) Nandi, A.; Qu, C.; Bowman, J. M. Using Gradients in Permutationally Invariant Polynomial Potential Fitting: A Demonstration for CH4 Using as Few as 100 Configurations. J. Chem. Theory Comput. 2019, 15 (5), 2826–2835. https://doi.org/10.1021/acs.jctc.9b00043.
- (3) Jiang, B.; Guo, H. Permutation Invariant Polynomial Neural Network Approach to Fitting Potential Energy Surfaces. J. Chem. Phys. 2013, 139 (5). https://doi.org/10.1063/1.4817187.
- (4) Li, J.; Jiang, B.; Guo, H. Permutation Invariant Polynomial Neural Network Approach to Fitting Potential Energy Surfaces. II. Four-Atom Systems. J. Chem. Phys. 2013, 139 (20). https://doi.org/10.1063/1.4832697.
- (5) Li, J.; Song, K.; Li, J. CQPES: A GPU-Aided Software Package for Developing Full-Dimensional Accurate Potential Energy Surfaces by Permutation-Invariant-Polynomial Neural Network. Chemistry (Basel) 2025, 7 (6), 201. https://doi.org/10.3390/chemistry7060201.
- (6) Liu, J.; Zhang, D. H. Higher-Order Geometric Updates for Levenberg-Marquardt Method via Riemann Normal Coordinates. arXiv [cs.LG], 2026. https://doi.org/10.48550/arXiv.2607.07623.