Initialization of hyperparameters and utilities
(argv: Sequence[str])
| 518 | |
| 519 | |
| 520 | def initialize(argv: Sequence[str]) -> tuple[pyconfig.HyperParameters, Any, Any]: |
| 521 | """Initialization of hyperparameters and utilities""" |
| 522 | pathwaysutils.initialize() |
| 523 | jax.config.update("jax_default_prng_impl", "unsafe_rbg") |
| 524 | # TF allocates extraneous GPU memory when using TFDS data |
| 525 | # this leads to CUDA OOMs. WAR for now is to hide GPUs from TF |
| 526 | tf.config.set_visible_devices([], "GPU") |
| 527 | os.environ["TF_CPP_MIN_LOG_LEVEL"] = "0" |
| 528 | if "xla_tpu_spmd_rng_bit_generator_unsafe" not in os.environ.get("LIBTPU_INIT_ARGS", ""): |
| 529 | os.environ["LIBTPU_INIT_ARGS"] = ( |
| 530 | os.environ.get("LIBTPU_INIT_ARGS", "") + " --xla_tpu_spmd_rng_bit_generator_unsafe=true" |
| 531 | ) |
| 532 | # TODO: mazumdera@ : ensure missing mandatory fields in base.yml are filled in in argv, |
| 533 | # or fill in here |
| 534 | config = pyconfig.initialize(argv) |
| 535 | max_utils.print_system_information() |
| 536 | validate_train_config(config) |
| 537 | jax.config.update("jax_use_shardy_partitioner", config.shardy) |
| 538 | # update explicit sharding-supported config |
| 539 | if config.shard_mode == ShardMode.EXPLICIT: |
| 540 | jax.config.update("jax_remove_size_one_mesh_axis_from_type", True) |
| 541 | os.environ["TFDS_DATA_DIR"] = config.dataset_path or "" |
| 542 | vertex_tensorboard_manager = VertexTensorboardManager() |
| 543 | if config.use_vertex_tensorboard or os.environ.get("UPLOAD_DATA_TO_TENSORBOARD"): |
| 544 | vertex_tensorboard_manager.configure_vertex_tensorboard(config) |
| 545 | |
| 546 | # Create the Goodput recorder |
| 547 | recorder = create_goodput_recorder(config) |
| 548 | |
| 549 | # Stack traces configurations |
| 550 | debug_config = debug_configuration.DebugConfig( |
| 551 | stack_trace_config=stack_trace_configuration.StackTraceConfig( |
| 552 | collect_stack_trace=config.collect_stack_trace, |
| 553 | stack_trace_to_cloud=config.stack_trace_to_cloud, |
| 554 | stack_trace_interval_seconds=config.stack_trace_interval_seconds, |
| 555 | ) |
| 556 | ) |
| 557 | diagnostic_config = diagnostic_configuration.DiagnosticConfig(debug_config) |
| 558 | return config, recorder, diagnostic_config |
| 559 | |
| 560 | |
| 561 | def run(config, recorder, diagnostic_config): |
no test coverage detected