Skip to content

Speed up log pdf in _BatchedTruncNormDistributions by vectorization#6220

Merged
y0z merged 2 commits intooptuna:masterfrom
nabenabe0928:enhance/vectorize-cont-log-pdf
Aug 1, 2025
Merged

Speed up log pdf in _BatchedTruncNormDistributions by vectorization#6220
y0z merged 2 commits intooptuna:masterfrom
nabenabe0928:enhance/vectorize-cont-log-pdf

Conversation

@nabenabe0928
Copy link
Copy Markdown
Contributor

Motivation

The vectorization for continuous distributions can speed up for multivariate=True.

Description of the changes

  • Use vectorization instead of dimension-wise log pdf calls

@nabenabe0928 nabenabe0928 added the enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. label Jul 28, 2025
@c-bata
Copy link
Copy Markdown
Member

c-bata commented Jul 30, 2025

@not522 @y0z Could you review this PR?

@c-bata c-bata assigned not522 and y0z Jul 30, 2025
Copy link
Copy Markdown
Member

@not522 not522 left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines -132 to -133
x_lower = np.maximum(xi_uniq - d.step / 2, lower_limit)[:, np.newaxis]
x_upper = np.minimum(xi_uniq + d.step / 2, upper_limit)[:, np.newaxis]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note: Since x is a sampled value, it is within the range of lower_limit and upper_limit.

@not522 not522 removed their assignment Jul 31, 2025
Copy link
Copy Markdown
Member

@y0z y0z left a comment

Choose a reason for hiding this comment

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

LGTM

@y0z y0z merged commit e1171f5 into optuna:master Aug 1, 2025
14 checks passed
@y0z y0z removed their assignment Aug 1, 2025
@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Change that does not break compatibility and not affect public interfaces, but improves performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants