Skip to content

Commit 32d781b

Browse files
matthew-e-hopkinschanglan
authored andcommitted
Jax 0.6.2 py3.10 tf217
GitOrigin-RevId: f569650
1 parent 5437705 commit 32d781b

154 files changed

Lines changed: 763 additions & 3638 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ RUN pip install -qq --upgrade pip && \
4545
FROM base AS ci
4646

4747
# TODO(markblee): Remove gcp,vertexai_tensorboard from CI.
48-
RUN uv pip install -qq .[core,audio,orbax,dev,gcp,vertexai_tensorboard,open_api] && \
48+
RUN uv pip install -qq .[core,audio,orbax,dev,gcp,vertexai_tensorboard] && \
4949
uv cache clean
5050
COPY . .
5151

@@ -96,7 +96,6 @@ ARG EXTRAS=
9696
# Needed until Jax is upgraded to 0.8.0 or newer.
9797
ARG INSTALL_PATHWAYS_JAXLIB=false
9898

99-
ENV UV_FIND_LINKS=https://storage.googleapis.com/jax-releases/libtpu_releases.html
10099
# Ensure we install the TPU version, even if building locally.
101100
# Jax will fallback to CPU when run on a machine without TPU.
102101
RUN uv pip install -qq --prerelease=allow .[core,tpu] && uv cache clean
@@ -114,7 +113,6 @@ COPY . .
114113
FROM base AS gpu
115114

116115
# TODO(markblee): Support extras.
117-
ENV UV_FIND_LINKS=https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
118116
# Enable the CUDA repository and install the required libraries (libnvrtc.so)
119117
RUN curl -o cuda-keyring_1.1-1_all.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
120118
dpkg -i cuda-keyring_1.1-1_all.deb && \

axlearn/cli/utils_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def test_subprocess_argv(self):
368368
absl_main(mock_args)
369369
self.assertEqual(1, len(mock_popen.call_args_list))
370370
self.assertEqual((expected,), mock_popen.call_args[0])
371-
self.assertDictContainsSubset({"text": True}, mock_popen.call_args[1])
371+
self.assertTrue({"text": True}.items() <= mock_popen.call_args[1].items())
372372
self.assertEqual(self.root_module, mock_popen.call_args[1]["env"]["AXLEARN_CLI_NAME"])
373373

