INNER CODE UNIT · Python
size
huggingface/large_language_model_training_playbook · throughput/all_reduce_bench.py:37
size = M * N * 4 # 4 is fp32
n = dist.get_world_size()
busbw = (size / duration) * (2 * (n - 1) / n) * 8
printflock(f"{id}:\n",
f"duration: {duration:.4f} sec\n",
f"algo throughput: {tput:.4f} bps, {tput/1e9:.4f} Gbps\n",
f"busbw: {busbw / 1e9:.4f} Gbps"
)
def run(local_rank):
hostname = socket.gethostname()
id = f"{hostname}:{local_rank}"
global_rank = dist.get_rank()
printflock(f"{id} data size: {M*N*4/1e9} GB")
mat = torch.rand(N, M, dtype=torch.float32).cuda(local_rank)
for i in range(TRIALS):