Skip to content

Feature/yuxuan cl matching integration - #90

Open
MadivB wants to merge 4 commits into
mainfrom
feature/yuxuan-cl-matching-integration
Open

Feature/yuxuan cl matching integration#90
MadivB wants to merge 4 commits into
mainfrom
feature/yuxuan-cl-matching-integration

Conversation

@MadivB

@MadivB MadivB commented Jul 2, 2026

Copy link
Copy Markdown

Summary

I have added the run-cl-matching/ production step that will be auto-installed through the install_everything under adimn. This will run the alpha release version charge-light matching (QL matching) after the existing run-ndlar-flow/ step. It is the same as the one discribed in the technote that can be seen in the technote. I included here three similar workflows with the same architecture, but different geometry, mirroring the existing sim/data × ND/2x2 grid:

Script Detector / mode
run_cl_matching_ND_sim.sh ND-LAr, simulation
run_cl_matching_2x2_sim.sh 2x2, simulation
run_cl_matching_2x2_data.sh 2x2, real data

All three wrappers drive the external MadivB/CLMatching_AlphaRelease repo, which install_cl_matching.sh clones into run-cl-matching/CLMatching_AlphaRelease/.

Files

  • run-cl-matching/install_cl_matching.sh — clones the CLMatching repo, runs its check_install.py which surfaces the one non-bundled asset (the ~490 MB ND-LAr perceiver, hosted on the CLMatching GitHub Release) with the exact curl command to fetch it.
  • run-cl-matching/run_cl_matching_ND_sim.sh — ND simulation.
  • run-cl-matching/run_cl_matching_2x2_sim.sh — 2x2 simulation.
  • run-cl-matching/run_cl_matching_2x2_data.sh — 2x2 real data (input file taken from ND_PRODUCTION_CLMATCH_DATA_FILE; no upstream chain wiring since real DAQ data isn't produced by the ND_Production pipeline).
  • run-cl-matching/.gitignore — excludes the cloned CLMatching_AlphaRelease/ from this repo (mirrors what run-larnd-sim/ and run-ndlar-flow/ do).
  • admin/install_everything.sh — chains the new install step inside the detector-specific block.

Conventions followed

  • Each run_*.sh sources ../util/reload_in_container.inc.sh + ../util/init.inc.sh, consumes ND_PRODUCTION_* env vars, wraps heavy commands with the run helper for logging/timing, and writes outputs to <OUTDIR_BASE>/run-cl-matching/<OUT_NAME>/{FLOW,PT}/<subDir>/.
  • install_cl_matching.sh follows the same error-out-if-installed pattern as install_ndlar_flow.sh / install_larnd_sim.sh.
  • Uses the shared NERSC nersc-python (torch pre-installed); no separate venv is built.

Override knobs

  • ND_PRODUCTION_CLMATCH_REPO — override the CLMatching install location (defaults to $ND_PRODUCTION_INSTALL_DIR/CLMatching_AlphaRelease).
  • ND_PRODUCTION_CLMATCH_BRANCH — override the CLMatching git branch (default main).
  • ND_PRODUCTION_CLMATCH_VERSION — 2x2 algorithm version, v1.0 (default, error-matrix) or v2.0 (region-grow + tiebreaker).
  • ND_PRODUCTION_CLMATCH_DATA_FILE — 2x2 data input file path (default is the standard dune cfs beam-data reflow file).

Mode A (in-place HDF5) vs Mode B (.pt) for ND

run_cl_matching_ND_sim.sh inspects the FLOW file's calib_prompt_hits and calib_final_hits dtypes. If both reserve t_0 and t_cluster_id (the new dtype format), it copies the file into tmpOutDir, has CLMatching write the two fields directly into the compound HDF5 datasets, then mvs the modified .FLOW.hdf5 to outDir/FLOW/<subDir>/. For older FLOW files without those fields, CLMatching's aggregator falls back to producing a .pt under <CLMatching repo>/output/QLmatchingvAlpha/.

Testing

I did a test run before uploading this to you guys and verified twice end-to-end from an empty folder simulating a fresh NERSC user

Serious things that might worth mentioning and discussion (if this makes you a lot of trouble, I am fine with changing the dafaults)

fireworks4dune's stock slurm/fw_gpu.slurm.sh uses --ntasks-per-node=4 --gpus-per-task=1, giving each fireworks task only 1 GPU. Our wrappers default to 8 workers on 4 GPUs. When a ccl_matching.yaml spec is authored, the accompanying submission line should use --ntasks-per-node=1 --gpus-per-node=4 (or set N_GPUS=1 N_WORKERS_PER_GPU=1 in the base_env if 1-GPU-per-task is preferred — both are supported via env-var overrides).

MadivB added 4 commits June 28, 2026 20:56
New step that runs charge-light matching after run-ndlar-flow. Drives the
external CLMatching_AlphaRelease repo via three wrappers following the
ND_Production convention (sources util/init.inc.sh, reads ND_PRODUCTION_*
env vars, writes outputs under <stepname>/<OUT_NAME>/{FLOW,PT}/<subDir>/):

  run_cl_matching_ND_sim.sh    in-place HDF5 writeback (Mode A: flow file
                               reserves t_0/t_cluster_id on calib_prompt_hits
                               and calib_final_hits). Output is a modified
                               .FLOW.hdf5, not a .pt. Falls back to .pt for
                               older flow files without those fields.
  run_cl_matching_2x2_sim.sh   2x2 simulation -> .qlmatch2x2.pt
  run_cl_matching_2x2_data.sh  2x2 real DAQ data -> .qlmatch2x2.pt
                               (input via ND_PRODUCTION_CLMATCH_DATA_FILE,
                               no upstream chain)

install_cl_matching.sh clones https://github.com/MadivB/CLMatching_AlphaRelease.git
into this directory (CLMatching_AlphaRelease/) and runs check_install.py
to surface any missing assets. Uses the shared NERSC nersc-python (torch
already installed there) -- no dedicated venv built here.

admin/install_everything.sh: chain run-cl-matching install in alongside
the other steps.

The cloned CLMatching_AlphaRelease/ is .gitignored (mirrors what
run-larnd-sim/ and run-ndlar-flow/ do for their cloned sources).

CLMatching requires a 4-GPU node per task and 8 workers. Standard
fw_gpu.slurm.sh in fireworks4dune uses --ntasks-per-node=4 --gpus-per-task=1
which would give each fw task only 1 GPU; when a cl_matching spec yaml is
added later it should pair with a new slurm wrapper (--ntasks-per-node=1
--gpus-per-node=4) so each fw task owns the whole node.
…k tmpdir

Two bugs surfaced when running the wrappers fresh on a real GPU node:

1. 2x2 wrappers stripped '.hdf5' when computing the expected .pt name, but
   the underlying aggregate_2x2_to_pt.py keeps '.hdf5' in the output name
   ('<basename incl. .hdf5>.qlmatch2x2.pt'). The wrappers therefore failed
   the post-run existence check even though the .pt was produced correctly.
   Fix: use 'basename "\$inFile"' instead of 'basename "\$inFile" .hdf5'.

2. run_cl_matching_ND_sim.sh invoked scripts/process_one_flow_file.sh
   without an explicit out_dir, so worker NPZ shards landed at
   <CLMatching_repo>/output/QLmatchingvAlpha/<basename>/. Over 10k+ files
   this would explode the cloned repo's output/ dir.
   Fix: pass per-task \$workDir under tmpOutDir as the 2nd positional arg
   to process_one_flow_file.sh; preserve the worker logs under the
   canonical LOGS dir, then rm -rf \$workDir after the .FLOW.hdf5 is moved.

Verified Bug 1 fix against the .pt produced by the previous failing run
(file exists at fixed path, not at the buggy path).
…ching-integration

# Conflicts:
#	admin/install_everything.sh
The ND sim wrapper's `run env ... process_one_flow_file.sh` was tripping
`set -o errexit` because the underlying CLMatching launcher's trailing
`ls .../*.v_alpha_test.pt | head` fails rc=2 in Mode A (no .pt produced),
which `set -o pipefail` propagates. Even though the HDF5 writeback fully
succeeded, the wrapper aborted before running its Python sanity-check or
mv'ing the file to outDir/FLOW/<subDir>/.

Bracket the `run` call with `set +/-o errexit` so the exit code cannot
prematurely kill us; the Python sanity check below is the authoritative
Mode A success criterion. A companion fix in CLMatching_AlphaRelease
(commit 056026d) removes the underlying spurious exit for future runs,
but this belt-and-suspenders is cheap and lets the wrapper stay correct
even against pre-fix CLMatching checkouts.
@MadivB
MadivB requested review from mjkramer and sindhu-ku July 2, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant