MCPcopy Create free account
hub / github.com/apple/axlearn / test_gda

Method test_gda

axlearn/common/checkpointer_test.py:395–419  ·  view source on GitHub ↗
(self, checkpointer_cls, mesh_shape)

Source from the content-addressed store, hash-verified

393 mesh_shape=[(1, 1), (2, 2), (4, 2)],
394 )
395 def test_gda(self, checkpointer_cls, mesh_shape):
396 if not test_utils.is_supported_mesh_shape(mesh_shape):
397 return
398 with _mesh(mesh_shape):
399 cfg = _checkpointer_config(checkpointer_cls)
400 ckpt: Checkpointer = cfg.instantiate(parent=None)
401 state = dict(x=jnp.arange(16).reshape((4, 4)))
402 ckpt.save(step=10, state=state)
403 ckpt.wait_until_finished()
404
405 state0 = dict(x=jnp.zeros(shape=(4, 4), dtype=jnp.int32))
406 step, restored_state = ckpt.restore(
407 step=None,
408 state=state0,
409 )
410 self.assertEqual(10, step)
411 self.assertNestedEqual(restored_state, state)
412
413 # dtype mismatch.
414 with self.assertRaisesRegex(ValueError, "checkpoint tree dtypes or shapes"):
415 ckpt.restore(
416 step=None,
417 state=dict(x=jnp.zeros(shape=(4, 4), dtype=jnp.float32)),
418 )
419 ckpt.stop()
420
421 @parameterized.product(
422 checkpointer_cls=[Checkpointer, OrbaxCheckpointer],

Callers

nothing calls this directly

Calls 8

assertNestedEqualMethod · 0.80
_meshFunction · 0.70
_checkpointer_configFunction · 0.70
instantiateMethod · 0.45
saveMethod · 0.45
wait_until_finishedMethod · 0.45
restoreMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected