Print min, max, and norm of all parameters.
(optimizer, iteration)
| 91 | |
| 92 | |
| 93 | def 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 | |
| 113 | class Timers: |
nothing calls this directly
no outgoing calls
no test coverage detected