A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 16, 05:45 UTC
[CI/Build] Replace mean with torch.all in test_pynccl.py (#10876)
Signed-off-by: Tyler Michael Smith <tyler@neuralmagic.com>
Tyler Michael Smith committed
Dec 3, 2024 at 22:23 UTC
d2bd88b1226fc93ba42cdcba51daff5e026343f0
1 file changed
+9
-16
tests/distributed/test_pynccl.py
+9
-16
@@ -62,8 +62,7 @@ def worker_fn():
62
with pynccl_comm.change_state(enable=True):
63
tensor = pynccl_comm.all_reduce(tensor)
64
torch.cuda.synchronize()
65
- result = tensor.mean().cpu().item()
66
- assert result == pynccl_comm.world_size
65
+ assert torch.all(tensor == pynccl_comm.world_size).cpu().item()
66
67
68
@pytest.mark.skipif(torch.cuda.device_count() < 2,
@@ -88,13 +87,11 @@ def multiple_allreduce_worker_fn():
87
tensor = pynccl_comm.all_reduce(tensor)
88
tensor = pynccl_comm.all_reduce(tensor)
89
torch.cuda.synchronize()
91
- result = tensor.mean().cpu().item()
92
- assert result == 4
90
+ assert torch.all(tensor == 4).cpu().item()
91
else:
92
tensor = pynccl_comm.all_reduce(tensor)
93
torch.cuda.synchronize()
96
- result = tensor.mean().cpu().item()
97
- assert result == 2
94
+ assert torch.all(tensor == 2).cpu().item()
95
96
97
@pytest.mark.skipif(torch.cuda.device_count() < 4,
@@ -116,13 +113,11 @@ def multiple_allreduce_with_vllm_worker_fn():
113
tensor = tensor_model_parallel_all_reduce(tensor)
114
tensor = tensor_model_parallel_all_reduce(tensor)
115
torch.cuda.synchronize()
119
- result = tensor.mean().cpu().item()
120
- assert result == 4
116
+ assert torch.all(tensor == 4).cpu().item()
117
else:
118
tensor = tensor_model_parallel_all_reduce(tensor)
119
torch.cuda.synchronize()
124
- result = tensor.mean().cpu().item()
125
- assert result == 2
120
+ assert torch.all(tensor == 2).cpu().item()
121
122
123
@pytest.mark.skipif(torch.cuda.device_count() < 4,
@@ -149,7 +144,7 @@ def worker_fn_with_cudagraph():
144
torch.cuda.synchronize()
145
graph.replay()
146
torch.cuda.synchronize()
152
- assert a_out.mean().cpu().item() == pynccl_comm.world_size**1
147
+ assert torch.all(a_out == pynccl_comm.world_size).cpu().item()
148
149
150
@worker_fn_wrapper
@@ -249,8 +244,7 @@ def send_recv_worker_fn():
244
src=(pynccl_comm.rank - 1) %
245
pynccl_comm.world_size)
246
torch.cuda.synchronize()
252
- result = tensor.mean().cpu().item()
253
- assert result == 1
247
+ assert torch.all(tensor == 1).cpu().item()
248
249
250
@pytest.mark.skipif(torch.cuda.device_count() < 2,
@@ -289,11 +283,10 @@ def multiple_send_recv_worker_fn():
283
src=(pynccl_comm.rank - 1) %
284
pynccl_comm.world_size)
285
torch.cuda.synchronize()
292
- result = tensor.mean().cpu().item()
286
if torch.distributed.get_rank() in [0, 2]:
294
- assert result == 1
287
+ assert torch.all(tensor == 1).cpu().item()
288
else:
296
- assert result == 2
289
+ assert torch.all(tensor == 2).cpu().item()
290
291
292
@pytest.mark.skipif(torch.cuda.device_count() < 4,