Search

Search papers and lessons

Semiseparable Matrix

Level 4 · 10 min read

A semiseparable matrix is a triangular matrix whose every lower-left block has low rank, which lets it be stored and multiplied in time linear in its size.

On this page

  • Colour = topic mix
  • Linear algebra
  • Discrete math
  • Sign in to see your progress

TL;DR

A semiseparable matrix is a square matrix with zeros above the diagonal, where every block sitting below the diagonal has low rank. That low-rank rule means the whole matrix can be described by a few small vectors and matrices, instead of every entry.

The payoff is speed. Multiplying a vector by a semiseparable matrix can be done as a running recurrence in time proportional to the length, not the square of it. This is why the structure matters for sequence models: a state space model is exactly a semiseparable matrix acting on a sequence.

Where you'll see it: in the structured form of state space models such as Mamba-2, in fast solvers for certain integral equations, and in the recurrence that computes a running weighted sum.

Intuition

Low rank below the diagonal

Think of a lower triangular matrix as a table of influences: entry MjiM_{ji} says how much input at time ii affects output at time jj, for j≥ij \ge i. For a generic lower triangular matrix, there is no shortcut. Every entry is a separate number, and storing or multiplying it costs about T2T^2 work for a length-TT sequence.

A semiseparable matrix adds one rule: any rectangular block that lies on or below the diagonal must have low rank. Low rank means the block is secretly built from only a few independent patterns. Intuitively, the influence of the early past on the late future flows through a narrow channel, a state of bounded size, so you never need to remember the full history entry by entry.

That narrow channel is the hidden state of a recurrence. Once you see the matrix as "a small memory passed forward through time", you have the algorithm too: carry the state, update it, read out the output.

0510152000.20.40.60.81lag j - ientry M(j, i)
  • a = 0.9
  • a = 0.5
For a 1-semiseparable matrix with constant a, the entry at lag j minus i is a to that power. The dots mark lag 0 and lag 10 for a = 0.9.

The math

Definition

Definition: N-semiseparable matrix

A lower triangular matrix M∈RT×TM \in \mathbb{R}^{T \times T} is NN-semiseparable if every submatrix that lies on or below the diagonal has rank at most NN. The number NN is the order of MM.

A submatrix is any choice of rows and columns, kept in their original order. The condition covers all of them, including the large block in the bottom-left corner. Entries on the diagonal and above the diagonal are either zero or set by the triangular rule.

The SSS representation

The definition says what the matrix looks like, not how to store it. The useful form is the sequentially semiseparable (SSS) representation. Pick vectors Bi,Cj∈RNB_i, C_j \in \mathbb{R}^N and matrices Ak∈RN×NA_k \in \mathbb{R}^{N \times N}, and write

Mji=Cj⊤AjAj−1⋯Ai+1Bi(j≥i).M_{ji} = C_j^{\top} A_j A_{j-1} \cdots A_{i+1} B_i \qquad (j \ge i).

Here MjiM_{ji} is the entry in row jj and column ii, BiB_i is an input vector, CjC_j is an output vector, and the product of AA matrices carries the state from time ii forward to time jj. The empty product for j=ij = i is the identity, so Mii=Ci⊤BiM_{ii} = C_i^{\top} B_i.

Two facts make this useful.

  1. Every SSS matrix is NN-semiseparable. Any block below the diagonal factors as a product of an NN-column matrix and an NN-row matrix, so its rank is at most NN.
  2. Every NN-semiseparable matrix has an SSS form. The converse holds, so the two descriptions are equivalent. The SSS form also compresses the parameters: the naive count is about N2TN^2 T, but it can be reduced to about NTNT.

Because of the SSS form, multiplying y=Mxy = Mx becomes a recurrence on an NN-dimensional state:

hi=Aihi−1+Bixi,yi=Ci⊤hi.h_i = A_i h_{i-1} + B_i x_i, \qquad y_i = C_i^{\top} h_i.

Each step costs about N2N^2 operations, so the total cost is linear in TT.

