Skip to content

Fix discrete_choices ordering with fixed_parameters (#5254) - #5293

Closed
bodapatisaikrishna wants to merge 3 commits into
facebook:mainfrom
bodapatisaikrishna:fix-5254-fixed-parameters-ordering
Closed

bodapatisaikrishna wants to merge 3 commits into
facebook:mainfrom
bodapatisaikrishna:fix-5254-fixed-parameters-ordering

Conversation

@bodapatisaikrishna

@bodapatisaikrishna bodapatisaikrishna commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #5254.

When fixed_parameters includes a continuous feature, mk_discrete_choices merges 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:

  • Indexes discrete choices by feature position in the local-search path (same pattern as the enumerate path)
  • Returns mk_discrete_choices as dict(sorted(...)) so callers that rely on key order stay consistent
  • Adds regression coverage for both

Test 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 / flake8 on touched files

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
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Sep 17, 2026

@saitcakmak saitcakmak 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.

thanks for the fix!

@meta-codesync

meta-codesync Bot commented Sep 17, 2026

Copy link
Copy Markdown

@saitcakmak has imported this pull request. If you are a Meta employee, you can view this in D120597307.

@codecov-commenter

codecov-commenter commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.57%. Comparing base (0e341dd) to head (34c76ca).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@meta-codesync meta-codesync Bot closed this in 1cb1f8a Sep 18, 2026
@meta-codesync meta-codesync Bot added the Merged label Sep 18, 2026
@meta-codesync

meta-codesync Bot commented Sep 18, 2026

Copy link
Copy Markdown

@saitcakmak merged this pull request in 1cb1f8a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Do not delete this pull request or issue due to inactivity. Merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: fixed_parameters causing BotorchError

3 participants