Skip to content

Commit 2efa84d

Browse files
committed
Remove chex dependencies.
1 parent 71445f4 commit 2efa84d

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

colabs/fine_tuning_tutorial_jax.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060
"# @title Python imports\n",
6161
"import pathlib\n",
6262
"from typing import Any, Mapping, Iterator\n",
63+
"import dataclasses\n",
6364
"import enum\n",
6465
"import functools\n",
6566
"\n",
6667
"# We import JAX and some related packages.\n",
67-
"import chex\n",
6868
"import jax\n",
6969
"import jax.numpy as jnp\n",
7070
"import optax\n",
@@ -363,7 +363,8 @@
363363
},
364364
"outputs": [],
365365
"source": [
366-
"@chex.dataclass(frozen=True)\n",
366+
"@jax.tree_util.register_dataclass\n",
367+
"@dataclasses.dataclass(frozen=True)\n",
367368
"class TrainingInput:\n",
368369
" # Input tokens given to the model\n",
369370
" input_tokens: jax.Array\n",

recurrentgemma/jax/sampler_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
from absl.testing import absltest
2020
from absl.testing import parameterized
21-
import chex
2221
import jax
2322
import jax.numpy as jnp
23+
import numpy as np
2424
from recurrentgemma import common
2525
import recurrentgemma.jax as griffin_lib
2626

@@ -229,12 +229,12 @@ def test_forward_equivalence(self, dtype: str):
229229
return_logits=True,
230230
)
231231
total_sampled_tokens = total_generation_steps + token_input.shape[-1]
232-
chex.assert_shape(
233-
jnp.array(output_sampler.logits),
232+
self.assertEqual(
233+
jnp.asarray(output_sampler.logits).shape,
234234
(batch_size, total_sampled_tokens, model_config.vocab_size),
235235
)
236-
chex.assert_shape(
237-
jnp.array(output_sampler.tokens),
236+
self.assertEqual(
237+
jnp.asarray(output_sampler.tokens).shape,
238238
(batch_size, total_sampled_tokens),
239239
)
240240

@@ -248,7 +248,7 @@ def test_forward_equivalence(self, dtype: str):
248248
rtol = 1e-6
249249
atol = 1e-6
250250

251-
chex.assert_trees_all_close(
251+
np.testing.assert_allclose(
252252
output_forward,
253253
out_logits,
254254
rtol=rtol,

0 commit comments

Comments
 (0)