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

Method test_index

axlearn/common/checkpointer_orbax_test.py:31–55  ·  view source on GitHub ↗

Tests that index files saved with orbax can be read with `read_index_file`.

(self)

Source from the content-addressed store, hash-verified

29
30class OrbaxCheckpointerTest(test_utils.TestCase):
31 def test_index(self):
32 """Tests that index files saved with orbax can be read with `read_index_file`."""
33 mesh_shape = (1, 1)
34 if not test_utils.is_supported_mesh_shape(mesh_shape):
35 return
36 with _mesh(mesh_shape), tempfile.TemporaryDirectory() as temp_dir:
37 ckpt = (
38 OrbaxCheckpointer.default_config()
39 .set(name="test", dir=temp_dir)
40 .instantiate(parent=None)
41 )
42 step = 123
43 state = dict(x=jnp.ones([3, 2]))
44 ckpt.save(step=step, state=state)
45 ckpt.wait_until_finished()
46
47 ref_index = read_index_file(os.path.join(temp_dir, "step_00000123", "index"))
48 test_index = ckpt._manager.restore(
49 step=step,
50 # The input iterator is saved as part of `save_tf_savables`.
51 args=ocp.args.Composite(
52 index=ocp.args.JsonSave(ckpt._get_spec(step=step, state=state))
53 ),
54 )
55 self.assertEqual(ref_index, test_index["index"])
56
57 def test_checkpoint_manager_with_tracker_file(self):
58 """Test CheckpointManagerWithTrackerFile"""

Callers

nothing calls this directly

Calls 10

read_index_fileFunction · 0.90
joinMethod · 0.80
_meshFunction · 0.70
instantiateMethod · 0.45
setMethod · 0.45
default_configMethod · 0.45
saveMethod · 0.45
wait_until_finishedMethod · 0.45
restoreMethod · 0.45
_get_specMethod · 0.45

Tested by

no test coverage detected