Add serialization for native random number generator of Pythia8 #247
Add serialization for native random number generator of Pythia8 #247
Conversation
|
There are couple of implementations here so far:
|
|
It turned out that that our save/restore functionality didn't work. The tests passed because |
|
The implementation, in principle, allowed to use any numpy's bit generator, by passing instead of integer seed an instance of bit generator like this The only problem is EposLHC which needed internally save and restore generators state. To allow this case to work, I added explicit structs of each of 5 bit generators in random.c. To choose the correct struct the id for each generator is added that is passed/set from python code.. |
|
It turned out that rng tests are not passed for EposLHCR, as it is relies of Urqmd internally. Urqmd has known issues with reproducibility of sequencies after resetting rng state, which means that there are some hidden state that is not reset by resetting rng state and influence rng state. I tried to investigate urqmd issue againt. However, it didn't give results. My conclusions about it:
|
|
Fix the problem with Pythia6 and add log info for it. |
|
For easier readability, |
afedynitch
left a comment
There was a problem hiding this comment.
Very nice implementation!
It could be a bit brittle if numpy makes many internal changes. We should add some sort of cron job to build chromo once a week with the latest version to check that but this doesn't need to happen here.
|
@jncots I still get an error when testing on WSL |
|
@afedynitch, I tested in my WSL environment and could not reproduce the problem. For a reference: Ubuntu 22.04.5 LTS (Jammy Jellyfish) Python: 3.12.12 numpy: 2.3.5 meson: 1.10.0 pytest: 9.0.2 pyhepmc: 2.15.1 |
|
The PR #247 adds serialization and deserialization for the native RNG state of the Pythia8, that allows saving and restoring the state of the generator. The PR introduces improvements and fixes related to RNGs across multiple generators and addresses related logging issues. Key Features and Changes
Known Issues and Resolved Dependencies
|
Add functions for setting/getting of 'RndmState' state in pybind11 pythia8 interface
cpp/_pythia8.cppand use them to implement Pythia8 class'srandom_stateproperty