Skip to content

Add QMCSampler to TestRelativeSampler coverage and clamp log-float untransform at low bound - #6799

Merged
c-bata merged 2 commits into
optuna:masterfrom
yen-0:fix/cliplow
Sep 4, 2026
Merged

c-bata merged 2 commits into
optuna:masterfrom
yen-0:fix/cliplow

Conversation

@yen-0

@yen-0 yen-0 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Motivation

In _SearchSpaceTransform.untransform for FloatDistribution(log=True) , a direct round trip at the lower edge could come back slightly below low due to floating-point error, and that leaked into sampler behavior. The missing coverage showed up in sampler test matrices that had previously been removed.

Description of the changes

  • Clamp log-scale float untransform results to both ends of the valid range, using [low, nextafter(high, high - 1)].

  • Restore sampler coverage for the cases that exercise this path:

    • QMCSampler in RelativeSamplerTestCase

@yen-0
yen-0 marked this pull request as ready for review August 12, 2026 08:36
@c-bata

c-bata commented Aug 17, 2026

Copy link
Copy Markdown
Member

@gen740 @not522 Could you review this PR?

Comment thread tests/samplers_tests/test_samplers.py Resolved
@not522 not522 added the bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. label Aug 17, 2026
@yen-0 yen-0 changed the title Clamp log-float untransform at low bound and restore sampler coverage Add QMCSampler to TestRelativeSampler coverage and clamp log-float untransform at low bound Aug 19, 2026

@not522 not522 left a comment

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.

LGTM!

@not522 not522 changed the title Add QMCSampler to TestRelativeSampler coverage and clamp log-float untransform at low bound Add QMCSampler to TestRelativeSampler coverage and clamp log-float untransform at low bound Aug 20, 2026
@not522 not522 removed their assignment Aug 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has not seen any recent activity.

@github-actions github-actions Bot added the stale Exempt from stale bot labeling. label Aug 28, 2026
Comment thread optuna/_transform.py
if d.single():
param = trans_param
else:
param = min(trans_param, np.nextafter(d.high, d.high - 1))

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.

Would it make sense to use np.clip here as well?

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.

Here, min is used to ensure the suggested value falls within the range [low, high). Note that while the current specification uses [low, high], this remains unchanged to maintain backward compatibility with older behavior.
In this line, trans_param hasn't performed any transformations like exp, so I think that it can safely trust the values passed as arguments and doesn't need to perform clipping on the lower bound.

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.

Thank you for your review!

We plan to begin the code freeze process for the next release soon. While the discussion from these review comments is still ongoing, I'll merge the bug fixes from this PR to incorporate them in the next release.

@github-actions github-actions Bot removed the stale Exempt from stale bot labeling. label Aug 30, 2026
@c-bata c-bata added this to the v5.0.0 milestone Sep 4, 2026

@c-bata c-bata left a comment

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.

LGTM.

@c-bata
c-bata merged commit 6ac05f5 into optuna:master Sep 4, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants