Skip to content
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

Merged
merged 12 commits into from
Feb 15, 2024
Merged

Conversation

SimonHeybrock
Copy link
Member

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.

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.
Base automatically changed from fix-qxy to main February 12, 2024 11:43
@@ -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)
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this change (and fixed the tests instead). Previously there was an (maybe unintentional) conversion done in normalize, which this PR remove.

I opened #88 instead.

Can you have another brief look @nvaytet?

SimonHeybrock and others added 4 commits February 13, 2024 05:40
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),
Copy link
Member

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?

Copy link
Member Author

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.

@SimonHeybrock SimonHeybrock merged commit 31a113a into main Feb 15, 2024
3 checks passed
@SimonHeybrock SimonHeybrock deleted the optimize-normalize branch February 15, 2024 10:39
@SimonHeybrock SimonHeybrock mentioned this pull request Feb 26, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants