Skip to content

Reduce allocations and logarithm calculations in categorical TPE - #273

Merged
y0z merged 1 commit into
mainfrom
review/issue-267-categorical
Oct 13, 2026
Merged

y0z merged 1 commit into
mainfrom
review/issue-267-categorical

Conversation

@y0z

@y0z y0z commented Oct 13, 2026

Copy link
Copy Markdown
Member

Represent categorical kernels using observed category indices and shared matching/nonmatching probabilities instead of per-observation probability arrays. Compute logarithms outside the observation loop to reduce allocations and repeated calculations during candidate scoring.

Closes #267.

Original implementation by @tkng, cherry-picked from 453a2a2 without code changes, preserving the original commit author.

Categorical TPE allocated an array of category probabilities for each
observation. Candidate scoring then recalculated logarithms for every
observation.

Each observation has one probability for its observed category and another
for all other categories. Store the observed category indices and these
shared probabilities instead of the arrays. Compute the two logarithms
once per density call and reuse them throughout the observation loop.

Preserve smoothing, the uniform prior, mixture weights, and correlations
between parameters. Add regression tests for probability values, weighted
joint densities, and correlated sampling.
@y0z
y0z marked this pull request as ready for review October 13, 2026 09:31
@y0z
y0z merged commit cbd7fd7 into main Oct 13, 2026
8 checks passed
@y0z
y0z deleted the review/issue-267-categorical branch October 13, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multivariate categorical TPE repeatedly calculates logarithms during candidate scoring

2 participants