Module layer

Module layer 

Source
Expand description

2026-09-25: Types every TransformerLayer shares: per-sequence layer state, the per-pass ForwardContext, and the attention and GDN metadata a pass hands its layers.

Owner: model-layers. Invariants: none beyond the types.

Structs§

AttnLayerState
2026-09-25: Per-sequence state of a Qwen3 attention layer. The KV cache lives outside it; the one field is the QSA indexer carry, created on first use and only on a layer that has a QSA indexer.
AttnMetadataDev
2026-09-25: Device addresses of one pass’s attention metadata, uploaded by the model before its layer loop. On a decode pass each row is one sequence, with one entry (or one block-table row) per row in each array. A prefill pass has num_seqs == 1 and one positions and slot entry per token.
BatchedAttnMetadata
2026-09-25: Device metadata for one kernel-batched prefill chunk over several streams, built by stage_batched_attn_metadata (model-engine prefill_b/stage_batched.rs) and passed to prefill_attn_batched_layer and prefill_ssm_batched_layer. Positions and KV slots are stacked in cu_seqlens order; block tables and sequence lengths are per-stream pointer arrays.
EmptyLayerState
2026-09-25: State of a layer that keeps nothing per sequence.
ForwardContext
2026-09-25: What one forward pass hands every layer: the GPU, buffers, config, the model’s switches and the pass’s metadata.
GdnCarryBinding
2026-09-26: A GDN layer’s device buffers for the carried-state verify, set once by the model (model-engine gdn_carry.rs) before any capture.
GdnPrefillBuffers
2026-09-25: Whole-prompt GDN buffers for the split SSM prefill: prefill_phase1 writes the inputs, prefill_gdn_full runs the recurrence into output, and prefill_phase3 reads output and z.
MidchunkCapture
2026-09-25: Per-pass descriptor for mid-chunk SSM tail capture: the reserved snapshot slot’s per-SSM-layer destinations and the split point in pass-local token coordinates.
SsmLayerState
2026-09-25: Per-sequence state of a recurrent (SSM/GDN) layer: the recurrent h state and the conv1d window, plus the copies speculative decode rolls back to.

Enums§

MoeLoraRoute
2026-09-25: MoE-LoRA fold decision for one forward pass. One MoE adapter is active at a time; MoeLayer::moe_route_gate (layers/moe/lora.rs) folds on Fold, skips on Skip and returns an error on Refuse. lora::resolve_moe_lora_route maps a request’s adapter_slot to a route.

Constants§

MTP_CATCHUP_MAX
2026-09-25: Catch-up stash rows per sequence (ModelLevers::mtp_kv_exact). The batched verify step stashes at most this many accepted drafts per sequence (verify_k4_batch_step.rs).
VERIFY_WY_LAYER_STRIDE_BYTES
2026-09-25: Bytes between consecutive GDN layers’ table slices.
VERIFY_WY_TABLES_PER_LAYER
2026-09-25: Tables per GDN layer: h_state plus up to 15 intermediates. upload_verify_wy_tables stages a verify only when k is in 2..=VERIFY_WY_TABLES_PER_LAYER, and returns NULL otherwise.
VERIFY_WY_TABLE_SEQS
2026-09-25: Batched-verify WY pointer-table layout. TransformerModel::upload_verify_wy_tables (model-engine verify_e2.rs) writes it; the qwen3_ssm GdnStates::Multi arm and the write-on-accept fold read it.
VERIFY_WY_TABLE_STRIDE_BYTES
2026-09-25: Bytes between consecutive tables within a layer slice.

Traits§

LayerAuxState
2026-09-26: A supertrait of TransformerLayer; see the module header.
LayerCapabilities
2026-09-26: A supertrait of TransformerLayer; see the module header.
LayerGraphHooks
2026-09-26: A supertrait of TransformerLayer; see the module header.
LayerSplitPrefill
2026-09-26: A supertrait of TransformerLayer; see the module header.
LayerState
2026-09-25: One layer’s per-sequence state, reached through as_any downcasts. Implementors here: EmptyLayerState, AttnLayerState and SsmLayerState.
LayerWeightSetup
2026-09-26: A supertrait of TransformerLayer; see the module header.
LayerWriteOnAccept
2026-09-26: A supertrait of TransformerLayer; see the module header.
TransformerLayer