Skip to content

Refactor qConstrainedLogEI - #6779

Merged
kAIto47802 merged 8 commits into
optuna:masterfrom
sawa3030:refactor-on-6744
Aug 7, 2026
Merged

kAIto47802 merged 8 commits into
optuna:masterfrom
sawa3030:refactor-on-6744

Conversation

@sawa3030

Copy link
Copy Markdown
Contributor

Motivation

Description of the changes

  • Simplify the handling of QMC seeds.
  • Avoid accessing private attributes from qConstrainedLogEI.

@sawa3030

Copy link
Copy Markdown
Contributor Author

I’ll mark this PR as ready for review once #6744 has been merged.

@sawa3030 sawa3030 mentioned this pull request Jul 29, 2026
@sawa3030
sawa3030 marked this pull request as ready for review August 3, 2026 01:28

@nabenabe0928 nabenabe0928 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@not522

not522 commented Aug 4, 2026

Copy link
Copy Markdown
Member

@kAIto47802 Could you review this PR?

@sawa3030 sawa3030 mentioned this pull request Aug 5, 2026
Comment thread optuna/_gp/acqf.py Resolved
Comment thread optuna/_gp/acqf.py Resolved
Comment thread optuna/_gp/acqf.py Resolved
Comment thread optuna/_gp/acqf.py Resolved
Comment thread optuna/_gp/acqf.py Resolved
Comment thread optuna/_gp/acqf.py Resolved
@sawa3030

sawa3030 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@kAIto47802 Thank you for pointing it out. I’ve applied the change!

Comment thread optuna/samplers/_gp/sampler.py Outdated
Comment on lines +53 to +55
# NOTE(nabe): Do NOT use 1 << 31 to avoid overflow. Multi-objective and constrained optimizations
# use qmc_seed + buffer. Since buffer is sufficiently small (like ~30), using `1 << 30` guarantees
# no overflow.

@kAIto47802 kAIto47802 Aug 5, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This comment seems inaccurate. SobolEngine internally uses torch.Generator.manual_seed, whose officially documented valid seed range is [-2^63, 2^64 - 1]. Therefore, 1 << 31 is within the supported range:
https://docs.pytorch.org/docs/2.13/generated/torch.Generator.html#torch.Generator.manual_seed

Also, the scalar result of RandomState.randint(...) and the subsequent i + 1 addition are handled as Python integers, so they do not overflow at the 32-bit boundary.

Suggested change
# NOTE(nabe): Do NOT use 1 << 31 to avoid overflow. Multi-objective and constrained optimizations
# use qmc_seed + buffer. Since buffer is sufficiently small (like ~30), using `1 << 30` guarantees
# no overflow.
# NOTE(nabe): Multi-objective and constrained optimization may derive QMC seeds by adding small
# (e.g., around 30) offsets to a base seed. Use `1 << 30` as a conservative upper bound.

@kAIto47802

Copy link
Copy Markdown
Collaborator

Thank you for the update! It almost looks good to me, with some comments.

@sawa3030

sawa3030 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Thank you! I had missed that point. I’ve updated the comment accordingly. PTAL!

Comment thread optuna/samplers/_gp/sampler.py Resolved

@kAIto47802 kAIto47802 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for the update! LGTM

@kAIto47802
kAIto47802 merged commit d02dad5 into optuna:master Aug 7, 2026
13 checks passed
@kAIto47802 kAIto47802 added the code-fix Change that does not change the behavior, such as code refactoring. label Aug 7, 2026
@kAIto47802 kAIto47802 added this to the v5.0.0 milestone Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-fix Change that does not change the behavior, such as code refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants