Skip to main content

High-performance Geometric GNN Engine

Project description

Hadronis

CodSpeed

High-performance Geometric GNN Engine for Chemistry and Physics

Overview

Hadronis is a high-throughput batch inference engine library for molecular graph neural networks (GNNs), designed for CPU-bound scientific computing at scale. It currently targets a PaiNN-style equivariant architecture rather than arbitrary GNNs, letting the implementation focus on optimizing a single, well-motivated model family instead of reimplementing a generic GNN framework. It combines the speed of C++ with the flexibility of Python, targeting real-world chemistry and physics applications.

Why Hadronis?

Modern molecular ML has shifted from structure → properties (classical QSAR, hand-crafted descriptors) to properties → structure with large generative graph transformers. These models can propose vast numbers of candidate molecules, but validating each one with high-level quantum methods like DFT is still orders of magnitude too slow for practical screening. Hadronis focuses on the complementary direction: a high-throughput, batched structure → properties engine that can rapidly filter out physically implausible or uninteresting candidates before expensive calculations. In other words, it is designed to sit between generative models and ab initio verification, providing a fast, geometry-aware signal that helps triage large libraries.

At the same time, Hadronis is explicitly not a drop-in replacement for first-principles methods or experimental data. Using AI to evaluate AI-generated structures carries risks: systematic biases in the training data, failure modes on out-of-distribution chemistry, and feedback loops where the generator over-optimizes for the surrogate model instead of real physics. The goal is therefore to provide a transparent, well-engineered inference engine that is easy to benchmark, stress-test, and validate against trusted reference methods, not to claim ground truth on its own.

Core Model: PaiNN

Hadronis is optimized around PaiNN-like message passing for molecular systems. PaiNN provides a strong balance between physical inductive bias and engineering practicality:

  • Equivariance built-in: PaiNN operates on scalar and vector features in a way that is invariant to global rotations and translations of the molecular geometry. This is a natural fit for 3D chemistry, where predictions should not depend on how a molecule is oriented in space.
  • Compact and efficient: Compared to very large graph transformers or attention-based 3D models, PaiNN-style networks are relatively lightweight in parameter count and memory footprint. This makes them well-suited to high-throughput, CPU-oriented screening where throughput and latency matter.
  • Targeted, not “framework-y”: By committing to a PaiNN-style architecture, Hadronis can specialize data layouts, neighbor list construction, and kernel implementations for this one family of models instead of trying to be a general-purpose GNN engine (which frameworks like PyTorch Geometric already cover). The goal is a small, focused runtime for fast, robust inference—not a full training ecosystem.

Chemistry Domain Knowledge

Hadronis builds molecular graphs from atomic coordinates and atomic numbers, representing each atom as a node and chemical bonds or spatial proximity as edges. The graph construction leverages domain knowledge:

  • Nodes: Atoms, defined by atomic number and 3D position.
  • Edges: Created using a distance-based cutoff, reflecting chemical bonding and physical interactions.
  • RBF Expansion:
    • Edge features are expanded using Radial Basis Functions (RBFs), a standard technique in molecular machine learning.

    • The typical RBF expansion formula is:

      $RBF_i(d) = \exp(-\gamma (d - \mu_i)^2)$

      where $d$ is the interatomic distance, $\mu_i$ is the center of the $i$-th basis function, and $\gamma$ controls the width.

    • RBF expansion transforms raw interatomic distances into a smooth, differentiable feature space, improving the GNN’s ability to learn complex spatial relationships.

    • This is critical for capturing both short-range (covalent) and long-range (non-covalent) interactions.

  • Symmetries and invariances: The underlying PaiNN-style architecture is designed to respect the fundamental symmetries of molecular systems: predictions are invariant to global translations and rotations of the molecule, and (ideally) to permutations of atoms within a molecule that leave the physical system unchanged. In practice, this means the model learns on relative geometry and composition rather than arbitrary coordinate frames or atom orderings, which is essential for chemically meaningful generalisation.
  • Cutoff Choice: The cutoff parameter (e.g., 1.2 Å for methane, 5.0 Å for large systems) is chosen to balance physical realism and computational efficiency. It captures both covalent bonds and relevant non-covalent interactions, ensuring the GNN sees all chemically meaningful neighbors without excessive noise.

Why This Cutoff?

  • Chemistry: Typical covalent bond lengths are 1–2 Å; non-covalent interactions (e.g., van der Waals) extend to 3–5 Å.
  • Use Case: The default cutoff is tuned to include all atoms that can influence local electronic structure or molecular properties, maximizing predictive power for quantum chemistry, drug design, and materials science.

Limitations

The current graph construction and cutoff design are primarily targeted at neutral organic and small-molecule chemistry in gas-phase or simple solvent-like environments. Systems with strong ionic character, highly delocalised electronic structure, extended periodic materials, or exotic bonding patterns may require adapted featurisation, longer-range interaction models, or specialised training data before Hadronis can be used reliably.

Usage

Python Example:

import hadronis
import numpy as np

engine = hadronis.compile(
	"painn.bin",
	cutoff=5.0,
    max_neighbors=64,
    n_threads=16
)

Z = np.array([6, 1, 1, 1, 1], dtype=np.int32)

