Skip to content

Improve RNG state #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 30, 2025
Merged

Improve RNG state #403

merged 6 commits into from
Jun 30, 2025

Conversation

SeverinDiederichs
Copy link
Collaborator

@SeverinDiederichs SeverinDiederichs commented Jun 26, 2025

This PR improves the RNG handling in 3 ways:

  1. the initial seed was depending only on the AdePT initial seed, the event id, and the track id. Thus, if a particle left the GPU region and was injected again, it would have received the same seed. This is fixed by generating the seed by scrambling the original seed with the kinetic energy and the global time.

  2. When the new ID was generated from the rng state without advancing it, there must have been some truncation because multiple collisions in the trackIds were observed at a rate way too high. This is solved by advancing the state.

  3. When a positron fell below the tracking cut, it would annihilate to two gammas. However, this could happen after the first interaction, meaning the newRNG was already used on the first generated secondary. This would lead to collisions of state.

There are still too many collisions observed, which are currently under investigation.

The failing of the CI was just a random fluctuation, the accuracy is not impacted by this PR.

@phsft-bot
Copy link

Can one of the admins verify this patch?

Copy link
Contributor

@agheata agheata left a comment

Choose a reason for hiding this comment

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

Thanks for this important fix/feature

@agheata agheata merged commit ea251a0 into apt-sim:master Jun 30, 2025
3 checks passed
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.

3 participants