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

Parallelization #9

Merged
merged 5 commits into from
Jan 28, 2025
Merged

Parallelization #9

merged 5 commits into from
Jan 28, 2025

Conversation

danyoungday
Copy link
Contributor

Added parallel functions into the evaluator as well as a unit test to help verify

@danyoungday danyoungday self-assigned this Jan 28, 2025
:return: The metrics of the population.
"""
if self.n_jobs != 1:
num_jobs = self.n_jobs if self.n_jobs != -1 else len(population)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use 1 thread per candidate if we enter -1 for n_jobs

pop_results = self.evaluate_subset(pop_subset, verbose=verbose)
for candidate, metrics in zip(pop_subset, pop_results):
candidate.metrics = metrics
candidate.outcomes = self.outcomes
Copy link
Contributor Author

Choose a reason for hiding this comment

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

evaluate_population is now solely responsible for selecting the correct candidates to evaluate then setting their metrics. The meat of the work is done in the bottom-level functions which get delegated to by evaluate_subset

TODO: Make parallel_evaluation take in force argument and handle evaluating a subset of the population in
parallel.
"""
parallel_results = Parallel(n_jobs=n_jobs)(delayed(self.evaluate_candidate)(cand) for cand in population)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uses the simple joblib convention for parallelization

val_metrics = self.validator.evaluate_candidate(candidate)

# Get validation results manually without setting cand's metrics or outcomes
valid_results = self.validator.evaluate_subset(self.population, verbose=1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that the code is refactored to have a function that takes in a population and returns the metrics without setting them, validation is much cleaner

@danyoungday danyoungday merged commit e669c67 into main Jan 28, 2025
1 check passed
@danyoungday danyoungday deleted the parallelization branch January 28, 2025 19:22
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.

1 participant