Module layer

Module layer 

Source
Expand description

Composable transformer layer traits (SDD).

Decouples the generic model loop (embed -> layers -> norm -> lm_head) from layer-specific logic (attention vs SSM, MoE vs dense FFN). Adding a new architecture only requires implementing TransformerLayer for each layer type, not duplicating the model loop.

Structs§

AttnLayerState
Attention-layer per-sequence state. KV lives in PagedKvCache; the only resident piece is the QSA indexer carry on the 12 qwen4_exp full-attention layers (Avarok #753 item B).
AttnMetadataDev
Pre-uploaded attention metadata device pointers.
BatchedAttnMetadata
Q12 batched-prefill device-side metadata.
EmptyLayerState
Empty state for layers that store all persistent state externally (e.g., attention layers where KV is in PagedKvCache).
ForwardContext
Shared context for a single forward pass step.
GdnPrefillBuffers
Device pointers to full-sequence GDN input/output buffers.
MidchunkCapture
Per-pass descriptor for mid-chunk SSM tail capture. Points at the reserved Marconi snapshot slot’s per-SSM-layer destination buffers (already offset to the slot) plus the split point in local (chunk) token coordinates.
SsmLayerState
SSM layer state: recurrent hidden state + conv1d sliding window.

Enums§

MoeLoraRoute
Feature-1 MoE-LoRA fold decision for a single forward pass.

Constants§

VERIFY_WY_LAYER_STRIDE_BYTES
Bytes between consecutive GDN layers’ table slices.
VERIFY_WY_TABLES_PER_LAYER
Tables per GDN layer: h_state + Hi0..Hi2 (K=4 verify → 3 intermediates).
VERIFY_WY_TABLE_SEQS
Batched-verify WY pointer-table layout (SSOT — writer: TransformerModel::upload_verify_wy_tables, reader: the qwen3_ssm GdnStates::Multi batched conv+WY arm).
VERIFY_WY_TABLE_STRIDE_BYTES
Bytes between consecutive tables within a layer slice.

Traits§

LayerState
Per-layer persistent state tracked across decode steps.
TransformerLayer