feat(backport): counter-based RNG for deterministic JER smearing#1536
Open
alefisico wants to merge 6 commits intoscikit-hep:backports-v0.7.xfrom
Open
feat(backport): counter-based RNG for deterministic JER smearing#1536alefisico wants to merge 6 commits intoscikit-hep:backports-v0.7.xfrom
alefisico wants to merge 6 commits intoscikit-hep:backports-v0.7.xfrom
Conversation
for more information, see https://pre-commit.ci
…sico/coffea into backports-v0.7.x_feat/JECs-jsonpog
5b92dc3 to
33939d7
Compare
Contributor
Author
dcc180c to
d55c910
Compare
for more information, see https://pre-commit.ci
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The current JER smearing in
CorrectedJetsFactoryusesnumpy.random, which produces different random numbers depending on how events are partitioned across chunks. This means the same jet can get different smearing corrections depending on the processing setup, making results non-reproducible.This PR adds an opt-in counter-based RNG (CBRNG) using the Squares algorithm (arXiv:2004.06278) that generates deterministic random numbers based on per-jet physics quantities (event number, phi, eta). The same jet always gets the same random number regardless of partitioning, chunk size, or parallelization strategy.
This is the v0.7.x backport of the same feature on master #1535 . The key difference is that CBRNG calls are executed eagerly with
numpy.asarray()instead of being wrapped inawkward.virtual, since v1's virtual arrays can produce stale data on sliced arrays.This developement was created by @chuyuanliu in our framework, and I am just putting it in the central coffea because I consider it important for other users.
Key points:
event_numberparameter onbuild()— when provided, uses CBRNG; when omitted (None), falls back to the legacy RNG. Fully backwards compatible.[event_number(64), phi_bits(32) << 32 | eta_bits(32)]virtualpitfallsFiles changed
coffea/jetmet_tools/CorrectedJetsFactory.py— addedevent_number/seedsparameters tobuild(), CBRNG path alongside legacy RNGcoffea/jetmet_tools/cbrng.py— new module implementing the Squares CBRNG algorithmcoffea/jetmet_tools/correctionlib_adapters.py— minor fixtests/test_correctionlib_adapters.py— addedtest_corrected_jets_factory_cbrngverifying determinism and partition independenceTest plan
test_corrected_jets_factory_cbrng— verifies same jets produce same smearing across calls