def create_surrogate_run_config(hp):
  """Create a run config.

  Args:
    hp: model hyperparameters
  Returns:
    a run config
  """
  save_ckpt_steps = max(FLAGS.iterations_per_loop, FLAGS.local_eval_frequency)
  save_ckpt_secs = FLAGS.save_checkpoints_secs or None
  if save_ckpt_secs:
    save_ckpt_steps = None
  assert FLAGS.surrogate_output_dir
  # the various custom getters we have written do not play well together yet.
  # TODO(noam): ask rsepassi for help here.
  daisy_chain_variables = (
      hp.daisy_chain_variables and hp.activation_dtype == "float32" and
      hp.weight_dtype == "float32")
  return trainer_lib.create_run_config(
      model_name=FLAGS.model,
      model_dir=os.path.expanduser(FLAGS.surrogate_output_dir),
      master=FLAGS.master,
      iterations_per_loop=FLAGS.iterations_per_loop,
      num_shards=FLAGS.tpu_num_shards,
      log_device_placement=FLAGS.log_device_placement,
      save_checkpoints_steps=save_ckpt_steps,
      save_checkpoints_secs=save_ckpt_secs,
      keep_checkpoint_max=FLAGS.keep_checkpoint_max,
      keep_checkpoint_every_n_hours=FLAGS.keep_checkpoint_every_n_hours,
      num_gpus=FLAGS.worker_gpu,
      gpu_order=FLAGS.gpu_order,
      num_async_replicas=FLAGS.worker_replicas,
      gpu_mem_fraction=FLAGS.worker_gpu_memory_fraction,
      enable_graph_rewriter=FLAGS.enable_graph_rewriter,
      use_tpu=FLAGS.use_tpu,
      schedule=FLAGS.schedule,
      no_data_parallelism=hp.no_data_parallelism,
      daisy_chain_variables=daisy_chain_variables,
      ps_replicas=FLAGS.ps_replicas,
      ps_job=FLAGS.ps_job,
      ps_gpu=FLAGS.ps_gpu,
      sync=FLAGS.sync,
      worker_id=FLAGS.worker_id,
      worker_job=FLAGS.worker_job,
      random_seed=FLAGS.random_seed,
      tpu_infeed_sleep_secs=FLAGS.tpu_infeed_sleep_secs,
      inter_op_parallelism_threads=FLAGS.inter_op_parallelism_threads,
      log_step_count_steps=FLAGS.log_step_count_steps,
      intra_op_parallelism_threads=FLAGS.intra_op_parallelism_threads)
def create_surrogate_run_config ( hp ) : save_ckpt_steps = max ( FLAGS . iterations_per_loop , FLAGS . local_eval_frequency ) save_ckpt_secs = FLAGS . save_checkpoints_secs or None if save_ckpt_secs : save_ckpt_steps = None assert FLAGS . surrogate_output_dir daisy_chain_variables = ( hp . daisy_chain_variables and hp . activation_dtype == "float32" and hp . weight_dtype == "float32" ) return trainer_lib . create_run_config ( model_name = FLAGS . model , model_dir = os . path . expanduser ( FLAGS . surrogate_output_dir ) , master = FLAGS . master , iterations_per_loop = FLAGS . iterations_per_loop , num_shards = FLAGS . tpu_num_shards , log_device_placement = FLAGS . log_device_placement , save_checkpoints_steps = save_ckpt_steps , save_checkpoints_secs = save_ckpt_secs , keep_checkpoint_max = FLAGS . keep_checkpoint_max , keep_checkpoint_every_n_hours = FLAGS . keep_checkpoint_every_n_hours , num_gpus = FLAGS . worker_gpu , gpu_order = FLAGS . gpu_order , num_async_replicas = FLAGS . worker_replicas , gpu_mem_fraction = FLAGS . worker_gpu_memory_fraction , enable_graph_rewriter = FLAGS . enable_graph_rewriter , use_tpu = FLAGS . use_tpu , schedule = FLAGS . schedule , no_data_parallelism = hp . no_data_parallelism , daisy_chain_variables = daisy_chain_variables , ps_replicas = FLAGS . ps_replicas , ps_job = FLAGS . ps_job , ps_gpu = FLAGS . ps_gpu , sync = FLAGS . sync , worker_id = FLAGS . worker_id , worker_job = FLAGS . worker_job , random_seed = FLAGS . random_seed , tpu_infeed_sleep_secs = FLAGS . tpu_infeed_sleep_secs , inter_op_parallelism_threads = FLAGS . inter_op_parallelism_threads , log_step_count_steps = FLAGS . log_step_count_steps , intra_op_parallelism_threads = FLAGS . intra_op_parallelism_threads )
Create a run config.

  Args:
    hp: model hyperparameters
  Returns:
    a run config