MCPcopy Create free account
hub / github.com/cupy/cupy / DistributedArray

Class DistributedArray

cupyx/distributed/array/_array.py:65–834  ·  view source on GitHub ↗

__init__(self, shape, dtype, chunks_map, mode=REPLICA, comms=None) Multi-dimensional array distributed across multiple CUDA devices. This class implements some elementary operations that :class:`cupy.ndarray` provides. The array content is split into chunks, contiguous arrays

Source from the content-addressed store, hash-verified

63
64
65class DistributedArray(ndarray):
66 """
67 __init__(self, shape, dtype, chunks_map, mode=REPLICA, comms=None)
68
69 Multi-dimensional array distributed across multiple CUDA devices.
70
71 This class implements some elementary operations that :class:`cupy.ndarray`
72 provides. The array content is split into chunks, contiguous arrays
73 corresponding to slices of the original array. Note that one device can
74 hold multiple chunks.
75
76 This direct constructor is designed for internal calls. Users should create
77 distributed arrays using :func:`distributed_array`.
78
79 Args:
80 shape (tuple of ints): Shape of created array.
81 dtype (dtype_like): Any object that can be interpreted as a numpy data
82 type.
83 chunks_map (dict from int to list of chunks): Lists of chunk objects
84 associated with each device.
85 mode (mode object, optional): Mode that determines how overlaps
86 of the chunks are interpreted. Defaults to
87 ``cupyx.distributed.array.REPLICA``.
88 comms (optional): Communicator objects which a distributed array
89 hold internally. Sharing them with other distributed arrays can
90 save time because their initialization is a costly operation.
91
92 .. seealso::
93 :attr:`DistributedArray.mode` for details about modes.
94 """
95
96 _chunks_map: dict[int, list[_Chunk]]
97 _mode: _modes.Mode
98 _streams: dict[int, Stream]
99 _comms: dict[int, _Communicator]
100
101 def __new__( # noqa: PYI034
102 cls, shape: tuple[int, ...], dtype: DTypeLike,
103 chunks_map: dict[int, list[_Chunk]],
104 mode: _modes.Mode = _modes.REPLICA,
105 comms: dict[int, _Communicator] | None = None,
106 ) -> DistributedArray:
107 mem = _MultiDeviceDummyMemory(0)
108 memptr = _MultiDeviceDummyPointer(mem, 0)
109 obj = super().__new__(cls, shape, dtype, memptr=memptr)
110 obj._chunks_map = chunks_map
111
112 obj._mode = mode
113
114 obj._streams = {}
115 obj._comms = comms if comms is not None else {}
116
117 return obj
118
119 def __init__(self, *args, **kwargs) -> None:
120 super().__init__(*args, **kwargs)
121
122 def __array_finalize__(self, obj):

Callers 3

_to_op_modeMethod · 0.85
reshardMethod · 0.85
distributed_arrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected