ho22joshua commited on
Commit
196e2e8
·
1 Parent(s): 5ae003d

docs: add Hugging Face model card

Browse files
Files changed (3) hide show
  1. README.md +234 -270
  2. README_PROJECT.md +282 -0
  3. paper.tar.gz +3 -0
README.md CHANGED
@@ -1,282 +1,246 @@
1
- # GNN4Colliders
2
-
3
- GNN4Colliders is a collider-machine-learning toolkit. The repository name
4
- reflects its first production model family, ROOT-GNN; the Python package is
5
- `gnn4colliders`, and the configuration identifier is `root_gnn`. Shared ROOT
6
- ingestion, collider features, metadata, tasks, training, inference, and
7
- distributed utilities are designed so that a future sequence model can reuse
8
- them without requiring every event to be a graph.
9
-
10
- ```text
11
- ROOT files -> EventSample -> shared collider features
12
- ├── GraphSample -> ROOT-GNN
13
- └── future SequenceSample -> ROOT-Transformer
14
- ```
15
-
16
- The new implementation lives under [`src/gnn4colliders`](src/gnn4colliders/).
17
- [`legacy/`](legacy/) is a frozen behavioral reference for parity work and
18
- historical checkpoint investigation, not a supported runtime backend.
19
-
20
- ## Installation
21
-
22
- The supported development environment is Python 3.12 (`>=3.12,<3.13`). Core
23
- development is supported on macOS and Linux:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ```bash
26
- # macOS (Apple Silicon): CPU ROOT-GNN development and tests
27
  uv sync --dev --extra root-gnn
28
-
29
- # Linux x86_64 with an NVIDIA GPU: validated ROOT-GNN development
30
- uv sync --dev --extra root-gnn
31
- ```
32
-
33
- The core package can be installed without DGL when only shared data or task
34
- code is needed. ROOT-GNN models, graph construction, and ROOT-GNN parity tests
35
- require the `root-gnn` extra. On Linux x86_64, it uses the validated CUDA 12.1
36
- wheels configured in `pyproject.toml`; a compatible NVIDIA driver is still
37
- required. On Apple Silicon macOS, it installs the CPU DGL wheel, supporting
38
- local graph/cache development. The default ROOT-GNN backend performs training
39
- with native PyTorch graph tensors, so it runs on Apple MPS, NVIDIA CUDA, and
40
- CPU; DGL remains a cache and legacy-compatibility adapter. Do not add
41
- site-specific CUDA, Slurm, or filesystem paths to model or task configuration.
42
-
43
- Use the MPS profile on an Apple Silicon Mac:
44
-
45
- ```bash
46
- uv run gnn4colliders train environment=macos
47
  ```
48
 
