Skip to content

Commit 6df0420

Browse files
QuinnMMcGarrycamiloCienet
authored andcommitted
Fixes for:
b/498080408 b/498074854 b/498090408 b/500231278
1 parent 22f5576 commit 6df0420

8 files changed

Lines changed: 21 additions & 21 deletions

File tree

axlearn/common/attention_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,8 +3479,8 @@ def test_scale_query_key_barrier(self):
34793479
self.assertIn(str(key_scale_factor), hlo)
34803480
# This test is unsupported on Jax 0.8.2 and later
34813481
# TODO(rohit-chatterjee): Rewrite or disable test entirely
3482-
if jax.__version__ < "0.8.2":
3483-
self.assertNotIn(str(query_scale_factor * key_scale_factor), hlo)
3482+
# if jax.__version__ < "0.8.2":
3483+
# self.assertNotIn(str(query_scale_factor * key_scale_factor), hlo)
34843484

34853485
@parameterized.product(
34863486
[

axlearn/common/flash_attention/tpu_paged_attention.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ def __call__(
258258

259259
in_specs = [
260260
q_block_spec, # Query
261-
pl.BlockSpec(memory_space=pltpu.ANY), # Key pages
262-
pl.BlockSpec(memory_space=pltpu.ANY), # Value pages
261+
pl.BlockSpec(memory_space=None), # Key pages
262+
pl.BlockSpec(memory_space=None), # Value pages
263263
bias_spec, # Bias
264264
logit_sink_spec, # Logit sink
265265
]

axlearn/common/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def scan(
288288
"""See `BaseSchedule.scan` for details."""
289289

290290
@functools.partial(
291-
jax.ad_checkpoint.checkpoint,
291+
jax.checkpoint,
292292
prevent_cse=False,
293293
policy=jax.checkpoint_policies.nothing_saveable,
294294
)
@@ -515,7 +515,7 @@ def scan(
515515
m = self.num_microbatches
516516

517517
@functools.partial(
518-
jax.ad_checkpoint.checkpoint,
518+
jax.checkpoint,
519519
prevent_cse=False,
520520
policy=jax.checkpoint_policies.save_only_these_names("iter_input"),
521521
)

axlearn/common/rnn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def extend_step(
208208
old_c = cached_states["c"]
209209
new_c = jax.nn.sigmoid(proj_f) * old_c + jax.nn.sigmoid(proj_g) * jax.nn.tanh(proj_i)
210210
if cfg.max_cell_value is not None:
211-
new_c = jnp.clip(new_c, a_min=-cfg.max_cell_value, a_max=cfg.max_cell_value)
211+
new_c = jnp.clip(new_c, min=-cfg.max_cell_value, max=cfg.max_cell_value)
212212
# [batch, output_dim].
213213
# Output_nonlinearity is default to True in Lingvo.
214214
# https://github.com/tensorflow/lingvo/blob/06553f297bbc38eb369503a421d07515d114cbb4/lingvo/core/rnn_cell.py#L247.

axlearn/common/ssm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ def initialize(
15191519
).astype(
15201520
dtype
15211521
) # math.log may return float64, so we need to cast to dtype
1522-
dt = jnp.clip(dt, a_min=cfg.dt_init_floor)
1522+
dt = jnp.clip(dt, min=cfg.dt_init_floor)
15231523
# Get inverse of softplus.
15241524
inv_dt = dt + jnp.log(-jnp.expm1(-dt))
15251525
return inv_dt

axlearn/common/trainer_test.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@ def mock_compile_train_step(*args, compiler_options=None, **kwargs):
535535
if not enable_python_cache:
536536
# As of Jax >= 0.6.0, enable_python_cache=False no longer affects the
537537
# 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-
)
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+
)
543543
# We expect to have hit the lowering cache on all but one step.
544544
self.assertEqual(end_cache_hits - start_cache_hits, cfg.max_step - 1)
545545
self.assertEqual(mocked_compile_fn.call_count, cfg.max_step)
@@ -551,11 +551,11 @@ def mock_compile_train_step(*args, compiler_options=None, **kwargs):
551551
self.assertEqual(compiled_with_options_call_count[0], 2)
552552
else:
553553
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-
)
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+
)
559559
self.assertEqual(end_cache_hits - start_cache_hits, cfg.max_step - 1)
560560
self.assertEqual(mocked_compile_fn.call_count, cfg.max_step)
561561
else:

axlearn/huggingface/hf_extractive_qa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ def forward( # pylint: disable=duplicate-code
277277
if start_positions is not None and end_positions is not None:
278278
# If the start/end positions are outside of model inputs, we ignore these terms.
279279
seq_len = start_logits.shape[1]
280-
start_positions = jnp.clip(start_positions, a_max=seq_len - 1)
281-
end_positions = jnp.clip(end_positions, a_max=seq_len - 1)
280+
start_positions = jnp.clip(start_positions, max=seq_len - 1)
281+
end_positions = jnp.clip(end_positions, max=seq_len - 1)
282282

283283
is_valid_input = jnp.logical_and(start_positions >= 0, end_positions >= 0)
284284
num_inputs = is_valid_input.sum()

axlearn/vision/clip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def forward(self, input_batch: NestedTensor) -> NestedTensor:
522522
log_logit_scale = self.parameters["log_logit_scale"]
523523
# Ref: https://arxiv.org/pdf/2103.00020.pdf pp.5 Sect. 2.5
524524
# Clip to prevent scaling the logits by more than 100.
525-
log_logit_scale = jnp.clip(log_logit_scale, a_max=jnp.log(cfg.temperature_max_cap))
525+
log_logit_scale = jnp.clip(log_logit_scale, max=jnp.log(cfg.temperature_max_cap))
526526
temperature = 1 / jnp.exp(log_logit_scale)
527527
similarity = contrastive_logits(x, y)
528528
loss = self._contrastive_loss_fn(similarity, similarity.T, temperature=temperature)

0 commit comments

Comments
 (0)