Types and Constants
Type wrappers, predefined value constants, and type aliases that appear in public method signatures.
Data type
NcclDataType
- class nccl.core.NcclDataType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
IntEnumNCCL data type, mirroring
ncclDataType_t.Used as the
dtypeof buffer specs and as thedatatypeargument of NCCL collective operations. Supports conversion to/from NumPy dtypes viafrom_numpy_dtype()andnumpy_dtype.- INT8 = 0
Signed 8-bit integer.
- UINT8 = 1
Unsigned 8-bit integer.
- INT32 = 2
Signed 32-bit integer.
- UINT32 = 3
Unsigned 32-bit integer.
- INT64 = 4
Signed 64-bit integer.
- UINT64 = 5
Unsigned 64-bit integer.
- FLOAT16 = 6
IEEE half-precision floating point (2 bytes).
- FLOAT32 = 7
IEEE single-precision floating point (4 bytes).
- FLOAT64 = 8
IEEE double-precision floating point (8 bytes).
- BFLOAT16 = 9
Brain floating-point (16-bit truncated single precision; CUDA 11+).
- FLOAT8E4M3 = 10
8-bit floating point, 4 exponent + 3 mantissa bits (CUDA >= 11.8, SM >= 90).
- FLOAT8E5M2 = 11
8-bit floating point, 5 exponent + 2 mantissa bits (CUDA >= 11.8, SM >= 90).
- classmethod from_numpy_dtype(dtype: numpy.dtype) NcclDataType
Maps a NumPy dtype to its NCCL equivalent.
- Parameters:
dtype – A NumPy dtype. Mapped first by name (for
ml-dtypeslikebfloat16,float8_e4m3fn,float8_e5m2) and then by(kind, itemsize)for standard types.- Returns:
Corresponding
NcclDataTypemember.- Raises:
NcclInvalid – If the dtype has no NCCL equivalent.
- property itemsize: int
Size in bytes of a single element of this data type.
- property numpy_dtype: numpy.dtype
Equivalent NumPy dtype.
- Returns:
NumPy dtype corresponding to this NCCL data type. For
BFLOAT16and the float8 variants,ml-dtypesmust be installed.- Raises:
NcclInvalid – If
ml-dtypesis required but not installed.
Predefined data type constants
Module-level NcclDataType instances for use as the dtype
argument of buffer specs.
Constant |
Maps to |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Reduction operator
NcclRedOp
- class nccl.core.NcclRedOp(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)
Bases:
IntEnumNCCL reduction operator, mirroring
ncclRedOp_t.Used as the
opargument of reduction collectives (Communicator.allreduce(),Communicator.reduce(),Communicator.reduce_scatter()).- SUM = 0
Element-wise sum (
+).
- PROD = 1
Element-wise product (
*).
- MAX = 2
Element-wise maximum.
- MIN = 3
Element-wise minimum.
- AVG = 4
Sum across all ranks divided by the number of ranks.
Predefined reduction operators
Module-level NcclRedOp instances for use as the op argument
of reduction collectives. User-defined operators are created via
Communicator.create_pre_mul_sum().
Constant |
Maps to |
|---|---|
|
|
|
|
|
|
|
|
|
Exceptions
NcclInvalid
Python-side validation exception, raised when a public API receives a malformed argument before it reaches NCCL itself.
- exception nccl.core.NcclInvalid(msg)
Bases:
ExceptionRaised when an argument provided to an NCCL4Py API is invalid.
Used for argument validation errors that the Python layer detects before forwarding the call to NCCL (e.g. unsupported dtype, mismatched buffer counts, wrong device). Errors raised by NCCL itself are reported as NCCLError from the bindings layer.