cupyx.distributed.array.DistributedArray#

class cupyx.distributed.array.DistributedArray(self, shape, dtype, chunks_map, mode=REPLICA, comms=None)[source]#

Multi-dimensional array distributed across multiple CUDA devices.

This class implements some elementary operations that cupy.ndarray provides. The array content is split into chunks, contiguous arrays corresponding to slices of the original array. Note that one device can hold multiple chunks.

This direct constructor is designed for internal calls. Users should create distributed arrays using distributed_array().

Parameters:
  • shape (tuple of ints) – Shape of created array.

  • dtype (dtype_like) – Any object that can be interpreted as a numpy data type.

  • chunks_map (dict from int to list of chunks) – Lists of chunk objects associated with each device.

  • mode (mode object, optional) – Mode that determines how overlaps of the chunks are interpreted. Defaults to cupyx.distributed.array.REPLICA.

  • comms (optional) – Communicator objects which a distributed array hold internally. Sharing them with other distributed arrays can save time because their initialization is a costly operation.

Return type:

DistributedArray

See also

DistributedArray.mode for details about modes.

Methods

__getitem__(*args, **kwargs)[source]#

Not supported.

__setitem__(*args, **kwargs)[source]#

Not supported.

__len__(*args, **kwargs)[source]#

Not supported.

__iter__(*args, **kwargs)[source]#

Not supported.

__copy__(*args, **kwargs)[source]#

Not supported.

all(*args, **kwargs)[source]#

Not supported.

all_chunks()[source]#

Return the chunks with all buffered data flushed.

Buffered data are created in situations such as resharding and mode changing.

Return type:

dict[int, list[cupy.ndarray]]

any(*args, **kwargs)[source]#

Not supported.

argmax(*args, **kwargs)[source]#

Not supported.

argmin(*args, **kwargs)[source]#

Not supported.

argpartition(*args, **kwargs)[source]#

Not supported.

argsort(*args, **kwargs)[source]#

Not supported.

astype(*args, **kwargs)[source]#

Not supported.

change_mode(mode)[source]#

Return a view or a copy in the given mode.

Parameters:

mode (mode Object) – How overlaps of the chunks are interpreted.

Return type:

DistributedArray

See also

DistributedArray.mode for details about modes.

choose(*args, **kwargs)[source]#

Not supported.

clip(*args, **kwargs)[source]#

Not supported.

compress(*args, **kwargs)[source]#

Not supported.

conj(self) ndarray#
conjugate(self) ndarray#
copy(*args, **kwargs)[source]#

Not supported.

cumprod(*args, **kwargs)[source]#

Not supported.

cumsum(*args, **kwargs)[source]#

Not supported.

diagonal(*args, **kwargs)[source]#

Not supported.

dot(*args, **kwargs)[source]#

Not supported.

dump(*args, **kwargs)[source]#

Not supported.

dumps(*args, **kwargs)[source]#

Not supported.

fill(*args, **kwargs)[source]#

Not supported.

flatten(*args, **kwargs)[source]#

Not supported.

get(stream=None, order='C', out=None, blocking=True)[source]#

Return a copy of the array on the host memory.

Return type:

ndarray

item(*args, **kwargs)[source]#

Not supported.

max(axis=None, out=None, keepdims=False)[source]#

Return the maximum along a given axis.

Note

Currently, it only supports non-None values for axis and the default values for out and keepdims.

mean(*args, **kwargs)[source]#

Not supported.

min(axis=None, out=None, keepdims=False)[source]#

Return the minimum along a given axis.

Note

Currently, it only supports non-None values for axis and the default values for out and keepdims.

nonzero(*args, **kwargs)[source]#

Not supported.

partition(*args, **kwargs)[source]#

Not supported.

prod(axis=None, dtype=None, out=None, keepdims=None)[source]#

Return the minimum along a given axis.

Note

Currently, it only supports non-None values for axis and the default values for out and keepdims.

ptp(*args, **kwargs)[source]#

Not supported.

put(*args, **kwargs)[source]#

Not supported.

ravel(*args, **kwargs)[source]#

Not supported.

reduced_view(*args, **kwargs)[source]#

Not supported.

repeat(*args, **kwargs)[source]#

Not supported.

reshape(*args, **kwargs)[source]#

Not supported.

reshard(index_map)[source]#

Return a view or a copy having the given index_map.

Data transfers across devices are done on separate streams created internally. To make them asynchronous, transferred data is buffered and reflected to the chunks when necessary.

