File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 39
39
40
40
import torch
41
41
from torch .distributed import ReduceOp , TCPStore
42
+ from torch .distributed .distributed_c10d import AllreduceOptions , ReduceOp
42
43
43
44
from torchft ._torchft import ManagerClient , ManagerServer
44
45
from torchft .checkpointing import CheckpointTransport , HTTPTransport
45
- from torchft .collectives import allreduce_quantized
46
46
from torchft .futures import future_timeout
47
47
48
48
if TYPE_CHECKING :
49
49
from torchft .process_group import ProcessGroup
50
50
51
+ IS_TRITON_AVAILABLE = True
52
+ try :
53
+ # pyre-ignore[21]: Could not find a module corresponding to import `triton`
54
+ import triton
55
+
56
+ from torchft .collectives import allreduce_quantized
57
+ except ImportError :
58
+ IS_TRITON_AVAILABLE = False
59
+
51
60
MANAGER_ADDR_KEY : str = "manager_addr"
52
61
MANAGER_PORT_ENV : str = "TORCHFT_MANAGER_PORT"
53
62
REPLICA_ID_KEY : str = "replica_id"
@@ -308,7 +317,7 @@ def allreduce(
308
317
| torch .futures .Future [torch .Tensor ]
309
318
| torch .futures .Future [List [torch .Tensor ]]
310
319
] = None
311
- if should_quantize :
320
+ if should_quantize and IS_TRITON_AVAILABLE :
312
321
fut = allreduce_quantized ([tensor ], ReduceOp .AVG , self ._pg )
313
322
else :
314
323
work = self ._pg .allreduce ([tensor ], ReduceOp .SUM )
You can’t perform that action at this time.
0 commit comments