MCPcopy Index your code
hub / github.com/THUDM/GLM / print_and_save_args

Function print_and_save_args

utils.py:74–90  ·  view source on GitHub ↗

Print arguments.

(args, verbose=True, log_dir=None)

Source from the content-addressed store, hash-verified

72
73
74def 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
93def print_params_min_max_norm(optimizer, iteration):

Callers 2

finetuneFunction · 0.90
mainFunction · 0.90

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected