Starts the GPU of the kernels asset, or with libPath of the library
there, and prepares cache's weights for it. The native CPU kernels
must already be loaded: they map the cache.
Isolates representative real weight matrices from model orchestration.
Each sample reuses fixed inputs for repetitions products in one
command buffer (one input quantization). This is a cache-reuse probe,
not an estimate of a complete token's memory traffic or latency.
q8WorkgroupSweep instead isolates the LM head with four rows per
subgroup and 64/128/256 invocations per workgroup, in six rounds.
q8VectorSweep instead alternates scalar/vector loads at 128
invocations, four rows per subgroup, for six rounds.
Releases every GPU buffer this forward pass made. The cache it wraps
stays mapped: unmap it after this, never before. Using the forward
pass afterwards throws.
Runs n tokens at positions position, ... whose embeddings are
already in residual: every layer, and with withLogits the final
norm and LM head of the last token into logits. With capture, the
residual stream is copied after every layer (see captured).
Applies vector in every following forward, after each layer it
steers and before that layer's capture, or stops with null. Uploads its
vectors to a buffer of its own, released when replaced, cleared or
disposed. Callers make sure no state computed under another vector is
reused (Lfm3Model.setControlVector).
Views of the state the first position tokens left behind, in the
order of LayerShard.stateBlocks: conv histories, then each attention
layer's key and value rows before position.
Rows per subgroup (SIMD group on Metal) of the decode kernels: 1, 2 or
4. Zero selects the reference: the old int8 GEMM on Vulkan, one row on
Metal. On Metal every setting computes the same bits. The default is 4
on Vulkan and 2 on Metal (restoreDecodeRowsDefault).
Times every dispatch on the GPU while on, for takeProfile. Vulkan
writes timestamps around each; Metal, which has none inside a command
buffer, commits and waits for every dispatch separately, so a forward
pass takes far longer on the wall clock while this is on.