Skip to content

Update YZ sim to address large memory usage#905

Open
SFBayLaser wants to merge 11 commits into
developfrom
feature/usher_fourmoduleyzsim
Open

Update YZ sim to address large memory usage#905
SFBayLaser wants to merge 11 commits into
developfrom
feature/usher_fourmoduleyzsim

Conversation

@SFBayLaser
Copy link
Copy Markdown
Contributor

@SFBayLaser SFBayLaser commented Jun 2, 2026

This PR provides the necessary updates to utilize improvements in the wirecell toolkit to address the ICARUS YZ simulation's large memory usage. While the main changes are in the toolkit itself we have modified the detector simulation at the ICARUS level to break the TPC simulation into four separate producer modules. At the same time we are maintaining the non-YZ simulation to a single producer module. This requires updates at the stage 0 processing level as well for the two cases.

At this point the comparison of non-YZ (top) to YZ (bottom) cpu and memory usage is:
image

image

Generally, we are now running the YZ sim with more than a 2x reduction in memory usage

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ICARUS WireCell-based YZ simulation configuration to reduce peak memory usage by splitting the YZ TPC simulation into four per-TPC producer modules, while also refactoring the Jsonnet graph generation to avoid expensive g.uses() expansion/dedup behavior.

Changes:

  • Add a new per-TPC YZ Jsonnet graph (wcls-per-tpc-...) driven by tpc_idx, designed to be run by four separate WireCellToolkit modules.
  • Refactor the existing multi-TPC YZ Jsonnet to use shared YZMap nodes and a memoized DFS-based uses resolver; update sim.jsonnet to derive YZ pipeline counts from tools.anodes.
  • Update detsim and stage0 FHiCL wiring for the per-TPC YZ module labels (daq0..daq3) and adjust YZ SimChannel merge inputs accordingly.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
icaruscode/TPC/ICARUSWireCell/icarus/wcls-per-tpc-sim-drift-simchannel-yzsim.jsonnet New per-TPC YZ simulation graph parameterized by tpc_idx to enable 4-module execution.
icaruscode/TPC/ICARUSWireCell/icarus/wcls-multitpc-sim-drift-simchannel-yzsim-refactored.jsonnet Refactors YZ graph pieces (YZMap, sink, uses traversal) and speeds up configuration emission.
icaruscode/TPC/ICARUSWireCell/icarus/wcls-multitpc-sim-drift-simchannel-refactored.jsonnet Replaces g.uses() emission with the same memoized DFS resolver (non-YZ path).
icaruscode/TPC/ICARUSWireCell/icarus/sim.jsonnet Makes YZ transform/reframer/analog pipeline counts depend on nanodes for per-TPC slicing.
icaruscode/TPC/ICARUSWireCell/detsimmodules_wirecell_per_TPC_ICARUS.fcl New detsim module definitions for running YZ as four modules (daq0..daq3) plus overlay variants.
icaruscode/TPC/ICARUSWireCell/detsimmodules_wirecell_ICARUS.fcl Switches the base icarus_simwire_wirecell config to the YZ-sim Jsonnet.
fcl/standard/standard_mc_all_stage0_icarus.fcl Changes the standard stage0 include to the YZ-specific stage0 config.
fcl/reco/Stage0/mc/stage0_run2_wcdnn_icarus_mc.fcl Changes the stage0+DNN entry point to include the YZ-specific stage0 config.
fcl/reco/Stage0/mc/stage0_run2_wc_yz_icarus_mc.fcl New stage0 config variant that overrides decoder fragment labels for per-TPC (daq0..daq3) inputs.
fcl/reco/Stage0/mc/stage0_run2_wc_raw_icarus_mc.fcl Switches the “keep raw digits” stage0 config to include the YZ-specific stage0 config.
fcl/reco/Stage0/mc/stage0_run2_wc_icarus_mc_notriggersim.fcl Switches the “no trigger sim” stage0 config to include the YZ-specific stage0 config.
fcl/g4/mergesimsources_icarus.fcl Updates YZ SimChannel merge input labels to use daq0..daq3:simpleSC*.
fcl/detsim/detsim_2d_icarus_refactored.fcl Includes the new per-TPC WireCell detsim module definitions (non-YZ still uses single daq).
fcl/detsim/detsim_2d_icarus_refactored_yzsim.fcl Rewires YZ detsim to run daq0..daq3 instead of a single daq producer.
fcl/detsim/detsim_2d_icarus_refactored_yzsim_overlay.fcl Updates overlay YZ detsim overrides to target daq0..daq3 producers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +31
local g = import 'pgraph.jsonnet';
local f = import 'pgrapher/common/funcs.jsonnet';
local wc = import 'wirecell.jsonnet';

local io = import 'pgrapher/common/fileio.jsonnet';
local tools_maker = import 'pgrapher/experiment/icarus/icarus_tools.jsonnet';
local base = import 'pgrapher/experiment/icarus/simparams.jsonnet';

Comment on lines +83 to +87
local tpc_idx = std.parseInt(std.extVar('tpc_idx'));
local apa_lo = tpc_idx * 2; // 2 anodes per TPC
local local_iota = std.range(0, 89); // 90 per-anode-plane-response branches
local volname = ["EE", "EW", "WE", "WW"];

// product instances match the single-module reference run.
// ---------------------------------------------------------------------------
local overlay_drifter = std.extVar("overlay_drifter");
local localeLiftime = [std.extVar('lifetime') * wc.us,std.extVar('lifetime') * wc.us,std.extVar('lifetime') * wc.us,std.extVar('lifetime') * wc.us,std.extVar('lifetime') * wc.us,std.extVar('lifetime') * wc.us,std.extVar('lifetime') * wc.us,std.extVar('lifetime') * wc.us];
Comment on lines +213 to +217
structs: {
DL: 4e-9
DT: 8.8e-9
coh_noise_scale: 1
gain0: 1.705212e1
Comment on lines +360 to +364
structs: {
DL: 4e-9
DT: 8.8e-9
coh_noise_scale: 1
gain0: 1.705212e1
@@ -1 +1 @@
#include "stage0_run2_icarus_mc.fcl"
#include "stage0_run2_wc_yz_icarus_mc.fcl"
@@ -1,3 +1,3 @@
#include "stage0_run2_wc_icarus_mc.fcl"
#include "stage0_run2_wc_yz_icarus_mc.fcl"
## This fhicl file takes the standard stage 0 wc mc file and keeps the raw digits
##
#include "stage0_run2_wc_icarus_mc.fcl"
#include "stage0_run2_wc_yz_icarus_mc.fcl"
@@ -1,4 +1,4 @@
#include "stage0_run2_wc_icarus_mc.fcl"
#include "stage0_run2_wc_yz_icarus_mc.fcl"
plugins: ["WireCellPgraph", "WireCellGen","WireCellSio","WireCellRoot","WireCellLarsoft", "WireCellHio"]
// needs to be found via your WIRECELL_PATH
configs: ["pgrapher/experiment/icarus/wcls-multitpc-sim-drift-simchannel-refactored.jsonnet"]
configs: ["pgrapher/experiment/icarus/wcls-multitpc-sim-drift-simchannel-yzsim-refactored.jsonnet"]
@SFBayLaser
Copy link
Copy Markdown
Contributor Author

The above PR is compatible with larsoft v10_20_09 and later. It also requires icarus_data v10_20_03.

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.

2 participants