Fix discrete_choices ordering with fixed_parameters (#5254) - #5293
Closed
bodapatisaikrishna wants to merge 3 commits into
Closed
bodapatisaikrishna wants to merge 3 commits into
bodapatisaikrishna wants to merge 3 commits into
Conversation
When fixed continuous parameters are merged into discrete_choices, dict ** insertion order can append keys out of feature-index order. The local-search path then builds its positional choices list from .values(), misaligning candidate columns vs bounds validation. Index discrete choices by feature position (matching the enumerate path) and sort mk_discrete_choices by key for defense in depth. Add regression coverage for both. Assisted-by: Cursor
|
@saitcakmak has imported this pull request. If you are a Meta employee, you can view this in D120597307. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5293 +/- ##
=======================================
Coverage 96.57% 96.57%
=======================================
Files 621 621
Lines 70926 70947 +21
=======================================
+ Hits 68497 68518 +21
Misses 2429 2429 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@saitcakmak merged this pull request in 1cb1f8a. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5254.
When
fixed_parametersincludes a continuous feature,mk_discrete_choicesmerges it into the choices dict with**, which can append that key out of feature-index order. The discrete local-search path then built its positional choices list from.values(), so candidate columns no longer lined up with bounds and BoTorch raised during generation.This change:
mk_discrete_choicesasdict(sorted(...))so callers that rely on key order stay consistentTest plan
python -m pytest ax/generators/tests/test_utils.py ax/generators/torch/tests/test_acquisition.py::AcquisitionTest::test_optimize_acqf_discrete_local_search ax/generators/torch/tests/test_acquisition.py::AcquisitionTest::test_optimize_acqf_discrete_local_search_fixed_feature_order ax/generators/torch/tests/test_acquisition.py::AcquisitionTest::test_optimize_acqf_discrete_too_many_choices -v(8 passed)ufmt/flake8on touched files