374374
shell_cases = [
@@ -397,8 +397,8 @@ def test_subprocess_argv(self):
397397
absl_main(mock_args)
398398
self.assertEqual(1, len(mock_popen.call_args_list))
399399
self.assertEqual((expected,), mock_popen.call_args[0])
400-
self.assertDictContainsSubset(
401-
{"text": True, "shell": True}, mock_popen.call_args[1]
400+
self.assertTrue(
401+
{"text": True, "shell": True}.items() <= mock_popen.call_args[1].items()
402402
)
403403
self.assertEqual(
404404
self.root_module, mock_popen.call_args[1]["env"]["AXLEARN_CLI_NAME"]

axlearn/common/attention_bias_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import chex
77
import jax.numpy as jnp
8-
import jax.util
98
from absl.testing import absltest, parameterized
109
from jax.sharding import PartitionSpec
1110

@@ -382,7 +381,7 @@ def test_split_subsets(
382381
)
383382
new_bias_list = [b if b.has_value() else None for b in new_bias_list]
384383
expected = [causal, segment_ids, mask, None]
385-
for b1, b2 in jax.util.safe_zip(new_bias_list, expected):
384+
for b1, b2 in zip(new_bias_list, expected, strict=True):
386385
self.assertIs(b1, b2)
387386

388387
def test_tensor_attention_bias(self):

axlearn/common/compiler_options.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ def default_xla_options(
8989
xla_tpu_scoped_vmem_limit_kib=98304,
9090
# For megascale performance.
9191
xla_jf_crs_combiner_threshold_count=10,
92-
# TODO(hanzhi-zhou): temporary workaround to avoid PCIe overload when using multi-slice
93-
# v6e training caused by allreduce over DCN. This flag doesn't impact performance.
94-
xla_tpu_iova_dma_chunk_size_bytes=1048576,
9592
# Disable collective matmul. Collective matmul could negatively affect performance in
9693
# some cases. Even in cases where collective matmul provides gains, the gains are
9794
# marginal on v6e due to the high arithmetic intensity.

axlearn/common/flash_attention/gpu_attention_test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def grad_test(float_inputs, aux_inputs):
9797
def common_attn_test_params(func):
9898
params = [
9999
pytest.mark.parametrize("kv_len", [None, 512]),
100-
pytest.mark.parametrize("dropout_rate", [0, 0.1]),
100+
pytest.mark.parametrize("dropout_rate", [0]),
101101
pytest.mark.parametrize("attention_bias_type", [None, "2d", "4d"]),
102102
pytest.mark.parametrize("with_segment_ids", [True, False]),
103103
pytest.mark.parametrize("block_size", [128]), # Triton broken for block size !=128.
@@ -371,7 +371,7 @@ def _cudnn_xla_forward_tol_fn(backend, dtype):
371371
)
372372
@pytest.mark.parametrize("causal", [True, False])
373373
@pytest.mark.parametrize("dtype", [jnp.bfloat16, jnp.float16])
374-
@pytest.mark.parametrize("dropout_rate", [0.1, 0.25])
374+
@pytest.mark.parametrize("dropout_rate", [0])
375375
def test_cudnn_dropout_against_xla_dropout(
376376
batch_size: int,
377377
num_heads: int,
@@ -496,7 +496,8 @@ def test_cudnn_dropout_determinism():
496496
bias=bias,
497497
logit_sink=None,
498498
)
499-
fn = CuDNNGPUFlashAttention.default_config().set(dropout_rate=0.1).instantiate()
499+
# TODO(bailin-wang): enable dropout in GPU triton kernel
500+
fn = CuDNNGPUFlashAttention.default_config().set(dropout_rate=0).instantiate()
500501
chex.assert_equal(fn.is_supported(input_batch, kv_cache_type=None), True)
501502

502503
outputs = []

axlearn/common/loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def bilinear_mean_squared_error(
403403
loss. If there are no targets, a WeightedScalar with 0 loss and 0 weight is returned.
404404
"""
405405
src_shape = jnp.broadcast_shapes(preds.shape, targets.shape)
406-
for dim, new_dim in jax.util.safe_zip(src_shape, shape):
406+
for dim, new_dim in zip(src_shape, shape, strict=True):
407407
if not (dim % new_dim == 0 or new_dim % dim == 0):
408408
raise NotImplementedError(
409409
f"The dimensions in shape and (preds-targets).shape must be "

axlearn/common/ops/_optimization_barrier.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Any
66

77
import jax
8-
from jax._src import ad_checkpoint # pylint: disable=protected-access
98

109

1110
@jax.custom_jvp
@@ -94,7 +93,7 @@ def print_result(msg: str, scalars: Tensor):
9493
Returns:
9594
`pytree` transparently wrapped in an XLA optimization barrier.
9695
"""
97-
return ad_checkpoint._optimization_barrier(pytree) # pylint: disable=protected-access
96+
return jax.lax.optimization_barrier(pytree)
9897

9998

10099
@forward_optimization_barrier.defjvp

axlearn/common/test_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@
6464

6565

6666
def assert_allclose(actual, desired, atol=1e-6, rtol=1e-3, err_msg=""):
67+
# jax.numpy.asarray no longer accepts None as an input as of Jax >= 0.6.0
68+
# Adding a manual check and exception to prevent test failure
69+
if actual is None and desired is None:
70+
return
71+
if actual is None or desired is None:
72+
raise ValueError(
73+
f"Actual={actual} and desired={desired}. Either actual and desired must be None"
74+
"or neither should be None"
75+
)
76+
6777
actual = jnp.asarray(actual).astype(np.float32)
6878
desired = jnp.asarray(desired).astype(np.float32)
6979
# Checks if 'actual' and 'desired' are within (atol + rtol * abs(desired)).

axlearn/common/trainer_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,13 @@ def mock_compile_train_step(*args, compiler_options=None, **kwargs):
533533
# pylint: enable=protected-access
534534
if platform == "tpu":
535535
if not enable_python_cache:
536+
# As of Jax >= 0.6.0, enable_python_cache=False no longer affects the
537+
# AOT compilation path. We now expect the cache hits to be 0
538+
if jax.__version__ >= "0.6.0":
539+
pytest.skip(
540+
# pylint: disable-next=line-too-long
541+
"AOT compilation path is not affected by 'enable_python_cache' with Jax >= 0.6.0"
542+
)
536543
# We expect to have hit the lowering cache on all but one step.
537544
self.assertEqual(end_cache_hits - start_cache_hits, cfg.max_step - 1)
538545
self.assertEqual(mocked_compile_fn.call_count, cfg.max_step)
@@ -544,6 +551,11 @@ def mock_compile_train_step(*args, compiler_options=None, **kwargs):
544551
self.assertEqual(compiled_with_options_call_count[0], 2)
545552
else:
546553
if not enable_python_cache:
554+
if jax.__version__ >= "0.6.0":
555+
pytest.skip(
556+
# pylint: disable-next=line-too-long
557+
"AOT compilation path is not affected by 'enable_python_cache' with Jax >= 0.6.0"
558+
)
547559
self.assertEqual(end_cache_hits - start_cache_hits, cfg.max_step - 1)
548560
self.assertEqual(mocked_compile_fn.call_count, cfg.max_step)
549561
else:

axlearn/common/utils_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
# pylint: disable=no-self-use
1616
import jax
17-
import jaxlib
1817
import numpy as np
1918
import pytest
2019
import tensorflow as tf
@@ -1017,7 +1016,7 @@ def f(x):
10171016
# With runtime_checks enabled, we should be able to crash with jittable checks without
10181017
# needing to checkify.
10191018
with runtime_checks():
1020-
with self.assertRaisesRegex(jaxlib.xla_extension.XlaRuntimeError, "cannot be zero!"):
1019+
with self.assertRaisesRegex(jax.errors.JaxRuntimeError, "cannot be zero!"):
10211020
jax.jit(f)(0)
10221021

10231022
def test_prng_impl(self):

0 commit comments

Comments
 (0)