Skip to content

Commit eea53b0

Browse files
committed
[envpool] Upgrade JAX 0.9 and harden state buffer fallback
1 parent 0099d73 commit eea53b0

9 files changed

Lines changed: 34 additions & 16 deletions

File tree

envpool/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# limitations under the License.
1414
"""EnvPool package for efficient RL environment simulation."""
1515

16+
import numpy as np
17+
1618
import envpool.entry # noqa: F401
1719
from envpool.registration import (
1820
list_all_envs,
@@ -24,7 +26,11 @@
2426
register,
2527
)
2628

27-
__version__ = "0.8.4"
29+
# Gym 0.26 still references np.bool8, which NumPy 2 removed.
30+
if not hasattr(np, "bool8"):
31+
np.bool8 = np.bool_ # type: ignore[attr-defined]
32+
33+
__version__ = "0.9.0"
2834
__all__ = [
2935
"register",
3036
"make",

envpool/core/state_buffer_queue.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ class StateBufferQueue {
140140
*/
141141
std::vector<Array> Wait(std::size_t additional_done_count = 0) {
142142
std::unique_ptr<StateBuffer> newbuf = stock_buffer_.Get();
143+
if (newbuf == nullptr) {
144+
newbuf = std::make_unique<StateBuffer>(batch_, max_num_players_, specs_,
145+
is_player_state_);
146+
}
143147
std::size_t pos = done_ptr_.fetch_add(1);
144148
std::size_t offset = pos % queue_size_;
145149
auto arr = queue_[offset]->Wait(additional_done_count);

envpool/python/xla_template.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from jax import numpy as jnp
2323
from jax.core import ShapedArray
2424
from jax.interpreters import xla
25-
from jax.lib import xla_client # type: ignore[attr-defined,unused-ignore]
25+
from jax._src.lib import xla_client
2626

2727
_core = cast(Any, core)
2828
_xla = cast(Any, xla)
@@ -54,10 +54,13 @@ def _make_xla_function(
5454
specs: Tuple[Tuple[Any, ...], Tuple[Any, ...]],
5555
capsules: Tuple[Any, Any],
5656
) -> Callable:
57-
if not hasattr(_xla, "backend_specific_translations"):
57+
if not (
58+
hasattr(_core, "Primitive") and
59+
hasattr(_xla, "backend_specific_translations")
60+
):
5861
raise RuntimeError(
5962
"XLA is unavailable because this JAX version removed the legacy "
60-
"backend translation API used by envpool."
63+
"primitive/translation APIs used by envpool."
6164
)
6265
in_specs, out_specs = specs
6366
in_specs = _normalize_specs(in_specs)

envpool/registration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@
1818
from typing import Any, Dict, List, Tuple
1919

2020
import gym
21+
import numpy as np
2122
from packaging import version
2223

2324
base_path = os.path.abspath(os.path.dirname(__file__))
2425

26+
# Gym 0.26 still references np.bool8, which NumPy 2 removed.
27+
if not hasattr(np, "bool8"):
28+
np.bool8 = np.bool_ # type: ignore[attr-defined]
29+
2530

2631
class EnvRegistry:
2732
"""A collection of available envs."""

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = envpool
3-
version = 0.8.4
3+
version = 0.9.0
44
author = "EnvPool Contributors"
55
author_email = "sail@sea.com"
66
description = "C++-based high-performance parallel environment execution engine (vectorized env) for general RL environments."

third_party/pip_requirements/requirements-dev-lock.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ gymnasium==1.2.3
2424
h5py==3.16.0
2525
idna==3.11
2626
imageio==2.37.3
27-
jax==0.4.38
28-
jaxlib==0.4.38
27+
jax==0.9.2
28+
jaxlib==0.9.2
2929
jinja2==3.1.6
3030
labmaze==1.0.6
3131
llvmlite==0.46.0
@@ -39,7 +39,7 @@ mujoco==3.6.0
3939
mujoco-py==2.1.2.14
4040
networkx==3.6.1
4141
numba==0.64.0
42-
numpy==1.26.4
42+
numpy==2.2.6
4343
nvidia-cublas-cu12==12.8.4.1
4444
nvidia-cuda-cupti-cu12==12.8.90
4545
nvidia-cuda-nvrtc-cu12==12.8.93
@@ -55,7 +55,7 @@ nvidia-nccl-cu12==2.27.5
5555
nvidia-nvjitlink-cu12==12.8.93
5656
nvidia-nvshmem-cu12==3.4.5
5757
nvidia-nvtx-cu12==12.8.90
58-
opencv-python-headless==4.11.0.86
58+
opencv-python-headless==4.12.0.88
5959
opt-einsum==3.4.0
6060
optree==0.19.0
6161
packaging==26.0

third_party/pip_requirements/requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
setuptools
22
wheel
3-
numpy<2
3+
numpy>=2,<3
44
dm-env>=1.6
55
gym>=0.26.2
66
gymnasium>=1.2.3
77
optree>=0.19.0
8-
jax[cpu]>=0.4.38,<0.5
8+
jax[cpu]>=0.9.2,<0.10
99
absl-py
1010
packaging>=26.0
1111
tqdm

third_party/pip_requirements/requirements-release-lock.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ farama-notifications==0.0.4
77
gym==0.26.2
88
gym-notices==0.1.0
99
gymnasium==1.2.3
10-
jax==0.4.38
11-
jaxlib==0.4.38
10+
jax==0.9.2
11+
jaxlib==0.9.2
1212
ml-dtypes==0.5.4
13-
numpy==1.26.4
13+
numpy==2.4.3
1414
opt-einsum==3.4.0
1515
optree==0.19.0
1616
packaging==26.0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
setuptools
22
wheel
3-
numpy<2
3+
numpy>=2,<3
44
dm-env>=1.6
55
gym>=0.26.2
66
gymnasium>=1.2.3
77
optree>=0.19.0
8-
jax[cpu]>=0.4.38,<0.5
8+
jax[cpu]>=0.9.2,<0.10
99
packaging>=26.0

0 commit comments

Comments
 (0)