Make JAX/numpyro imports lazy in fully Bayesian models (#3292)#3292
Open
sdaulton wants to merge 2 commits intometa-pytorch:mainfrom
Open
Make JAX/numpyro imports lazy in fully Bayesian models (#3292)#3292sdaulton wants to merge 2 commits intometa-pytorch:mainfrom
sdaulton wants to merge 2 commits intometa-pytorch:mainfrom
Conversation
|
@sdaulton has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102367287. |
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 24, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3292 +/- ##
=======================================
Coverage 99.98% 99.98%
=======================================
Files 225 225
Lines 22249 22250 +1
=======================================
+ Hits 22245 22246 +1
Misses 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 24, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
2979002 to
3f376a6
Compare
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 24, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
93466c0 to
6701523
Compare
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 24, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 24, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 26, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
6701523 to
76262ca
Compare
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 26, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
…ytorch#3291) Summary: X-link: facebook/Ax#5190 Reviewed By: saitcakmak Differential Revision: D102367257
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
76262ca to
07f286c
Compare
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 26, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 26, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 26, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
sdaulton
added a commit
to sdaulton/botorch
that referenced
this pull request
Apr 26, 2026
…3292) Summary: `botorch.models.fully_bayesian` and `botorch.models.fully_bayesian_multitask` eagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes an `ImportError` even for callers that never use fully Bayesian models. This diff wraps the JAX/numpyro imports in a `try/except` block, deferring the failure to when `AbstractFullyBayesianSingleTaskGP` or `SaasFullyBayesianMultiTaskGP` is actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Since `from __future__ import annotations` is already present, type annotations referencing `jax.Array` remain valid as strings. Reviewed By: saitcakmak Differential Revision: D102367287
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:
botorch.models.fully_bayesianandbotorch.models.fully_bayesian_multitaskeagerly import JAX and numpyro at module level. When JAX requires NumPy >= 2.0 but the environment has an older NumPy (e.g., pyper Bento kernel with NumPy 1.24), this causes anImportErroreven for callers that never use fully Bayesian models.This diff wraps the JAX/numpyro imports in a
try/exceptblock, deferring the failure to whenAbstractFullyBayesianSingleTaskGPorSaasFullyBayesianMultiTaskGPis actually instantiated. The error message is preserved and clearly states the NumPy >= 2.0 requirement. Sincefrom __future__ import annotationsis already present, type annotations referencingjax.Arrayremain valid as strings.Reviewed By: saitcakmak
Differential Revision: D102367287