Skip to content

Seed per-track RNG from the unique Geant4 event ID - #2580

Merged
sethrj merged 3 commits into
celeritas-project:developfrom
esseivaju:fix-reseed-event-correlation
Oct 25, 2026
Merged

sethrj merged 3 commits into
celeritas-project:developfrom
esseivaju:fix-reseed-event-correlation

Conversation

@esseivaju

Copy link
Copy Markdown
Member

With CELERITAS_RESEED=track, each primary's RNG is seeded from (seed, event ID, primary ID). Geant4 offload always sets the local event ID to 0, and primary IDs restart at 0 each event. So the k-th offloaded primary of every event, on every thread, got the same random stream, and its secondaries branched the same way. This adds to #2124.

  • Primary gains a UniqueEventId unique_event_id, which LocalTransporter sets from the Geant4 event ID.
  • Per-track seeding uses it, falling back to the local EventId when it's unset, so celer-sim and existing tests are unchanged.
  • initialize_rng_state takes a 64-bit event ID. States are unchanged for IDs below 2^32.
  • New tests: InitializeRngStateTest.wide_event_id and TrackInitHostTest.unique_event_rng.

Behavior change: Geant4 offload results change with RESEED=track. trackslot and celer-sim results are unchanged.

Note: with RESEED=track, global/Stepper and global/StepperGeant fail before and after this PR. Their expected values assume trackslot seeding, and some primaries lack a primary_id. CI doesn't build this mode.


AI-assisted: implemented with Claude Code (Claude Opus 5.5).

🤖 Generated with Claude Code

Take a 64-bit event ID in initialize_rng_state so that a unique event
number (e.g. from Geant4) can be mixed into per-track seeds. SplitMix64
already xors 64-bit values into its state, so initializers are unchanged
for all event IDs that fit in 32 bits.

Assisted-by: Claude Code (Claude Opus 5.5)
With CELERITAS_RESEED=track, primaries are seeded from the seed, their
event ID, and their primary ID. Offloaded Geant4 primaries always have
the local event ID 0 (the slot used for counting tracks), and their
primary IDs restart at zero each event, so the k-th offloaded primary of
every event, on every thread, got the same random stream.

Add a UniqueEventId to Primary, set it from the Geant4 event ID in
LocalTransporter, and seed from it, falling back to the local event ID
when it is unset.

Behavior change: Geant4 offload results change with
CELERITAS_RESEED=track. celer-sim and trackslot reseeding are unchanged.

Assisted-by: Claude Code (Claude Opus 5.5)
@esseivaju esseivaju added ai-assisted Generated/refactored substantially with agentic/LLM AI tools bug Something isn't working external Dependencies and framework-oriented features labels Oct 23, 2026
@esseivaju
esseivaju marked this pull request as ready for review October 23, 2026 18:21
@esseivaju
esseivaju requested review from davidsgr and sethrj and removed request for sethrj October 23, 2026 18:22
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Test summary

 6 468 files  10 669 suites   19m 23s ⏱️
 2 438 tests  2 390 ✅  48 💤 0 ❌
38 166 runs  37 923 ✅ 243 💤 0 ❌

Results for commit 5134a25.

♻️ This comment has been updated with latest results.

Comment thread src/accel/LocalTransporter.cc
Comment thread src/celeritas/track/detail/ProcessPrimariesExecutor.hh
Add a todo from review: seeding from event IDs read from input files is
based on flawed assumptions. Event and stream IDs, and seeding from the
unique event ID and Geant4 track ID, should be revisited along with the
supported threading/tasking models.

Assisted-by: Claude Code (Claude Opus 5.5)
@codecov

codecov Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.99%. Comparing base (7032e53) to head (5134a25).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2580      +/-   ##
===========================================
+ Coverage    86.98%   86.99%   +0.01%     
===========================================
  Files         1420     1421       +1     
  Lines        46043    46100      +57     
  Branches     14028    14061      +33     
===========================================
+ Hits         40050    40106      +56     
  Misses        4681     4681              
- Partials      1312     1313       +1     
Files with missing lines Coverage Δ
src/accel/LocalTransporter.cc 66.38% <100.00%> (-0.19%) ⬇️
src/celeritas/phys/Primary.hh 100.00% <ø> (ø)
...celeritas/track/detail/ProcessPrimariesExecutor.hh 100.00% <ø> (ø)
src/corecel/random/engine/InitializeRngState.hh 100.00% <100.00%> (ø)

... and 51 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sethrj
sethrj added this pull request to the merge queue Oct 25, 2026
Merged via the queue into celeritas-project:develop with commit 6ee8d00 Oct 25, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Generated/refactored substantially with agentic/LLM AI tools bug Something isn't working external Dependencies and framework-oriented features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants