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 (Atlas #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..Hi14 (K=16 verify → 15 intermediates). 4 → 16 (2026-09-01): the wyN pointer-table twins extend the cross-sequence batched verify to K=5..16, so the staging gate (2..=THIS) must admit gamma-width verifies; at 4 every K>4 batch silently declined to the per-sequence loop (measured 09-01: 187,392 wy10 launches = 27.7% of GPU time in a C=16 prose window). Cost: 48 layers x 16 x 32 x 8 B = 192 KB of host+device tables.
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