Communicator Class
- class nccl.core.Communicator(ptr: int = 0)
Bases:
objectNCCL communicator for collective and point-to-point operations.
A communicator represents a group of ranks that can perform collective operations (e.g. allreduce, broadcast) and point-to-point operations (send/recv). Each rank has a unique ID in
[0, nranks).Communicator instances expose a number of properties for inspection (
ptr,nranks,device,rank, plus device-API related properties likecuda_dev,nvml_dev,device_api_support,multimem_support,gin_type,n_lsa_teams,host_rma_support,railed_gin_type); see the per-property documentation for details.- __init__(ptr: int = 0) None
Initializes a communicator with a raw NCCL pointer.
Unlike the
init()classmethod, this constructor allowsptr=0for creating null communicators (e.g. whensplit()excludes a rank). A null communicator can later be initialized viainitialize(), or used as the caller forgrow()to join an existing communicator.- Parameters:
ptr – Integer representing an NCCL communicator pointer (0 for a null communicator). Defaults to 0.
Properties
Identity
- Communicator.ptr
Raw pointer to the underlying
ncclComm_tstructure (0 if destroyed or null).
- Communicator.is_valid
Whether the communicator is valid (not destroyed or null).
- Communicator.nranks
Total number of ranks in the communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.device
CUDA device associated with this communicator.
Returns a
cuda.core.Deviceproviding additional functionality such asto_system_devicefor obtaining the NVML device, device properties, and synchronization.- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.rank
This caller’s rank within the communicator (0 to nranks - 1).
- Raises:
NcclInvalid – If the communicator is not initialized.
Device-API capability
These properties reflect the underlying NCCL ncclCommProperties_t
structure.
- Communicator.cuda_dev
CUDA device ID associated with this communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.nvml_dev
NVML device ID for the GPU associated with this communicator.
Uses the NVML indexing space, which may differ from CUDA indexing.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.device_api_support
Whether device-side NCCL operations are supported on this platform.
If False, a device communicator cannot be created.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.multimem_support
Whether ranks in the same LSA team can communicate using multimem.
If False, a device communicator cannot be created with multimem resources.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.gin_type
GPU-Initiated Networking (GIN) type.
If equal to NcclGinType.NONE, a device communicator cannot be created with GIN resources.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.n_lsa_teams
Number of Load/Store Accessible (LSA) teams for this communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.host_rma_support
Whether host RMA is supported on this communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.railed_gin_type
Railed GIN type supported by this communicator.
If equal to
NcclGinType.NONE, a device communicator cannot be created with GIN connection typeNcclGinConnectionType.RAIL.- Raises:
NcclInvalid – If the communicator is not initialized.
Teams
A NCCLTeam names a strided subset of the communicator’s ranks.
These properties return the predefined teams; pass one to
TeamRequirement or to the rank converters below. See
Teams for team semantics.
- Communicator.team_world
The world team for this communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.team_lsa
The LSA team for this communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.team_rail
The rail team for this communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.team_rank_to_world(team: NCCLTeam, team_rank: int) int
Maps a rank within
teamto its rank in this communicator.teamis anchored at this rank, soteam.rankmaps back torankand neighbours are offset byteam.stride.- Parameters:
team – The team
team_rankis expressed in, as returned byteam_world,team_lsa, orteam_rail.team_rank – Rank within
team.
- Returns:
The corresponding rank in this communicator.
- Raises:
NcclInvalid – If the communicator is not initialized.
- Communicator.team_rank_to_lsa(team: NCCLTeam, team_rank: int) int
Maps a rank within
teamto its rank in the LSA team.The LSA-relative counterpart of
team_rank_to_world():team.rankmaps back to this rank’s index inteam_lsa. Only meaningful whenteam_ranknames a peer that shares this rank’s LSA team.- Parameters:
team – The team
team_rankis expressed in, as returned byteam_world,team_lsa, orteam_rail.team_rank – Rank within
team.
- Returns:
The corresponding rank in the LSA team, or
-1if the device resource state could not be initialized.- Raises:
NcclInvalid – If the communicator is not initialized.