class_docstr: The DeepSpeed Autotuner automatically discovers the optimal DeepSpeed configuration that delivers good training speed. The Autotuner uses model information, system information, and heuristics to efficiently tune system knobs that affect compute and memory efficiencies, such as ZeRO optimization stages, micro-batch sizes, and many other ZeRO optimization configurations. It not only reduces the time and resources user spend on tuning, but also can discover configurations better than hand-tuned methods.
  Autotuning with DeepSpeed requires no code change from DeepSpeed users. Please refer to the README for usage details.
class_docstr_tok: ["The","DeepSpeed","Autotuner","automatically","discovers","the","optimal","DeepSpeed","configuration","that","delivers","good","training","speed",".","The","Autotuner","uses","model","information",",","system","information",",","and","heuristics","to","efficiently","tune","system","knobs","that","affect","compute","and","memory","efficiencies",",","such","as","ZeRO","optimization","stages",",","micro-batch","sizes",",","and","many","other","ZeRO","optimization","configurations",".","It","not","only","reduces","the","time","and","resources","user","spend","on","tuning",",","but","also","can","discover","configurations","better","than","hand-tuned","methods",".","Autotuning","with","DeepSpeed","requires","no","code","change","from","DeepSpeed","users",".","Please","refer","to","the","README","for","usage","details","."]
docstr: Does a model information profiling experiment that collects the number of model parameters and activation memory.            The experiment produces a "profile_model_info" folder under self.results_dir.
  Returns:
      [dict]: a model information dictionary, e.g., {"num_params": 335144976, "trainable_num_params": 335144976, "activation_mem_per_gpu": 324358144, "rank": 0}
docstr_tok: ["Does","a","model","information","profiling","experiment","that","collects","the","number","of","model","parameters","and","activation","memory",".","The","experiment","produces","a","``","profile_model_info","''","folder","under","self.results_dir",".","Returns",":","[","dict","]",":","a","model","information","dictionary",",","e.g.",",","{","``","num_params","''",":","335144976",",","``","trainable_num_params","''",":","335144976",",","``","activation_mem_per_gpu","''",":","324358144",",","``","rank","''",":","0","}"]
code: def model_info_profile_run(self):
      """Does a model information profiling experiment that collects the number of model parameters and activation memory.\
              The experiment produces a "profile_model_info" folder under self.results_dir.
          Returns:
              [dict]: a model information dictionary, e.g., {"num_params": 335144976, "trainable_num_params": 335144976, "activation_mem_per_gpu": 324358144, "rank": 0}
          """
      logger.info("Starting model info profile run.")
      model_info = self.autotuning_config.model_info
      if model_info and MODEL_INFO_NUM_PARAMS in model_info:
          return model_info
  
      ds_config = copy.deepcopy(self.user_config)
      replace_dict(ds_config, DEFAULT_MIN_MEM_CONFIG)
  
      model_info_path = os.path.join(
          self.results_dir, "profile_model_info", "model_info.json"
      )
      ds_config[AUTOTUNING] = {
          "enabled": True,
          "model_info_path": model_info_path,
          "model_info": {"profile": True},
      }
  
      exp_config = {}
      exp_name = "profile_model_info"
      exp_config["name"] = exp_name
      exp_config[DS_CONFIG] = ds_config
      exp_config["num_gpus"] = self.exp_num_gpus
      exp_config["num_nodes"] = self.exp_num_nodes
      exp_path = os.path.join(self.exps_dir, f"{exp_name}.json")
  
      with open(exp_path, "w", buffering=BUFSIZE) as fd:
          json.dump(exp_config, fd)
          fd.flush()
          os.fsync(fd)
  
      self.rm.schedule_experiments([exp_path])
      self.rm.run()
  
      for exp_id, (
          exp_json,
          err,
      ) in self.rm.finished_experiments.items():
          self.rm.clear()
          if err:
              logger.error(
                  f"The model is not runnable with DeepSpeed with error = {err}"
              )
              return None
  
      if os.path.exists(model_info_path):
          with open(model_info_path, "r") as f:
              model_info = hjson.load(f)
              return model_info
  
imports: import shutil
  import subprocess
  import time
  import datetime
  import math
  import hjson
  from ..runtime.config_utils import dict_raise_error_on_duplicate_keys
  from ..runtime.constants import *
  from ..runtime.zero.config import ZERO_OPTIMIZATION, ZeroStageEnum
  from ..utils import logger
  from .config import DeepSpeedAutotuningConfig
  from .constants import *
  from .scheduler import ResourceManager
  from .tuner import GridSearchTuner, RandomTuner, ModelBasedTuner
  from .utils import *
  from deepspeed.accelerator import get_accelerator
label_desc: Use image node_id 22 for calling the Autotuner obj's underlying member method code with example usage: obj.model_info_profile_run() and returns: model_info, None, model_info