__init__.pyi 2.65 KB
Newer Older
Mandeep Singh Baines's avatar
Mandeep Singh Baines committed
1
2
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.

Tom Birch's avatar
Tom Birch committed
3
from typing import Any, List, Union, Optional
Mandeep Singh Baines's avatar
Mandeep Singh Baines committed
4
from torch import Tensor
Tom Birch's avatar
Tom Birch committed
5
import datetime
Mandeep Singh Baines's avatar
Mandeep Singh Baines committed
6

Tom Birch's avatar
Tom Birch committed
7
from . import rpc as rpc
8
from . import distributed_c10d as distributed_c10d
Tom Birch's avatar
Tom Birch committed
9

10
11
12
13
class Backend:
    GLOO: str
    MPI: str
    NCCL: str
Tom Birch's avatar
Tom Birch committed
14
15
16
17

class ProcessGroup:
    def size(self) -> int: ...
    def rank(self) -> int: ...
Mandeep Singh Baines's avatar
Mandeep Singh Baines committed
18

Tom Birch's avatar
Tom Birch committed
19
20
21
22
23
24
25
26
27
28
29
30
class ReduceOp:
    SUM: ReduceOp
    PRODUCT: ReduceOp
    MIN: ReduceOp
    MAX: ReduceOp
    BAND: ReduceOp
    BOR: ReduceOp
    BXOR: ReduceOp

def get_rank(group: Any = None) -> int: ...

def get_world_size(group: Any = None) -> int: ...
31
def get_backend(group: Optional[Any] = None) -> Any: ...
Mandeep Singh Baines's avatar
Mandeep Singh Baines committed
32
def broadcast(tensor: Tensor, src: Any, group: Any, async_op: Any = False): ...
33
34
def gather(tensor: Tensor, gather_list: Optional[List[Tensor]], dst: Any, group:Optional[ProcessGroup] = None, async_op: Optional[bool] = False): ...
def reduce(tensor: Tensor, dst: Any, op: Optional[Any]=ReduceOp.SUM, group:Optional[ProcessGroup] = None, async_op: Optional[bool] = False): ...
35
def broadcast_object_list(object_list: List[Any], src: int, group:Optional[ProcessGroup] = None): ...
Mandeep Singh Baines's avatar
Mandeep Singh Baines committed
36

Tom Birch's avatar
Tom Birch committed
37
38
def is_initialized() -> bool: ...

39
def init_process_group(backend: Union[str, Backend], init_method: Optional[str] = None, timeout: datetime.timedelta = datetime.timedelta(0, 1800), rank: Optional[int] = None, world_size: Optional[int] = None): ...
Tom Birch's avatar
Tom Birch committed
40
41
def new_group(ranks: List[int], timeout: datetime.timedelta = datetime.timedelta(0, 1800), backend: Union[None, str, Backend] = None): ...

42
43
def all_to_all(output: List[Tensor], input: List[Tensor], group:Optional[ProcessGroup] = None, async_op: bool = False): ...
def all_to_all_single(output: Tensor, input: Tensor, output_split_size: Optional[List[int]] = None, input_split_size: Optional[List[int]] = None, group:Optional[ProcessGroup] = None, async_op: bool = False): ...
Tom Birch's avatar
Tom Birch committed
44
45
46
def all_reduce(tensor: Tensor, op: ReduceOp = ReduceOp.SUM, group:Optional[ProcessGroup] = None, async_op: bool = False): ...
def all_gather(tensor_list: List[Tensor], tensor: Tensor, group:Optional[ProcessGroup] = None, async_op: bool = False): ...

47
48
def destroy_process_group() -> None: ...

Tom Birch's avatar
Tom Birch committed
49
50
51
52
53
def send(tensor: Tensor, dst: int, group: Optional[ProcessGroup] = None, tag: Optional[int] = None) -> None: ...
def isend(tensor: Tensor, dst: int, group: Optional[ProcessGroup] = None, tag: Optional[int] = None) -> None: ...
def recv(tensor: Tensor, src: Optional[int] = None, group: Optional[ProcessGroup] = None, tag: Optional[int] = None) -> int: ...
def irecv(tensor: Tensor, src: Optional[int] = None, group: Optional[ProcessGroup] = None, tag: Optional[int] = None) -> int: ...

Mandeep Singh Baines's avatar
Mandeep Singh Baines committed
54
55
class group(object):
    WORLD: Any
Tom Birch's avatar
Tom Birch committed
56
57

class RRef: ...