Diagonal S4-style state-space layer #
This module provides TorchLean's diagonal recurrent SSM layer in the S4 family. It exposes the state-space recurrence used by S4-style models:
h_{t+1} = A h_t + B x_t,
y_t = C h_{t+1} + D x_t.
The diagonal form is intentional: it shares the selective-scan core used by Mamba-style models, admits direct recurrence proofs, and can be connected to convolutional S4 kernels through a separate structured-kernel layer.
Reference: Gu, Goel, Ré. "Efficiently Modeling Long Sequences with Structured State Spaces", ICLR 2022.
Parameters for a diagonal S4-style sequence layer.
- inProj : Spec.Tensor α (Spec.Shape.dim inputDim (Spec.Shape.dim stateDim Spec.Shape.scalar))
Input projection from token/features into SSM state channels.
- outProj : Spec.Tensor α (Spec.Shape.dim stateDim (Spec.Shape.dim outputDim Spec.Shape.scalar))
Output projection from SSM channels to token/features.
- ssm : NN.Spec.Dynamics.DiagonalSSM α stateDim
Diagonal recurrent state-space core.
Instances For
Project an input token into state channels.
Instances For
Project state channels to output channels.
Instances For
One recurrent S4-style token step, returning (new_state, output).
Instances For
Run a list of tokens through the recurrent layer.
Instances For
A recurrent S4 pass emits one output token per input token.