MCPcopy Create free account
hub / github.com/THUDM/GLM / print_params_min_max_norm

Function print_params_min_max_norm

utils.py:93–110  ·  view source on GitHub ↗

Print min, max, and norm of all parameters.

(optimizer, iteration)

Source from the content-addressed store, hash-verified

91
92
93def print_params_min_max_norm(optimizer, iteration):
94 """Print min, max, and norm of all parameters."""
95 index = 0
96 rank = torch.distributed.get_rank()
97 string = 'iteration, rank, index, model-parallel,min, max, norm\n'
98 optimizer_ = optimizer
99 if isinstance(optimizer, FP16_Optimizer):
100 optimizer_ = optimizer.optimizer
101 for param_group in optimizer_.param_groups:
102 for param in param_group['params']:
103 index += 1
104 min_ = param.data.min()
105 max_ = param.data.max()
106 norm = param.data.norm()
107 string += '{:7d}, {:4d}, {:4d}, {:2d}, '.format(
108 iteration, rank, index, int(param.model_parallel))
109 string += '{:.6E}, {:.6E}, {:.6E}\n'.format(min_, max_, norm)
110 print(string, flush=True)
111
112
113class Timers:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected