Types and Constants
Type wrappers, predefined value constants, and type aliases that appear in public method signatures.
Data type
NcclDataType
- class nccl.core.NcclDataType(*values)
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
- CHAR = 0
- UINT8 = 1
- INT32 = 2
- INT = 2
- UINT32 = 3
- INT64 = 4
- UINT64 = 5
- FLOAT16 = 6
- HALF = 6
- FLOAT32 = 7
- FLOAT = 7
- FLOAT64 = 8
- DOUBLE = 8
- BFLOAT16 = 9
- FLOAT8E4M3 = 10
- FLOAT8E5M2 = 11
- 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(*values)
Bases:
IntEnumNCCL reduction operator, mirroring
ncclRedOp_t.Used as the
opargument of reduction collectives (Communicator.allreduce(),Communicator.reduce(),Communicator.reduce_scatter()).- SUM = 0
- PROD = 1
- MAX = 2
- MIN = 3
- AVG = 4
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 |
|---|---|
|
|
|
|
|
|
|
|
|
Team
NCCLTeam
Type aliases
Aliases naming the argument types accepted by public methods. Each expands to a union of concrete types, so a value of any member type is accepted.
- nccl.core.NcclBufferSpec
Represent a union type
E.g. for int | str
- nccl.core.NcclScalarSpec
Represent a union type
E.g. for int | str
- nccl.core.NcclDeviceSpec
Represent a union type
E.g. for int | str
- nccl.core.NcclStreamSpec
Represent a union type
E.g. for int | str
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.