Repository navigation
Highlights
- 10-20x faster spherical harmonics and tensor products vs e3nn
- 1.4x faster fused SH+TP pipeline
- Full autograd support for force computation
Benchmarks (RTX 3090)
| Operation | e3nn | batteries | Speedup |
|---|---|---|---|
| Spherical Harmonics (L=3) | 0.142 ms | 0.012 ms | 11.8x |
| Tensor Product | 1.847 ms | 0.089 ms | 20.8x |
| TP Backward | 3.21 ms | 0.156 ms | 20.6x |
Fused Pipeline (N=5000, C=64)
| Pipeline | Time | Speedup |
|---|---|---|
| Unfused (SH + TP + scatter) | 8.604 ms | - |
| Fused (fused_sh_tp + scatter) | 5.935 ms | 1.45x |
Installation
Requires CUDA 11.8+ and PyTorch 2.0+
```bash
pip install .
```
Usage
```python
import batteries
Spherical harmonics
Y_lm = batteries.spherical_harmonics(edge_vectors, L_max=3)
Tensor product with weights
messages = batteries.tensor_product(node_feats, Y_lm, weights)
Fused SH + TP (faster)
messages = batteries.fused_sh_tp_simple(edge_vectors, node_feats, source_idx)
```
See examples/mace_inference.py for a complete MACE-style inference demo.