Class ParallelState
java.lang.Object
smile.llm.parallel.ParallelState
Per-rank view of a
ParallelConfig mesh.
Phase 1: globalRank == tpRank with ppRank == 0. Phase 2
multi-node PP will set globalRank = ppRank * tpSize + tpRank.
-
Constructor Summary
ConstructorsConstructorDescriptionParallelState(ParallelConfig config, int tpRank) Phase-1 constructor (ppRank=0,dpRank=0).ParallelState(ParallelConfig config, int tpRank, int ppRank, int dpRank) Full mesh-coordinate constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the thread-local parallel state.config()Returns the process-mesh configuration.static ParallelStatecurrent()Returns the state bound to the calling thread, if any.byteReturns the CUDA device index for this rank.intdpRank()Returns this rank's data-parallel index.intReturns the global rank in the process mesh.booleanReturns whether this rank is the first pipeline stage.booleanReturns whether this rank is the last pipeline stage.booleanisTpRoot()Returns whether this rank is the TP root (tpRank == 0).intppRank()Returns this rank's pipeline-parallel index.static voidsetCurrent(ParallelState state) Binds this state to the calling thread for collective helpers.inttpRank()Returns this rank's tensor-parallel index.inttpSize()Returns the tensor-parallel size.
-
Constructor Details
-
ParallelState
Phase-1 constructor (ppRank=0,dpRank=0).- Parameters:
config- process-mesh configuration.tpRank- tensor-parallel rank.
-
ParallelState
Full mesh-coordinate constructor.- Parameters:
config- process-mesh configuration.tpRank- tensor-parallel rank.ppRank- pipeline-parallel rank.dpRank- data-parallel rank.
-
-
Method Details
-
config
-
tpSize
public int tpSize()Returns the tensor-parallel size.- Returns:
- TP size.
-
tpRank
public int tpRank()Returns this rank's tensor-parallel index.- Returns:
- TP rank.
-
ppRank
public int ppRank()Returns this rank's pipeline-parallel index.- Returns:
- PP rank.
-
dpRank
public int dpRank()Returns this rank's data-parallel index.- Returns:
- DP rank.
-
globalRank
public int globalRank()Returns the global rank in the process mesh.- Returns:
- global rank.
-
deviceIndex
public byte deviceIndex()Returns the CUDA device index for this rank.- Returns:
- device index.
-
isTpRoot
public boolean isTpRoot()Returns whether this rank is the TP root (tpRank == 0).- Returns:
trueif TP root.
-
isFirstStage
public boolean isFirstStage()Returns whether this rank is the first pipeline stage.- Returns:
trueifppRank == 0.
-
isLastStage
public boolean isLastStage()Returns whether this rank is the last pipeline stage.- Returns:
trueif last PP stage.
-
setCurrent
Binds this state to the calling thread for collective helpers.- Parameters:
state- state to bind, ornullto clear.
-
current
Returns the state bound to the calling thread, if any.- Returns:
- current state, or
nullif unset.
-
clearCurrent
public static void clearCurrent()Clears the thread-local parallel state.
-