MCPcopy
hub / github.com/hpcaitech/ColossalAI / check_4gpu

Function check_4gpu

tests/test_fp8/test_fp8_allreduce.py:27–42  ·  view source on GitHub ↗
(shape, dtype, fp8_format, async_op)

Source from the content-addressed store, hash-verified

25@parameterize("fp8_format", ["e4m3", "e5m2"])
26@parameterize("async_op", [True, False])
27def check_4gpu(shape, dtype, fp8_format, async_op):
28 x = torch.rand(shape, dtype=dtype, device=get_accelerator().get_current_device())
29 x_fp8 = x.clone()
30 origin_handle = dist.all_reduce(x, async_op=async_op)
31 fp8_handle = all_reduce_fp8(x_fp8, fp8_format=fp8_format, async_op=async_op)
32 if async_op:
33 origin_handle.wait()
34 fp8_handle.wait()
35 assert_close(x, x_fp8, rtol=0.1, atol=0.1)
36
37 origin_handle = dist.all_reduce(x, op=dist.ReduceOp.AVG, async_op=async_op)
38 fp8_handle = all_reduce_fp8(x_fp8, op=dist.ReduceOp.AVG, fp8_format=fp8_format, async_op=async_op)
39 if async_op:
40 origin_handle.wait()
41 fp8_handle.wait()
42 assert_close(x, x_fp8, rtol=0.1, atol=0.1)
43
44
45def run_dist(rank, world_size, port):

Callers 1

run_distFunction · 0.70

Calls 5

get_acceleratorFunction · 0.90
all_reduce_fp8Function · 0.90
get_current_deviceMethod · 0.45
cloneMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…