Record Class TensorShardSpec
java.lang.Object
java.lang.Record
smile.llm.parallel.TensorShardSpec
- Record Components:
tpSize- tensor-parallel world size.tpRank- this rank.numHeads- local query heads (global / tpSize).numKvHeads- local KV heads.intermediateSize- local FFN intermediate size.linearNumKeyHeads- local DeltaNet key heads (may equal global when not sharded).linearNumValueHeads- local DeltaNet value heads.
public record TensorShardSpec(int tpSize, int tpRank, int numHeads, int numKvHeads, int intermediateSize, int linearNumKeyHeads, int linearNumValueHeads)
extends Record
Local shard sizes for a dense decoder under tensor parallelism.
-
Constructor Summary
ConstructorsConstructorDescriptionTensorShardSpec(int tpSize, int tpRank, int numHeads, int numKvHeads, int intermediateSize, int linearNumKeyHeads, int linearNumValueHeads) Creates an instance of aTensorShardSpecrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static TensorShardSpecforRank(int tpSize, int tpRank, int numHeads, int numKvHeads, int intermediateSize, int linearNumKeyHeads, int linearNumValueHeads) Builds a per-rank shard spec.final inthashCode()Returns a hash code value for this object.intReturns the value of theintermediateSizerecord component.intReturns the value of thelinearNumKeyHeadsrecord component.intReturns the value of thelinearNumValueHeadsrecord component.intnumHeads()Returns the value of thenumHeadsrecord component.intReturns the value of thenumKvHeadsrecord component.static TensorShardSpecsingle(int numHeads, int numKvHeads, int intermediateSize, int linearNumKeyHeads, int linearNumValueHeads) Single-device shard (no tensor parallelism).final StringtoString()Returns a string representation of this record class.inttpRank()Returns the value of thetpRankrecord component.inttpSize()Returns the value of thetpSizerecord component.
-
Constructor Details
-
TensorShardSpec
public TensorShardSpec(int tpSize, int tpRank, int numHeads, int numKvHeads, int intermediateSize, int linearNumKeyHeads, int linearNumValueHeads) Creates an instance of aTensorShardSpecrecord class.- Parameters:
tpSize- the value for thetpSizerecord componenttpRank- the value for thetpRankrecord componentnumHeads- the value for thenumHeadsrecord componentnumKvHeads- the value for thenumKvHeadsrecord componentintermediateSize- the value for theintermediateSizerecord componentlinearNumKeyHeads- the value for thelinearNumKeyHeadsrecord componentlinearNumValueHeads- the value for thelinearNumValueHeadsrecord component
-
-
Method Details
-
single
public static TensorShardSpec single(int numHeads, int numKvHeads, int intermediateSize, int linearNumKeyHeads, int linearNumValueHeads) Single-device shard (no tensor parallelism).- Parameters:
numHeads- query head count.numKvHeads- key/value head count.intermediateSize- FFN intermediate size.linearNumKeyHeads- DeltaNet key head count.linearNumValueHeads- DeltaNet value head count.- Returns:
- shard with
tpSize=1.
-
forRank
public static TensorShardSpec forRank(int tpSize, int tpRank, int numHeads, int numKvHeads, int intermediateSize, int linearNumKeyHeads, int linearNumValueHeads) Builds a per-rank shard spec. RequiresnumHeads,numKvHeads, andintermediateSizeto be divisible bytpSize. Linear-attn head counts must also divide when> 0.- Parameters:
tpSize- tensor-parallel size.tpRank- this rank.numHeads- global query head count.numKvHeads- global key/value head count.intermediateSize- global FFN intermediate size.linearNumKeyHeads- global DeltaNet key heads (0if unused).linearNumValueHeads- global DeltaNet value heads (0if unused).- Returns:
- local shard sizes for
tpRank.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with thecomparemethod from their corresponding wrapper classes. -
tpSize
-
tpRank
-
numHeads
-
numKvHeads
public int numKvHeads()Returns the value of thenumKvHeadsrecord component.- Returns:
- the value of the
numKvHeadsrecord component
-
intermediateSize
public int intermediateSize()Returns the value of theintermediateSizerecord component.- Returns:
- the value of the
intermediateSizerecord component
-
linearNumKeyHeads
public int linearNumKeyHeads()Returns the value of thelinearNumKeyHeadsrecord component.- Returns:
- the value of the
linearNumKeyHeadsrecord component
-
linearNumValueHeads
public int linearNumValueHeads()Returns the value of thelinearNumValueHeadsrecord component.- Returns:
- the value of the
linearNumValueHeadsrecord component
-