Avoid storing inconsistent sum/sum_sq on summed D1S tallies#3949
Merged
Conversation
For sum_nuclides=True, apply_time_correction returns a derived tally with the ParentNuclideFilter removed. The previous code left _sum/_sum_sq set to per-parent-nuclide arrays shaped for the pre-removal filter set. These are unreachable through the public Tally.sum/sum_sq accessors (which return None for any derived tally) and are inconsistent with the tally's remaining filters. Set sum/sum_sq to None for the summed result (matching the observable develop behavior, since the accessors already return None) and skip the two full-size array multiplies that are never read. mean/std_dev are unchanged bit-for-bit. This speeds up the summed path by up to ~2.8x for large mesh tallies by not computing the discarded arrays.
bb451c5 to
48ee0ec
Compare
paulromano
approved these changes
May 30, 2026
Contributor
paulromano
left a comment
There was a problem hiding this comment.
LGTM. Thanks @jon-proximafusion!
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.
Description
I think we are doing some compute that we don't need to when working with D1S tallies.
For sum_nuclides=True, apply_time_correction returns a derived tally with the ParentNuclideFilter removed. The previous code left _sum/_sum_sq set to per-parent-nuclide arrays shaped for the pre-removal filter set. These are unreachable through the public Tally.sum/sum_sq accessors (which return None for any derived tally) and are inconsistent with the remaining filters, so converting such a tally with Tally.sparse raises a reshape error.
Set sum/sum_sq to None for the summed result (matching the observable develop behavior) and skip the two full-size array multiplies that are never read. mean/std_dev are unchanged bit-for-bit. This fixes Tally.sparse on summed D1S tallies and speeds up the summed path for large mesh tallies by not computing the discarded arrays.
Fixes # (issue)
Checklist