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

Generalize the search strategy to use a candidate generator #485

Merged
merged 12 commits into from
Feb 29, 2024

Conversation

jeremykubica
Copy link
Contributor

Remove the hard coded search strategy from C++ and replace it with a generator class in Python that creates a list of trajectories to search out of each pixel.

Copy link
Member

@DinoBektesevic DinoBektesevic left a comment

Choose a reason for hiding this comment

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

I like this, I've requested changes, but I'm not requiring them. I'm willing to approve pending hearing your thoughts on the proposed changes.

src/kbmod/candidate_generator.py Outdated Show resolved Hide resolved
src/kbmod/candidate_generator.py Outdated Show resolved Hide resolved
@@ -41,7 +42,7 @@ def get_angle_limits(self, config):
ang_max = config["average_angle"] + config["ang_arr"][1]
return [ang_min, ang_max]

def do_gpu_search(self, config, search):
def do_gpu_search(self, config, search, strategy):
Copy link
Member

Choose a reason for hiding this comment

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

I'd also just name this trajectory_generator, since a user could make a run method (eventually) be a logical loop like:

- sample a grid based generator
- run search, get results
- find most likely velocities/pixels/angles 
- resample with a finer grid generator

and now "strategy" becomes an overloaded term.

print(f"Average Angle = {config['average_angle']}")
print(f"Search Angle Limits = {ang_lim}")
print(f"Velocity Limits = {config['v_arr']}")
print(strategy.debug_string())
Copy link
Member

Choose a reason for hiding this comment

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

with str this becomes print(strategy). Nothing shameful about using dunder methods in Python.

)

# Do the actual search.
candidates = strategy.get_candidate_trajectories()
Copy link
Member

Choose a reason for hiding this comment

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

This, I agree will become a problem in the future where we can't, at least at the moment, be nearly as flexible on the CPP and CUDA side as we'd want. I don't have a good solution for that in my mind yet. We definitely can wrap at least this function in the near future to have a Python-binding that can leverage this flexibility:
https://github.com/dirac-institute/kbmod/blob/main/src/kbmod/search/stack_search.cpp#L193
but we definitely rely on having the Trajectories realized on the GPU to do the search:
https://github.com/dirac-institute/kbmod/blob/main/src/kbmod/search/kernels.cu#L272

The current proposal is not stopping us here I don't think, it just replaces a method with a list comprehension expression.

We have talked about doing "batch-like" searches before. We just need to figure out how do we create a batch of trajectories, do search, create new batch of traj's, do more search (what happens to results?) and then do that in for loop until the generator says stop. Easy peasy no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where we still need the list generation step. I don't have a good solution for it yet either.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jeremykubica jeremykubica merged commit 46de496 into main Feb 29, 2024
2 checks passed
@jeremykubica jeremykubica deleted the candidates_generator branch February 29, 2024 17:13
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