-
Notifications
You must be signed in to change notification settings - Fork 2
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
Optimize spectra merge and normalization #81
Conversation
This adds the following optimizations: - Bypass some multi-threading shortcomings of DataArray.bin - Avoid bins.concat where possible - Use in-place normalization I have tried this on a 10 GByte file and it shaves off several seconds of runtime when returning event data.
src/esssans/loki/io.py
Outdated
@@ -38,6 +38,8 @@ def _patch_data( | |||
) -> sc.DataArray: | |||
out = da.copy(deep=False) | |||
if out.bins is not None: | |||
# Currently ScippNexus adds 32 bit event weights, this may cause trouble. | |||
out.bins.data = out.bins.data.to(dtype='float64', copy=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this also happen with the ISIS files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so actually. We should probably have a chat about this. It would be nice if we could keep 32 bit until needed, so I was not happy about changing this here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes #84. For 1e9 events this reduces the time for the call to this function from 10 seconds to 1 second.
Simpler and faster event-mode upper-bound broadcast
atol=sc.scalar(1e-11), | ||
# Could be 1e-11, but currently the workflow defaults to float32 data, as | ||
# returned by ScippNexus. | ||
rtol=sc.scalar(1e-7), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow anymore. So the changes you made here have degraded the accuracy of the results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because I change numerator / denominator
to numerator /= denominator
. So previously we ended up converting to float64
in that step.
This adds the following optimizations:
I have tried this on a 10 GByte file and it shaves off several seconds of runtime when returning event data.