State Space Models for Language › Discretization with a Zero-Order Hold
Language AI HandbookAll chapters A sequence gives one input per position. Choose a step size and hold over . This is a zero-order hold (ZOH). Name the state at the start of the interval and the state at its end , so input updates initial state . We read out by combining the endpoint state with the held input before the next input replaces it. Integrating the linear equation across the interval gives
The first term propagates the initial state. The integrand propagates the contribution made at each instant for the remaining time . Reversing the integration variable and pulling the constant input outside the integral gives the recurrence below.
With our endpoint convention, the output is . The step changes the transition and the write map. The readout and direct path already act on instantaneous values.
For invertible , the integral equals . The integral itself works for singular matrices too. To see why, integrate the matrix exponential's power series term by term.
The factorial in the denominator gives convergence for any finite square matrix. For , the only nonzero term is , so each step adds .
A Diagonal Example You Can Compute by Hand
Take and a single stable rate . The continuous system is . Then
Since and , the factor is negative, so . The discrete system is a geometric decay. Two sanity checks are worth doing.
First, as the fraction tends to , so . With a zero rate, the state simply accumulates the input. Mamba's reference implementation also uses , as a first-order approximation to the write at finite rates.
Second, the continuous half-life is in units of time. The discrete half-life in units of steps is
For a single mode, sets the half-life in step units. This scale can be fractional. The first whole update at which the magnitude is at or below half its starting value is .
When the rate stays fixed, increasing the step size makes one update cover more continuous time. The contribution decays more in each step. Later we will let the input determine the step size separately at each position.
PythonIn [3]Expand
import numpy as np
rate_grid = -np.logspace(np.log10(0.01), np.log10(4.0), 240) # a in [-4, -0.01]
step_grid = np.logspace(
np.log10(0.01), np.log10(2.0), 240
) # Delta in [0.01, 2]
persistence = np.exp(
np.multiply.outer(step_grid, rate_grid)
) # shape (step, rate)
halflife_steps = np.log(2.0) / np.multiply.outer(step_grid, -rate_grid)We now have a grid of over a range of continuous rates and step sizes. The map below makes the joint dependence visible.
VisualizationOut [4]Expand

A point near the upper left combines a large step with a strongly negative rate. Little of the previous state survives that step. As you move toward the lower right, the rate and the step produce a multiplier closer to one. The contour lines pick out combinations with the same half-life.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!