Skip to content

Commit

Permalink
First go at full workflow (pending other PRs)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonge committed Jan 9, 2025
1 parent c5f076c commit 4646a89
Show file tree
Hide file tree
Showing 4 changed files with 310 additions and 65 deletions.
106 changes: 54 additions & 52 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,62 +125,64 @@ get_data:
- runner_system_failure

include:
- local: 'benchmarks/backgrounds/config.yml'
- local: 'benchmarks/backwards_ecal/config.yml'
- local: 'benchmarks/calo_pid/config.yml'
- local: 'benchmarks/ecal_gaps/config.yml'
- local: 'benchmarks/tracking_detectors/config.yml'
- local: 'benchmarks/tracking_performances/config.yml'
- local: 'benchmarks/tracking_performances_dis/config.yml'
- local: 'benchmarks/barrel_ecal/config.yml'
- local: 'benchmarks/barrel_hcal/config.yml'
- local: 'benchmarks/lfhcal/config.yml'
- local: 'benchmarks/zdc/config.yml'
- local: 'benchmarks/zdc_lyso/config.yml'
- local: 'benchmarks/zdc_neutron/config.yml'
- local: 'benchmarks/zdc_photon/config.yml'
- local: 'benchmarks/zdc_pi0/config.yml'
- local: 'benchmarks/material_scan/config.yml'
- local: 'benchmarks/pid/config.yml'
- local: 'benchmarks/timing/config.yml'
- local: 'benchmarks/b0_tracker/config.yml'
- local: 'benchmarks/insert_muon/config.yml'
- local: 'benchmarks/insert_tau/config.yml'
- local: 'benchmarks/zdc_sigma/config.yml'
- local: 'benchmarks/zdc_lambda/config.yml'
- local: 'benchmarks/insert_neutron/config.yml'
- local: 'benchmarks/femc_electron/config.yml'
- local: 'benchmarks/femc_photon/config.yml'
- local: 'benchmarks/femc_pi0/config.yml'
# - local: 'benchmarks/backgrounds/config.yml'
# - local: 'benchmarks/backwards_ecal/config.yml'
# - local: 'benchmarks/calo_pid/config.yml'
# - local: 'benchmarks/ecal_gaps/config.yml'
# - local: 'benchmarks/tracking_detectors/config.yml'
# - local: 'benchmarks/tracking_performances/config.yml'
# - local: 'benchmarks/tracking_performances_dis/config.yml'
# - local: 'benchmarks/barrel_ecal/config.yml'
# - local: 'benchmarks/barrel_hcal/config.yml'
# - local: 'benchmarks/lfhcal/config.yml'
# - local: 'benchmarks/zdc/config.yml'
# - local: 'benchmarks/zdc_lyso/config.yml'
# - local: 'benchmarks/zdc_neutron/config.yml'
# - local: 'benchmarks/zdc_photon/config.yml'
# - local: 'benchmarks/zdc_pi0/config.yml'
# - local: 'benchmarks/material_scan/config.yml'
# - local: 'benchmarks/pid/config.yml'
# - local: 'benchmarks/timing/config.yml'
# - local: 'benchmarks/b0_tracker/config.yml'
# - local: 'benchmarks/insert_muon/config.yml'
# - local: 'benchmarks/insert_tau/config.yml'
# - local: 'benchmarks/zdc_sigma/config.yml'
# - local: 'benchmarks/zdc_lambda/config.yml'
# - local: 'benchmarks/insert_neutron/config.yml'
# - local: 'benchmarks/femc_electron/config.yml'
# - local: 'benchmarks/femc_photon/config.yml'
# - local: 'benchmarks/femc_pi0/config.yml'
- local: 'benchmarks/lowq2/reconstruction_training/config.yml'
deploy_results:
allow_failure: true
stage: deploy
needs:
- "collect_results:backgrounds"
- "collect_results:backwards_ecal"
- "collect_results:barrel_ecal"
- "collect_results:barrel_hcal"
- "collect_results:calo_pid"
- "collect_results:ecal_gaps"
- "collect_results:lfhcal"
- "collect_results:material_scan"
- "collect_results:pid"
- "collect_results:tracking_performance"
- "collect_results:tracking_performance_campaigns"
- "collect_results:zdc_sigma"
- "collect_results:zdc_lambda"
- "collect_results:insert_neutron"
- "collect_results:tracking_performances_dis"
- "collect_results:zdc"
- "collect_results:zdc_lyso"
- "collect_results:zdc_neutron"
- "collect_results:insert_muon"
- "collect_results:insert_tau"
- "collect_results:zdc_photon"
- "collect_results:zdc_pi0"
- "collect_results:femc_electron"
- "collect_results:femc_photon"
- "collect_results:femc_pi0"
# - "collect_results:backgrounds"
# - "collect_results:backwards_ecal"
# - "collect_results:barrel_ecal"
# - "collect_results:barrel_hcal"
# - "collect_results:calo_pid"
# - "collect_results:ecal_gaps"
# - "collect_results:lfhcal"
# - "collect_results:material_scan"
# - "collect_results:pid"
# - "collect_results:tracking_performance"
# - "collect_results:tracking_performance_campaigns"
# - "collect_results:zdc_sigma"
# - "collect_results:zdc_lambda"
# - "collect_results:insert_neutron"
# - "collect_results:tracking_performances_dis"
# - "collect_results:zdc"
# - "collect_results:zdc_lyso"
# - "collect_results:zdc_neutron"
# - "collect_results:insert_muon"
# - "collect_results:insert_tau"
# - "collect_results:zdc_photon"
# - "collect_results:zdc_pi0"
# - "collect_results:femc_electron"
# - "collect_results:femc_photon"
# - "collect_results:femc_pi0"
- "collect_results:lowq2_reconstruction_training"
script:
- snakemake $SNAKEMAKE_FLAGS --cores 1 results/metadata.json
- find results -print | sort | tee summary.txt
Expand Down
56 changes: 44 additions & 12 deletions benchmarks/lowq2/reconstruction_training/Snakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import os

