Class ColumnParallelLinear
java.lang.Object
smile.llm.parallel.ColumnParallelLinear
Megatron-style column-parallel linear: shards
out_features across TP
ranks. Input is replicated; output is the local shard (no gather).
Supports dense LinearLayer or quantized LinearOp (FP8 /
NVFP4 / Marlin). Quantized weights must be sharded then packed before
constructing this wrapper.
-
Constructor Summary
ConstructorsConstructorDescriptionColumnParallelLinear(int inFeatures, int globalOutFeatures, boolean bias, int tpSize, int tpRank) Creates a dense column-parallel linear layer for the given TP rank.ColumnParallelLinear(LinearOp local, int globalOutFeatures, int tpSize, int tpRank) Wraps an already-sharded (and packed, if quantized) local linear op. -
Method Summary
Modifier and TypeMethodDescriptionApplies the local linear transform toinput.linear()Returns the underlying dense linear layer.linearOp()Returns the localLinearOp(dense or quantized).intReturns the local output feature count for this TP rank.module()Returns the native module handle for weight registration (dense only).inttpRank()Returns this tensor-parallel rank.inttpSize()Returns the tensor-parallel world size.
-
Constructor Details
-
ColumnParallelLinear
public ColumnParallelLinear(int inFeatures, int globalOutFeatures, boolean bias, int tpSize, int tpRank) Creates a dense column-parallel linear layer for the given TP rank.- Parameters:
inFeatures- input feature count.globalOutFeatures- global output feature count (must be divisible bytpSize).bias- whether to include a bias term.tpSize- tensor-parallel world size.tpRank- this rank in[0, tpSize).
-
ColumnParallelLinear
Wraps an already-sharded (and packed, if quantized) local linear op.- Parameters:
local- already-sharded local linear op.globalOutFeatures- global output feature count (must be divisible bytpSize).tpSize- tensor-parallel world size.tpRank- this rank in[0, tpSize).
-
-
Method Details
-
linearOp
-
linear
Returns the underlying dense linear layer.- Returns:
- dense
LinearLayer. - Throws:
IllegalStateException- if this wrapper holds a quantized op.
-
module
Returns the native module handle for weight registration (dense only).- Returns:
- native module handle.
-
localOutFeatures
public int localOutFeatures()Returns the local output feature count for this TP rank.- Returns:
globalOutFeatures / tpSize.
-
tpRank
public int tpRank()Returns this tensor-parallel rank.- Returns:
- rank in
[0, tpSize).
-
tpSize
public int tpSize()Returns the tensor-parallel world size.- Returns:
- TP world size.
-
forward
-