Skip to content

Commit

Permalink
[JAX] Replace uses of jax.devices("cpu") with jax.local_devices(backe…
Browse files Browse the repository at this point in the history
…nd="cpu").

An upcoming change to JAX will include non-local (addressable) CPU devices in jax.devices() when JAX is used multicontroller-style, where there are multiple Python processes.

This change preserves the current behavior by replacing uses of jax.devices("cpu"), which previously only returned local devices, with jax.local_devices("cpu"), which will return local devices both now and in the future.

This change is always be safe (i.e., it should always preserve the previous behavior) but it may sometimes be unnecessary if code is never used in a multicontroller setting.

PiperOrigin-RevId: 582700237
  • Loading branch information
hawkinsp authored and romanngg committed Nov 21, 2023
1 parent 3e10a78 commit aa3620d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/rules_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ def _test_primitive(
def test_unary(self, primitive: Optional[Primitive], shape, dtype, params):
if primitive == lax.device_put_p:
# Can't instantiate devices at test generation time; using subtests.
devices = [None] + jax.devices() + jax.devices('cpu')
devices = [None] + jax.devices() + jax.local_devices(backend='cpu')
for device in devices:
for src in devices:
with self.subTest(device=device, src=src):
Expand Down

0 comments on commit aa3620d

Please sign in to comment.