Skip to content

Commit 0fe4dc7

Browse files
Merge pull request #4455 from AI-Hypercomputer:fix/relax-tolerance-TPUv7x-tests
PiperOrigin-RevId: 949053863
2 parents eedd68e + 597ad8c commit 0fe4dc7

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

tests/integration/diloco_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def loss_fn(params, batch):
235235
# = 0.81
236236
diloco_test_state, loss = diloco_train_step(diloco_test_state, (inputs, labels), jax.random.key(seed=42))
237237
chex.assert_equal(diloco_test_state.step, 2.0)
238-
chex.assert_trees_all_close(loss, 0.65)
238+
chex.assert_trees_all_close(loss, 0.65, rtol=1e-2, atol=1e-2)
239239
# Assert no updates to the global model yet (no synchronization)
240240
if test_config.pure_nnx:
241241
_, params_pure, _ = nnx.split(initial_test_state.model, nnx.Param, ...)
@@ -280,7 +280,7 @@ def loss_fn(params, batch):
280280
# based outer optimizer.
281281
diloco_test_state, loss = diloco_train_step(diloco_test_state, (inputs, labels), jax.random.key(seed=42))
282282
chex.assert_equal(diloco_test_state.step, 3.0)
283-
chex.assert_trees_all_close(loss, 0.4481)
283+
chex.assert_trees_all_close(loss, 0.4481, rtol=1e-2, atol=1e-2)
284284
# Assert that inner and outer parameters are all equal now that
285285
# synchronization has happened.
286286
if test_config.pure_nnx:
@@ -338,7 +338,7 @@ def loss_fn(params, batch):
338338
step_three_outer_params = diloco_test_state.params
339339
diloco_test_state, loss = diloco_train_step(diloco_test_state, (inputs, labels), jax.random.key(seed=42))
340340
chex.assert_equal(diloco_test_state.step, 4.0)
341-
chex.assert_trees_all_close(loss, 0.574244)
341+
chex.assert_trees_all_close(loss, 0.574244, rtol=1e-2, atol=1e-2)
342342
# Assert no updates to the global model since previous step (no
343343
# synchronization).
344344
chex.assert_trees_all_equal(diloco_test_state.params, step_three_outer_params)

tests/unit/attention_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def test_flash_attention_block_masked_soft_cap(self):
8888
np.testing.assert_allclose(
8989
np.asarray(output),
9090
np.asarray(expected),
91-
rtol=1e-6,
92-
atol=1e-6,
91+
rtol=1e-2,
92+
atol=1e-2,
9393
)
9494

9595

tests/unit/moe_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def test_dense(self):
535535
mesh = Mesh(devices_array, cfg.mesh_axes)
536536
variables, expected_output = self.get_expected_output(rng_model, hidden_states, cfg, mesh)
537537
actual_output, _, _ = self.get_moe_output(variables, hidden_states, cfg, mesh)
538-
self.assertTrue(jax.numpy.allclose(expected_output, actual_output, rtol=1e-03, atol=1e-03, equal_nan=False))
538+
self.assertTrue(jax.numpy.allclose(expected_output, actual_output, rtol=1e-02, atol=1e-02, equal_nan=False))
539539

540540
@pytest.mark.tpu_only
541541
def test_moe_emb_chunking_gmm_v2(self):

0 commit comments

Comments
 (0)