Q8Cache class final

Properties

file → MappedFile
The mapping, for handing the whole file to the GPU in one piece.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shapes → Iterable<(String, int, int)>
Every cached matrix: name, rows and columns.
no setter

Methods

close() → void
Unmaps the cache once no other open of it holds the mapping. The matrices from matrix point into it and must not be used afterwards.
matrix(String name, int rows, int cols) → NativeMatrix?
The cached matrix name, or null if absent or of another shape.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
offsets(String name, int rows, int cols) → ({int end, String format, int qs, int scales})?
Matrix name's format and the byte offsets and lengths in file of its values and scales, or null if it is absent or of another shape.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

keyFor(String modelDir, {String weights = 'q8'}) → String
Fingerprint of the checkpoint in modelDir and of this cache format for weights (q8 or q4).
open(String path, String key) → Q8Cache?
Maps path if it is a cache with key; otherwise returns null. A cache that exists but cannot be mapped is an error rather than a miss: a miss would quantize from model.safetensors, which a device bundle (lfm3 pack) does not hold. So is a cache with this format's magic whose header or matrices do not fit the file, such as a truncated copy: it throws FormatException, since the kernels would otherwise read past the mapping.
write(String path, String key, Map<String, CachedMatrix> matrices) → void
Writes matrices to path under key, through a temporary file and a rename so a reader never maps a half-written cache.
writeEach(String path, String key, List<(String, String, int, int)> shapes, CachedMatrix matrix(String name), {void done(CachedMatrix written)?}) → void
Writes a cache of the matrices shapes lists (name, format, rows, cols), in that order, asking matrix for each when its turn comes and handing it to done once written. A producer that makes each matrix on demand keeps only one in memory at a time, however large the cache.