# Get the LOWQ2_DATADIR environment variable, or use a default value if it is not set
outputdir = os.getenv("LOWQ2_DATADIR", "")
resultsdir = os.getenv("LOWQ2_RESULTSDIR", "")

# Creates or copies the feature and target tensors for the lowq2 reconstruction training into a new file.
rule lowq2_tensor_recon:
output:
"tensors.eicrecon.tree.edm4eic.root",
f"{outputdir}tensors.eicrecon.tree.edm4eic.root",
log:
"tensors.eicrecon.tree.edm4eic.root.log",
params:
input=expand("root://dtn-eic.jlab.org//work/eic2/EPIC/RECO/24.12.0/epic_craterlake/SIDIS/pythia6-eic/1.0.0/10x100/q2_0to1/pythia_ep_noradcor_10x100_q2_0.000000001_1.0_run{run}.ab.{number:04d}.eicrecon.tree.edm4eic.root", run=range(1,3), number=range(0, 20)),
f"{outputdir}tensors.eicrecon.tree.edm4eic.root.log",
params:
input=expand("root://dtn-eic.jlab.org//work/eic2/EPIC/RECO/24.12.0/epic_craterlake/SIDIS/pythia6-eic/1.0.0/10x100/q2_0to1/pythia_ep_noradcor_10x100_q2_0.000000001_1.0_run{run}.ab.{number:04d}.eicrecon.tree.edm4eic.root", run=range(1,2), number=range(0, 1)),
compact_xml="epic_lowq2.xml",
shell:
"""
Expand All @@ -18,10 +24,10 @@ rule lowq2_tensor_recon:
# Trains a regression model to predict the TaggerTrackerTargetTensor from the TaggerTrackerFeatureTensor.
rule lowq2_reconstruction_training:
input:
data="tensors.eicrecon.tree.edm4eic.root",
data=f"{outputdir}tensors.eicrecon.tree.edm4eic.root",
script="TaggerRegression.py",
output:
"TestTaggerRegression.onnx",
f"{outputdir}TestTaggerTrackerTransportation.onnx",
shell:
"""
python {input.script} --dataFiles {input.data} --outModelFile {output}
Expand All @@ -30,9 +36,9 @@ rule lowq2_reconstruction_training:
# Runs the inference with the default model.
rule lowq2_reconstruction_inference:
input:
data="tensors.eicrecon.tree.edm4eic.root",
data=f"{outputdir}tensors.eicrecon.tree.edm4eic.root",
output:
"TaggerInference.eicrecon.tree.edm4eic.root",
f"{outputdir}TaggerInference.eicrecon.tree.edm4eic.root",
params:
compact_xml="epic_lowq2.xml",
shell:
Expand All @@ -43,13 +49,13 @@ rule lowq2_reconstruction_inference:
-Pdd4hep:xml_files={params.compact_xml} \
"""

# Runs the inference with the new model.
# Check inference runs with the new model.
rule lowq2_reconstruction_new_inference:
input:
data="tensors.eicrecon.tree.edm4eic.root",
model="TestTaggerRegression.onnx",
data=f"{outputdir}tensors.eicrecon.tree.edm4eic.root",
model=f"{outputdir}TestTaggerTrackerTransportation.onnx",
output:
"TaggerInferenceNew.eicrecon.tree.edm4eic.root",
f"{outputdir}TaggerInferenceNew.eicrecon.tree.edm4eic.root",
params:
compact_xml="epic_lowq2.xml",
shell:
Expand All @@ -60,4 +66,30 @@ rule lowq2_reconstruction_new_inference:
-Pdd4hep:xml_files={params.compact_xml} \
-PLOWQ2:TaggerTrackerTransportationInference:modelPath={input.model} \
-Peicrecon:LogLevel=error \
"""

# Create plots showing the performance of a model.
rule lowq2_reconstruction_new_plot:
input:
data=f"{outputdir}tensors.eicrecon.tree.edm4eic.root",
model=lambda wildcards: f"{outputdir}{wildcards.model}.onnx",
output:
directory(expand(f"{resultsdir}{{model}}", model="{model}")),
shell:
"""
mkdir -p {output}
python TestModel.py --dataFiles {input.data} --modelFile {input.model} --outDir {output}
"""

# Create plots showing the performance of a model.
rule lowq2_reconstruction_old_plot:
input:
data=f"{outputdir}tensors.eicrecon.tree.edm4eic.root",
model=lambda wildcards: f"calibrations/onnx/{wildcards.model}.onnx",
output:
directory(expand(f"{resultsdir}{{model}}", model="{model}")),
shell:
"""
mkdir -p {output}
python TestModel.py --dataFiles {input.data} --modelFile {input.model} --outDir {output}
"""
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

print(f"Training data: {len(train_input_data)} samples")

epochs = 100
epochs = 1000
model = trainModel(epochs, train_loader, val_loader)

# Save the trained model to ONNX format
Expand Down
Loading

0 comments on commit 4646a89

Please sign in to comment.