pub struct SsmLayerState {
pub h_state: DevicePtr,
pub conv_state: DevicePtr,
pub h_state_checkpoint: Option<DevicePtr>,
pub conv_state_checkpoint: Option<DevicePtr>,
pub h_state_intermediates: Vec<DevicePtr>,
pub conv_state_intermediates: Vec<DevicePtr>,
pub h_is_f16: bool,
pub h_prefill_stage: Option<DevicePtr>,
pub ple: Option<PleSeqState>,
}Expand description
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.
Fields§
§h_state: DevicePtr2026-09-25: Recurrent state; FP32, or FP16 when h_is_f16.
conv_state: DevicePtr2026-09-25: Conv1d window, FP32 [conv_dim, d_conv].
h_state_checkpoint: Option<DevicePtr>2026-09-25: Copy of h_state restored when a verify accepts no draft. A pool
address, or allocated on first use by the checkpoint save
(checkpoint_ssm_states_dispatch, start_checkpoint_async_dispatch).
conv_state_checkpoint: Option<DevicePtr>2026-09-25: Copy of conv_state, restored with h_state_checkpoint.
h_state_intermediates: Vec<DevicePtr>2026-09-25: Per-token h states of a verify: element i holds the state after
verify token i. A rollback to n accepted tokens copies element n - 1.
conv_state_intermediates: Vec<DevicePtr>2026-09-25: Per-token conv states of a verify, indexed like
h_state_intermediates.
h_is_f16: bool2026-09-25: Storage format of h_state: false = FP32, true = FP16.
A sequence on an f16-sized pool (h_prefill_stage is Some) starts true: the
slot holds only 2 bytes per element. On an FP32-sized pool it starts false, and
TransformerModel::ssm_h_to_f16_dispatch converts the state and sets it true on
the first decode step when FP16 h-state is enabled.
h_prefill_stage: Option<DevicePtr>2026-09-25: FP32 staging blob for this sequence’s slot when the pool is f16-sized
(--ssm-h-dtype f16-pool). GDN prefill widens h_state into it before its FP32
kernels and narrows it back after (qwen3_ssm::ssm_h_fp16). None means the slot
is FP32 and prefill writes h_state in place. One blob per slot, shared by every
layer of the sequence.
ple: Option<PleSeqState>2026-09-25: PLE per-sequence carry (token history and dilated-conv state), created
on first use, only on a layer that hosts a PleLayer.