MCPcopy Create free account
hub / github.com/AI-Hypercomputer/maxtext / main

Function main

tests/sharding_dump.py:258–288  ·  view source on GitHub ↗

Load a config that describes a model with topology and slices to be dumped.

(argv: Sequence[str])

Source from the content-addressed store, hash-verified

256
257
258def main(argv: Sequence[str]) -> None:
259 """Load a config that describes a model with topology and slices to be dumped."""
260 jax.config.update("jax_default_prng_impl", "unsafe_rbg")
261 os.environ["LIBTPU_INIT_ARGS"] = (
262 os.environ.get("LIBTPU_INIT_ARGS", "") + " --xla_tpu_spmd_rng_bit_generator_unsafe=true"
263 )
264 print("Starting sharding_tests.py...", flush=True)
265
266 config = pyconfig.initialize(argv)
267 validate_config(config)
268
269 json_path = (
270 f"sharding_info/{config.model_name}/"
271 f"{config.compile_topology}/"
272 f"slice_{config.compile_topology_num_slices}/"
273 f"named_shardings.json"
274 )
275
276 try:
277 topology_mesh = get_topology_mesh(config)
278 _, _, state_mesh_shardings, _ = get_shaped_inputs(topology_mesh, config)
279 except: # pylint: disable=bare-except
280 state_mesh_shardings = {}
281
282 if state_mesh_shardings == {}:
283 return
284
285 sharding_dict = named_shardings_to_json(state_mesh_shardings)
286 save_named_sharding_dict(json_path, sharding_dict)
287 load_named_sharding_json(json_path)
288 print(config.model_name, config.compile_topology)
289
290
291if __name__ == "__main__":

Callers

nothing calls this directly

Calls 8

validate_configFunction · 0.90
get_topology_meshFunction · 0.90
get_shaped_inputsFunction · 0.90
named_shardings_to_jsonFunction · 0.85
save_named_sharding_dictFunction · 0.85
load_named_sharding_jsonFunction · 0.85
updateMethod · 0.80
initializeMethod · 0.45

Tested by

no test coverage detected