hip / README.md
nielsr's picture
nielsr HF Staff
Improve model card: Add graph-ml tag, Apache-2.0 license, abstract, correct links & usage
588f963 verified
|
Raw
History Blame
6.73 kB
metadata
license: apache-2.0
pipeline_tag: graph-ml

Molecular Hessians Without Derivatives

This repository contains the model presented in the paper Shoot from the HIP: Hessian Interatomic Potentials without derivatives.

Abstract: Fundamental tasks in computational chemistry, from transition state search to vibrational analysis, rely on molecular Hessians, which are the second derivatives of the potential energy. Yet, Hessians are computationally expensive to calculate and scale poorly with system size, with both quantum mechanical methods and neural networks. In this work, we demonstrate that Hessians can be predicted directly from a deep learning model, without relying on automatic differentiation or finite differences. We observe that one can construct SE(3)-equivariant, symmetric Hessians from irreducible representations (irrep) features up to degree $l$=2 computed during message passing in graph neural networks. This makes HIP Hessians one to two orders of magnitude faster, more accurate, more memory efficient, easier to train, and enables more favorable scaling with system size. We validate our predictions across a wide range of downstream tasks, demonstrating consistently superior performance for transition state search, accelerated geometry optimization, zero-point energy corrections, and vibrational analysis benchmarks. We open-source the HIP codebase and model weights to enable further development of the direct prediction of Hessians at this https URL

The official codebase is open-sourced and available at: https://github.com/BurgerAndreas/hip

This work introduces Hessian Interatomic Potentials (HIP), a novel deep learning approach to directly predict molecular Hessians (second derivatives of potential energy) without relying on automatic differentiation or finite differences. This approach addresses the computational expense and poor scaling of traditional Hessian calculation methods. Trained on the HORM Hessian dataset, which consists of off-equilibrium geometries of small, neutral organic molecules, contained H, C, N, O, based on the T1x and RGD1 datasets, at the $\omega$B97X/6-31G(d) level of theory.

Compared to autograd Hessians:

  • 10-70x faster for a single molecule of 5-30 atoms
  • 70x faster for a typical T1x batch in batched prediction
  • 3x memory reduction
  • Better accuracy (Hessian, Hessian eigenvalues and eigenvectors)
  • Better downstream accuracy (relaxation, transition state search, frequency analysis)
Speed and memory comparison

Available checkpoints

  • hesspred_v1: Used for the paper. Trained to predict Hessians. Can be used for energies, forces, learned and autograd Hessians.
  • hesspred_v2: Potentially better Hessian prediction, less tested. Trained with MAE.
  • hesspred_v3: Potentially better Hessian prediction, less tested. Trained for longer.
  • ckpt/eqv2.ckpt: HORM EquiformerV2 finetuned on the HORM Hessian dataset. Not trained to predict Hessians! Can be used for energies, forces, and autograd Hessian.

Use our model

Download the checkpoint from Hugging Face:

# assuming you are in the cloned hip directory
wget https://huggingface.co/andreasburger/heigen/resolve/main/ckpt/hesspred_v1.ckpt -O ckpt/hesspred_v1.ckpt
import os
import torch
from hip.equiformer_torch_calculator import EquiformerTorchCalculator
from hip.equiformer_ase_calculator import EquiformerASECalculator # also try this
from hip.inference_utils import get_dataloader
from hip.frequency_analysis import analyze_frequencies_torch


device = "cuda" if torch.cuda.is_available() else "cpu"

# you might need to change this
project_root = os.path.dirname(os.path.dirname(__file__))
checkpoint_path = os.path.join(project_root, "ckpt/hesspred_v1.ckpt")
calculator = EquiformerTorchCalculator(
    checkpoint_path=checkpoint_path,
    hessian_method="predict",
)

# Example 1: load a dataset file and predict the first batch
dataset_path = os.path.join(project_root, "data/sample_100.lmdb")
dataloader = get_dataloader(
    dataset_path, calculator.potential, batch_size=1, shuffle=False
)
batch = next(iter(dataloader))
results = calculator.predict(batch)
print("
Example 1:")
print(f"  Energy: {results['energy'].shape}")
print(f"  Forces: {results['forces'].shape}")
print(f"  Hessian: {results['hessian'].shape}")

print("
GAD:")
gad = calculator.get_gad(batch)
print(f"  GAD: {gad['gad'].shape}")

# Example 2: create a random data object with random positions and predict
n_atoms = 10
elements = torch.tensor([1, 6, 7, 8])  # H, C, N, O
pos = torch.randn(n_atoms, 3)  # (N, 3)
atomic_nums = elements[torch.randint(0, 4, (n_atoms,))]  # (N,)
results = calculator.predict(coords=pos, atomic_nums=atomic_nums)
print("
Example 2:")
print(f"  Energy: {results['energy'].shape}")
print(f"  Forces: {results['forces'].shape}")
print(f"  Hessian: {results['hessian'].shape}")

print("
Frequency analysis:")
hessian = results["hessian"]
frequency_analysis = analyze_frequencies_torch(hessian, pos, atomic_nums)
print(f"eigvals: {frequency_analysis['eigvals'].shape}")
print(f"eigvecs: {frequency_analysis['eigvecs'].shape}")
print(f"neg_num: {frequency_analysis['neg_num']}")
print(f"natoms: {frequency_analysis['natoms']}")

Citation

If you found this code useful, please consider citing:

@inproceedings{
burger2025hessians,
title={Molecular Hessians Without Derivatives},
author={Andreas Burger and Luca Thiede and  Nikolaj Rønne and Nandita Vijaykumar and Tejs Vegge and Arghya Bhowmik and Alan Aspuru-Guzik},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/forum?id=CNLC4ZkLmW}
}

The training code and the dataset are based on the HORM paper, dataset, and code. We thank the authors from DeepPrinciple for making their code and data openly available.

@misc{cui2025hormlargescalemolecular,
      title={HORM: A Large Scale Molecular Hessian Database for Optimizing Reactive Machine Learning Interatomic Potentials}, 
      author={Taoyong Cui and Yunhong Han and Haojun Jia and Chenru Duan and Qiyuan Zhao},
      year={2025},
      eprint={2505.12447},
      archivePrefix={arXiv},
      primaryClass={physics.chem-ph},
      url={https://arxiv.org/abs/2505.12447}, 
}