Fix rollout edep mismatch and add truth overlay to Tier 4 observables
load_rollout_vs_truth was including rollout.py's synthetic termination- bookkeeping rows (escaped/unknown_pdg/energy_cutoff/max_steps) unfiltered: these carry step_length=0 and edep=pre_E dumped in one row for shower-level energy conservation, not a real per-step value, and nearly doubled the apparent mean edep in a repro. _load_world_frame_side now drops them, keeping only real generated steps (continuing or natural_end). Also documents the remaining, unfixable difference: rollout's edep on real steps absorbs any secondary-energy budget Stage 2 didn't allocate, which truth's edep never does. Adds compute_truth_observables, the truth-schema counterpart to compute_rollout_observables, so the Tier 4 event-level plots (plot_rollout_longitudinal/transverse/total_energy) can overlay a real reference computed directly from load_rollout_vs_truth's own truth file, without needing a separate paired giant predict --coord local file. Shares the depth/transverse binning core with compute_rollout_observables via a new _event_axis_depth_transverse helper. Updates rollout_validation.ipynb's Tier 4 section to use this reference and points ROLLOUT_FILE/TRUTH_FILE at a real prediction/shard pair. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -43,10 +43,10 @@
|
||||
"from giant.analysis import load_rollout_vs_truth, plot_kl_bars\n",
|
||||
"\n",
|
||||
"# `giant rollout` output for the shower(s) under test.\n",
|
||||
"ROLLOUT_FILE = \"/home/lars/Programming/giant/rollout.parquet\"\n",
|
||||
"ROLLOUT_FILE = \"/ceph/lbogner/geant_steps/predictions/e7ee73b7-70c9-4390-83e6-a31e50a7d3cb.parquet\"\n",
|
||||
"# Any held-out file sharing giant train's input schema (real miniCaloSim\n",
|
||||
"# steps) \u2014 e.g. the val split the rollout's seed events were drawn from.\n",
|
||||
"TRUTH_FILE = \"/home/lars/Programming/giant/val.parquet\"\n",
|
||||
"TRUTH_FILE = \"/ceph/lbogner/geant_steps/processed/steps/gen3/schema2/pbwo4/shard-009.parquet\"\n",
|
||||
"\n",
|
||||
"# sample_frac subsamples each file independently (kept memory-bounded for\n",
|
||||
"# large files); both default to every row when omitted.\n",
|
||||
@@ -188,9 +188,9 @@
|
||||
"source": [
|
||||
"## Tier 4: event-level (shower) observables\n",
|
||||
"\n",
|
||||
"Built on `compute_rollout_observables`, not `compute_event_observables_pl` \u2014 the rollout file carries its own `track_id`/`termination_reason` columns that the event-level aggregation needs, and the shower here already *is* a full autoregressive rollout rather than one-step generations re-aggregated by event.\n",
|
||||
"Built on `compute_rollout_observables` for the rollout side, not `compute_event_observables_pl` \u2014 the rollout file carries its own `track_id`/`termination_reason` columns that the event-level aggregation needs, and the shower here already *is* a full autoregressive rollout rather than one-step generations re-aggregated by event.\n",
|
||||
"\n",
|
||||
"To overlay a real reference profile, pass a *paired* `giant predict --coord local` file for the same held-out events as `reference_path` below (see `analysis/export_rollout_observables.py`) \u2014 `TRUTH_FILE` above can't serve as that reference directly, since it's the raw training-input schema, not predict output. Leave `reference_path = None` to skip the overlay."
|
||||
"The real-shower overlay comes from `compute_truth_observables(TRUTH_FILE)` \u2014 the truth-side counterpart, computed directly from the same raw truth-schema file used for Tiers 1-3 above (no separate paired `giant predict --coord local` file needed, unlike `analysis/export_rollout_observables.py`'s `reference_path`)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -200,14 +200,12 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from giant.analysis import compute_rollout_observables, compute_event_observables_pl\n",
|
||||
"from giant.analysis import compute_rollout_observables, compute_truth_observables\n",
|
||||
"from giant.analysis import plot_rollout_longitudinal, plot_rollout_transverse\n",
|
||||
"from giant.analysis import plot_rollout_total_energy\n",
|
||||
"\n",
|
||||
"obs = compute_rollout_observables(ROLLOUT_FILE)\n",
|
||||
"\n",
|
||||
"reference_path = None # optional: a `giant predict --coord local` file, see above\n",
|
||||
"reference = compute_event_observables_pl(reference_path) if reference_path else None"
|
||||
"reference = compute_truth_observables(TRUTH_FILE)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user