Add multi-index apply_time_correction with einsum contraction (variant)#104
Open
jon-proximafusion wants to merge 1 commit into
Open
Add multi-index apply_time_correction with einsum contraction (variant)#104jon-proximafusion wants to merge 1 commit into
jon-proximafusion wants to merge 1 commit into
Conversation
Variant of the multi-index apply_time_correction that evaluates the summed TCF-weighted sum over the parent-nuclide axis with an einsum contraction instead of a broadcast-multiply-and-reduce. This is substantially faster for large mesh tallies but shifts mean/std_dev by ~1e-15 relative (floating-point summation order), so results match develop to machine precision rather than bit-for-bit -- well below Monte Carlo statistical noise and regression-test tolerances. Same multi-index API and sum/sum_sq handling as the bitwise variant.
7533108 to
a419b3e
Compare
5 tasks
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
This is a faster variant of the multi-index
apply_time_correctionfrom #103. Like #103, it adds support for an iterable of time indices (returning a list of derived tallies, one per index) and reads/reshapes the tally arrays once instead of per call.The difference is in the summed (
sum_nuclides=True) path: the TCF-weighted reduction over the parent-nuclide axis is evaluated as aneinsumcontraction (BLAS-backed) rather than a Python-level broadcast-multiply-and-reduce. Variances combine in quadrature, sostd_devcontracts the squared values.Trade-off vs #103
The
einsumcontraction sums in a different order than the explicit broadcast-and-reduce, so results matchdevelopto machine precision (~1e-15 relative) rather than bit-for-bit. This is far below Monte Carlo statistical noise and well within regression-test tolerances, but it is the reason this is offered as a separate PR.develop.The two PRs are mutually exclusive; only one should be merged.
Behavior
Identical public API to #103:
index→ singleTally(unchanged API).index→list[Tally], one per index, in the order requested.sum_nuclides=True, the derived result leavessum/sum_squnset (the public accessors returnNonefor any derived tally, matchingdevelop). Keeping the per-nuclide arrays would only waste two full-array multiplies per index and would be shaped inconsistently with the poppedParentNuclideFilter, breakingTally.sparse.develop, not between scalar and multi-index calls here).Testing
Adds
test_apply_time_correction_multi_index, which checks each element of a multi-index call against the corresponding scalar call (mean, std_dev, filters, sum/sum_sq), that unordered/partial index sequences are honored, that scalar input still returns a singleTally, and that the original tally is left unmodified.Fixes # (issue)
Checklist