Repository navigation
Speed up plot_pareto_front by replacing O(N * |P|) list lookup in _get_non_pareto_front_trials - #6938
Merged
kAIto47802 merged 1 commit intoNov 4, 2026
Conversation
… `_get_non_pareto_front_trials` Precompute the set of Pareto-optimal trial numbers in `_get_non_pareto_front_trials` instead of performing a linear `trial not in pareto_trials` scan over `FrozenTrial` objects for every trial. Signed-off-by: Parth Vadera <[email protected]>
Member
|
@kAIto47802 Could you review this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
In$O(N \cdot |P|)$ complexity where $N = \text{len(trials)}$ and $|P| = \text{len(pareto_trials)}$ .
optuna/visualization/_pareto_front.py,_get_non_pareto_front_trials(trials, pareto_trials)filters out Pareto-optimal trials usingif trial not in pareto_trials:inside a loop over alltrials. Becausepareto_trialsis alist[FrozenTrial], each membership check performs a linear scan comparing fullFrozenTrialobjects (params,distributions,user_attrs,system_attrs,intermediate_values, etc.), resulting inDescription of the Changes
Precompute$O(N \cdot |P|)$ $O(N + |P|)$ integer set lookups while preserving the exact output order and semantics.
pareto_trial_numbers = {trial.number for trial in pareto_trials}once and filter bytrial.number not in pareto_trial_numbers, reducing_get_non_pareto_front_trialsfromFrozenTrial.__eq__comparisons toMicro-benchmark (
N = 3,000trials,|P| = 1,500Pareto-front trials)listmembership onFrozenTrial):431.70 mssetmembership ontrial.number):0.21 ms(~2,036x speedup)Acknowledgments
constraints_funcinplot_pareto_front#3128, Unify pareto front #3389), @nabenabe0928 (Speed up non-dominated sort #5302), and @c-bata for designing and maintainingoptuna/visualization/_pareto_front.py.