# samvanstroud/hepattn architecture

> Architecture diagram of the GitHub repository samvanstroud/hepattn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samvanstroud/hepattn
- Repository: https://github.com/samvanstroud/hepattn

## Overview

hepattn is a PyTorch/Lightning research codebase for transformer-based particle-physics reconstruction. Experiment entry points configure a task model, dataset module, and shared CLI; the model stack turns detector constituents into reconstructed objects, with experiment-specific evaluation and output. The README documents additional reconstruction domains beyond the sampled entry points, so these appear as capability nodes without speculative implementation links. Source-index references and excerpts support the shown calls; unsampled domain internals are represented only at their existing directory paths.

Main entry points: [`src/hepattn/utils/cli.py`](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/cli.py) (Experiment CLI), [`src/hepattn/experiments/pixel/main.py`](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/pixel/main.py) (Pixel training), [`src/hepattn/experiments/tide/main.py`](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/tide/main.py) (TIDE training), [`src/hepattn/experiments/cld/main.py`](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/cld/main.py) (CLD training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experiments["Reconstruction experiments"]
  node_pixel_main["Pixel training<br/>[main.py]"]
  node_pixel_data["Pixel data<br/>[data.py]"]
  node_pixel_model["Pixel splitter<br/>[model.py]"]
  node_tide_main["TIDE training<br/>[main.py]"]
  node_tide_data["TIDE data<br/>[data.py]"]
  node_tide_model["TIDE model<br/>[model.py]"]
  node_cld_main["CLD training<br/>[main.py]"]
  node_cld_data["CLD data<br/>[data.py]"]
  node_cld_model["CLD reconstructor<br/>[model.py]"]
  node_clic_main["CLIC training<br/>[main.py]"]
  node_clic_data["Particle-flow data<br/>[pflow_data.py]"]
  node_clic_model["Particle-flow module"]
  node_collider_main["ColliderML training<br/>[main.py]"]
  node_collider_data["ColliderML data<br/>[data.py]"]
  node_collider_model["ColliderML model<br/>[model.py]"]
  node_trackml["TrackML filtering/tracking"]
  node_itk["ITk filtering/tracking"]
  node_atlas_muon["ATLAS muon tracking"]
end

subgraph group_model["Model architecture"]
  node_decoder["Transformer components<br/>[decoder.py]"]
  node_task["Task and loss<br/>[task.py]"]
  node_loss["Loss functions<br/>[loss.py]"]
  node_wrapper["Model wrapper<br/>[wrapper.py]"]
  node_flex["Efficient attention<br/>[fast_local_ca.py]"]
end

subgraph group_data["Data and utilities"]
  node_cli["Experiment CLI<br/>[cli.py]"]
  node_dataset["Dataset utilities<br/>[lrsm_dataset.py]"]
  node_scaling["Feature scaling<br/>[scaling.py]"]
  node_tensor_utils["Tensor utilities<br/>[tensor_utils.py]"]
end

subgraph group_assignment["Assignment solver"]
  node_lap_api["Assignment Python API<br/>[main.cpp]"]
  node_lap_solver["Assignment solver<br/>[lap_solver.h]"]
  node_lap_cost["Cost matrix<br/>[lap_cost.h]"]
  node_lap_header["Solver interface<br/>[lap.h]"]
end

node_user(("Researcher"))

node_user -.->|"starts training"| node_pixel_main
node_user -.->|"starts training"| node_tide_main
node_user -.->|"starts training"| node_cld_main
node_user -.->|"starts training"| node_clic_main
node_user -.->|"starts training"| node_collider_main
node_pixel_main -->|"configures"| node_cli
node_pixel_main -->|"registers"| node_pixel_data
node_pixel_main -->|"registers"| node_pixel_model
node_tide_main -->|"configures"| node_cli
node_tide_main -->|"registers"| node_tide_data
node_tide_main -->|"registers"| node_tide_model
node_cld_main -->|"configures"| node_cli
node_cld_main -->|"registers"| node_cld_data
node_cld_main -->|"registers"| node_cld_model
node_clic_main -->|"configures"| node_cli
node_clic_main -->|"registers"| node_clic_data
node_clic_main -->|"registers"| node_clic_model
node_collider_main -->|"configures"| node_cli
node_collider_main -->|"registers"| node_collider_data
node_collider_main -->|"registers"| node_collider_model
node_pixel_data -->|"uses"| node_tensor_utils
node_tide_data -->|"uses"| node_tensor_utils
node_cld_data -->|"uses"| node_dataset
node_cld_model -->|"uses"| node_wrapper
node_collider_model -->|"uses"| node_wrapper
node_clic_model -->|"uses"| node_wrapper
node_clic_data -->|"uses"| node_scaling
node_task -->|"uses"| node_loss
node_task -->|"uses"| node_scaling
node_decoder -.->|"uses"| node_flex
node_lap_api -->|"calls solver interface"| node_lap_header
node_lap_header -->|"includes"| node_lap_solver
node_lap_header -->|"includes"| node_lap_cost
node_trackml -->|"supports tracking"| node_user
node_itk -->|"supports filtering"| node_user
node_atlas_muon -->|"supports muon tracking"| node_user

click node_cli "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/cli.py"
click node_pixel_main "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/pixel/main.py"
click node_pixel_data "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/pixel/data.py"
click node_pixel_model "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/pixel/model.py"
click node_tide_main "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/tide/main.py"
click node_tide_data "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/tide/data.py"
click node_tide_model "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/tide/model.py"
click node_cld_main "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/cld/main.py"
click node_cld_data "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/cld/data.py"
click node_cld_model "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/cld/model.py"
click node_clic_main "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/clic/main.py"
click node_clic_data "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/clic/pflow_data.py"
click node_clic_model "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/clic/lightning_module.py"
click node_collider_main "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/colliderml/main.py"
click node_collider_data "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/colliderml/data.py"
click node_collider_model "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/colliderml/model.py"
click node_trackml "https://github.com/samvanstroud/hepattn/tree/main/src/hepattn/experiments/trackml"
click node_itk "https://github.com/samvanstroud/hepattn/tree/main/src/hepattn/experiments/itk"
click node_atlas_muon "https://github.com/samvanstroud/hepattn/tree/main/src/hepattn/experiments/atlas_muon"
click node_decoder "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/decoder.py"
click node_task "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/task.py"
click node_loss "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/loss.py"
click node_wrapper "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/wrapper.py"
click node_flex "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/flex/fast_local_ca.py"
click node_dataset "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/lrsm_dataset.py"
click node_scaling "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/scaling.py"
click node_tensor_utils "https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/tensor_utils.py"
click node_lap_api "https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/main.cpp"
click node_lap_solver "https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/csrc/core/lap_solver.h"
click node_lap_cost "https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/csrc/core/lap_cost.h"
click node_lap_header "https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/csrc/lap.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pixel_main,node_pixel_data,node_pixel_model,node_tide_main,node_tide_data,node_tide_model,node_cld_main,node_cld_data,node_cld_model,node_clic_main,node_clic_data,node_clic_model,node_collider_main,node_collider_data,node_collider_model,node_trackml,node_itk,node_atlas_muon toneBlue
class node_decoder,node_task,node_loss,node_wrapper,node_flex toneAmber
class node_cli,node_dataset,node_scaling,node_tensor_utils toneMint
class node_lap_api,node_lap_solver,node_lap_cost,node_lap_header toneRose
class node_user toneIndigo
```

## Components

### Reconstruction experiments

- [Pixel training](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/pixel/main.py): `src/hepattn/experiments/pixel/main.py`
- [Pixel data](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/pixel/data.py): `src/hepattn/experiments/pixel/data.py`
- [Pixel splitter](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/pixel/model.py): `src/hepattn/experiments/pixel/model.py`
- [TIDE training](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/tide/main.py): `src/hepattn/experiments/tide/main.py`
- [TIDE data](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/tide/data.py): `src/hepattn/experiments/tide/data.py`
- [TIDE model](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/tide/model.py): `src/hepattn/experiments/tide/model.py`
- [CLD training](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/cld/main.py): `src/hepattn/experiments/cld/main.py`
- [CLD data](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/cld/data.py): `src/hepattn/experiments/cld/data.py`
- [CLD reconstructor](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/cld/model.py): `src/hepattn/experiments/cld/model.py`
- [CLIC training](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/clic/main.py): `src/hepattn/experiments/clic/main.py`
- [Particle-flow data](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/clic/pflow_data.py): `src/hepattn/experiments/clic/pflow_data.py`
- [Particle-flow module](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/clic/lightning_module.py): `src/hepattn/experiments/clic/lightning_module.py`
- [ColliderML training](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/colliderml/main.py): `src/hepattn/experiments/colliderml/main.py`
- [ColliderML data](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/colliderml/data.py): `src/hepattn/experiments/colliderml/data.py`
- [ColliderML model](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/experiments/colliderml/model.py): `src/hepattn/experiments/colliderml/model.py`
- [TrackML filtering/tracking](https://github.com/samvanstroud/hepattn/tree/main/src/hepattn/experiments/trackml): `src/hepattn/experiments/trackml`
- [ITk filtering/tracking](https://github.com/samvanstroud/hepattn/tree/main/src/hepattn/experiments/itk): `src/hepattn/experiments/itk`
- [ATLAS muon tracking](https://github.com/samvanstroud/hepattn/tree/main/src/hepattn/experiments/atlas_muon): `src/hepattn/experiments/atlas_muon`

### Model architecture

- [Transformer components](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/decoder.py): `src/hepattn/models/decoder.py`
- [Task and loss](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/task.py): `src/hepattn/models/task.py`
- [Loss functions](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/loss.py): `src/hepattn/models/loss.py`
- [Model wrapper](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/models/wrapper.py): `src/hepattn/models/wrapper.py`
- [Efficient attention](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/flex/fast_local_ca.py): `src/hepattn/flex/fast_local_ca.py`

### Data and utilities

- [Experiment CLI](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/cli.py): `src/hepattn/utils/cli.py`
- [Dataset utilities](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/lrsm_dataset.py): `src/hepattn/utils/lrsm_dataset.py`
- [Feature scaling](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/scaling.py): `src/hepattn/utils/scaling.py`
- [Tensor utilities](https://github.com/samvanstroud/hepattn/blob/main/src/hepattn/utils/tensor_utils.py): `src/hepattn/utils/tensor_utils.py`

### Assignment solver

- [Assignment Python API](https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/main.cpp): `src/lap1015/src/main.cpp`
- [Assignment solver](https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/csrc/core/lap_solver.h): `src/lap1015/src/csrc/core/lap_solver.h`
- [Cost matrix](https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/csrc/core/lap_cost.h): `src/lap1015/src/csrc/core/lap_cost.h`
- [Solver interface](https://github.com/samvanstroud/hepattn/blob/main/src/lap1015/src/csrc/lap.h): `src/lap1015/src/csrc/lap.h`

### Other components

- **Researcher**

## Connections

- Researcher → Pixel training: starts training
- Researcher → TIDE training: starts training
- Researcher → CLD training: starts training
- Researcher → CLIC training: starts training
- Researcher → ColliderML training: starts training
- Pixel training → Experiment CLI: configures (evidence: `src/hepattn/experiments/pixel/main.py`)
- Pixel training → Pixel data: registers (evidence: `src/hepattn/experiments/pixel/main.py`)
- Pixel training → Pixel splitter: registers (evidence: `src/hepattn/experiments/pixel/main.py`)
- TIDE training → Experiment CLI: configures (evidence: `src/hepattn/experiments/tide/main.py`)
- TIDE training → TIDE data: registers (evidence: `src/hepattn/experiments/tide/main.py`)
- TIDE training → TIDE model: registers (evidence: `src/hepattn/experiments/tide/main.py`)
- CLD training → Experiment CLI: configures (evidence: `src/hepattn/experiments/cld/main.py`)
- CLD training → CLD data: registers (evidence: `src/hepattn/experiments/cld/main.py`)
- CLD training → CLD reconstructor: registers (evidence: `src/hepattn/experiments/cld/main.py`)
- CLIC training → Experiment CLI: configures (evidence: `src/hepattn/experiments/clic/main.py`)
- CLIC training → Particle-flow data: registers (evidence: `src/hepattn/experiments/clic/main.py`)
- CLIC training → Particle-flow module: registers (evidence: `src/hepattn/experiments/clic/main.py`)
- ColliderML training → Experiment CLI: configures (evidence: `src/hepattn/experiments/colliderml/main.py`)
- ColliderML training → ColliderML data: registers (evidence: `src/hepattn/experiments/colliderml/main.py`)
- ColliderML training → ColliderML model: registers (evidence: `src/hepattn/experiments/colliderml/main.py`)
- Pixel data → Tensor utilities: uses (evidence: `src/hepattn/experiments/pixel/data.py`)
- TIDE data → Tensor utilities: uses (evidence: `src/hepattn/experiments/tide/data.py`)
- CLD data → Dataset utilities: uses (evidence: `src/hepattn/experiments/cld/data.py`)
- CLD reconstructor → Model wrapper: uses (evidence: `src/hepattn/experiments/cld/model.py`)
- ColliderML model → Model wrapper: uses (evidence: `src/hepattn/experiments/colliderml/model.py`)
- Particle-flow module → Model wrapper: uses (evidence: `src/hepattn/experiments/clic/lightning_module.py`)
- Particle-flow data → Feature scaling: uses (evidence: `src/hepattn/experiments/clic/pflow_data.py`)
- Task and loss → Loss functions: uses (evidence: `src/hepattn/models/task.py`)
- Task and loss → Feature scaling: uses (evidence: `src/hepattn/models/task.py`)
- Transformer components → Efficient attention: uses
- Assignment Python API → Solver interface: calls solver interface (evidence: `src/lap1015/src/main.cpp`)
- Solver interface → Assignment solver: includes (evidence: `src/lap1015/src/csrc/lap.h`)
- Solver interface → Cost matrix: includes (evidence: `src/lap1015/src/csrc/lap.h`)
- TrackML filtering/tracking → Researcher: supports tracking
- ITk filtering/tracking → Researcher: supports filtering
- ATLAS muon tracking → Researcher: supports muon tracking
