Paper (OpenReview) • Paper (arXiv) • Model Architecture • Quick start • Citation
E2Former is an E(3)-equivariant molecular foundation model for energy and force prediction. It combines efficient Wigner-6j-based tensor products with equivariant attention to improve scalability while preserving geometric symmetries.
The repository includes:
| Path | Purpose |
|---|---|
src/ |
Core E2Former model components (layers, equivariant blocks, wrappers). |
configs/ |
Experiment, dataset, and optimization YAML files. |
main.py |
FairChem-style training entrypoint. |
start_exp.py |
Background launcher for tmux-based jobs. |
simulate.py |
Molecular dynamics rollout entrypoint. |
Figure. E2Former architecture for scalable E(3)-equivariant molecular modeling.
- Installation
- Quick start
- Where key code lives
- Repository layout
- Configuration guide
- Documentation
- Related E2Former variants
- Citation
- License
| Component | Version / Expectation |
|---|---|
| OS | Linux with NVIDIA GPU recommended |
| Python | 3.10 |
| PyTorch | 2.4.1 + CUDA 12.1 (from env.yml) |
Tip
Use mamba when available for faster environment solving.
conda env create -f env.yml
conda activate e2formerOr with mamba:
mamba env create -f env.yml
conda activate e2formergit clone https://github.com/FAIR-Chem/fairchem.git
pip install -e fairchem/packages/fairchem-corepre-commit installgit clone https://github.com/kyonofx/MDsim.git
pip install -e MDsim| Phase | Goal | Output |
|---|---|---|
| A) Configure | Point config to your data and experiment settings. | Ready-to-run YAML |
| B) Train | Launch single-/multi-GPU training jobs. | Checkpoints + logs |
| C) Validate / Simulate | Run smoke checks and MD rollout. | Sanity metrics + trajectories |
Tip
Start with configs/oc22/s2ef/e2former/e2former.yaml, then set your dataset paths before running training.
Use one of the provided templates:
configs/oc22/s2ef/e2former/e2former.yaml
Before training, update dataset paths in your config:
dataset.train.srcdataset.val.src
Single GPU
python main.py \
--mode train \
--num-gpus 1 \
--config-yml configs/oc22/s2ef/e2former/e2former.yaml \
--run-dir ./runs \
--identifier e2former_oc22Resume from checkpoint
python main.py \
--mode train \
--num-gpus 1 \
--config-yml configs/oc22/s2ef/e2former/e2former.yaml \
--run-dir ./runs \
--identifier e2former_oc22 \
--checkpoint /path/to/checkpoint.ptBackground run via tmux
python start_exp.py \
--config-yml configs/oc22/s2ef/e2former/e2former.yaml \
--mode train \
--cvd 0 \
--run-dir ./runs \
--identifier e2former_bgMulti-GPU (single node)
torchrun --standalone --nproc_per_node 4 main.py \
--distributed \
--num-gpus 4 \
--mode train \
--config-yml configs/oc22/s2ef/e2former/e2former.yaml \
--run-dir ./runs \
--identifier e2former_4gpuSmoke/equivariance check
python test_e2former.pyMolecular dynamics rollout
python simulate.py \
--simulation_config_yml <SIMULATION_YML> \
--model_dir <MODEL_DIR> \
--model_config_yml <MODEL_CONFIG_YML> \
--identifier <RUN_NAME>| Component | Location | Main class / symbol |
|---|---|---|
| E2Former model (FairChem-facing wrapper) | src/models/E2Former_wrapper.py |
E2FormerBackbone |
| E2Former core architecture (transformer stack) | src/models/e2former_main.py |
E2former |
| Wigner-6j convolution primitive | src/wigner6j/tensor_product.py |
FullyConnectedTensorProductWigner6j |
| Arbitrary-order E(3)-equivariant tensor product (attention) | src/wigner6j/tensor_product.py |
E2TensorProductArbitraryOrder |
| Attention modules calling arbitrary-order tensor products | src/layers/attention/orders.py |
FirstOrderAttention, SecondOrderAttention, AllOrderAttention |
.
├── configs/ # Training, dataset, and experiment YAMLs
├── src/ # E2Former implementation
│ ├── core/
│ ├── layers/
│ ├── models/
│ ├── utils/
│ └── wigner6j/
├── assets/ # Figures used in README/docs
├── main.py # Main training/inference entrypoint
├── start_exp.py # tmux-based background training launcher
├── test_e2former.py # Smoke/equivariance test script
├── simulate.py # Molecular dynamics rollout entrypoint
├── model_architecture.md # Architecture notes
└── env.yml # Conda environment file
Important
Start tuning graph radius/neighbors and batch size first; these usually dominate memory and speed behavior.
Common high-impact settings:
| Config keys | Why it matters |
|---|---|
model.backbone.max_neighbors, model.backbone.max_radius |
Controls graph density and geometric context range. |
model.backbone.num_layers, model.backbone.num_attn_heads |
Main capacity/performance scaling knobs. |
model.backbone.attn_type, model.backbone.atten_name |
Selects attention formulation and kernel backend. |
model.backbone.use_fp16_backbone, model.backbone.use_compile |
Throughput and memory optimization controls. |
optim.batch_size, optim.eval_batch_size, optim.lr_initial |
Core optimization stability/performance parameters. |
Start with:
| Resource | Purpose |
|---|---|
model_architecture.md |
High-level architecture rationale and design notes. |
configs/oc22/s2ef/e2former/e2former.yaml |
Primary training template for this repository. |
test_e2former.py |
Smoke/equivariance checks for installation and basic model sanity. |
| Variant | Paper | Repository | Artifact |
|---|---|---|---|
E2Former-LSR |
Scalable Machine Learning Force Fields for Macromolecular Systems Through Long-Range Aware Message Passing | IQuestLab/UBio-MolFM | UBio-E2Former-LSR |
E2Former-V2 |
E2Former-V2: On-the-Fly Equivariant Attention with Linear Activation Memory | IQuestLab/UBio-MolFM (e2formerv2) | Included in the e2formerv2 branch |
If you use E2Former in your work, please cite:
@inproceedings{li2025eformer,
title={E2Former: An Efficient and Equivariant Transformer with Linear-Scaling Tensor Products},
author={Yunyang Li and Lin Huang and Zhihao Ding and Xinran Wei and Chu Wang and Han Yang and Zun Wang and Chang Liu and Yu Shi and Peiran Jin and Tao Qin and Mark Gerstein and Jia Zhang},
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
year={2025},
url={https://openreview.net/forum?id=ls5L4IMEwt}
}This project is released under the MIT License.
