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

Method test_one_per_process

axlearn/common/utils_test.py:2008–2039  ·  view source on GitHub ↗

Test a case where every process produces a slice. This is recommended to run on >1 process, e.g. v5e-16.

(self)

Source from the content-addressed store, hash-verified

2006 if isinstance(expected, Exception):
2007 with self.assertRaisesRegex(type(expected), str(expected)):
2008 create_device_mesh(mesh_shape=logical_mesh, devices=devices)
2009 else:
2010 # Check that the constructed mesh has the expected shape.
2011 device_mesh = create_device_mesh(mesh_shape=logical_mesh, devices=devices)
2012 self.assertEqual(expected or logical_mesh, device_mesh.shape)
2013
2014 # Check that the sub_mesh along the first non-singleton mesh axis only contains devices
2015 # from one of the slices.
2016 mesh_shape = device_mesh.shape
2017 for dim in mesh_shape:
2018 if dim != 1:
2019 break
2020 device_mesh = device_mesh[0]
2021 for ix, sub_mesh in enumerate(device_mesh):
2022 self.assertTrue(all(el.slice_index == ix for el in sub_mesh.flatten()))
2023
2024 @parameterized.parameters(
2025 {"logical_mesh": (2, 128, 2)},
2026 {"logical_mesh": (2, 16, 16)},
2027 # Use the first axis that divides number of granules for DCN mesh.
2028 {"logical_mesh": (1, 2, 16, 16)},
2029 # First non-singleton dim does not divide number of granules.
2030 {"logical_mesh": (3, 2, 16, 16), "expected": ValueError("First non-singleton")},
2031 # At least one ICI mesh should divide number of granules.
2032 {"logical_mesh": (1, 1), "expected": ValueError("At least one")},
2033 # Test a case where we infer -1 in ICI mesh.
2034 {"logical_mesh": (2, -1, 2), "expected": (2, 128, 2)},
2035 # Test a case where we infer -1 in DCN mesh.
2036 {"logical_mesh": (-1, 16, 16), "expected": (2, 16, 16)},
2037 # Test a basic hybrid mesh case.
2038 {
2039 "logical_mesh": HybridMeshShape(ici_mesh_shape=(1, 128, 2), dcn_mesh_shape=(2, 1, 1)),
2040 "expected": (2, 128, 2),
2041 },
2042 # Test that ICI mesh should respect the number of devices.

Callers

nothing calls this directly

Calls 3

replicate_to_local_dataFunction · 0.90
assertNestedEqualMethod · 0.80

Tested by

no test coverage detected