- Python >= 3.9
- CUDA 12.x (for GPU support)
- conda (Miniconda or Miniforge recommended)
| Package | Version |
|---|---|
| JAX | >= 0.8.0 |
| Flax | >= 0.12.0 |
| e3nn-jax | >= 0.20.8 |
| jraph | >= 0.0.6 |
| optax | >= 0.2.5 |
| ASE | >= 3.27.0 |
| matscipy | >= 1.2.0 |
conda create -n bam_jax python=3.12 -c conda-forge -y
conda activate bam_jaxJAX requires a CUDA-specific installation. Choose the command matching your CUDA version.
nvidia-smiLook for CUDA Version: XX.X in the top-right corner of the output.
pip install "jax[cuda12]>=0.8.0"pip install "jax>=0.8.0"Note: For other CUDA versions or advanced configurations, refer to the official JAX installation guide: https://jax.readthedocs.io/en/latest/installation.html
pip install "flax>=0.12.0" "e3nn-jax>=0.20.8" "jraph==0.0.6.dev0" "optax>=0.2.5" "ase>=3.27.0" "matscipy>=1.2.0" numpy scipy tqdmNote:
jraphonly provides dev releases on PyPI, so0.0.6.dev0is the correct version to install.
git clone https://github.com/Godorina/BAM-JAX.git
cd BAM-JAX
pip install -e .python -c "
import jax
import flax
import e3nn_jax
import jraph
import optax
import ase
import matscipy
import bam
print(f'JAX: {jax.__version__}')
print(f'Flax: {flax.__version__}')
print(f'e3nn-jax: {e3nn_jax.__version__}')
print(f'jraph: {jraph.__version__}')
print(f'optax: {optax.__version__}')
print(f'ASE: {ase.__version__}')
print(f'matscipy: {matscipy.__version__}')
print(f'Backend: {jax.default_backend()}')
print(f'Devices: {jax.devices()}')
"Expected output (example with 2 GPUs):
JAX: 0.9.0.1
Flax: 0.12.4
e3nn-jax: 0.20.8
jraph: 0.0.6.dev0
optax: 0.2.6
ASE: 3.27.0
matscipy: 1.2.0
Backend: gpu
Devices: [CudaDevice(id=0), CudaDevice(id=1)]
If Backend: cpu appears instead of gpu, your JAX CUDA installation may not match your driver. Re-check Step 2.
- Prepare your data and configuration file (
input.json):
cd bam/examples/training- Edit
input.jsonto set your data paths:
{
"train_traj": "../data/3BPA/train_300K_train.xyz",
"valid_traj": "../data/3BPA/train_300K_val.xyz",
"train_path": "data/train_pkl",
"valid_path": "data/valid_pkl",
...
}- Run training:
export CUDA_VISIBLE_DEVICES=0 # select GPU
export XLA_PYTHON_CLIENT_MEM_FRACTION=0.95
# Build data
python -m bam.scripts.build_pkl --input <train.xyz> --output data/train_pkl --prefix train --fit-energies
python -m bam.scripts.build_pkl --input <valid.xyz> --output data/valid_pkl --prefix valid --atom-energies atom_energies.json
# Train
python -m bam.training.train_unified input.jsonOr simply use the provided script:
bash run.shcd bam/examples/training/eval
bash run.shSet "evaluate_tag": true in the "predict" section of input.json to enable evaluation mode.
RACE model pre-trained on SPICE 1.1.4 dataset, then fine-tuned using multihead replay strategy on 3BPA. Compared against MACE-based fine-tuning methods (ELoRA, MMEA) which use MACE-OFF as foundation.
| Method | Foundation | E_RMSE (meV) | F_RMSE (meV/Å) |
|---|---|---|---|
| ELoRA | MACE-OFF | 3.0 | 7.5 |
| MMEA | MACE-OFF | 2.7 | 7.5 |
| BAM Multihead | RACE/SPICE | 0.083 | 4.94 |
| Method | Foundation | E_RMSE (meV) | F_RMSE (meV/Å) |
|---|---|---|---|
| ELoRA | MACE-OFF | 6.5 | 15.5 |
| MMEA | MACE-OFF | 6.5 | 15.4 |
| BAM Multihead | RACE/SPICE | 0.179 | 9.74 |
| Method | Foundation | E_RMSE (meV) | F_RMSE (meV/Å) |
|---|---|---|---|
| ELoRA | MACE-OFF | 17.6 | 42.0 |
| MMEA | MACE-OFF | 17.1 | 39.7 |
| BAM Multihead | RACE/SPICE | 0.420 | 23.1 |
References:
- ELoRA: Low-Rank Adaptation for Equivariant GNNs (ICML 2025)
- MMEA: Magnitude-Modulated Equivariant Adapter (2024)
BAM-JAX/
├── bam/
│ ├── configs/ # Default configuration templates
│ ├── data/ # Data loading and preprocessing
│ ├── examples/ # Training, evaluation, and LAMMPS examples
│ │ ├── training/ # Single-head training example
│ │ ├── multihead/ # Multi-head training example
│ │ ├── lammps/ # LAMMPS MD interface
│ │ └── data/ # Example datasets
│ ├── inference/ # ASE calculator and evaluation
│ ├── lammps/ # LAMMPS integration
│ ├── models/ # NequIP and RACE model architectures
│ ├── scripts/ # Data preprocessing scripts
│ └── training/ # Training loops (unified, multi-head)
├── pyproject.toml
└── setup.py
python -c "import jax; print(jax.devices())"If this shows [CpuDevice(id=0)]:
- Verify your NVIDIA driver:
nvidia-smi - Reinstall JAX with CUDA support:
pip install "jax[cuda12]>=0.8.0" --force-reinstall - Check for CUDA version mismatch between driver and JAX
Reduce batch size in input.json or limit GPU memory:
export XLA_PYTHON_CLIENT_MEM_FRACTION=0.90Use CUDA_VISIBLE_DEVICES to select specific GPUs:
export CUDA_VISIBLE_DEVICES=0,1 # use GPU 0 and 1
python -m bam.training.train_unified input.json~