Record Class KvCacheLayout
java.lang.Object
java.lang.Record
smile.llm.cache.KvCacheLayout
- Record Components:
numLayers- number of transformer layers that store KV in the pool.numKvHeads- number of key/value heads.headDim- dimension of each attention head.maxBatchSize- maximum concurrent batch size (used for CPU / test sizing).maxSeqLen- maximum sequence length (used for CPU / test sizing and minima).
public record KvCacheLayout(int numLayers, int numKvHeads, int headDim, int maxBatchSize, int maxSeqLen)
extends Record
Family-agnostic layout used to size a
KvCachePool.-
Constructor Summary
ConstructorsConstructorDescriptionKvCacheLayout(int numLayers, int numKvHeads, int headDim, int maxBatchSize, int maxSeqLen) Creates an instance of aKvCacheLayoutrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intheadDim()Returns the value of theheadDimrecord component.intReturns the value of themaxBatchSizerecord component.intReturns the value of themaxSeqLenrecord component.intReturns the value of thenumKvHeadsrecord component.intReturns the value of thenumLayersrecord component.static KvCacheLayoutBuilds a layout from common dense-decoder dimensions.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
KvCacheLayout
public KvCacheLayout(int numLayers, int numKvHeads, int headDim, int maxBatchSize, int maxSeqLen) Creates an instance of aKvCacheLayoutrecord class.- Parameters:
numLayers- the value for thenumLayersrecord componentnumKvHeads- the value for thenumKvHeadsrecord componentheadDim- the value for theheadDimrecord componentmaxBatchSize- the value for themaxBatchSizerecord componentmaxSeqLen- the value for themaxSeqLenrecord component
-
-
Method Details
-
of
public static KvCacheLayout of(int numLayers, int dim, int numHeads, Integer numKvHeads, int maxBatchSize, int maxSeqLen) Builds a layout from common dense-decoder dimensions.- Parameters:
numLayers- layer count.dim- token embedding dimension.numHeads- query head count.numKvHeads- key/value head count, ornullto usenumHeads.maxBatchSize- max batch size.maxSeqLen- max sequence length.- Returns:
- the cache layout.
-
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. -
numLayers
-
numKvHeads
public int numKvHeads()Returns the value of thenumKvHeadsrecord component.- Returns:
- the value of the
numKvHeadsrecord component
-
headDim
-
maxBatchSize
public int maxBatchSize()Returns the value of themaxBatchSizerecord component.- Returns:
- the value of the
maxBatchSizerecord component
-
maxSeqLen
-