Skip to content

Commit c03f8bd

Browse files
Merge pull request #4550 from AI-Hypercomputer:fix-moe-test-dense
PiperOrigin-RevId: 952149623
2 parents d557e88 + b9c47a4 commit c03f8bd

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/unit/moe_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
def assert_moe_close(actual, expected, dtype):
3939
"""Asserts that the actual and expected MoE outputs are close."""
4040
assert np.isfinite(actual).all(), "Actual output contains NaNs or Infs!"
41-
if dtype == jnp.bfloat16:
41+
42+
if jax.default_backend() == "tpu" or dtype == jnp.bfloat16:
43+
# TPU float32 (which is downcasted/accumulates differently) and bfloat16
44+
# both exhibit accumulation drift, especially on newer hardware like v7x.
4245
rtol, atol = 2e-2, 1e-2
4346
else:
4447
rtol, atol = 1e-5, 1e-6

0 commit comments

Comments
 (0)