Module state

Module state 

Source
Expand description

2026-09-30: The state a circuit keeps between steps, declared per block ([[block.<name>.state]]), and the one function that sizes it (M5, LIFECYCLE-DESIGN.md section 3.3): the recurrent slots of GatedDeltaNet and Mamba2 layers with their verify intermediates and checkpoints, and the paged KV blocks of attention layers.

A declaration says what one unit of a state holds: one sequence slot of a recurrent state, one token of one side of a KV cache. How many units exist (slots, the padding dummy, verify intermediates per slot, KV blocks) is a plan input (StateInputs), decided by the engine and passed in explicitly; this module multiplies and never reads a process global.

Owner: metrale-circuit. Invariants:

  • Every byte count is units x elements x element size, the element count evaluated from the circuit’s dims when it is instantiated; one function (StatePlan::new) produces every term, so the reserve and the allocation cannot size a state two ways.
  • A format named by a key ({kv_cache_dtype}) must be given in StateInputs::formats; a missing key is an error, never a default.

Structs§

KvInputs
2026-09-30: One paged KV cache: blocks of block_size tokens.
StateDecl
2026-09-30: One declared state of one block instance.
StateInputs
2026-09-30: The plan inputs the engine decides.
StatePlan
2026-09-30: Every state of a circuit, sized.
StateTerm
2026-09-30: One sized term: a state, what it holds, its units and bytes.
VerifyInputs
2026-09-30: The verify pools of a speculative serve over the recurrent states.

Enums§

Holding
2026-09-30: What a term of the plan holds.
Lifetime
2026-09-30: How long a unit of state lives (LIFECYCLE-DESIGN.md section 3.3).
StateAccess
2026-09-30: How a node touches a state of its block (state = { h = "update" }).
StateDtype
2026-09-30: The storage element of a state.
StateError
2026-09-30: Why a state plan could not be made.
StateFormat
2026-09-30: A state’s storage format: fixed by the circuit, or named by a key the plan inputs give.
StateKind
2026-09-30: What a state is.
VerifySteps
2026-09-30: Which verify intermediate count a recurrent state keeps per verify slot.