MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / flops_calculator

Function flops_calculator

DeepSpeedExample/megatron/utils.py:198–207  ·  view source on GitHub ↗
(model, args, iteration_time)

Source from the content-addressed store, hash-verified

196
197
198def flops_calculator(model, args, iteration_time):
199 gpus_per_model = torch.distributed.get_world_size(group = mpu.get_model_parallel_group())
200
201 approx_parameters_in_billions = get_parameters_in_billions(model)
202
203 giga_flops_per_model_per_train_step = approx_parameters_in_billions * args.batch_size * args.seq_length * 2.0 * 4.0
204
205 effective_tera_flops_per_gpu = giga_flops_per_model_per_train_step / (iteration_time * 1000.0 * gpus_per_model)
206
207 print_rank_0(f"Effective Tera Flops per GPU: {round(effective_tera_flops_per_gpu, 2)} and total parameters {round(approx_parameters_in_billions, 3)} B")

Callers 1

training_logFunction · 0.90

Calls 4

print_rank_0Function · 0.90
get_world_sizeMethod · 0.80

Tested by

no test coverage detected