Skip to content

Commit 32893b8

Browse files
Jammy2211Jammy2211
authored andcommitted
feat: JAX as a default dependency, marker-gated for Intel macOS (PyAutoLens#702)
1 parent b6b6ab6 commit 32893b8

2 files changed

Lines changed: 30 additions & 6 deletions

File tree

autonerves/jax_wrapper.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
import importlib.util
12
import logging
23

34
logger = logging.getLogger(__name__)
45

56
import os
67

8+
if importlib.util.find_spec("jax") is None:
9+
logger.warning(
10+
"""
11+
JAX is not installed, so all computations will run on the pure NumPy
12+
path. Performance is significantly reduced without JAX — model fits
13+
that take minutes with JAX can take hours without it.
14+
15+
JAX is a default dependency of the PyAuto libraries; it is absent
16+
either because this platform has no JAX wheels (e.g. Intel macOS) or
17+
because it was uninstalled. On supported platforms, restore it with:
18+
19+
pip install jax
20+
"""
21+
)
22+
723
xla_env = os.environ.get("XLA_FLAGS")
824

925
xla_env_set = True

pyproject.toml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,15 @@ keywords = ["cli"]
2626
dependencies = [
2727
"typing-inspect>=0.4.0",
2828
"PyYAML>=6.0.1",
29-
"numpy>=1.24.0,<3.0.0"
29+
"numpy>=1.24.0,<3.0.0",
30+
# JAX is a default dependency (PyAutoLens#702): CPU wheels exist for every
31+
# supported platform except Intel macOS (jaxlib ships no macosx_x86_64
32+
# wheels for >=0.7), so the markers let Intel Macs resolve to the
33+
# NumPy-only path instead of failing at install. jax_wrapper warns loudly
34+
# at import when JAX is absent.
35+
'jax>=0.7.0,<0.12.0; sys_platform != "darwin" or platform_machine == "arm64"',
36+
'jaxlib>=0.7.0,<0.12.0; sys_platform != "darwin" or platform_machine == "arm64"',
37+
'jaxnnls==1.0.1; sys_platform != "darwin" or platform_machine == "arm64"'
3038
]
3139

3240
[project.urls]
@@ -43,11 +51,11 @@ version_scheme = "post-release"
4351
local_scheme = "no-local-version"
4452

4553
[project.optional-dependencies]
46-
jax = [
47-
"jax>=0.7.0,<0.11.0",
48-
"jaxlib>=0.7.0,<0.11.0",
49-
"jaxnnls==1.0.1"
50-
]
54+
# JAX moved into the base dependencies (PyAutoLens#702). The extra is kept as
55+
# a declared no-op so `pip install autonerves[jax]` keeps resolving — removing
56+
# it would revive the pip history-walk trap ("version X does not provide the
57+
# extra 'jax'" is a warning, not an error; PyAutoLens#687) in reverse.
58+
jax = []
5159
optional = [
5260
"autonerves[jax]",
5361
"astropy>=5.0"

0 commit comments

Comments
 (0)