Class WeightSharding
java.lang.Object
smile.llm.parallel.WeightSharding
Slices full (unsharded) HuggingFace / Meta weights into the local TP shard.
Linear weights use PyTorch layout [out_features, in_features].
Column-parallel layers take a contiguous out-feature band; row-parallel
layers take a contiguous in-feature band.
-
Method Summary
Modifier and TypeMethodDescriptionstatic TensorcolumnParallel(Tensor weight, int tpSize, int tpRank) Column-parallel slice along dim 0 (output features).static TensorcolumnParallelBias(Tensor bias, int tpSize, int tpRank) Column-parallel bias[globalOut].static TensorcolumnParallelHeads(Tensor weight, int numHeads, int headWidth, int tpSize, int tpRank) Head-wise column shard for fused QKV / gate projections packed as[numHeads * headDim * pack, dim]wherepackis 1 or 2.static TensorrowParallel(Tensor weight, int tpSize, int tpRank) Row-parallel slice along dim 1 (input features).static TensorrowParallelHeads(Tensor weight, int numHeads, int headDim, int tpSize, int tpRank) Head-wise row shard for output projections[dim, numHeads * headDim].
-
Method Details
-
columnParallel
Column-parallel slice along dim 0 (output features).- Parameters:
weight- full weight[globalOut, in].tpSize- TP size.tpRank- this rank.- Returns:
- a view/narrow of the local out-feature rows (caller should clone if needed).
-
columnParallelBias
-
rowParallel
-
columnParallelHeads
public static Tensor columnParallelHeads(Tensor weight, int numHeads, int headWidth, int tpSize, int tpRank) Head-wise column shard for fused QKV / gate projections packed as[numHeads * headDim * pack, dim]wherepackis 1 or 2.- Parameters:
weight- full projection weight.numHeads- global head count.headWidth- channels per head (headDimorheadDim * pack).tpSize- TP size.tpRank- this rank.- Returns:
- local head rows.
-
rowParallelHeads
public static Tensor rowParallelHeads(Tensor weight, int numHeads, int headDim, int tpSize, int tpRank) Head-wise row shard for output projections[dim, numHeads * headDim].- Parameters:
weight- full output-projection weight.numHeads- global head count.headDim- per-head dimension.tpSize- TP size.tpRank- this rank.- Returns:
- local head columns.
-