Skip to main content

A versatile Lorentz-equivariant transformer for high-energy physics

Project description

Lorentz-Equivariant Geometric Algebra Transformer

pytorch black

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:

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, 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.

Using L-GATr

  1. Instantiate the LGATr class. Hyperparameters related to attention and mlp blocks are organized in dataclasses, see lgatr/layers/attention/config.py and lgatr/layers/mlp/config.py. They can be initialized using dicts or these dataclass classes.
  2. Embed the network inputs into the geometric algebra using functions from lgatr/interface/. You might want to use spurions.py to 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.
  3. Now you're ready to push your data through the L-GATr network!

More features:

  • Global LGATr design choices are controlled by the gatr_config object from lgatr/primitives/config.py.
  • L-GATr supports mixed precision. The critical operations are performed in float32.

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.

  • More attention backends like flex_attention or xformers to support attention on sparse tensors etc. For now we support these features in seperate branches.
  • L-GATr transformer decoder using cross-attention.
  • Add docs

Examples

Let us know if you use lgatr!

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lgatr-1.0.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lgatr-1.0.0-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file lgatr-1.0.0.tar.gz.

File metadata

  • Download URL: lgatr-1.0.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lgatr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8b88067ca1e6b8f809c3bb5c758be1fd78dbafc4799fa580e690fc3769e52d29
MD5 258687f63e0819b7ddf0d989b8b9729d
BLAKE2b-256 61698f43019a35e1d788da75267f6fb09387563f8c6a0961df2524596ee4e310

See more details on using hashes here.

Provenance

The following attestation bundles were made for lgatr-1.0.0.tar.gz:

Publisher: release.yaml on heidelberg-hepml/lgatr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lgatr-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: lgatr-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lgatr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74cf0ecb2c9c9e8af860e224a87a560d9c419b22e3dfbd3963352b65cb92689e
MD5 73db9a237d0d9adf73fc470308267685
BLAKE2b-256 fa77a44377551f73b80c25b4ad49aecef6424d404903a389698c24e1e0ec26fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for lgatr-1.0.0-py3-none-any.whl:

Publisher: release.yaml on heidelberg-hepml/lgatr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page