Class TensorParallelGroup
java.lang.Object
smile.llm.parallel.TensorParallelGroup
- All Implemented Interfaces:
AutoCloseable
Single-process tensor-parallel group: one
ParallelState and CUDA
device per TP rank, plus NCCL (or peer-copy fallback) collectives.
When NCCL is available, each rank calls allReduceSumInPlace(int, Tensor) on its
own tensor without a host barrier gather. The communicator is retained for
future pipeline-parallel send/recv on the same process group.
-
Constructor Summary
ConstructorsConstructorDescriptionTensorParallelGroup(ParallelConfig config) Creates a TP group for the given mesh configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidallReduceSumInPlace(int tpRank, Tensor local) In-place sum all-reduce.voidBroadcastslocals[root]to every other slot.voidclose()config()Returns the process-mesh configuration.device(int tpRank) Returns the CUDA device for a TP rank.booleanhasNccl()Returns whether NCCL backs collectives for this group.booleanisClosed()Returns whetherclose()has been called.mesh()Returns the device mesh for this group.state(int tpRank) Returns the parallel state for a TP rank.inttpSize()Returns the tensor-parallel size.
-
Constructor Details
-
TensorParallelGroup
Creates a TP group for the given mesh configuration.- Parameters:
config- process-mesh configuration (ppSizemust be 1 in phase 1).
-
-
Method Details
-
config
-
mesh
-
tpSize
public int tpSize()Returns the tensor-parallel size.- Returns:
- TP size.
-
hasNccl
public boolean hasNccl()Returns whether NCCL backs collectives for this group.- Returns:
truewhen an NCCL communicator was created.
-
state
Returns the parallel state for a TP rank.- Parameters:
tpRank- tensor-parallel rank.- Returns:
- per-rank state.
-
device
Returns the CUDA device for a TP rank.- Parameters:
tpRank- tensor-parallel rank.- Returns:
- device for that rank.
-
allReduceSumInPlace
In-place sum all-reduce. Every TP rank's worker thread must call this with its local tensor (same shape/dtype). No-op whentpSize == 1.- Parameters:
tpRank- calling rank.local- local tensor to reduce in place.
-
broadcast
Broadcastslocals[root]to every other slot. Caller must supply the full array (one tensor per rank) from a single coordinating thread, or use per-rank buffers that are already filled.- Parameters:
locals- one tensor per TP rank.root- source rank whose tensor is copied to the others.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
isClosed
-