MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / test_case

Method test_case

tests/distributed/custom_all_reduce.py:45–68  ·  view source on GitHub ↗

Check if the CustomAllreduce function works properly.

(self)

Source from the content-addressed store, hash-verified

43 fleet.init(is_collective=True, strategy=strategy)
44
45 def test_case(self):
46 """
47 Check if the CustomAllreduce function works properly.
48 """
49
50 mns = [[1, 2048], [2, 4096], [20, 4096], [128, 4096], [256, 4096], [256, 8192]]
51
52 hcg = fleet.get_hybrid_communicate_group()
53 model_parallel_group = hcg.get_model_parallel_group()
54 fa = CustomAllreduce(model_parallel_group)
55
56 for m, n in mns:
57 data_custom_ar = paddle.rand([m, n], dtype="bfloat16")
58 data_paddle = data_custom_ar.clone()
59 if fa.should_custom_ar(data_custom_ar):
60 data_custom_ar = fa.custom_all_reduce(data_custom_ar)
61 dist.all_reduce(data_paddle)
62 if dist.get_rank() == 0:
63 np.testing.assert_allclose(
64 data_custom_ar.numpy(),
65 data_paddle.numpy(),
66 rtol=1e-04,
67 atol=1e-04,
68 )
69
70
71if __name__ == "__main__":

Callers

nothing calls this directly

Calls 7

should_custom_arMethod · 0.95
custom_all_reduceMethod · 0.95
CustomAllreduceClass · 0.90
cloneMethod · 0.80
all_reduceMethod · 0.80
get_rankMethod · 0.80
numpyMethod · 0.80

Tested by

no test coverage detected