Skip to content

LoupGYM

LoupGYM (loupgym) is LoupMD's companion training package for pure-CUDA foundation MACE fine-tuning and automatic student distillation.

It is intentionally kept separate from loupmd: loupmd stays a pure MD and inference runtime with zero training entry points, while loupgym handles adapting foundation potentials or distilling ultra-fast student models and outputs verified .loup bundles that load directly into loupmd.

import loupmd as lm
import loupgym as lg

# 1. Pure-CUDA foundation fine-tuning (zero PyTorch in training or inference)
ft = lg.finetune(model="omat0-small", train_data="dft.extxyz", output="./ft_out", epochs=30)

# 2. Or auto-distill a fast student from any foundation teacher
dist = lg.auto_distill(teacher="omat0-medium", structure="cell.cif", speed="fast50", output="./student_out")

# 3. Run MD directly on the resulting .loup bundle (no PyTorch needed)
run = lm.md("cell.cif", model=ft.bundle_path, temperature_K=300, steps=10_000, output="md_run")

Two workflows

Workflow Command / Function When to use it Output
Foundation fine-tuning loupgym finetune / lg.finetune(...) Adapt any of the 18 LoupMD foundation models (omat0, mp0, mp0b3, mpa0, matpes, mh1, off23/off24, omol0-xl, polar1-s/m/l) to your DFT data with minimal frames Verified .loup bundle (arch=generic, same architecture & speed as base model)
Auto-distillation loupgym distill / lg.auto_distill(...) Distill a compact, system-specific FastLR-SK student (< 0.05 µs/atom MD) from a foundation teacher and/or your own MD/DFT data Verified .loup bundle (arch=ilmlip) + PyTorch student checkpoint

Installing

loupgym ships in the loupmd wheel: pip install "loupmd[export]" installs both packages and the loupgym command. The trainers drive mace-torch models, so they need the export extra's torch and mace-torch; loupmd itself does not.

The wheel carries LoupGYM's three pure-CUDA training libraries in loupgym/_lib, built for the same GPU generations as libloupmd.so (compute capability 8.0, 8.6, 8.9, 9.0, 10.0 and 12.0). They are separate shared libraries, never linked into libloupmd.so.

Building the native CUDA training libraries in a checkout

From a source checkout, build the libraries for your own GPU:

# Pure-CUDA foundation MACE fine-tuning library (libloupmd_ft.so)
make -j4 mace-ft-lib CUDA_ARCH=sm_120

# Pure-CUDA FastLR-SK student distillation library (build/libloup_lrsk_full_train_v3.so)
make -j4 lrsk-train-lib CUDA_ARCH=sm_120

# Loup-S training library of loupgym.fasttrain (build/sm_120/libloupstrain.so)
make -j4 train-lib CUDA_ARCH=sm_120

Replace sm_120 with your GPU's compute capability (sm_80 for A100, sm_86 for RTX A4000 / 30-series, sm_89 for RTX 4000 Ada / L4 / 40-series, sm_120 for RTX 50-series). make wheel-train-libs builds all three for the wheel's GPU generations in build/wheel (WHEEL_ARCHS narrows the list).

When loupgym runs, loupgym/_lib.py locates the libraries automatically: first the path in LOUP_FT_LIB, LOUP_LRSK_FT_LIB or LOUP_STRAIN_LIB (see environment variables), then the wheel's copies, then a checkout's builds.

Next steps