Class RowParallelLinear
java.lang.Object
smile.llm.parallel.RowParallelLinear
Megatron-style row-parallel linear: shards
in_features across TP
ranks. After the local matmul the caller must
TensorParallelGroup.allReduceSumInPlace(int, Tensor) so outputs are replicated.
Supports dense LinearLayer or quantized LinearOp. Quantized
weights must be sharded then packed before wrapping.
-
Constructor Summary
ConstructorsConstructorDescriptionRowParallelLinear(int globalInFeatures, int outFeatures, boolean bias, int tpSize, int tpRank) Creates a dense row-parallel linear layer.RowParallelLinear(LinearOp local, int globalInFeatures, int tpSize, int tpRank) Wraps an already-sharded (and packed, if quantized) local linear op. -
Method Summary
Modifier and TypeMethodDescriptionLocal matmul; caller must all-reduce for replicated outputs.linear()Returns the dense linear layer when present.linearOp()Returns the underlying linear op.intReturns local input features (globalInFeatures / tpSize).module()Returns the dense module handle.inttpRank()Returns this TP rank.inttpSize()Returns the TP world size.
-
Constructor Details
-
RowParallelLinear
public RowParallelLinear(int globalInFeatures, int outFeatures, boolean bias, int tpSize, int tpRank) Creates a dense row-parallel linear layer.- Parameters:
globalInFeatures- global input features (must be divisible bytpSize).outFeatures- output features.bias- whether to include bias.tpSize- tensor-parallel world size.tpRank- this rank.
-
RowParallelLinear
Wraps an already-sharded (and packed, if quantized) local linear op.- Parameters:
local- local linear op.globalInFeatures- global input features.tpSize- tensor-parallel world size.tpRank- this rank.
-
-
Method Details
-
linearOp
-
linear
Returns the dense linear layer when present.- Returns:
- dense
LinearLayer.
-
module
-
localInFeatures
public int localInFeatures()Returns local input features (globalInFeatures / tpSize).- Returns:
- local input features.
-
tpRank
public int tpRank()Returns this TP rank.- Returns:
- TP rank.
-
tpSize
public int tpSize()Returns the TP world size.- Returns:
- TP world size.
-
forward
-