Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jax.clear_backends() is not doing what it is intended to do, users should try to avoid using it. #20219

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jax/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ pytype_strict_library(
visibility = [":jax_extend_users"],
deps = [
"//jax/extend",
"//jax/extend:backend",
"//jax/extend:core",
"//jax/extend:linear_util",
"//jax/extend:random",
Expand Down
7 changes: 7 additions & 0 deletions jax/extend/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pytype_strict_library(
name = "extend",
srcs = ["__init__.py"],
deps = [
":backend",
":core",
":linear_util",
":random",
Expand All @@ -45,6 +46,12 @@ pytype_strict_library(
deps = ["//jax:core"],
)

pytype_strict_library(
name = "backend",
srcs = ["backend.py"],
deps = ["//jax"],
)

pytype_strict_library(
name = "random",
srcs = ["random.py"],
Expand Down
1 change: 1 addition & 0 deletions jax/extend/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"""

from jax.extend import (
backend as backend,
core as core,
linear_util as linear_util,
random as random,
Expand Down
20 changes: 20 additions & 0 deletions jax/extend/backend.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2024 The JAX Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Note: import <name> as <name> is required for names to be exported.
# See PEP 484 & https://github.com/google/jax/issues/7570

from jax._src.api import (
clear_backends as clear_backends,
)
2 changes: 2 additions & 0 deletions tests/extend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import jax.extend as jex
import jax.numpy as jnp

from jax._src import api
from jax._src import abstract_arrays
from jax._src import linear_util
from jax._src import prng
Expand All @@ -39,6 +40,7 @@ def test_symbols(self):
self.assertIs(jex.random.unsafe_rbg_prng_impl, prng.unsafe_rbg_prng_impl)

# Assume these are tested elsewhere, only check equivalence
self.assertIs(jex.backend.clear_backends, api.clear_backends)
self.assertIs(jex.core.array_types, abstract_arrays.array_types)
self.assertIs(jex.linear_util.StoreException, linear_util.StoreException)
self.assertIs(jex.linear_util.WrappedFun, linear_util.WrappedFun)
Expand Down