Parameters:

index_map (dict from int to array indices) – Indices for the chunks that devices with designated IDs own. The current index_map of a distributed array can be obtained from DistributedArray.index_map.

Return type:

DistributedArray

round(*args, **kwargs)[source]#

Not supported.

scatter_add(*args, **kwargs)[source]#

Not supported.

scatter_max(*args, **kwargs)[source]#

Not supported.

scatter_min(*args, **kwargs)[source]#

Not supported.

searchsorted(*args, **kwargs)[source]#

Not supported.

set(*args, **kwargs)[source]#

Not supported.

sort(*args, **kwargs)[source]#

Not supported.

squeeze(*args, **kwargs)[source]#

Not supported.

std(*args, **kwargs)[source]#

Not supported.

sum(axis=None, dtype=None, out=None, keepdims=False)[source]#

Return the minimum along a given axis.

Note

Currently, it only supports non-None values for axis and the default values for out and keepdims.

swapaxes(*args, **kwargs)[source]#

Not supported.

take(*args, **kwargs)[source]#

Not supported.

toDlpack(*args, **kwargs)[source]#

Not supported.

tobytes(*args, **kwargs)[source]#

Not supported.

tofile(*args, **kwargs)[source]#

Not supported.

tolist(*args, **kwargs)[source]#

Not supported.

trace(*args, **kwargs)[source]#

Not supported.

transpose(*args, **kwargs)[source]#

Not supported.

var(*args, **kwargs)[source]#

Not supported.

view(*args, **kwargs)[source]#

Not supported.

__eq__(value, /)#

Return self==value.

__ne__(value, /)#

Return self!=value.

__lt__(value, /)#

Return self<value.

__le__(value, /)#

Return self<=value.

__gt__(value, /)#

Return self>value.

__ge__(value, /)#

Return self>=value.

__bool__()#

True if self else False

Attributes

T#

Not supported.

base#

Not supported.

cstruct#

Not supported.

data#

Not supported.

device#

Not supported.

devices#

A collection of device IDs holding part of the data.

dtype#
flags#

Not supported.

flat#

Not supported.

imag#

Not supported.

index_map#

Indices for the chunks that devices with designated IDs own.

itemsize#

Size of each element in bytes.

mode#

Describe how overlaps of the chunks are interpreted.

In the replica mode, chunks are guaranteed to have identical values on their overlapping segments. In other modes, they are not necessarily identical and represent the original data as their max, sum, etc.

DistributedArray currently supports cupyx.distributed.array.REPLICA, cupyx.distributed.array.MIN, cupyx.distributed.array.MAX, cupyx.distributed.array.SUM, cupyx.distributed.array.PROD modes.

Many operations on distributed arrays including cupy.ufunc and matmul() involve changing their mode beforehand. These mode conversions are done automatically, so in most cases users do not have to manage modes manually.

Example

>>> A = distributed_array(
...     cupy.arange(6).reshape(2, 3),
...     make_2d_index_map([0, 2], [0, 1, 3],
...                       [[{0}, {1, 2}]]))
>>> B = distributed_array(
...     cupy.arange(12).reshape(3, 4),
...     make_2d_index_map([0, 1, 3], [0, 2, 4],
...                       [[{0}, {0}],
...                        [{1}, {2}]]))
>>> C = A @ B
>>> C
array([[20, 23, 26, 29],
       [56, 68, 80, 92]])
>>> C.mode
'sum'
>>> C.all_chunks()
{0: [array([[0, 0],
            [0, 3]]),     # left half
     array([[0, 0],
            [6, 9]])],    # right half
 1: [array([[20, 23],
            [56, 65]])],  # left half
 2: [array([[26, 29],
            [74, 83]])]}  # right half
>>> C_replica = C.change_mode('replica')
>>> C_replica.mode
'replica'
>>> C_replica.all_chunks()
{0: [array([[20, 23],
            [56, 68]]),   # left half
     array([[26, 29],
            [80, 92]])],  # right half
 1: [array([[20, 23],
            [56, 68]])],  # left half
 2: [array([[26, 29],
            [80, 92]])]}  # right half
nbytes#

Total size of all elements in bytes.

It does not count skips between elements.

ndim#

Number of dimensions.

a.ndim is equivalent to len(a.shape).

real#

Not supported.

shape#

Tuple of array dimensions.

Assignment to this property is currently not supported.

size#
strides#

Not supported.