(self, checkpointer_cls, mesh_shape)
| 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], |
nothing calls this directly
no test coverage detected