The scalar case: 1-semiseparable matrices

Set N=1N = 1. Then each BiB_i and CjC_j is a number, and they can be pulled out as diagonal scalings. What remains is a lower triangular matrix with entries Mji=aj:iM_{ji} = a_{j:i}, where aj:ia_{j:i} is the product ajaj−1⋯ai+1a_j a_{j-1} \cdots a_{i+1} and ai:i=1a_{i:i} = 1. For length 3 this is

[100a110a2a1a21].\begin{bmatrix} 1 & 0 & 0 \\ a_1 & 1 & 0 \\ a_2 a_1 & a_2 & 1 \end{bmatrix}.

Multiplying this matrix by xx is the scalar recurrence yt=atyt−1+xty_t = a_t y_{t-1} + x_t with y0=x0y_0 = x_0. This is the cumulative product-sum, the simplest case of a state space model. The causal mask in linear attention is also a 1-semiseparable matrix.

Why the rank condition is the right one

A rank bound on every lower block is a statement about information flow. If the lower-left block has rank NN, the future depends on the past through NN numbers. Rank counts how many independent directions the block can move in, which is exactly the size of the state the recurrence must carry. This is the connection the Mamba-2 paper builds on: state space models are semiseparable matrices, so their hidden state size is the semiseparable order.

Worked examples

Example
Checking a 1-semiseparable matrix by hand

Take a1=2a_1 = 2 and a2=3a_2 = 3, and the 3 by 3 matrix

