Skip to content

Rework detector selection for preprocess loading #1116

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

Merged
merged 11 commits into from
May 30, 2025
Merged

Conversation

mmccrackan
Copy link
Contributor

This branch changes the way detectors are restricted when loading from either a single layer or multilayer preprocessing run. Detectors are now restricted to the number remaining at the end of the initial preprocess run.

Copy link
Contributor

@msilvafe msilvafe left a comment

Choose a reason for hiding this comment

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

One inline comment to address/discuss before merging.

Comment on lines 298 to 300
logger.info("Restricting detectors on all processes")
for process in pipe[:]:
process.select(meta)
Copy link
Contributor

@msilvafe msilvafe Mar 14, 2025

Choose a reason for hiding this comment

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

I think since you fixed this here, you don't need to run the select step in load_and_preprocess so on line 347 you should be able to run pipe.run with select=False and if other functions call load_preprocess_det_select before pipe.run then the select=False should be used there as well. But we should test that it doesn't break other things.

It would be awesome if load_and_preprocess_det_select could collect all of the restriction flags and union them and do one call to restrict as there is quite an overhead to each call to restrict (hence my suggestion to not call it again in pipe.run).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added select=False for both single and multilayer loading pipeline.run() calls. Tested in both cases and confirm they begin with the correct number of detectors and loading runs to completion.

It would be awesome if load_and_preprocess_det_select could collect all of the restriction flags and union them and do one call to restrict as there is quite an overhead to each call to restrict (hence my suggestion to not call it again in pipe.run).

For this, we could add an in_place option to the select functions which would apply flags if True and return the flags (or some new axis manager) instead if False. I think that would be the most general way of handling this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a good plan.

@mmccrackan mmccrackan requested a review from msilvafe April 9, 2025 14:58
Comment on lines +147 to +151
if in_place:
meta.restrict("dets", meta.dets.vals[keep])
return meta
else:
return keep
Copy link
Contributor

Choose a reason for hiding this comment

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

since this 5 line block is copied in every select step should we make a method of the Pipeline class called restrict or cut that takes in meta, in_place, and keep and then make these 5 lines: return self.cut(meta, keep, in_place)?

Comment on lines 1193 to 1201
if in_place:
meta.restrict("dets", meta.dets.vals[keep])
source_flags.restrict("dets", source_flags.dets.vals[keep])
else:
keep_all &= keep
if in_place:
return meta
else:
return keep_all
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this one different than the rest? This breaks my generalization :(

@mmccrackan
Copy link
Contributor Author

After some offline discussion we decided to just merge this without moving to a single function since there are differences in the handling between processing functions and other open PRs are adjusting them.

Added one more change to the noisy subscan flags which didn't have the in_place option added. I removed following check in that function:

if hasattr(proc_aman.noisy_dets_flags, "valid_dets"):

Since I think it should be guaranteed to exist and we don't do this check elsewhere. This makes sure it always returns either meta or keep.

@mmccrackan
Copy link
Contributor Author

Okay after the two latest changes I ran all the way through and reloaded with the iso-v2 configs and confirmed that it loads with the same number of detectors that survive to the end of the initial run.

@mmccrackan mmccrackan merged commit b6f1c04 into master May 30, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants