Open source · MIT · Apple silicon

mlxmolkit

Molecular modelling on the Apple GPU. Conformers, force fields, clustering and semi-empirical quantum chemistry, written as batched MLX and Metal kernels.

pip install mlxmolkit-rdkit

Runs on macOS with Apple silicon (M1–M4). RDKit reads the molecules: conda install -c conda-forge rdkit

24 conformers of cis-Hedione, a jasmine odorant, from generate_conformers_nk (ETKDGv3 + MMFF94), aligned on the ring.
2,625conformers per secondDG + ETK, 10,000 molecules × 10 conformers, M3 Max
152×faster Butina clustering than RDKit20,000 molecules clustered in 0.35 s
99.7%of conformers converge100,000 conformers in a single GPU batch
1,604testsacross 119 files, checked against RDKit and MOPAC

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-RS

σ-profiles, σ-potentials, activity coefficients and solubility in solvent mixtures.

mlxmolkit.cosmo

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.

MMFF on Metal is not faster than RDKit at matched accuracy

At 200 iterations the fused kernel beats RDKit on 14 threads by 1.22×, but only 800 of 2,500 conformers reach RDKit’s energy. Matching it takes ~2,000 iterations, which leaves Metal ~6× behind. The kernel is fast; the optimiser converges slowly.

The measurements, and three ways to get them wrong

Quick start

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.