R = np.array([
    [0.0, 0.0, 0.0],
    [0.6, 0.6, 0.6],
    [-0.6, -0.6, 0.6],
    [-0.6, 0.6, -0.6],
    [0.6, -0.6, -0.6],
], dtype=np.float32)

# Map each atom to its molecule
batch = np.zeros(len(Z), dtype=np.int32)

predictions = engine.predict(
    atomic_numbers=Z,
    positions=R,
    batch=batch,
)
  • Graph Construction: The engine automatically builds a graph using atomic positions and applies the cutoff to define edges.
  • Inference: The GNN processes the graph, aggregating neighbor information for each atom.

Future Work

  • GPU backend for high-throughput inference: Add an optional CUDA backend for neighbor list construction and message passing, while keeping the current CPU path as a portable reference. This would let Hadronis saturate modern accelerators for massive screening campaigns, without forcing GPU as a hard dependency for users who only need lightweight CPU inference.

License

MIT OR Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hadronis-0.0.1.tar.gz (112.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

hadronis-0.0.1-cp312-cp312-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.12Windows x86-64

hadronis-0.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (673.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

hadronis-0.0.1-cp312-cp312-macosx_11_0_arm64.whl (626.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

hadronis-0.0.1-cp311-cp311-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.11Windows x86-64

hadronis-0.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (673.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

hadronis-0.0.1-cp311-cp311-macosx_11_0_arm64.whl (625.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

hadronis-0.0.1-cp310-cp310-win_amd64.whl (2.0 MB view details)

Uploaded CPython 3.10Windows x86-64

hadronis-0.0.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (672.3 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

hadronis-0.0.1-cp310-cp310-macosx_11_0_arm64.whl (624.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file hadronis-0.0.1.tar.gz.

File metadata

  • Download URL: hadronis-0.0.1.tar.gz
  • Upload date:
  • Size: 112.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hadronis-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f757c7cb7c2d9a3d998d11287dcbd359ffdf3c78cc5270b75d6efeadbe57c280
MD5 e511dbe93a47e6a58c43d393a030998d
BLAKE2b-256 60b35a0eddb6ea405466c466e5cc09f0b77a1ce7eaf7ac74c67fd45dd3551fda

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: hadronis-0.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hadronis-0.0.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6b6a1fb70c127415a5e628332d006fe84d9dbdc456505570755190fe861b71ff
MD5 a64363e26ae17ba82846e208a1ea5c00
BLAKE2b-256 28bade059a73ae2f67cdb01cf6b8da3c5ef6dfbddf49386f300347b0e7bf97f6

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hadronis-0.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d3db3d868466ca15b8a120256a53dcb88a349f191eb5fc4a0e52e145227ac9d1
MD5 8875520cfc367e5e52e630c39d4d0758
BLAKE2b-256 b1ce4b58b38afe2cac086c4e877c767fe03907aeff4d92e4f4f9a1ac2cd53ef4

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hadronis-0.0.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93080406c47080e27014797652a32b187a69c756244c74e7b37a2b339af4d13a
MD5 08e8e9024782895e17e832c51ec617a3
BLAKE2b-256 67a1785d3c561fb1451f6cd3ec89d5910dfd1e6e3bbe0d8d13e2e6d2577b5888

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: hadronis-0.0.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hadronis-0.0.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 97c16a4434bc8a088f9d30c702a0e66cd039b051bb7b5c9cb921bd57d5826280
MD5 8e97f3161c45ec166f1c32fca6ad3b74
BLAKE2b-256 6f0d76c3087683e47aede1549a15d49211cc23b22aed35980f25ddd3c5daff20

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hadronis-0.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c4186f8831ddd1e66fd4451005db69e4925303e3be2ab19878f58b02edf25f7e
MD5 9606661795b97b79e4ecce1995c72f8c
BLAKE2b-256 c2bf1c843f0ffb0c870c2a2a628aae229fe34579f871edaf9d2cadcb8fe5d8a4

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hadronis-0.0.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 267a6328106e5e9c26981ce3d0b3824b4c4896d9693cc0135fc6ffba32f62fe8
MD5 a9759fd6d2ac9fe0201de0f641bf86b5
BLAKE2b-256 7edd592049ba2bacd2252b432935364656c3240dfc5766ab4738d415e4e075d3

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: hadronis-0.0.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.0 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hadronis-0.0.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 06b9b0692e52d47e7b4c6bd3c96ce3160e810f36ed4ae22cd99800b8ff0ffded
MD5 9756809970aed02f5495bb0132b9c33b
BLAKE2b-256 5d468664761459990fe02e98d0196843b70c72f46a6691a5512026b93a9076fc

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for hadronis-0.0.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 53ea1003654ff96ede686a48bb7c132d62162f2bd91ce36da9ebf94f72427a1f
MD5 82863a1b78581ac30f55fd75955da7f9
BLAKE2b-256 5a142df06ea8615d87865a389a1429abbb9d866972a9d38e210ec0df3ed67888

See more details on using hashes here.

File details

Details for the file hadronis-0.0.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hadronis-0.0.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2665c1fc4f48035aa44f820ec33ca18759eb37bd6c3ceee09b747852fe1238ee
MD5 8a2b5faeef97c225ef7b23f6bf370fb3
BLAKE2b-256 d949eb58e29d1dc69898ef6a999a64765ffc5a2270902760c34fa6cf3436c1d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page