Skip to main content

q2m3: A Hybrid Quantum-Classical QM/MM Simulation Framework

q2m3 logo

Python 3.11+ License: MIT Documentation Docs codecov DOI PennyLane Catalyst PySCF

q2m3 is a research framework for hybrid quantum-classical QM/MM (quantum mechanics / molecular mechanics). It connects PySCF molecular integrals and Hartree–Fock references to PennyLane Quantum Phase Estimation (QPE) circuits. It also supports explicit MM point charges, Monte Carlo (MC) solvation, and sample-based quantum diagonalization (SQD).

Use q2m3 to explore small-molecule QPE workflows and early fault-tolerant quantum computing (EFTQC) resource estimates. The project is an alpha proof of concept. Its approximations and small-system checks do not establish production chemistry accuracy.

Install

q2m3 requires Python 3.11+. Install from PyPI to use the library. Use a source checkout to run the example scripts and the development tools.

From PyPI

In a virtual environment (POSIX shell):

python -m venv .venv
source .venv/bin/activate
python -m pip install q2m3

The package is available as q2m3 on PyPI.

From source

With uv installed:

git clone https://github.com/yjmaxpayne/q2m3.git
cd q2m3
uv sync

The core install supports the three H₂ starter scripts in the example guide. Select optional extras by purpose:

Extra Use
solvation Monte Carlo workflows (includes Catalyst and JAX)
catalyst Circuit compilation without the full solvation extra
gpu GPU dependencies (requires a compatible NVIDIA/CUDA setup)
viz Molecular visualization tools
dev / docs Tests and code quality tools / Sphinx documentation
sqd ffsim/Qiskit SQD workflows (see the SQD guide)

For example, run uv sync --extra solvation in a source checkout. In a library environment, run python -m pip install "q2m3[solvation]".

Minimal Python API

This snippet estimates resources for H₂/STO-3G. The active space has two electrons in two spatial orbitals, which gives four Jordan–Wigner system qubits. Coordinates are in Å. The target energy error is in Hartree. Run the snippet with python in the PyPI environment, or with uv run python in the source checkout.

import numpy as np

from q2m3.core import estimate_resources

resources = estimate_resources(
    symbols=["H", "H"],
    coords=np.array([[0.0, 0.0, 0.0], [0.0, 0.0, 0.74]]),
    basis="sto-3g",
    active_electrons=2,
    active_orbitals=2,
    target_error=0.0016,
)
print("System qubits:", resources.n_system_qubits)
print("Logical qubits:", resources.logical_qubits)
print("Toffoli gates:", resources.toffoli_gates)

estimate_resources returns an EFTQCResources object. The logical-qubit and Toffoli-gate counts come from an algorithmic cost model. They do not predict local simulator runtime or Catalyst compilation memory.

SQD workflows

To install the SQD dependencies in a source checkout, run uv sync --frozen --extra sqd. SQD does not require Catalyst. The public supervisor requires Linux x86_64 and serial native threads. The unified lock also moves the core-only PySCF version to 2.14.0. The calibrated resource profile uses Python 3.12.3.

SQD has two entry points:

  • from q2m3 import run_sqd starts from a molecular geometry.
  • from q2m3.sqd import run_sqd_from_integrals starts from an authenticated integral Hamiltonian and a same-frame CCSD seed.

Both functions require an explicit closed-shell active space. Both return the complete SQDResult. The SQD guide gives runnable examples for both. It also covers fixed-frame MM semantics, reference tiers, installation boundaries, and resource caps. The SQD API reference lists the public contracts, the authenticated integral producers, and the resource-policy functions.

Current evidence supports the default benchmark scope of two repetitions and 100000 shots. H₂ and H₃O⁺ are full-space regressions. Glycine is worse than CCSD for all five seeds. N₂ is worse than both CCSD and matched-size SCI. The original orbital-basis (E1) and connectivity (E6) studies remain inconclusive. Historical four-repetition runs remain outside the certified resource domain. These results do not establish SQD superiority or quantum hardware readiness.

Examples and documentation

Start with the example guide. It gives runnable H₂ commands and the complete script index. It also separates MC workflows from larger diagnostics.

Goal Entry point
Validate vacuum and MM-embedded QPE H₂ QPE tutorial
Compare resource estimates H₂ resource tutorial
Explore fixed-MO embedding Full one-electron example
Run Monte Carlo solvation H₂ MC tutorial
Run sampled diagonalization end to end SQD H₂-to-glycine tutorial
Understand the model and API Documentation site

q2m3 computes energies in Hartree and converts them explicitly for kcal/mol reports. QPE–HF differences contain numerical errors as well as correlation contributions. Fixed-MO MM embedding keeps the vacuum orbital frame and the two-electron tensor fixed. Runtime MC coefficient updates are diagonal-only. Read the example boundaries before you interpret energies physically.

Runnable capability map

Goal Learning path
QPE validation and resolution QPE examples
SQD ground states and scaling H₂ → glycine CAS 6/8/10 → integrals
Fixed-MO embedding and QPE–MC QM/MM examples
Quantum resource estimates Resource examples
Catalyst and compilation costs Performance examples

SQD tutorials save complete results, CSV files, and PNG/SVG figures to a unique run directory under data/output/examples/. The default glycine scan runs 15 actual points in sequence, each in a fresh process. Local development tools are not part of the installed package and are not required in a fresh clone. Use q2m3.profiling.measure_command for complete-process monitoring. The SQD tutorial documents its result contract, units, environment defaults, and sampling limits. Historical benchmark and calibration records describe their original inputs and versions. Shared CI does not promise to regenerate those studies.

Development, citation, and license

See the development guide for test, lint, and build commands. See AGENTS.md for contribution conventions. Do not commit generated coverage files, caches, or benchmark outputs.

For research use, cite the release that produced your results. Use CITATION.cff for the citation metadata. q2m3 uses the MIT License.

Metadata

Release files for q2m3 0.2.1

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

Source distribution (sdist)

Source distribution for q2m3 0.2.1
File Size Uploaded Provenance Actions
q2m3-0.2.1.tar.gz 1.4 MB With provenance Details for q2m3-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for q2m3 0.2.1
File Interpreter ABI Platform Actions
q2m3-0.2.1-py3-none-any.whl Python 3 none any Details for q2m3-0.2.1-py3-none-any.whl

Total release size: 1.6 MB

Release files / q2m3-0.2.1.tar.gz

Download URL q2m3-0.2.1.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
11133c498e50b7c6355fdf4dda2d1809ad751e557a7e9729a9946074e8256b5a
BLAKE2b-256 checksum
How to use checksums
7e97c677fcf81de064eade26d5ee7f16f9f60fb64d96596b3fcf08f4effa7084
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Release files / q2m3-0.2.1-py3-none-any.whl

Download URL q2m3-0.2.1-py3-none-any.whl
Size 175.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51cf1494f78a07a3e6b23499287052ca8c55e360e2ac9aed93f60b6730292344
BLAKE2b-256 checksum
How to use checksums
b27d2b6ea33aa9909ee71d0bbe1967e8349ba4e8dab8581b51468521d9ecaa48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

Security for q2m3 0.2.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for q2m3-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 19, 2026.

Transparency log

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