Repository navigation
Align constraint observations by name in GPSampler - #6887
Conversation
Close pyplot figures retained by earlier tests before rendering the empty-study regression, and close the returned figure afterward. Keep RuntimeWarnings as errors so invalid numerical operations still fail.
|
@not522 @kAIto47802 Could you review this PR? |
| if any(len(_constraint_vals[0]) != len(c) for c in _constraint_vals): | ||
| raise ValueError("The number of constraints must be the same for all trials.") | ||
| constraints = [trial.constraints for trial in trials] | ||
| constraint_keys = constraints[0].keys() |
There was a problem hiding this comment.
Thank you for your PR!
I think it would be better to arrange the keys in alphabetical order, as this makes it easier to ensure the reproducibility of optimization.
| constraint_keys = constraints[0].keys() | |
| constraint_keys = sorted(constraints[0].keys()) |
There was a problem hiding this comment.
Updated in e01f706. I sorted the constraint names alphabetically while keeping key-set validation separate. The tests now check a reversed first trial as well as later reporting order, and all 36 three-constraint order pairs produce the same canonical matrix. The focused GP/EDF tests pass (80 passed, one CUDA case deselected), along with Ruff and full-repository mypy. Current-head CI has 12 passing contexts. The Windows job failed in the unchanged default-TPE parallel test with sqlite3.OperationalError: database is locked. Could you rerun that job?
Motivation
GPSamplerfits one Gaussian process per constraint, but collecting each trial'sconstraints.values()mixes different functions when users report the same names in different orders. The feasibility mask remains unchanged and conceals the mismatched model inputs.Description of the changes
I sort constraint names alphabetically and gather every trial's values by those names. I retain key-set validation so different names raise
ValueError, including when their counts match. The canonical order also removes dependence on the first trial's reporting order, as requested in review.Regression coverage checks named and numeric-index keys, inconsistent name sets, reordered first and subsequent trials, and seeded suggestions for single- and multi-objective studies. Storage formats, feasibility thresholds, GP fitting and acquisition algorithms are unchanged. Legacy sequence constraints use their existing string-index names in canonical string order.
The separate EDF figure cleanup is already upstream. This PR contains only the GP sampler and its tests.
Validation of
e01f706on Windows:pytest tests/samplers_tests/test_gp.py tests/visualization_tests/test_edf.py -k 'not cuda_default_device' -q -W error::RuntimeWarning: 80 passed, one CUDA-default-device case deselected, four existing UserWarnings.The two new canonical-order matrix cases fail on the preceding head and pass after this update. Current-head CI has 12 passing check contexts. The Windows job reports 5,136 passed, 69 skipped and one failure: the unchanged
test_optimize_parallel_timeout[grpc_rdb--1-None]test hitsqlite3.OperationalError: database is lockedwhile writing a trial parameter. That test uses the default TPE sampler and does not call the changed GP constraint helper. A maintainer must rerun the failed job. The full test suite, cross-process reproducibility, Linux/macOS and optimization-quality benchmarks were not run locally.Checklist