Skip to content

Restart a chain with RetryChainFromStart from the simulation state before its first pass - #213

Merged
jbeirer merged 1 commit into
mainfrom
chain-restart-restores-state
Nov 24, 2026
Merged

jbeirer merged 1 commit into
mainfrom
chain-restart-restores-state

Conversation

@jbeirer

@jbeirer jbeirer commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

With RetryChainFromStart(), a chain (TFCSParametrizationChain, TFCSParametrizationBinnedChain, TFCSParametrizationPDGIDSelectChain) that gets a retry request runs the whole chain again on the same TFCSSimulationState. The parametrizations before the one asking for the retry have already changed the state (deposited cell energies, layer energies, auxiliary info) and do it again. Example: A deposits 10 MeV into a cell, B asks for one retry, A deposits another 10 MeV, B succeeds: the cell has 20 MeV. The existing RestartFromStart test counted calls only. Retrying a single parametrization is not affected: a parametrization asks for a retry only before it changes the state (see the hit-and-miss in TFCSPCAEnergyParametrization). The bug is inherited: TFCSParametrizationChain::simulate in Athena upstream/main (ISF_FastCaloSimEvent) restarts on the same state too. Nothing to port from Athena.

Change

When RetryChainFromStart() is set, simulate_with_restarts copies the simulation state before the first pass and restores it before each repeated pass, so every pass starts from the same state. The random engine is not part of the restored state, so a repeated pass draws new random numbers. Chains without the flag do not copy anything. New test ChainRetryTest.RestartStartsFromTheInitialState checks the cell energy, the layer energy and the auxiliary info after a restart, as well as an auxiliary value set before the chain.

Checks

Run on main (73c5cc7) with #205 to #213 together, against main:

  • GCC 15 (LCG_110, developer build): 0 warnings; ctest 138/138 passed (main: 128/128), incl. the unchanged AtlasTransportTests and AtlasSimTests references
  • AtlasBenchmark dump (BENCH_N=50): byte-identical to main
  • SliceCheck on the MC23 file TFCSparam_dev_Hybrid_Ha_v5_all_baryons_0_500.root (BENCH_N=20): byte-identical to main, max RSS 4.76 GB on both
  • clang-format 20.1.8
  • GCC 16 and Clang 22 with the CI flags: 0 warnings
  • Alma 10 ci-linux (clang-tidy 21, cppcheck): 0 warnings; its ctest 138/138 passed
  • Production files: no TFCSParametrizationChain, TFCSParametrizationBinnedChain or TFCSParametrizationPDGIDSelectChain in TFCSparam_AF3_MC23_Sep23.root has RetryChainFromStart() set, so production simulation is unchanged. All 564 TFCSEnergyAndHitGANV2 report RetryChainFromStart() because their kGANfreemem is the same bit (BIT(17), as in Athena), but TFCSEnergyAndHitGANV2::simulate does not use simulate_with_restarts, so this PR changes nothing for them (that bit clash is reported separately)

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4125eb86-8d66-47f1-ab90-7176db395da8
Commits

Reviewing files that changed from the base of the PR and between 73c5cc7 and b2a93a6.

Files selected for processing: 6

  • include/FastCaloSim/Core/TFCSParametrizationChain.h
  • include/FastCaloSim/Core/TFCSParametrizationChain.icc
  • source/Core/TFCSParametrizationBinnedChain.cxx
  • source/Core/TFCSParametrizationChain.cxx
  • source/Core/TFCSParametrizationPDGIDSelectChain.cxx
  • test/source/ChainRetryTests.cxx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
...nclude/FastCaloSim/Core/TFCSParametrizationChain.h 85.00% <ø> (ø)
...lude/FastCaloSim/Core/TFCSParametrizationChain.icc 93.75% <100.00%> (+1.15%) ⬆️
source/Core/TFCSParametrizationBinnedChain.cxx 52.38% <ø> (ø)
source/Core/TFCSParametrizationChain.cxx 67.81% <ø> (ø)
...ource/Core/TFCSParametrizationPDGIDSelectChain.cxx 95.45% <ø> (ø)
test/source/ChainRetryTests.cxx 99.12% <100.00%> (-0.88%) ⬇️

@jbeirer
jbeirer merged commit 130c993 into main Nov 24, 2026
19 checks passed
@jbeirer
jbeirer deleted the chain-restart-restores-state branch November 24, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Issues affecting the CI tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant