Print arguments.
(args, verbose=True, log_dir=None)
| 72 | |
| 73 | |
| 74 | def print_and_save_args(args, verbose=True, log_dir=None): |
| 75 | """Print arguments.""" |
| 76 | if verbose: |
| 77 | print('arguments:', flush=True) |
| 78 | for arg in vars(args): |
| 79 | dots = '.' * (29 - len(arg)) |
| 80 | print(' {} {} {}'.format(arg, dots, getattr(args, arg)), flush=True) |
| 81 | if log_dir is not None: |
| 82 | json_file = os.path.join(log_dir, "config.json") |
| 83 | with open(json_file, "w") as output: |
| 84 | json.dump(vars(args), output, sort_keys=True) |
| 85 | if args.deepspeed and args.deepspeed_config is not None: |
| 86 | with open(args.deepspeed_config) as file: |
| 87 | deepspeed_config = json.load(file) |
| 88 | deepspeed_json_file = os.path.join(log_dir, "config_gpt_large.json") |
| 89 | with open(deepspeed_json_file, "w") as output: |
| 90 | json.dump(deepspeed_config, output) |
| 91 | |
| 92 | |
| 93 | def print_params_min_max_norm(optimizer, iteration): |