Expand description
Prefill engine: a prompt chunk of up to a few thousand tokens runs through the model layer by layer, so each layerβs experts are streamed once for the whole chunk instead of once per few tokens.
Dense projections use simdgroup-matrix GEMM kernels; attention is the GEMM form (S = QK^T, causal softmax with the QSA visibility mask, O = PV) in sub-chunks of queries; the DeltaNet scan and the PLE conv walk the chunk sequentially per channel. Routed experts are handled per expert: its tokensβ rows are gathered, run through gate/up/act/down GEMMs and scatter-added back with their routing weights; records stream through a ring of pool slots, a fetch thread filling batches ahead of the GPU with two events per batch. Every side effect (KV cache, index keys, recurrent state, PLE ring, MTP cache) is left exactly as the row-batched engine would have left it, so decode continues from the result.
ModulesΒ§
- allocation π
- Prefill scratch allocation and chunk capacity.
- attention π
- QSA masks and GEMM attention over query sub-chunks.
- deltanet π
- Prefill DeltaNet convolution, scan, and output gate.
- experts π
- Prefill expert grouping and event-protected streaming ring.
- hyperconnection π
- Prefill grouped residual reads and injection.
- ple π
- Prefill PLE n-gram gather, gating, and dilated convolution.
- projection π
- Dense prefill projections with narrow-output fallback.
- stats π
- Cumulative completed prefill chunks. Sequence rollback does not undo work.
StructsΒ§
- Chunk
Stats - Timing of one prefill chunk.
- MoeRef π
- Prefill
Scratch π - Prefill
Stats
ConstantsΒ§
- GROUP π
- MAX_
PREFILL_ ROWS - QS π
- Query rows per attention sub-chunk (bounds the S matrix).
- RING π
- Slots of the expert stream ring, and experts per fetch batch.