A versatile Lorentz-equivariant transformer for high-energy physics
Project description
This repository contains a minimal implementation of the Lorentz-Equivariant Geometric Algebra Transformer (L-GATr) by Jonas Spinner, Víctor Bresó, Pim de Haan, Tilman Plehn, Huilin Qu, Jesse Thaler, and Johann Brehmer. L-GATr uses spacetime geometric algebra representations to construct Lorentz-equivariant layers and combines them into a transformer architecture. You can read more about L-GATr in the following two papers:
- Lorentz-Equivariant Geometric Algebra Transformers for High-Energy Physics (ML audience)
- A Lorentz-Equivariant Transformer for All of the LHC (HEP audience)
Installation
You can either install the latest release using pip
pip install lgatr
or clone the repository and install the package in dev mode
git clone https://github.com/heidelberg-hepml/lgatr.git
cd lgatr
pip install -e .
If you want a specific branch (e.g. the xformers or flex_attention branch), you can do pip install https://github.com/heidelberg-hepml/lgatr.git@basics or have a line lgatr @ https://github.com/heidelberg-hepml/lgatr.git@basics in your requirements.txt.
How to use L-GATr
- Instantiate the
LGATrclass. Hyperparameters related to attention and mlp blocks are organized in dataclasses, seelgatr/layers/attention/config.pyandlgatr/layers/mlp/config.py. They can be initialized using dicts or these dataclass classes. - Embed the network inputs into the geometric algebra using functions from
lgatr/interface/. You might want to usespurions.pyto break Lorentz equivariance at the input level, see Section 2.3 of the HEP paper for a discussion on symmetry breaking and when it is needed. - Now you're ready to push your data through the L-GATr network!
More features:
- Global
LGATrdesign choices are controlled by thegatr_configobject fromlgatr/primitives/config.py. - L-GATr supports mixed precision. The critical operations are performed in
float32. - The default branch only has the default torch attention backend. There are seperate branches for the
xformersandflex_attentionbackends. We do not include them in the main branch yet because of their additional requirements.
Future
We are planning to extend this package in the future. If you would use them or you have more ideas, please use open an issue or a pull request.
- L-GATr transformer decoder using cross-attention.
- Add
docs
Examples
- https://github.com/heidelberg-hepml/lorentz-gatr: Original
LGATrimplementation used for the papers - https://github.com/spinjo/weaver-core/blob/lgatr/weaver/nn/model/LGATr.py: L-GATr in the CMS boosted object tagging library
weaver
Let us know if you use lgatr, so we can add your repo to the list!
Citation
If you find this code useful in your research, please cite the following papers
@article{Brehmer:2024yqw,
author = "Brehmer, Johann and Bres\'o, V\'\i{}ctor and de Haan, Pim and Plehn, Tilman and Qu, Huilin and Spinner, Jonas and Thaler, Jesse",
title = "{A Lorentz-Equivariant Transformer for All of the LHC}",
eprint = "2411.00446",
archivePrefix = "arXiv",
primaryClass = "hep-ph",
reportNumber = "MIT-CTP/5802",
month = "11",
year = "2024"
}
@inproceedings{spinner2025lorentz,
title={Lorentz-Equivariant Geometric Algebra Transformers for High-Energy Physics},
author={Spinner, Jonas and Bres{\'o}, Victor and De Haan, Pim and Plehn, Tilman and Thaler, Jesse and Brehmer, Johann},
booktitle={Advances in Neural Information Processing Systems},
year={2024},
volume={37},
eprint = {2405.14806},
url = {https://arxiv.org/abs/2405.14806}
}
@inproceedings{brehmer2023geometric,
title = {Geometric Algebra Transformer},
author = {Brehmer, Johann and de Haan, Pim and Behrends, S{\"o}nke and Cohen, Taco},
booktitle = {Advances in Neural Information Processing Systems},
year = {2023},
volume = {36},
eprint = {2305.18415},
url = {https://arxiv.org/abs/2305.18415},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lgatr-1.0.1.tar.gz.
File metadata
- Download URL: lgatr-1.0.1.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d7791de5ffcbffe840ac3598855f9e758221745e0cb7a89155a957a283b4392
|
|
| MD5 |
2938da0eb9d92fc14c0f246177c2413b
|
|
| BLAKE2b-256 |
e7dedbdd46ad5c9956d541428bbb58ffaac8eeebb5b711d8e5727b1d61805d46
|
Provenance
The following attestation bundles were made for lgatr-1.0.1.tar.gz:
Publisher:
release.yaml on heidelberg-hepml/lgatr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lgatr-1.0.1.tar.gz -
Subject digest:
7d7791de5ffcbffe840ac3598855f9e758221745e0cb7a89155a957a283b4392 - Sigstore transparency entry: 191421174
- Sigstore integration time:
-
Permalink:
heidelberg-hepml/lgatr@5e3d5b0a9e7443739cbb3d824b2471b292b7b662 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/heidelberg-hepml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5e3d5b0a9e7443739cbb3d824b2471b292b7b662 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lgatr-1.0.1-py3-none-any.whl.
File metadata
- Download URL: lgatr-1.0.1-py3-none-any.whl
- Upload date:
- Size: 41.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1562fb89aeacff7c199a303fecb441ba6dc3f95e2b78c398d4b017705b338fc6
|
|
| MD5 |
31a40e4d90c89fbb3dbfa324f0fca791
|
|
| BLAKE2b-256 |
8808864603e106c5dc998a2fc509ac6847694672621a5296076a63dbd680b537
|
Provenance
The following attestation bundles were made for lgatr-1.0.1-py3-none-any.whl:
Publisher:
release.yaml on heidelberg-hepml/lgatr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lgatr-1.0.1-py3-none-any.whl -
Subject digest:
1562fb89aeacff7c199a303fecb441ba6dc3f95e2b78c398d4b017705b338fc6 - Sigstore transparency entry: 191421176
- Sigstore integration time:
-
Permalink:
heidelberg-hepml/lgatr@5e3d5b0a9e7443739cbb3d824b2471b292b7b662 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/heidelberg-hepml
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5e3d5b0a9e7443739cbb3d824b2471b292b7b662 -
Trigger Event:
push
-
Statement type: