Skip to content

Prefer predictive adapter over fallback in GenerationNode._fitted_adapter#5199

Closed
andycylmeta wants to merge 1 commit into
facebook:mainfrom
andycylmeta:export-D99358260
Closed

Prefer predictive adapter over fallback in GenerationNode._fitted_adapter#5199
andycylmeta wants to merge 1 commit into
facebook:mainfrom
andycylmeta:export-D99358260

Conversation

@andycylmeta
Copy link
Copy Markdown
Contributor

Summary:
When BoTorch candidate generation fails after MAX_GEN_ATTEMPTS (e.g. due to
search space exhaustion), the generation node falls back to Sobol for that
particular gen call. This fallback overwrites _generator_spec_to_gen_from
with a RandomAdapter, which cannot make predictions.

The problem is that downstream analysis code reads GenerationStrategy.adapter to generate model-dependent
plots (cross-validation, sensitivity, surface, modeled arm effects, etc.).
Since the adapter now points to the Sobol fallback's RandomAdapter, all these
analyses fail with "does not support predictions" or "TorchAdapter is required"
errors -- even though the original fitted TorchAdapter is still preserved on
the generator spec.

This diff fixes GenerationNode._fitted_adapter to check: if the current
adapter cannot predict, look for a fitted predictive adapter among the
original generator_specs and prefer that instead. This is safe because the
original TorchAdapter is never destroyed by the fallback -- it's just
shadowed by the _generator_spec_to_gen_from override.

Reviewed By: ItsMrLin

Differential Revision: D99358260

…pter

Summary:
When BoTorch candidate generation fails after MAX_GEN_ATTEMPTS (e.g. due to
search space exhaustion), the generation node falls back to Sobol for that
particular gen call. This fallback overwrites `_generator_spec_to_gen_from`
with a RandomAdapter, which cannot make predictions.

The problem is that downstream analysis code reads `GenerationStrategy.adapter` to generate model-dependent
plots (cross-validation, sensitivity, surface, modeled arm effects, etc.).
Since the adapter now points to the Sobol fallback's RandomAdapter, all these
analyses fail with "does not support predictions" or "TorchAdapter is required"
errors -- even though the original fitted TorchAdapter is still preserved on
the generator spec.

This diff fixes `GenerationNode._fitted_adapter` to check: if the current
adapter cannot predict, look for a fitted predictive adapter among the
original `generator_specs` and prefer that instead. This is safe because the
original TorchAdapter is never destroyed by the fallback -- it's just
shadowed by the `_generator_spec_to_gen_from` override.

Reviewed By: ItsMrLin

Differential Revision: D99358260
@meta-cla meta-cla Bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label May 7, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 7, 2026

@andycylmeta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99358260.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.38%. Comparing base (bbb0d71) to head (491b301).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5199      +/-   ##
==========================================
- Coverage   96.39%   96.38%   -0.01%     
==========================================
  Files         617      617              
  Lines       69476    69494      +18     
==========================================
+ Hits        66972    66985      +13     
- Misses       2504     2509       +5     

☔ View full report in Codecov by Sentry.
📢 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
Copy link
Copy Markdown

meta-codesync Bot commented May 7, 2026

This pull request has been merged in 75c0ed4.

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. fb-exported Merged meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants