mlxmolkit

Molecular modelling on Apple silicon

Prepare molecular structures, run simulations and compare results in one open-source Python toolkit. MLX and Metal accelerate batched calculations on the GPU.

cis-Hedione24 conformers · ETKDGv3 + MMFF94
58.60754PM7 heat of formation for NaHkcal/mol at 1.85 Å, matching MOPAC
15.68 msdynamic Butina on Metal20,000 fingerprints, exact RDKit cluster order
0.785 ms64 fingerprint searches on Metal20,000 resident fingerprints, exact top eight
0.0011 Åmedian ibuprofen RMSDBoth enantiomers after MMFF, relative to RDKit

What it computes

Conformers

ETKDG on Metal — distance geometry in 4D, ETK in 3D, then MMFF94 — for N molecules × k conformers in one batch. Every conformer passes RDKit’s embedding checks.

generate_conformers_nk

Clustering

Morgan fingerprints, Tanimoto neighbour lists and Butina clustering for 150,000+ molecules, with divide-and-conquer memory.

butina_tanimoto_mlx

NDDO semi-empirical

MNDO, RM1, AM1, PM3, PM6 and PM7 with their corrections: scalar and batched SCF, gradients and geometry optimisation, no MOPAC needed.

mlxmolkit.nddo

xTB

GFN0, GFN1, GFN2 and g-xTB energies, analytical gradients, ANCOPT geometry optimisation and ALPB water solvation.

mlxmolkit.xtb

COSMO and COSMO-RS

Surface charge profiles and σ-potentials. Activity coefficients and solubility in solvent mixtures through openCOSMO-RS.

mlxmolkit.xtb

Similarity and descriptors

ERG fingerprints, dense cosine similarity, CHEESE embeddings, Connolly surfaces and dipole atom features.

from mlxmolkit import …

Conformers: N molecules × k conformers, one batch

Every stage after the extraction runs on the GPU. An attempt is kept only if it passes RDKit’s embedding checks — chirality, E/Z, tetrahedral centres — after each minimisation.

  1. 1CPU

    Extract

    RDKit reads each of the N SMILES and builds its constraints once.

  2. 2CPU

    Pack

    The k conformers of a molecule share its constraints: ~50% less memory.

  3. 3Metal

    DG minimise

    Distance geometry in 4D, L-BFGS inside the kernel, one threadgroup per conformer.

    ✓ RDKit checks
  4. 4Metal

    ETK minimise

    Collapse to 3D, then CSD torsion preferences and 1-2/1-3/1-4 distances.

    ✓ RDKit checks
  5. 5Metal

    MMFF94

    Seven force-field terms, BFGS or L-BFGS, optimised inside the kernel.

    ✓ RDKit checks
  6. 6CPU

    Accept or resample

    Molecules short of k conformers get new random starts, in bounded rounds.

Packed Metal MMFF benchmark

On an M3 Max, packed Metal BFGS took 300 ms to optimise 2,500 conformers, compared with 555 ms for RDKit on 14 threads. 2,444 final energies were within 0.1 kcal/mol of RDKit. RDKit reached lower residual forces.

See the MMFF benchmark

Quick start

Install from GitHub main
python -m pip install rdkit \
  git+https://github.com/guillaume-osmo/mlxmolkit.git@main

Requires an Apple silicon Mac, Python 3.10 or later, Git and Xcode Command Line Tools.

python
from mlxmolkit import generate_conformers_nk, butina_tanimoto_mlx
import mlx.core as mx

# 3D conformers — N molecules × k conformers, one GPU batch
result = generate_conformers_nk(
    smiles_list=["c1ccccc1", "CC(=O)O", "CC(=O)Oc1ccccc1C(=O)O"],
    n_confs_per_mol=10,
    run_mmff=True,
)

# Clustering — 150k+ molecules
clusters = butina_tanimoto_mlx(mx.array(fp_bytes), cutoff=0.4)

# Semi-empirical SCF
from mlxmolkit.nddo import nddo_energy
e = nddo_energy(atoms=[8, 1, 1],
                coords=[[0, 0, 0], [0.97, 0, 0.93], [-0.97, 0, 0.93]],
                method="PM6_D")

# xTB
from mlxmolkit.xtb import gfn2_energy
e = gfn2_energy(atoms, coords)

How to cite mlxmolkit

Author

Guillaume Godin

Develops machine-learning models for olfaction, fragrance formulation, biodegradation, toxicity, molecular properties and chemical reactions, and builds open-source tools for molecular modelling.