M=[100210631].M = \begin{bmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 6 & 3 & 1 \end{bmatrix}.
  1. Check the rank condition on the lower block made of rows 2 and 3 and columns 1 and 2: it is [2163]\begin{bmatrix} 2 & 1 \\ 6 & 3 \end{bmatrix}.
  2. Its determinant is 2⋅3−1⋅6=02 \cdot 3 - 1 \cdot 6 = 0, so its rank is 1, which is at most N=1N = 1.
  3. Multiply by x=(1,1,1)x = (1, 1, 1) directly: y0=1y_0 = 1, y1=2+1=3y_1 = 2 + 1 = 3, y2=6+3+1=10y_2 = 6 + 3 + 1 = 10.
  4. Run the recurrence yt=atyt−1+xty_t = a_t y_{t-1} + x_t with y0=x0=1y_0 = x_0 = 1: y1=2⋅1+1=3y_1 = 2 \cdot 1 + 1 = 3, then y2=3⋅3+1=10y_2 = 3 \cdot 3 + 1 = 10.

Interpretation: both routes give the same answer, but the recurrence uses two multiplications and two additions, while the dense product uses six multiplications by nonzero entries. The gap grows with length.

Example
Impulse response of a decaying memory

Let at=0.9a_t = 0.9 for every step, so Mji=0.9 j−iM_{ji} = 0.9^{\,j-i} on and below the diagonal. Use length T=4T = 4 and input x=(1,0,0,0)x = (1, 0, 0, 0), a single spike at the start.

  1. Multiplying by xx picks out the first column of MM: (1,0.9,0.81,0.729)(1, 0.9, 0.81, 0.729).
  2. Run the recurrence to confirm: y0=1y_0 = 1, y1=0.9⋅1=0.9y_1 = 0.9 \cdot 1 = 0.9, y2=0.9⋅0.9=0.81y_2 = 0.9 \cdot 0.9 = 0.81, y3=0.9⋅0.81=0.729y_3 = 0.9 \cdot 0.81 = 0.729.
  3. Each step multiplies the old state by 0.90.9, so the spike fades geometrically.

Interpretation: the matrix encodes a memory that forgets at a fixed rate. Changing 0.90.9 to a value nearer 00 shortens the memory. A state space model learns these decay rates, and a selective model lets them depend on the input.

Tradeoffs and failure modes

Semiseparable structure is a bet that the influence of the past can be summarised by a small state. When that bet holds, you get linear-time computation. When it does not, the structure is a poor fit.

SituationWhat goes wrongBetter choice
Long sequence, information decays with distanceStructure fits; linear cost pays offUse a semiseparable or state space model
Every token must be compared with every other token, arbitrary patternLow-rank blocks cannot capture it; the state is too smallDense attention, accepting quadratic cost
Need to store the full matrix for a dense solveStorage is quadratic and the structure is ignoredExploit the rank structure directly with a structured solver
Recurrence is computed one step at a time on a GPUSequential steps underuse parallel hardwareUse the chunked or block decomposition, which trades a little memory for parallelism
Numerical errors accumulate over very long productsRepeated multiplication by AA can driftKeep the decay factors well inside the unit circle, or normalise the state

The rank condition is exact, but the parameters that realise it are usually learned or chosen. A matrix that is semiseparable in principle can still be hard to use if its state is too small for the task.

History

Semiseparable and quasiseparable matrices were studied in numerical linear algebra and in systems theory during the late twentieth century, where they give fast algorithms for certain structured linear systems. The Mamba-2 paper calls these rank-structured matrices and notes that several related definitions exist (quasiseparable and other semiseparable variants).

For most of that time the connection to sequence models was not part of the picture. Recurrent and state space models were treated as signal-processing tools. Dao and Gu (2024), in the Mamba-2 paper, showed that a state space model is exactly a semiseparable matrix acting on a sequence. That equivalence gave a new block decomposition of the matrix, which yields a fast algorithm that mixes the linear recurrence with a quadratic form.

Check yourself

QuestionIn one sentence, what does the semiseparable condition require of the blocks below the diagonal?Show answer

Every submatrix on or below the diagonal has rank at most NN, where NN is the order. Equivalently, the influence of the past on the future passes through a state of at most NN dimensions.

QuestionFor a1=2a_1 = 2, a2=3a_2 = 3, compute the product MxM x with x=(1,2,0)x = (1, 2, 0) using the matrix MM from the first worked example.Show answer

Rows of MM are (1,0,0)(1, 0, 0), (2,1,0)(2, 1, 0) and (6,3,1)(6, 3, 1). So y0=1y_0 = 1, y1=2⋅1+1⋅2=4y_1 = 2 \cdot 1 + 1 \cdot 2 = 4, and y2=6⋅1+3⋅2+1⋅0=12y_2 = 6 \cdot 1 + 3 \cdot 2 + 1 \cdot 0 = 12. The recurrence agrees: y0=1y_0 = 1, y1=2⋅1+2=4y_1 = 2 \cdot 1 + 2 = 4, y2=3⋅4+0=12y_2 = 3 \cdot 4 + 0 = 12.

QuestionWhy does a rank-NN bound give an algorithm that runs in time linear in the length, not quadratic?Show answer

The rank bound lets the matrix factor into an SSS form with NN-dimensional state. Multiplying by the matrix then becomes a recurrence that carries an NN-vector from one step to the next. Each step costs about N2N^2 operations, so the total is about N2TN^2 T, linear in TT for fixed NN. A dense product costs about T2T^2.

QuestionA state space model has state size N=16N = 16 and sequence length T=1000T = 1000. Roughly how many multiplications does the recurrence need, compared with the dense product?Show answer

The recurrence needs about N2T=256⋅1000=256,000N^2 T = 256 \cdot 1000 = 256{,}000 multiplications for the matrix-vector step, ignoring constants. The dense product needs about T2=1,000,000T^2 = 1{,}000{,}000. The ratio is T/N2≈3.9T / N^2 \approx 3.9, so the recurrence is about four times cheaper here, and the gap widens as TT grows.

QuestionGive one reason the 1-semiseparable case is more than a special case of little interest.Show answer

It is exactly the scalar recurrence yt=atyt−1+xty_t = a_t y_{t-1} + x_t, which is the core operation of many sequence models and of the causal mask in linear attention. Any fast algorithm for this recurrence is also a fast algorithm for the structured matrix, which is why the Mamba-2 paper treats it as the building block of its main algorithm.

Sources