Skip to main content

mshqc

A Pure Thin-Core C++20 / Python Quantum Chemistry Engine for $\mathcal{O}(V^4)$-Memory-Free Orbital-Optimized Møller–Plesset Perturbation Theory

PyPI version License: Apache-2.0 C++20 Python 3.10+ Release CI


Overview

mshqc v2.0 is a lean, high-performance electronic structure library built on an irreducible 9-file C++20 kernel core (~5,500 LOC, zero HDF5 dependency) paired with clean, modular Python orchestration and pluggable compute backends:

  • Unified ERI Modes: Density Fitting ("df"), full-pivoted Cholesky decomposition ("cholesky"), and exact 4-center ERIs ("exact", powered by TBLIS 4D tensor contractions).
  • SCF References & Symmetry: RHF, UHF, ROHF featuring Pure-Python SAD guess + zero-GEMM diagonal Iter-0 exchange, diagonal-equilibrated Pulay DIIS, level-shifting, Pure-Python Abelian point-group symmetry detection & MO irrep labeling (C2v, D2h, etc.), .npz orbital checkpoints, and zero-overhead telemetry callbacks.
  • Canonical / Semicanonical MP: RMP2, UMP2, ROMP2, RMP3, UMP3, ROMP3 (all-electron & strict frozen-core).
  • Orbital-Optimized Perturbation Theory (TR-SOSCF):
    • OMP2, SCS-OMP2, SOS-OMP2, OMP2.5, OMP3 (RHF & UHF, all-electron & frozen-core)
    • kappa-OOMP2 ($\kappa$-regularized OMP2 with degeneracy-safe L'Hôpital orbital gradients & exact analytical nuclear gradients)
    • LT-SOS-OMP2 ($\mathcal{O}(N^4)$ zero-$T_2$ Laplace-Transformed SOS-OMP2 powered by OpenMP C++20 quadrature kernels)
  • Dynamic Compute Backends (mshqc.backends): Switch transparently between the default C++20/TBLIS backend, pure NumPy (use_backend("numpy")), or PyTorch FP64 GPU/CPU acceleration (enable_torch_backend(device="auto"), supporting RHF, LT-SOS-OMP2, and OMP3; includes a free Colab/Kaggle runner in benchmarks/colab_kaggle_gpu_runner.py).
  • Properties, Gradients & Visualization: Analytical DF nuclear gradients (DF-RHF, DF-UHF, DF-ROHF, DF-OMP2, DF-SCS-OMP2, DF-SOS-OMP2, DF-kappa-OOMP2), geometry optimization, $\mathcal{O}(N)$ harmonic vibrational frequencies + RRHO thermochemistry (all-electron & frozen-core), 1D PES bond scans, Natural Orbitals/NOONs, Mulliken/Löwdin charges, .molden export, and one-line presets (mshqc.molecule("H2O"), mshqc.atom("O")).

Thesis & v1.0 Monolithic Archive: The original monolithic C++20 implementation with legacy C++ PetiteList symmetry and HDF5 out-of-core streaming is permanently archived under git tag v1.0.5-thesis-archive (and branch test) for full reproducibility of thesis benchmarks.


Installation

Option 1: Precompiled Wheels from PyPI (Linux, macOS ARM64, Windows x64; Python 3.10+)

pip install mshqc

Basis Set Data (mshqc-basis)

Gaussian basis sets (.gbs) are bundled inside official PyPI wheels and maintained in syahrulhidayat/mshqc-basis. When building from source, clone mshqc-basis and point MSHQC_BASIS_PATH to its data/basis directory (or copy into data/basis/).

Option 2: Build from Source (~25–40 s, Zero-HDF5)

git clone [https://github.com/syahrulhidayat/mshqc.git](https://github.com/syahrulhidayat/mshqc.git)
cd mshqc
conda env create -f environment.yml
conda activate mshqc_314
pip install --no-build-isolation --no-deps -e . -v

Quickstart

1. One-Line Multi-Method Pipeline (mshqc.run & Presets)

import mshqc

mol = mshqc.molecule("H2O")  # or pass XYZ string / .xyz file / list of tuples
results = mshqc.run(
    mol,
    method=["RHF", "OMP2", "SCS-OMP2", "LT-SOS-OMP2", "kappa-OMP2", "OMP2.5", "OMP3"],
    basis="cc-pVTZ",
    eri_method="df",  # "df", "cholesky", or "exact"
    threshold=1e-9,
)

for name, info in results.items():
    print(f"{name:<12}: {info['energy']:.10f} Ha ({info['time']:.3f} s)")

2. Geometry Optimization, Frequencies & Analytic kappa-OOMP2 Gradients

import mshqc

mol = mshqc.build_molecule(
    "O 0 0 0.125\nH 0 0.780 -0.490\nH 0 -0.780 -0.490",
    units="angstrom",
)
opt = mol.optimize_geometry(method="kappa-omp2", basis="cc-pVDZ", g_convergence="gau_tight")
vib = mol.frequencies(method="omp2", basis="cc-pVDZ", freeze_core=True)
print(f"R_OH = {opt.bond_lengths_angstrom['O1-H2']:.6f} A | Freqs = {vib.frequencies_cm1}")

3. Dynamic Backends (NumPy / PyTorch CUDA FP64) & Abelian Symmetry

import mshqc
from mshqc import methods as M
from mshqc.backends import enable_torch_backend, use_backend

mol = M.align_principal_axes(mshqc.molecule("H2O"))
sym = M.detect_abelian_symmetry(mol)
calc = mshqc.MSHQCCalculator(mol, basis_name="cc-pVDZ", eri_method="df")

# Switch to PyTorch CUDA FP64 (with automatic fallback to C++20 kernels)
enable_torch_backend(device="auto", name="torch", fallback_to_cpp=True)
with use_backend("torch"):
    scf_res = calc.run_scf()
    omp3_res = calc.run_omp3(scf_res, grad_thresh=1e-6)

labels = M.label_mo_irreps(mol, calc.basis, scf_res.C_alpha, calc._get_s_ovlp(), sym)
print(f"Point group: {sym.point_group} | Occ irreps: {labels[:5]} | E(OMP3)={omp3_res.energy_total:.8f} Ha")

4. Stateless Interoperability with PySCF (run_from_pyscf)

from pyscf import gto, scf
import mshqc.methods as M

mol = gto.M(atom="O 0 0 0.1173; H 0 0.7572 -0.4692; H 0 -0.7572 -0.4692", basis="cc-pVTZ")
mf = scf.RHF(mol).density_fit(auxbasis="cc-pVTZ-RI").run()
res = M.run_from_pyscf(mf, method="kappa-omp2")
print(f"PySCF -> mshqc DF-kappa-OOMP2: {res.energy_total:.10f} Ha ({res.iterations} it)")

See docs/QUICKSTART.md for open-shell radicals (UHF/ROHF/ROMP2/ROMP3), .molden export, .npz checkpoints, and custom optimize_orbitals_* hooks.


Testing & Benchmarks

# Run full v2.0 verification suite (Stages 3–12, symmetry, backends, exact/DF/Cholesky parity)
pytest tests/ -v

# Quick universal & Bab IV benchmark runners
python benchmarks/run_universal_v2.py --tier quick --basis cc-pVDZ --extended
python benchmarks/run_bab4_v2.py --quick --skip-ram

Verified v2.0.0 CI Benchmarks (cc-pVTZ / cc-pVTZ-RI, 4 Threads)

System ERI Mode Method Energy (Ha) Wall Time (s) Peak RSS (MB) Net RAM (MB)
H2O exact OMP3 -76.33711056 0.530 294.30 216.02
H2O cholesky OMP3 -76.33711056 1.085 202.54 124.51
H2O df OMP2 -76.33402331 0.040 107.42 29.31
H2O df kappa-OOMP2 -76.32973119 0.057 — —
H2O df LT-SOS-OMP2 -76.32966314 0.120 — —
H2O df OMP3 -76.33725847 0.274 142.00 63.92
H2O (cc-pVQZ) df OMP3 72.32x MO RAM cut — 284.87 206.73
O2 (triplet) df OMP2 -150.14712919 0.147 — —
O2 (triplet) df OMP3 -150.13330241 2.131 213.61 135.59

CI Verification Highlights (Linux x86_64, Python 3.11, 4 threads, $\tau = 10^{-9}\text{ Ha}$): pytest tests/ 34 passed (2 optional skipped); Universal Validation (cc-pVDZ, 26 systems $\times$ 3 ERI modes) 78/78 PASS in 42.29 s; Analytic vs Central-FD orbital gradients $\le 1.49 \times 10^{-9}\text{ Ha/rad}$; Analytic DF nuclear gradients (all-electron & frozen-core OMP2/kappa-OOMP2) $\le 6.46 \times 10^{-8}\text{ Ha/Bohr}$; $\mathcal{O}(N^4)$ LT-SOS-OMP2 vs $\mathcal{O}(N^5)$ parity $\le 2.27 \times 10^{-13}\text{ Ha}$.


Citing mshqc

Official releases are archived on Zenodo via automated GitHub Actions release workflows.

@software{Hidayat2026mshqc,
  author  = {Hidayat, Muhamad Syahrul},
  title   = {mshqc: A Pure Thin-Core C++20/Python Quantum Chemistry Engine for O(V^4)-Memory-Free Orbital-Optimized M{\o}ller--Plesset Perturbation Theory},
  year    = {2026},
  version = {2.0.0},
  url     = {[https://github.com/syahrulhidayat/mshqc](https://github.com/syahrulhidayat/mshqc)},
  note    = {PyPI: [https://pypi.org/project/mshqc/](https://pypi.org/project/mshqc/) | ORCID: 0009-0005-4112-1807}
}

License

Apache License 2.0 — see LICENSE for details.

Metadata

Release files for mshqc 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mshqc 2.0.0
File Size Uploaded Provenance Actions
mshqc-2.0.0.tar.gz 6.4 MB Without provenance Details for mshqc-2.0.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mshqc 2.0.0
File Actions
mshqc-2.0.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for mshqc-2.0.0-cp313-cp313-win_amd64.whl
mshqc-2.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details for mshqc-2.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
mshqc-2.0.0-cp313-cp313-macosx_26_0_arm64.whl CPython 3.13 CPython 3.13 macOS 26.0+ ARM64 Details for mshqc-2.0.0-cp313-cp313-macosx_26_0_arm64.whl
mshqc-2.0.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for mshqc-2.0.0-cp312-cp312-win_amd64.whl
mshqc-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for mshqc-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
mshqc-2.0.0-cp312-cp312-macosx_26_0_arm64.whl CPython 3.12 CPython 3.12 macOS 26.0+ ARM64 Details for mshqc-2.0.0-cp312-cp312-macosx_26_0_arm64.whl
mshqc-2.0.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details for mshqc-2.0.0-cp311-cp311-win_amd64.whl
mshqc-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for mshqc-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
mshqc-2.0.0-cp311-cp311-macosx_26_0_arm64.whl CPython 3.11 CPython 3.11 macOS 26.0+ ARM64 Details for mshqc-2.0.0-cp311-cp311-macosx_26_0_arm64.whl

Total release size: 143.7 MB

Release files / mshqc-2.0.0.tar.gz

Download URL mshqc-2.0.0.tar.gz
Size 6.4 MB
Tags Source
SHA-256 checksum
How to use checksums
d7e6e4ae66d2a95f37a5d561b0a923dc53cba66ae5e4c4f5aebeccd612281e1f
BLAKE2b-256 checksum
How to use checksums
89500dfbd77eacc55e226d67f746494abd10824efbc19146fd617f661ec73866
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp313-cp313-win_amd64.whl

Download URL mshqc-2.0.0-cp313-cp313-win_amd64.whl
Size 10.3 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
b2881ae4b91337f88b5af748d5eb0243dfccaad05f1513bd070a2b9099069448
BLAKE2b-256 checksum
How to use checksums
d12a8f8400853cd73871be10025149ed65c5d243390f50f9ebfbb6bdee28cac2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL mshqc-2.0.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 10.9 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
deb204b24984dcd730f75a5000a790169156af4be191a1f20ac4c1ce3aab6e69
BLAKE2b-256 checksum
How to use checksums
c67384fc72e81ed65929c1d358e923e934feeb52eb1388e42d05bcca111221ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp313-cp313-macosx_26_0_arm64.whl

Download URL mshqc-2.0.0-cp313-cp313-macosx_26_0_arm64.whl
Size 24.5 MB
Tags CPython 3.13 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
e7dac58ea20ea4b05ddc871a8eca9edf876715ef955031ff8cf335712c2afbe4
BLAKE2b-256 checksum
How to use checksums
9a31a969244e1834365f9c758053a81ea0b556fd987d30eb4881f21a9224cb50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp312-cp312-win_amd64.whl

Download URL mshqc-2.0.0-cp312-cp312-win_amd64.whl
Size 10.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
6b13d3acfefbbadaf08d703f72f7b6320779ae8e91eaeb01b88ef96905953c24
BLAKE2b-256 checksum
How to use checksums
214c3de23fc8c228f9d84bd037a522dc7c975623d941047e07e96b1242277058
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL mshqc-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 10.9 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
53fcd1e4a09c4a0343c248e0f1eded8a73e07c54aa0986a1d147dcc6776380f4
BLAKE2b-256 checksum
How to use checksums
db7ca1e56e2e5de5ae6d8648ed41894beb4073b4cb1b53e47934f2256cf7f8b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp312-cp312-macosx_26_0_arm64.whl

Download URL mshqc-2.0.0-cp312-cp312-macosx_26_0_arm64.whl
Size 24.5 MB
Tags CPython 3.12 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
060a144658fb0be431d7fdc33cf36a2193d4a20b1459209df2177476b21f25a2
BLAKE2b-256 checksum
How to use checksums
c240f00b4411c8de28c818f926e7cfb7279d809beafbafb41c04da0cf0b09b0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp311-cp311-win_amd64.whl

Download URL mshqc-2.0.0-cp311-cp311-win_amd64.whl
Size 10.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
01adbf3c12537a0322cd01870b650ec42bc2ee339582c03fe099fbe2a2804f3e
BLAKE2b-256 checksum
How to use checksums
a9745dd9e2acaf2718f54efd1825560fe24c43a15e082afda78f2843a742d2ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL mshqc-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 10.9 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c166e5bc80345a5cf9b204abe7d13600ed446fb93cc29d67ec7f9f4173486286
BLAKE2b-256 checksum
How to use checksums
7b35977624b9c21e704f1b0218f54b8c24e5f4eb0a26cd118876e3e37a70273e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / mshqc-2.0.0-cp311-cp311-macosx_26_0_arm64.whl

Download URL mshqc-2.0.0-cp311-cp311-macosx_26_0_arm64.whl
Size 24.5 MB
Tags CPython 3.11 macOS 26.0+ ARM64
SHA-256 checksum
How to use checksums
d64e3ac68fae9dd6a372e406c4c982cdef829a32a69c271d01c44463fbf51cbe
BLAKE2b-256 checksum
How to use checksums
54e9b79fe6deb7333bcb169b09a29bdbd5a4be45a07c8ef13435831afa094f76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for mshqc 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page