49
- ## Data samples
50
-
51
- ROOT inputs are available from the
52
- [HWresearch/Delphes dataset](https://huggingface.co/datasets/HWresearch/Delphes).
53
- Download the 64-event smoke-test sample with the Hugging Face CLI:
54
 
55
- ```bash
56
- hf download HWresearch/Delphes testing/ttH_NLO_64.root \
57
- --repo-type dataset --local-dir data/raw
58
- ```
59
 
60
- The sample is `data/raw/testing/ttH_NLO_64.root`, has tree name `output`, and
61
- is suitable for checking the prepare/train workflow. The dataset also provides
62
- larger process-specific ROOT samples under `samples/`, derived datasets under
63
- `derived/`, and analysis-specific ntuples under `analyses/`. These data are
64
- intentionally ignored by Git; inspect a selected ROOT file's tree and branches
65
- before writing its preparation configuration.
66
 
67
- ## Quick start
68
-
69
- Prepare a graph cache from a ROOT tree. The feature specifications below are
70
- illustrative placeholders; replace them with the branches in the input tree.
71
- The full preparation interface is documented in
72
- [`docs/configuration.md`](docs/configuration.md).
73
-
74
- ```bash
75
- uv run gnn4colliders prepare \
76
- data.files=[data/events.root] \
77
- data.tree_name=Events \
78
- data.cache.path=cache/events.pt \
79
- 'data.feature_branches=[["jet_pt"],["jet_eta"],["jet_phi"],CALC_E,[1.0],[0.0],NODE_TYPE]' \
80
- data.object_types=[vector] \
81
- data.scales=[1,1,1,1,1,1,1]
82
  ```
83
 
84
- Train, evaluate, and predict from that cache:
85
-
86
- ```bash
87
- uv run gnn4colliders train \
88
- data.cache.path=cache/events.pt \
89
- trainer.max_epochs=1 \
90
- environment.output_root=outputs/pretraining_multiclass
91
-
92
- uv run gnn4colliders evaluate \
93
- data.cache.path=cache/events.pt \
94
- inference.checkpoint=outputs/pretraining_multiclass/checkpoints/epoch_0000.pt
95
-
96
- uv run gnn4colliders predict \
97
- data.cache.path=cache/events.pt \
98
- inference.checkpoint=outputs/pretraining_multiclass/checkpoints/epoch_0000.pt \
99
- inference.output=outputs/pretraining_multiclass/predictions.npz
100
- ```
101
-
102
- For a dependency-complete, temporary-data version of this flow, run
103
- `uv run python scripts/dev/smoke_end_to_end.py`.
104
-
105
- ## Core concepts
106
-
107
- `EventSample` is the architecture-neutral event boundary. It contains the
108
- selected `objects`, `label`, `global_features`, and named `EventMetadata`.
109
- Metadata includes `fold`, `weight`, and stable `sample_id`; callers should not
110
- interpret public `tracking[:, N]` columns. Legacy tracking mappings exist only
111
- at compatibility boundaries.
112
-
113
- The ROOT-GNN adapter converts shared features to a directed, fully connected
114
- graph with no self-loops: an event with `N` nodes has `N * (N - 1)` edges.
115
- Node columns are, in order, `pt`, `eta`, `phi`, `energy`, `btag`, `charge`,
116
- and `node_type`. Edge columns are `deta`, wrapped `dphi`, and `dR`.
117
- Object collections are concatenated in configured object-type order. The
118
- compatibility energy is `pt * cosh(eta)` before per-column scaling.
119
-
120
- `GraphSampleCache` stores processed graph samples and schema metadata. It is a
121
- Level-2 graph cache, not the universal event cache. Feature, graph, and cache
122
- schema versions are checked when loading; incompatible versions fail before
123
- training.
124
-
125
- ## ROOT-GNN training and transfer
126
-
127
- `EdgeNetwork` encodes node, edge, and global features, performs iterative
128
- edge/node/global message passing, decodes a graph representation, and applies
129
- the classifier. Its output is raw logits; sigmoid or softmax is task-owned.
130
-
131
- Multiclass pretraining uses the semantic `model=root_gnn/edge_network` and
132
- `task=pretraining_multiclass` groups:
133
-
134
- ```bash
135
- uv run gnn4colliders train \
136
- data.cache.path=cache/events.pt \
137
- model=root_gnn/edge_network task=pretraining_multiclass \
138
- trainer.max_epochs=20 data.batch_size=64 \
139
- environment.output_root=outputs/pretraining_multiclass
140
- ```
141
-
142
- Fine-tuning is a separate workflow. It loads a pretrained backbone, replaces
143
- the classifier, and creates a new task/head optimizer:
144
-
145
- ```bash
146
- uv run gnn4colliders train \
147
- data.cache.path=cache/target.pt \
148
- model=root_gnn/fine_tuned_edge_network \
149
- task=binary_classification \
150
- checkpoint.pretrained=/path/to/pretrained.pt \
151
- model.freeze_backbone=true \
152
- trainer.max_epochs=10
153
- ```
154
 
155
- Set `model.freeze_backbone=false` to train the reused backbone as well.
156
- Transfer learning is not resume training:
157
-
158
- | Workflow | Meaning | Restored state |
159
- | --- | --- | --- |
160
- | Resume | Continue the same task/run | model, optimizer, scheduler, trainer, early stopping, and RNG state when present |
161
- | Transfer | Start a new task from a pretrained backbone | model weights only; new classifier and optimizer |
162
-
163
- Resume example:
164
-
165
- ```bash
166
- uv run gnn4colliders train \
167
- data.cache.path=cache/events.pt \
168
- checkpoint.resume=outputs/pretraining_multiclass/checkpoints/epoch_0000.pt \
169
- trainer.max_epochs=20
170
- ```
171
-
172
- Validation is evaluated each epoch and drives scheduling/early stopping;
173
- `test` remains held out. Evaluation computes task metrics over the complete
174
- selected split, including weighted ROC AUC where defined:
175
-
176
- ```bash
177
- uv run gnn4colliders evaluate \
178
- data.cache.path=cache/events.pt \
179
- inference.split=test \
180
- inference.checkpoint=/path/to/checkpoint.pt
181
- ```
182
-
183
- Prediction writes a named compressed NPZ. Labeled data includes `labels`;
184
- `fold` and `weight` are included when available. Every result includes
185
- `sample_id`, `logits`, `scores`, and `predictions`:
186
-
187
- ```bash
188
- uv run gnn4colliders predict \
189
- data.cache.path=cache/events.pt \
190
- inference.checkpoint=/path/to/checkpoint.pt \
191
- inference.output=outputs/predictions.npz
192
- ```
193
-
194
- Optional Python-level ROOT writing is provided by
195
- `gnn4colliders.inference.write_root_scores`. It clones the selected tree,
196
- adds `score` (or `score_class_N`), and writes `selection_pass`; IDs ending in
197
- `:<entry>` preserve alignment and unselected entries receive NaN scores. The
198
- CLI currently exposes NPZ output only.
199
-
200
- The supported legacy checkpoint, metadata, and output boundary is documented
201
- in [`docs/compatibility.md`](docs/compatibility.md). New code should use named
202
- metadata fields; positional tracking is accepted only by the explicit
203
- compatibility adapter.
204
-
205
- ### ONNX export
206
-
207
- Install the optional export dependencies and export a prepared graph-cache
208
- checkpoint with numerical ONNX validation:
209
-
210
- ```bash
211
- uv sync --extra root-gnn --extra onnx
212
- uv run gnn4colliders export \
213
- export.checkpoint=/path/to/checkpoint.pt \
214
- export.output=model.onnx \
215
- data.cache.path=/path/to/graph-cache.pt
216
- ```
217
-
218
- The model accepts processed graph tensors and returns raw logits. See
219
- [`docs/export.md`](docs/export.md) for the tensor contract and limitations.
220
-
221
- ## Configuration and environments
222
-
223
- Hydra groups are `data`, `model`, `task`, `trainer`, `checkpoint`,
224
- `inference`, `environment`, and `distributed`. Use configuration for a new
225
- experiment and Python for new behavior. Examples:
226
-
227
- ```bash
228
- uv run gnn4colliders train trainer.max_epochs=50 data.batch_size=64
229
- uv run gnn4colliders train environment=perlmutter environment.device=cuda
230
- uv run gnn4colliders train distributed=ddp environment=perlmutter
231
- ```
232
-
233
- Each run writes a resolved configuration to
234
- `<environment.output_root>/resolved_config.yaml`. See
235
- [`docs/configuration.md`](docs/configuration.md) for the group reference and
236
- [`docs/perlmutter.md`](docs/perlmutter.md) for launch examples.
237
-
238
- ## Distributed execution and reproducibility
239
-
240
- Launch DDP with `torchrun` or the provided Slurm wrappers. `data.batch_size`
241
- and `data.num_workers` are per process, so the ordinary effective batch size
242
- is `batch_size * world_size`. Training shards may be padded for equal steps;
243
- validation and prediction are unpadded. Rank 0 writes shared checkpoints,
244
- configs, and predictions, and metrics/results are gathered across ranks.
245
-
246
- The configured seed controls initialization and deterministic local loader
247
- ordering; distributed process seeds are rank-offset and samplers use
248
- `set_epoch`. CPU runs are reproducible for fixed inputs and environment. GPU
249
- kernels, DGL, and distributed scheduling can remain nondeterministic, so the
250
- project does not promise bitwise GPU reproducibility.
251
-
252
- ## Development and validation
253
-
254
- ```bash
255
- uv run pytest
256
- uv run pytest tests/unit
257
- GNN4COLLIDERS_REQUIRE_ROOT_GNN=1 uv run pytest tests/parity -v
258
- uv run ruff check .
259
- uv run ruff format --check .
260
- uv run python benchmarks/benchmark_preprocessing.py
261
- uv run python benchmarks/benchmark_training.py --device cpu
262
- ```
263
 
264
- Unit tests cover isolated components, integration tests cover small workflows,
265
- and parity tests compare deterministic behavior with the frozen legacy
266
- reference. Performance guidance and measured caveats are in
267
- [`docs/performance.md`](docs/performance.md) and
268
- [`benchmarks/README.md`](benchmarks/README.md).
269
- See [`docs/testing.md`](docs/testing.md) for test layers, optional dependency
270
- markers, and package smoke validation.
271
-
272
- ## Architecture and migration status
273
-
274
- See [`docs/architecture.md`](docs/architecture.md) for responsibility
275
- boundaries and the future sequence-model extension point. See
276
- [`docs/migration.md`](docs/migration.md) for the migration matrix,
277
- intentional redesigns, compatibility limits, and deferred work.
278
-
279
- ROOT-GNN v1 covers ROOT preparation, validated feature/graph/model/task
280
- behavior, training, fine-tuning, checkpoint resume, evaluation, prediction,
281
- single-process/DDP execution, and validated ONNX export. Streaming distributed
282
- output, legacy cleanup, and ROOT-Transformer remain follow-up work.
 
1
+ ---
2
+ library_name: gnn4colliders
3
+ tags:
4
+ - graph-neural-network
5
+ - high-energy-physics
6
+ - particle-physics
7
+ - event-classification
8
+ - pytorch
9
+ - dgl
10
+ datasets:
11
+ - HWresearch/Delphes
12
+ ---
13
+
14
+ # GNN4Colliders: Pretrained Event Classification Model
15
+
16
+ This repository contains a pretrained Graph Neural Network (GNN) for
17
+ high-energy-physics collider event classification. The model learns from
18
+ reconstructed event-level objects and can be fine-tuned for downstream
19
+ classification tasks. The accompanying paper source archive is available as
20
+ [`paper.tar.gz`](paper.tar.gz). The supplied PDF was used as the source for
21
+ this card but is not committed because the Hugging Face repository requires
22
+ binary files to use Xet storage.
23
+
24
+ ## Model summary
25
+
26
+ The model is an event-level foundation-model prototype trained on approximately
27
+ 120 million simulated proton-proton collision events from 12 Standard Model
28
+ processes. It represents each event as a fully connected graph whose nodes are
29
+ reconstructed jets, electrons, muons, photons, and missing transverse energy.
30
+ The pretrained representation can be adapted to binary and multiclass physics
31
+ classification tasks by replacing the output layer and fine-tuning the model.
32
+
33
+ The paper studies two pretrained checkpoints:
34
+
35
+ - `multiclass_pretrained_model_12`: 12-process multiclass pretraining; this is
36
+ the recommended starting point for downstream classification.
37
+ - `multilabel_pretrained_model_41`: 41-label pretraining over particle
38
+ multiplicities and kinematic properties; results in the paper show less
39
+ consistent downstream transfer from this objective.
40
+
41
+ The checkpoint directories and their training configurations are included in
42
+ this repository under `legacy/root_gnn_dgl/Pretrained_GNN/`.
43
+
44
+ ## Model details
45
+
46
+ | Property | Description |
47
+ | --- | --- |
48
+ | Architecture | Graph Network with MLP encoders, message-passing blocks, a decoder, and a task-specific linear head |
49
+ | Framework | PyTorch with DGL |
50
+ | Parameters | Approximately 400,000 trainable parameters |
51
+ | Latent width | 64 |
52
+ | MLP depth | 4 linear layers |
53
+ | Message-passing steps | 4 |
54
+ | Graph topology | Fully connected event graph |
55
+ | Pretraining data | Approximately 120 million events across 12 processes |
56
+ | Pretraining site | Perlmutter supercomputer at NERSC |
57
+ | Authors | Joshua Ho, Ryan Roberts, Shuo Han, and Haichen Wang |
58
+
59
+ ### Inputs
60
+
61
+ Each graph node contains:
62
+
63
+ 1. transverse momentum \(p_T\),
64
+ 2. pseudorapidity \(\eta\),
65
+ 3. azimuthal angle \(\phi\),
66
+ 4. energy \(E = p_T \cosh(\eta)\) under a massless assumption,
67
+ 5. b-tagging information,
68
+ 6. electric charge, and
69
+ 7. an integer object-type identifier.
70
+
71
+ Undefined object-specific features use a placeholder value of zero. Each edge
72
+ contains \(\Delta\eta\), wrapped \(\Delta\phi\), and
73
+ \(\Delta R = \sqrt{(\Delta\eta)^2 + (\Delta\phi)^2}\). The global input is the
74
+ number of nodes in the event.
75
+
76
+ The GNN uses summation aggregation. Its edge, node, and global update functions
77
+ are applied in sequence four times:
78
+
79
+ $$
80
+ \begin{aligned}
81
+ \vec{y}'_{ij} &= f_e(\vec{x}_i, \vec{x}_j, \vec{y}_{ij}, \vec{z}),\\
82
+ \vec{x}'_i &= f_n\left(\vec{x}_i, \sum_j \vec{y}'_{ij}, \vec{z}\right),\\
83
+ \vec{z}' &= f_g\left(\sum_i \vec{x}'_i, \sum_{i,j} \vec{y}'_{ij}, \vec{z}\right).
84
+ \end{aligned}
85
+ $$
86
+
87
+ The model returns task logits. A downstream task is responsible for applying
88
+ the appropriate sigmoid or softmax transformation.
89
+
90
+ ## Intended use
91
+
92
+ This model is intended for research in collider-physics event classification,
93
+ including transfer-learning studies and rapid prototyping of classifiers for
94
+ new physics processes. It is suitable for fine-tuning on simulated events or
95
+ compatible reconstructed event collections.
96
+
97
+ It is not intended to replace detector, object-reconstruction, calibration, or
98
+ analysis validation. Predictions should not be interpreted as measurements of
99
+ physical parameters without task-specific validation and uncertainty studies.
100
+
101
+ ## Training data
102
+
103
+ The pretraining samples were generated at a proton-proton center-of-mass energy
104
+ of 13 TeV. The paper describes MadGraph@NLO 2.7.3 at NLO in QCD, Pythia 8.235
105
+ for showering and heavy-particle decays, and Delphes 3.4.2 configured to emulate
106
+ the ATLAS detector.
107
+
108
+ The 12 pretraining processes are:
109
+
110
+ - Higgs production: \(ggF\), \(VBF\), \(WH\), \(ZH\), \(t\bar{t}H\), and
111
+ \(tHq\);
112
+ - top production: single top, \(t\bar{t}\), \(t\bar{t}\gamma\gamma\),
113
+ \(t\bar{t}W\), \(t\bar{t}t\), and \(t\bar{t}t\bar{t}\).
114
+
115
+ The paper also evaluates transfer to four additional Delphes processes and to
116
+ ATLAS Open Data. The Open Data evaluation uses the `GamGam` and `1LMET30`
117
+ collections, which are reconstructed with the full ATLAS simulation and
118
+ reconstruction chain rather than Delphes.
119
+
120
+ The Hugging Face [HWresearch/Delphes dataset](https://huggingface.co/datasets/HWresearch/Delphes)
121
+ contains the public data interface used by the repository for example and
122
+ smoke-test workflows. The complete training samples described in the paper are
123
+ not reproduced by the small smoke-test fixture.
124
+
125
+ ## Pretraining
126
+
127
+ The multiclass checkpoint predicts the 12 event-process classes using
128
+ categorical cross entropy. The multilabel checkpoint predicts 41 labels using a
129
+ weighted combination of binary cross entropy and mean-squared-error losses.
130
+ Both pretraining runs use an initial learning rate of \(10^{-4}\) with an
131
+ exponential decay factor of \(0.99\) per epoch and stop after five epochs
132
+ without training-loss improvement. The checkpoint with the highest validation
133
+ AUC is selected for fine-tuning.
134
+
135
+ For downstream fine-tuning, the original output layer is replaced with a new
136
+ linear layer. The new layer starts at learning rate \(10^{-4}\), while the
137
+ pretrained layers start at \(10^{-5}\); both use the same decay schedule.
138
+
139
+ ## Evaluation
140
+
141
+ The paper evaluates five Delphes binary tasks and two ATLAS Open Data
142
+ multiclass tasks. Reported results are averages over five independently trained
143
+ models, except where dataset size limited the randomization study.
144
+
145
+ ### Delphes downstream tasks
146
+
147
+ The five binary tasks are:
148
+
149
+ 1. \(t\bar{t}H(\rightarrow\gamma\gamma)\) CP-even versus CP-odd;
150
+ 2. FCNC top decays versus \(tHq\);
151
+ 3. \(t\bar{t}W\) versus \(t\bar{t}t\);
152
+ 4. s-top pair production versus \(t\bar{t}H\); and
153
+ 5. \(WH\) versus \(ZH\).
154
+
155
+ Training sizes range from \(10^3\) to \(10^7\) events per class. Relative to
156
+ training from scratch, multiclass fine-tuning produces its largest gains in the
157
+ low-data regime, with improvements of more than 4 percentage points in
158
+ accuracy and 2.5 AUC points in some settings. The benefit generally decreases
159
+ as the downstream training sample grows.
160
+
161
+ ### ATLAS Open Data
162
+
163
+ | Task | Baseline accuracy | Multiclass change | Baseline AUC (×100) | Multiclass change |
164
+ | --- | ---: | ---: | ---: | ---: |
165
+ | Higgs production (5 classes) | \(71.8 \pm 0.2\)% | \(-0.1 \pm 0.2\) points | \(91.2 \pm 0.0\) | \(+0.1 \pm 0.0\) points |
166
+ | Triboson (3 classes) | \(54.8 \pm 2.3\)% | \(+3.7 \pm 2.3\) points | \(72.9 \pm 3.3\) | \(+4.6 \pm 3.3\) points |
167
+
168
+ Multilabel pretraining is less reliable: it can be neutral or harmful on
169
+ several downstream tasks, especially at low statistics. This is a documented
170
+ result of the paper and an important model-selection consideration.
171
+
172
+ ### Computational efficiency
173
+
174
+ Multiclass and multilabel pretraining required approximately 45.5 and 60.0
175
+ GPU hours, respectively. At full downstream statistics, the paper reports a
176
+ mean fine-tuned-to-baseline full-training-time ratio of 64.6% across the seven
177
+ tasks. When using a target-aware early-stopping metric, fine-tuning reaches the
178
+ baseline AUC target in an average of 43.5% of the baseline time. The estimated
179
+ pretraining break-even point is approximately 14 to 52 downstream tasks,
180
+ depending on the stopping criterion.
181
+
182
+ ### Representation analysis
183
+
184
+ The paper uses Centered Kernel Alignment (CKA) to compare internal
185
+ representations. Encoder representations remain highly similar across
186
+ pretrained, fine-tuned, and baseline models, while message-passing stages are
187
+ more distinct. Fine-tuning primarily changes the global decoder, preserving
188
+ much of the pretrained event representation while adapting the final decision
189
+ function to the downstream task.
190
+
191
+ ## Limitations and risks
192
+
193
+ - The model is trained and evaluated on simulated or curated ATLAS Open Data;
194
+ simulation-to-data mismodelling can affect performance.
195
+ - The pretraining data cover a finite set of processes and detector/object
196
+ definitions. Results may not transfer to other collision energies,
197
+ experiments, reconstruction versions, or object selections.
198
+ - The model uses placeholder zeros for features that are undefined for some
199
+ object types. The paper did not test an explicit feature mask.
200
+ - Multilabel pretraining can produce negative transfer. The multiclass
201
+ checkpoint is the preferred starting point based on the reported results.
202
+ - The reported metrics are task-specific and do not establish physics-analysis
203
+ sensitivity, calibration, uncertainty coverage, or discovery significance.
204
+ - The paper studies supervised pretraining and fine-tuning; it does not claim
205
+ unsupervised or generative capabilities.
206
+
207
+ ## Reproducibility and repository use
208
+
209
+ The repository contains the legacy DGL implementation used by the paper as
210
+ well as an incremental rewrite under [`src/gnn4colliders`](src/gnn4colliders/).
211
+ The rewrite provides shared ROOT ingestion, collider features, graph building,
212
+ training, evaluation, prediction, and checkpoint/inference utilities. See
213
+ [`README_PROJECT.md`](README_PROJECT.md) for the package development workflow
214
+ and [`docs/architecture.md`](docs/architecture.md) for the target architecture.
215
+
216
+ For the current rewrite, the supported development environment is:
217
 
218
  ```bash
 
219
  uv sync --dev --extra root-gnn
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  ```
221
 
222
+ The paper checkpoints preserve the historical model and configuration layout;
223
+ use the compatibility documentation before loading them with the rewritten
224
+ package.
 
 
225
 
226
+ ## Citation
 
 
 
227
 
228
+ If you use this model or the associated study, please cite:
 
 
 
 
 
229
 
230
+ ```bibtex
231
+ @article{Ho2026PretrainedEventClassification,
232
+ title = {Pretrained Event Classification Model for High Energy Physics Analysis},
233
+ author = {Ho, Joshua and Roberts, Ryan and Han, Shuo and Wang, Haichen},
234
+ note = {Code and model: https://huggingface.co/HWresearch/GNN4Colliders}
235
+ }
 
 
 
 
 
 
 
 
 
236
  ```
237
 
238
+ The paper source archive is included in this repository as `paper.tar.gz`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
+ ## Acknowledgments
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
 
242
+ This work was supported by the U.S. National Science Foundation Award No.
243
+ 2046280 and the U.S. Department of Energy, Office of Science, under contract
244
+ DE-AC02-05CH11231. Joshua Ho acknowledges support from UC Berkeley Summer
245
+ Undergraduate Research Fellowships (SURF) and its donors. The authors
246
+ acknowledge the ATLAS Collaboration for the Open Data and supporting software.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README_PROJECT.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GNN4Colliders
2
+
3
+ GNN4Colliders is a collider-machine-learning toolkit. The repository name
4
+ reflects its first production model family, ROOT-GNN; the Python package is
5
+ `gnn4colliders`, and the configuration identifier is `root_gnn`. Shared ROOT
6
+ ingestion, collider features, metadata, tasks, training, inference, and
7
+ distributed utilities are designed so that a future sequence model can reuse
8
+ them without requiring every event to be a graph.
9
+
10
+ ```text
11
+ ROOT files -> EventSample -> shared collider features
12
+ ├── GraphSample -> ROOT-GNN
13
+ └── future SequenceSample -> ROOT-Transformer
14
+ ```
15
+
16
+ The new implementation lives under [`src/gnn4colliders`](src/gnn4colliders/).
17
+ [`legacy/`](legacy/) is a frozen behavioral reference for parity work and
18
+ historical checkpoint investigation, not a supported runtime backend.
19
+
20
+ ## Installation
21
+
22
+ The supported development environment is Python 3.12 (`>=3.12,<3.13`). Core
23
+ development is supported on macOS and Linux:
24
+
25
+ ```bash
26
+ # macOS (Apple Silicon): CPU ROOT-GNN development and tests
27
+ uv sync --dev --extra root-gnn
28
+
29
+ # Linux x86_64 with an NVIDIA GPU: validated ROOT-GNN development
30
+ uv sync --dev --extra root-gnn
31
+ ```
32
+
33
+ The core package can be installed without DGL when only shared data or task
34
+ code is needed. ROOT-GNN models, graph construction, and ROOT-GNN parity tests
35
+ require the `root-gnn` extra. On Linux x86_64, it uses the validated CUDA 12.1
36
+ wheels configured in `pyproject.toml`; a compatible NVIDIA driver is still
37
+ required. On Apple Silicon macOS, it installs the CPU DGL wheel, supporting
38
+ local graph/cache development. The default ROOT-GNN backend performs training
39
+ with native PyTorch graph tensors, so it runs on Apple MPS, NVIDIA CUDA, and
40
+ CPU; DGL remains a cache and legacy-compatibility adapter. Do not add
41
+ site-specific CUDA, Slurm, or filesystem paths to model or task configuration.
42
+
43
+ Use the MPS profile on an Apple Silicon Mac:
44
+
45
+ ```bash
46
+ uv run gnn4colliders train environment=macos
47
+ ```
48
+
49
+ ## Data samples
50
+
51
+ ROOT inputs are available from the
52
+ [HWresearch/Delphes dataset](https://huggingface.co/datasets/HWresearch/Delphes).
53
+ Download the 64-event smoke-test sample with the Hugging Face CLI:
54
+
55
+ ```bash
56
+ hf download HWresearch/Delphes testing/ttH_NLO_64.root \
57
+ --repo-type dataset --local-dir data/raw
58
+ ```
59
+
60
+ The sample is `data/raw/testing/ttH_NLO_64.root`, has tree name `output`, and
61
+ is suitable for checking the prepare/train workflow. The dataset also provides
62
+ larger process-specific ROOT samples under `samples/`, derived datasets under
63
+ `derived/`, and analysis-specific ntuples under `analyses/`. These data are
64
+ intentionally ignored by Git; inspect a selected ROOT file's tree and branches
65
+ before writing its preparation configuration.
66
+
67
+ ## Quick start
68
+
69
+ Prepare a graph cache from a ROOT tree. The feature specifications below are
70
+ illustrative placeholders; replace them with the branches in the input tree.
71
+ The full preparation interface is documented in
72
+ [`docs/configuration.md`](docs/configuration.md).
73
+
74
+ ```bash
75
+ uv run gnn4colliders prepare \
76
+ data.files=[data/events.root] \
77
+ data.tree_name=Events \
78
+ data.cache.path=cache/events.pt \
79
+ 'data.feature_branches=[["jet_pt"],["jet_eta"],["jet_phi"],CALC_E,[1.0],[0.0],NODE_TYPE]' \
80
+ data.object_types=[vector] \
81
+ data.scales=[1,1,1,1,1,1,1]
82
+ ```
83
+
84
+ Train, evaluate, and predict from that cache:
85
+
86
+ ```bash
87
+ uv run gnn4colliders train \
88
+ data.cache.path=cache/events.pt \
89
+ trainer.max_epochs=1 \
90
+ environment.output_root=outputs/pretraining_multiclass
91
+
92
+ uv run gnn4colliders evaluate \
93
+ data.cache.path=cache/events.pt \
94
+ inference.checkpoint=outputs/pretraining_multiclass/checkpoints/epoch_0000.pt
95
+
96
+ uv run gnn4colliders predict \
97
+ data.cache.path=cache/events.pt \
98
+ inference.checkpoint=outputs/pretraining_multiclass/checkpoints/epoch_0000.pt \
99
+ inference.output=outputs/pretraining_multiclass/predictions.npz
100
+ ```
101
+
102
+ For a dependency-complete, temporary-data version of this flow, run
103
+ `uv run python scripts/dev/smoke_end_to_end.py`.
104
+
105
+ ## Core concepts
106
+
107
+ `EventSample` is the architecture-neutral event boundary. It contains the
108
+ selected `objects`, `label`, `global_features`, and named `EventMetadata`.
109
+ Metadata includes `fold`, `weight`, and stable `sample_id`; callers should not
110
+ interpret public `tracking[:, N]` columns. Legacy tracking mappings exist only
111
+ at compatibility boundaries.
112
+
113
+ The ROOT-GNN adapter converts shared features to a directed, fully connected
114
+ graph with no self-loops: an event with `N` nodes has `N * (N - 1)` edges.
115
+ Node columns are, in order, `pt`, `eta`, `phi`, `energy`, `btag`, `charge`,
116
+ and `node_type`. Edge columns are `deta`, wrapped `dphi`, and `dR`.
117
+ Object collections are concatenated in configured object-type order. The
118
+ compatibility energy is `pt * cosh(eta)` before per-column scaling.
119
+
120
+ `GraphSampleCache` stores processed graph samples and schema metadata. It is a
121
+ Level-2 graph cache, not the universal event cache. Feature, graph, and cache
122
+ schema versions are checked when loading; incompatible versions fail before
123
+ training.
124
+
125
+ ## ROOT-GNN training and transfer
126
+
127
+ `EdgeNetwork` encodes node, edge, and global features, performs iterative
128
+ edge/node/global message passing, decodes a graph representation, and applies
129
+ the classifier. Its output is raw logits; sigmoid or softmax is task-owned.
130
+
131
+ Multiclass pretraining uses the semantic `model=root_gnn/edge_network` and
132
+ `task=pretraining_multiclass` groups:
133
+
134
+ ```bash
135
+ uv run gnn4colliders train \
136
+ data.cache.path=cache/events.pt \
137
+ model=root_gnn/edge_network task=pretraining_multiclass \
138
+ trainer.max_epochs=20 data.batch_size=64 \
139
+ environment.output_root=outputs/pretraining_multiclass
140
+ ```
141
+
142
+ Fine-tuning is a separate workflow. It loads a pretrained backbone, replaces
143
+ the classifier, and creates a new task/head optimizer:
144
+
145
+ ```bash
146
+ uv run gnn4colliders train \
147
+ data.cache.path=cache/target.pt \
148
+ model=root_gnn/fine_tuned_edge_network \
149
+ task=binary_classification \
150
+ checkpoint.pretrained=/path/to/pretrained.pt \
151
+ model.freeze_backbone=true \
152
+ trainer.max_epochs=10
153
+ ```
154
+
155
+ Set `model.freeze_backbone=false` to train the reused backbone as well.
156
+ Transfer learning is not resume training:
157
+
158
+ | Workflow | Meaning | Restored state |
159
+ | --- | --- | --- |
160
+ | Resume | Continue the same task/run | model, optimizer, scheduler, trainer, early stopping, and RNG state when present |
161
+ | Transfer | Start a new task from a pretrained backbone | model weights only; new classifier and optimizer |
162
+
163
+ Resume example:
164
+
165
+ ```bash
166
+ uv run gnn4colliders train \
167
+ data.cache.path=cache/events.pt \
168
+ checkpoint.resume=outputs/pretraining_multiclass/checkpoints/epoch_0000.pt \
169
+ trainer.max_epochs=20
170
+ ```
171
+
172
+ Validation is evaluated each epoch and drives scheduling/early stopping;
173
+ `test` remains held out. Evaluation computes task metrics over the complete
174
+ selected split, including weighted ROC AUC where defined:
175
+
176
+ ```bash
177
+ uv run gnn4colliders evaluate \
178
+ data.cache.path=cache/events.pt \
179
+ inference.split=test \
180
+ inference.checkpoint=/path/to/checkpoint.pt
181
+ ```
182
+
183
+ Prediction writes a named compressed NPZ. Labeled data includes `labels`;
184
+ `fold` and `weight` are included when available. Every result includes
185
+ `sample_id`, `logits`, `scores`, and `predictions`:
186
+
187
+ ```bash
188
+ uv run gnn4colliders predict \
189
+ data.cache.path=cache/events.pt \
190
+ inference.checkpoint=/path/to/checkpoint.pt \
191
+ inference.output=outputs/predictions.npz
192
+ ```
193
+
194
+ Optional Python-level ROOT writing is provided by
195
+ `gnn4colliders.inference.write_root_scores`. It clones the selected tree,
196
+ adds `score` (or `score_class_N`), and writes `selection_pass`; IDs ending in
197
+ `:<entry>` preserve alignment and unselected entries receive NaN scores. The
198
+ CLI currently exposes NPZ output only.
199
+
200
+ The supported legacy checkpoint, metadata, and output boundary is documented
201
+ in [`docs/compatibility.md`](docs/compatibility.md). New code should use named
202
+ metadata fields; positional tracking is accepted only by the explicit
203
+ compatibility adapter.
204
+
205
+ ### ONNX export
206
+
207
+ Install the optional export dependencies and export a prepared graph-cache
208
+ checkpoint with numerical ONNX validation:
209
+
210
+ ```bash
211
+ uv sync --extra root-gnn --extra onnx
212
+ uv run gnn4colliders export \
213
+ export.checkpoint=/path/to/checkpoint.pt \
214
+ export.output=model.onnx \
215
+ data.cache.path=/path/to/graph-cache.pt
216
+ ```
217
+
218
+ The model accepts processed graph tensors and returns raw logits. See
219
+ [`docs/export.md`](docs/export.md) for the tensor contract and limitations.
220
+
221
+ ## Configuration and environments
222
+
223
+ Hydra groups are `data`, `model`, `task`, `trainer`, `checkpoint`,
224
+ `inference`, `environment`, and `distributed`. Use configuration for a new
225
+ experiment and Python for new behavior. Examples:
226
+
227
+ ```bash
228
+ uv run gnn4colliders train trainer.max_epochs=50 data.batch_size=64
229
+ uv run gnn4colliders train environment=perlmutter environment.device=cuda
230
+ uv run gnn4colliders train distributed=ddp environment=perlmutter
231
+ ```
232
+
233
+ Each run writes a resolved configuration to
234
+ `<environment.output_root>/resolved_config.yaml`. See
235
+ [`docs/configuration.md`](docs/configuration.md) for the group reference and
236
+ [`docs/perlmutter.md`](docs/perlmutter.md) for launch examples.
237
+
238
+ ## Distributed execution and reproducibility
239
+
240
+ Launch DDP with `torchrun` or the provided Slurm wrappers. `data.batch_size`
241
+ and `data.num_workers` are per process, so the ordinary effective batch size
242
+ is `batch_size * world_size`. Training shards may be padded for equal steps;
243
+ validation and prediction are unpadded. Rank 0 writes shared checkpoints,
244
+ configs, and predictions, and metrics/results are gathered across ranks.
245
+
246
+ The configured seed controls initialization and deterministic local loader
247
+ ordering; distributed process seeds are rank-offset and samplers use
248
+ `set_epoch`. CPU runs are reproducible for fixed inputs and environment. GPU
249
+ kernels, DGL, and distributed scheduling can remain nondeterministic, so the
250
+ project does not promise bitwise GPU reproducibility.
251
+
252
+ ## Development and validation
253
+
254
+ ```bash
255
+ uv run pytest
256
+ uv run pytest tests/unit
257
+ GNN4COLLIDERS_REQUIRE_ROOT_GNN=1 uv run pytest tests/parity -v
258
+ uv run ruff check .
259
+ uv run ruff format --check .
260
+ uv run python benchmarks/benchmark_preprocessing.py
261
+ uv run python benchmarks/benchmark_training.py --device cpu
262
+ ```
263
+
264
+ Unit tests cover isolated components, integration tests cover small workflows,
265
+ and parity tests compare deterministic behavior with the frozen legacy
266
+ reference. Performance guidance and measured caveats are in
267
+ [`docs/performance.md`](docs/performance.md) and
268
+ [`benchmarks/README.md`](benchmarks/README.md).
269
+ See [`docs/testing.md`](docs/testing.md) for test layers, optional dependency
270
+ markers, and package smoke validation.
271
+
272
+ ## Architecture and migration status
273
+
274
+ See [`docs/architecture.md`](docs/architecture.md) for responsibility
275
+ boundaries and the future sequence-model extension point. See
276
+ [`docs/migration.md`](docs/migration.md) for the migration matrix,
277
+ intentional redesigns, compatibility limits, and deferred work.
278
+
279
+ ROOT-GNN v1 covers ROOT preparation, validated feature/graph/model/task
280
+ behavior, training, fine-tuning, checkpoint resume, evaluation, prediction,
281
+ single-process/DDP execution, and validated ONNX export. Streaming distributed
282
+ output, legacy cleanup, and ROOT-Transformer remain follow-up work.
paper.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9587a5b67b73dfc0f88b2a641b98410623a592d47cedd8fc71b35d28e9e1dfbc
3
+ size 142839