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
Overview
mshqc v2.1 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,ROHFfeaturing 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.),.npzorbital 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"), supportingRHF,OMP2,LT-SOS-OMP2, andOMP3with 0 lines of CUDA C++; includes Colab/Kaggle runners innotebooks/colab_a100_cpc_benchmark.ipynb). - 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,.moldenexport, and one-line presets (mshqc.molecule("H2O"),mshqc.atom("O")).
Thesis & v1.0 Monolithic Archive: The original monolithic C++20 implementation with legacy C++
PetiteListsymmetry and HDF5 out-of-core streaming is permanently archived under git tagv1.0.5-thesis-archive(and branchtest) 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
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 workflows. If you use mshqc in research, benchmarks, or derivative software, please cite:
@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},
publisher = {Zenodo},
doi = {10.5281/zenodo.24534344},
url = {https://doi.org/10.5281/zenodo.24534344},
note = {GitHub: https://github.com/syahrulhidayat/mshqc | PyPI: https://pypi.org/project/mshqc/ | ORCID: 0009-0005-4112-1807}
}
License
Apache License 2.0 — see LICENSE for details.
3. CPC Reproducibility Test Run (< 10 s)
python3 repro_cpc/run_cpc_test_run.py
Metadata
Release files for mshqc 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mshqc-2.1.0.tar.gz | 6.5 MB | Without provenance | Details for mshqc-2.1.0.tar.gz |
Built distributions (wheels)
Total release size: 144.5 MB
Release files / mshqc-2.1.0.tar.gz
| Download URL | mshqc-2.1.0.tar.gz |
|---|---|
| Size | 6.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a19e5deb0901e2ac545aef5b346608a4481098aa6e55518663f6f5487337a6e0
|
|
BLAKE2b-256 checksum How to use checksums |
2da685356ebabfe3d1734378fd23934cc8bf84d270d2f3d6500187ee13903215
|
| 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.1.0-cp313-cp313-win_amd64.whl
| Download URL | mshqc-2.1.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 10.4 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9841db0b456d4f112f712b16933c41ab4529cd3fe3649d1476483991ec13be3d
|
|
BLAKE2b-256 checksum How to use checksums |
7a2938201aac560194842ef3daa554f8189b9a5a59a92443f0c1011ce1163261
|
| 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.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | mshqc-2.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.0 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
33556470e379829c4c6024796f6e6b506613aecde31c6681cffd753d13ca89b9
|
|
BLAKE2b-256 checksum How to use checksums |
e31ac30c0607c2b7ecc25c9b8e9192109d52ad4ae3841b3e75e42fc2e59182d0
|
| 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.1.0-cp313-cp313-macosx_26_0_arm64.whl
| Download URL | mshqc-2.1.0-cp313-cp313-macosx_26_0_arm64.whl |
|---|---|
| Size | 24.6 MB |
| Tags | CPython 3.13 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9b1033876748411890b8479e602156ccc76f4cb3e3f7cd28a239b5e3033407f9
|
|
BLAKE2b-256 checksum How to use checksums |
3a7be5c45c398b695016ce4b3316caef9714b299411e447ed1ee14a5b1e62a8e
|
| 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.1.0-cp312-cp312-win_amd64.whl
| Download URL | mshqc-2.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 10.4 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
68e2ab517aeff9da8f8ca0a4efcaadc3b443be5e0f12cf3d765576e88993860c
|
|
BLAKE2b-256 checksum How to use checksums |
e0771977bee516990aed7e866f814ffffbe4e77462d2c2f34f860ec5e2d4ab9e
|
| 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.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | mshqc-2.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.0 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
2a0dcff033a3dd562792fc82c381d00b4b4552cffc9ff16396a285d15eb6fb49
|
|
BLAKE2b-256 checksum How to use checksums |
813663687d717dcd9ca4cc1f72289b9a7e76e1226a9fab41645b296aa81cd967
|
| 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.1.0-cp312-cp312-macosx_26_0_arm64.whl
| Download URL | mshqc-2.1.0-cp312-cp312-macosx_26_0_arm64.whl |
|---|---|
| Size | 24.6 MB |
| Tags | CPython 3.12 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
514adc76d9513b9936d256782902074e434562ce63c7aee9210efedd2625c420
|
|
BLAKE2b-256 checksum How to use checksums |
a9e1881630c3645e68d57a6505ac84a494a2f201cc37734291bcc2758972ee20
|
| 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.1.0-cp311-cp311-win_amd64.whl
| Download URL | mshqc-2.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 10.4 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4ebed686cad43b3ebca3f3720b63dfef9f0d855d7dd99e448f268d63d4504a6b
|
|
BLAKE2b-256 checksum How to use checksums |
f3f4eff5519175b5ea1aa70ddabf24befb13184a965791ffe486c0a76140f0d3
|
| 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.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | mshqc-2.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 11.0 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
4f4b62776ac9f5a18e0d33e6368572f9687d60eeb44de0bd7058d0a7d79e3e18
|
|
BLAKE2b-256 checksum How to use checksums |
3a62c392946b696e60edda1f06bb9362d0ccd26f3889e3857bdca0a88fe63c97
|
| 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.1.0-cp311-cp311-macosx_26_0_arm64.whl
| Download URL | mshqc-2.1.0-cp311-cp311-macosx_26_0_arm64.whl |
|---|---|
| Size | 24.6 MB |
| Tags | CPython 3.11 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
06a1ff28e8f4df432885eed737a529e96c728bd2e62b84aa7ab0c1c02361eb87
|
|
BLAKE2b-256 checksum How to use checksums |
37bd738040a559e12341a9b1c639b700f2957c34b63652cb80780f70c0584662
|
| 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.1.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.