LayerShard class final

Constructors

LayerShard.load(String modelDir, {required int index, required int shards, required int maxSeq, required int maxChunk, WeightFormat format = WeightFormat.f32, List<String> keepF32 = const [], Q8Cache? q8Cache, Map<String, NativeMatrix>? q8Built})
Loads shard index of shards from model.safetensors, quantizing to format every matrix whose name contains no entry of keepF32. With Q8, matrices found in q8Cache are mapped instead of read and quantized, and newly quantized ones are collected in q8Built.
factory

Properties

config → Lfm3Config
final
hashCode → int
The hash code for this object.
no setterinherited
maxChunk → int
final
maxSeq → int
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
vocabRows → int
no setter
vocabStart → int
First vocabulary row of this shard's LM-head slice.
final

Methods

ffn(int layer, Float32List a, int n) → Float32List
This shard's partial of layer layer's SwiGLU FFN.
lmHead(Float32List normed) → Float32List
Logits of vocabulary rows [vocabStart, vocabStart + vocabRows).
mixer(int layer, Float32List a, int n, int position) → Float32List
This shard's partial of layer layer's mixer for the n normalized inputs a (n, H) at positions position, position + 1, ... Returns a view of n, H valid until the next call.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Clears the conv histories so the next call starts a new sequence. KV cache rows are overwritten before they are read, so they need no reset.
restoreState(List<Float32List> state) → void
Puts back conv histories from saveState.
saveState() → List<Float32List>
A copy of the conv histories: with the KV cache rows before the current position, which later tokens never overwrite, they are all the state a position carries.
stateBlocks(int position) → List<Float32List>
Views of everything the first position tokens left behind: the conv histories, then each attention layer's keys and values rows before position. Writing them out and reading them back into another model on the same backend restores that position (see Lfm3Model.saveState).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited