{"notes":[{"id":"mamba/s4","category":"mamba","legacyPath":"mamba/2111-s4","legacySlug":"2111-s4","legacyPaths":[],"title":"S4","subtitle":"The Prelude of Mamba","author":"Z. Yuan","paperDate":"2021-10-31","publishedOn":"2024-11-17","paperTitle":"Efficiently Modeling Long Sequences with Structured State Spaces","paperUrl":"https://arxiv.org/abs/2111.00396","bibliography":{"title":"Efficiently Modeling Long Sequences with Structured State Spaces","authors":["Albert Gu","Karan Goel","Christopher Ré"],"url":"https://arxiv.org/abs/2111.00396","pdfUrl":"https://arxiv.org/pdf/2111.00396","codeUrl":null,"preprint":{"id":"2111.00396","submittedOn":"2021-10-31","url":"https://arxiv.org/abs/2111.00396"},"publication":{"venue":"ICLR","year":2022,"kind":"conference","url":"https://arxiv.org/abs/2111.00396"},"citation":"@misc{mambas42021,\n  title = {{Efficiently Modeling Long Sequences with Structured State Spaces}},\n  author = {Albert Gu and Karan Goel and Christopher Ré},\n  year = {2021},\n  eprint = {2111.00396},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2111.00396}\n}\n","citationPath":"/content/papers/citations/mamba/s4.bd8f80223f7e.bib"},"thumbnail":{"src":"/content/papers/assets/86eedb9a9143dff790f0e1e5af878b5b3eb93e2b6ea2d3c788567363967af802.jpg","width":1224,"height":424},"locale":"en","path":"/content/papers/en/mamba/s4.c1074bff2ec5.md","headings":[{"id":"state-space-models","text":"State Space Models","depth":2},{"id":"hippo-theory","text":"HiPPO Theory","depth":3},{"id":"discretization","text":"Discretization","depth":3},{"id":"convolutional-representation","text":"Convolutional Representation","depth":3},{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"s4-parameterization","text":"S4 Parameterization","depth":3},{"id":"s4-complexity","text":"S4 Complexity","depth":3},{"id":"architecture-details","text":"Architecture Details","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"efficiency-benchmarks","text":"Efficiency Benchmarks","depth":3},{"id":"stability-benchmarks","text":"Stability Benchmarks","depth":3},{"id":"visualization","text":"Visualization","depth":3},{"id":"a-general-model","text":"A General Model?","depth":3},{"id":"importance-of-hippo","text":"Importance of HiPPO","depth":3},{"id":"experiment-1-unconstrained-ssm-initialization","text":"Experiment 1: Unconstrained SSM Initialization","depth":4},{"id":"experiment-2-combining-nplr-parameterization-with-hippo","text":"Experiment 2: Combining NPLR Parameterization with HiPPO","depth":4},{"id":"experiment-3-regularization-and-full-s4-performance","text":"Experiment 3: Regularization and Full S4 Performance","depth":4},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"mamba/hippo","relation":"background","topic":"From state-space memory to visual sequences"},{"id":"mamba/mamba","relation":"next","topic":"From state-space memory to visual sequences"}]},{"id":"mamba/hippo","category":"mamba","legacyPath":"mamba/2008-hippo","legacySlug":"2008-hippo","legacyPaths":[],"title":"HiPPO","subtitle":"Hippo's Memory","author":"Z. Yuan","paperDate":"2020-08-17","publishedOn":"2024-12-07","paperTitle":"HiPPO: Recurrent Memory with Optimal Polynomial Projections","paperUrl":"https://arxiv.org/abs/2008.07669","bibliography":{"title":"HiPPO: Recurrent Memory with Optimal Polynomial Projections","authors":["Albert Gu","Tri Dao","Stefano Ermon","Atri Rudra","Christopher Re"],"url":"https://arxiv.org/abs/2008.07669","pdfUrl":"https://arxiv.org/pdf/2008.07669","codeUrl":null,"preprint":{"id":"2008.07669","submittedOn":"2020-08-17","url":"https://arxiv.org/abs/2008.07669"},"publication":{"venue":"NeurIPS","year":2020,"kind":"conference","url":"https://papers.nips.cc/paper_files/paper/2020/hash/102f0bb6efb3a6128a3c750dd16729be-Abstract.html"},"citation":"@misc{mambahippo2020,\n  title = {{HiPPO: Recurrent Memory with Optimal Polynomial Projections}},\n  author = {Albert Gu and Tri Dao and Stefano Ermon and Atri Rudra and Christopher Re},\n  year = {2020},\n  eprint = {2008.07669},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2008.07669}\n}\n","citationPath":"/content/papers/citations/mamba/hippo.b20e3393056b.bib"},"thumbnail":{"src":"/content/papers/assets/0edb34026ecfca3a51cdc9a978386d1f6a0aab6d88e101c0fd44d7a9db21462f.jpg","width":1440,"height":514},"locale":"en","path":"/content/papers/en/mamba/hippo.4ae9143e5667.md","headings":[{"id":"problem-definition","text":"Problem Definition","depth":2},{"id":"problem-solution","text":"Problem Solution","depth":2},{"id":"compressed-representation-of-sequences","text":"Compressed Representation of Sequences","depth":3},{"id":"the-advantages-and-disadvantages-of-approximation","text":"The Advantages and Disadvantages of Approximation","depth":3},{"id":"hippo-framework","text":"HiPPO Framework","depth":2},{"id":"orthogonal-polynomials-and-coefficient-projection","text":"Orthogonal Polynomials and Coefficient Projection","depth":3},{"id":"transforming-into-a-differential-equation","text":"Transforming into a Differential Equation","depth":3},{"id":"hippo-abstraction","text":"HiPPO Abstraction","depth":3},{"id":"hippo-application-examples","text":"HiPPO Application Examples","depth":3},{"id":"hippo-discretization","text":"HiPPO Discretization","depth":3},{"id":"hippo-low-degree-projection","text":"HiPPO Low-Degree Projection","depth":3},{"id":"timescale-robustness-of-hippo","text":"Timescale Robustness of HiPPO","depth":2},{"id":"definition-of-the-legs-measure","text":"Definition of the LegS Measure","depth":3},{"id":"theoretical-properties-and-advantages","text":"Theoretical Properties and Advantages","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"long-term-memory-benchmark-task","text":"Long-Term Memory Benchmark Task","depth":3},{"id":"timescale-robustness","text":"Timescale Robustness","depth":3},{"id":"scalability-verification","text":"Scalability Verification","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"mamba/s4","relation":"next","topic":"From state-space memory to visual sequences"}]},{"id":"mamba/mamba","category":"mamba","legacyPath":"mamba/2312-mamba","legacySlug":"2312-mamba","legacyPaths":[],"title":"Mamba","subtitle":"Who is the Successor","author":"Z. Yuan","paperDate":"2023-12-01","publishedOn":"2024-12-25","paperTitle":"Mamba: Linear-Time Sequence Modeling with Selective State Spaces","paperUrl":"https://arxiv.org/abs/2312.00752","bibliography":{"title":"Mamba: Linear-Time Sequence Modeling with Selective State Spaces","authors":["Albert Gu","Tri Dao"],"url":"https://arxiv.org/abs/2312.00752","pdfUrl":"https://arxiv.org/pdf/2312.00752","codeUrl":null,"preprint":{"id":"2312.00752","submittedOn":"2023-12-01","url":"https://arxiv.org/abs/2312.00752"},"publication":{"venue":"COLM","year":2024,"kind":"conference","url":"https://colmweb.org/2024/AcceptedPapers.html"},"citation":"@misc{mambamamba2023,\n  title = {{Mamba: Linear-Time Sequence Modeling with Selective State Spaces}},\n  author = {Albert Gu and Tri Dao},\n  year = {2023},\n  eprint = {2312.00752},\n  archivePrefix = {arXiv},\n  url = {https://arxiv.org/abs/2312.00752}\n}\n","citationPath":"/content/papers/citations/mamba/mamba.5671f143cfd6.bib"},"thumbnail":{"src":"/content/papers/assets/8f6187d5a2a7a17c0687f2ca08ea302601584bb95f5cd5f52927c54d6e76089a.jpg","width":1224,"height":500},"locale":"en","path":"/content/papers/en/mamba/mamba.53a616bdc015.md","headings":[{"id":"defining-the-problem","text":"Defining the Problem","depth":2},{"id":"solving-the-problem","text":"Solving the Problem","depth":2},{"id":"selective-mechanism","text":"Selective Mechanism","depth":3},{"id":"s6-architecture","text":"S6 Architecture","depth":3},{"id":"mamba-architecture","text":"Mamba Architecture","depth":3},{"id":"revisiting-the-selective-mechanism","text":"Revisiting the Selective Mechanism","depth":3},{"id":"training-methods-and-protocols","text":"Training Methods and Protocols","depth":3},{"id":"discussion","text":"Discussion","depth":2},{"id":"scaling-laws","text":"Scaling Laws","depth":3},{"id":"comparison-with-other-language-models","text":"Comparison with Other Language Models","depth":3},{"id":"inference-efficiency-comparison","text":"Inference Efficiency Comparison","depth":3},{"id":"ablation-study---selective-mechanism","text":"Ablation Study - Selective Mechanism","depth":3},{"id":"ablation-study---key-parameters","text":"Ablation Study - Key Parameters","depth":3},{"id":"ablation-study---other-settings","text":"Ablation Study - Other Settings","depth":3},{"id":"conclusion","text":"Conclusion","depth":2}],"anchorAliases":{},"guide":null,"relatedReading":[{"id":"mamba/s4","relation":"background","topic":"From state-space memory to visual sequences"},{"id":"mamba/vim","relation":"next","topic":"From state-space memory to visual sequences"}]}],"text":"We wanted to dive into Mamba, but we discovered there were quite a few prerequisites to tackle first—some foundational knowledge needed to be addressed.\n\nSo, we’re starting with S4.\n\nThis paper primarily aims to improve upon existing issues with State Space Models (SSMs).\n\nSince it involves SSMs, it means we need to backtrack and delve into the relevant concepts of SSMs first.\n\n\n> [!TIP]\n> \n> Why does reading a paper feel like solving a puzzle?\n\n\n## State Space Models\n\n\n> [!NOTE]\n> \n> The authors are well aware that readers might not be familiar with SSMs, so they included some background knowledge in the paper. Let’s take a look together.\n\n\nState Space Models (SSMs) are mathematical tools used to describe the behavior of dynamic systems. They are widely applied in control engineering, signal processing, economics, and, more recently, deep learning.\n\nThe core idea of SSMs is to describe the dynamic behavior of systems through internal \"states.\" It maps external input signals to the system's internal states, which then generate output signals. This framework captures the temporal evolution of systems, making it particularly suitable for handling time-series data and dynamic processes.\n\nSSMs describe system behavior using two core equations:\n\n1. **State Equation**: Describes how the system's state evolves over time.\n\n   $$\n   \\dot{x}(t) = A x(t) + B u(t)\n   $$\n\n   - **State Transition Matrix $A$**: Determines the intrinsic dynamics of the system, such as natural decay or oscillation.\n   - **Input Matrix $B$**: Defines how inputs affect the system's state.\n\n2. **Output Equation**: Describes how to obtain outputs from the states.\n\n   $$\n   y(t) = C x(t) + D u(t)\n   $$\n\n   - **Output Matrix $C$**: Specifies which states influence the output.\n   - **Direct Transmission Matrix $D$**: Represents the direct impact of inputs on outputs (if any).\n\nThus, given an initial state $x(0)$ and an input $u(t)$, one can solve for $x(t)$ and $y(t)$, describing how the system evolves over time.\n\n\n> [!TIP]\n> \n> At this point, it feels quite similar to RNNs—they both handle time-series data and involve hidden states.\n\n\n### HiPPO Theory\n\nIn prior studies, basic State Space Models (SSMs) struggled in some practical applications. Their dynamics involve a matrix exponential, and gradients can vanish or explode as sequence length grows, depending on the state matrix. This can hinder learning on tasks that require long-term memory; the exponential form alone does not make every SSM unstable.\n\n\n> [!TIP]\n> \n> In other words, the problem of gradient vanishing or exploding.\n\n\nTo address this issue, the Linear State Space Layer (LSSL) model introduced the **HiPPO Theory** (High-order Polynomial Projection Operators), which focuses on a mathematical framework for continuous-time memory.\n\nHiPPO introduces a class of specialized matrices $A \\in \\mathbb{R}^{N \\times N}$. When these matrices are applied to the state transition equation in SSMs, they enable the state $x(t)$ to efficiently retain information about the input history $u(t)$.\n\nThe mathematical definition of the HiPPO matrix is as follows:\n\n$$\nA_{nk} =\n\\begin{cases}\n-\\sqrt{2n+1}\\sqrt{2k+1} & \\text{if } n > k \\\\\n-(n+1) & \\text{if } n = k \\\\\n0 & \\text{if } n < k\n\\end{cases}\n$$\n\n- **$n > k$**: Defines the interaction between different orders.\n- **$n = k$**: Represents reflexivity (self-interaction).\n- **$n < k$**: Indicates no influence between states.\n\nThis is the HiPPO-LegS-derived matrix used to initialize the SSM; the indices start at zero. The original online HiPPO-LegS dynamics also have a $1/t$ factor, so this time-invariant SSM is not the same as the online projection. In the Sequential MNIST experiment cited by S4, replacing the baseline initialization with HiPPO raised accuracy from about **60% to 98%**, showing the value of this memory design in that setting.\n\n\n> [!TIP]\n> \n> **Intuitive Understanding of HiPPO**\n> \n> The HiPPO matrix can be seen as a method of compressing historical signals into a fixed dimension while continuously updating this compressed information at each time step. For example:\n> \n> - Higher-order polynomial coefficients describe more complex variation in the input history; polynomial order is not the age of an input.\n> - Lower-order coefficients describe coarser structure. Together, the coefficients offer a fixed-dimensional approximation to past inputs.\n> \n> **How is it different from RNNs? It sounds like RNN hidden layers.**\n> \n> HiPPO matrices are based on a \"continuous-time mathematical framework\" to compress and update historical input signals. They emphasize dynamic projection of inputs and structured multi-order memory, leveraging orthogonal bases to effectively represent past signals. RNN hidden states, on the other hand, rely on \"discrete nonlinear update rules,\" typically carried out by neural networks with activation functions (e.g., $\\text{tanh}$ or $\\text{ReLU}$) to update the hidden states and encode current inputs via nonlinear transformations.\n> \n> HiPPO gives the state an explicit objective for representing history, using orthogonal polynomials and a structured transition matrix. A conventional RNN learns its state update, and its gradients may vanish or explode when modeling long dependencies. HiPPO can also be used inside an RNN; these are not mutually exclusive model families.\n> \n> LSTM and GRU address part of the gradient problem with gates. Their update rules differ from HiPPO's structured projection, although which method is more efficient depends on the task, state size, implementation, and hardware.\n\n\n### Discretization\n\nWhen handling discrete input sequences $(u_0, u_1, \\dots)$, SSMs need to discretize the continuous-time equations because inputs $u_k$ are typically discrete samples derived from a continuous signal $u(t)$:\n\n$$\nu_k = u(k\\Delta),\n$$\n\nwhere $\\Delta$ represents the time step. This indicates that the $k$-th sample corresponds to the value of the continuous signal at time $k\\Delta$.\n\nTo achieve this transformation, the **bilinear method** is commonly used, which converts the continuous-time state matrix $A$ into its discrete counterpart $\\bar{A}$.\n\nThe state space model in its discrete form is represented as:\n\n$$\n\\begin{aligned}\nx_k &= \\bar{A} x_{k-1} + \\bar{B} u_k, \\\\\ny_k &= \\bar{C} x_k,\n\\end{aligned}\n$$\n\nwhere:\n\n$$\n\\begin{aligned}\n\\bar{A} &= \\left( I - \\frac{\\Delta}{2} A \\right)^{-1} \\left( I + \\frac{\\Delta}{2} A \\right), \\\\\n\\bar{B} &= \\left( I - \\frac{\\Delta}{2} A \\right)^{-1} \\Delta B, \\\\\n\\bar{C} &= C.\n\\end{aligned}\n$$\n\n- **$\\bar{A}$**: The discrete state matrix, describing the evolution of the hidden state.\n- **$\\bar{B}$**: The discrete input matrix, describing how the input influences the state.\n- **$\\bar{C}$**: The output matrix, identical to the continuous case.\n\nThe discretized equations transform the continuous-time representation into a sequence-to-sequence mapping, where the hidden state at each time step $x_k$ is linked to the previous state $x_{k-1}$, resembling the structure of Recurrent Neural Networks (RNNs).\n\nIn this formulation, $x_k \\in \\mathbb{R}^N$ can be seen as the hidden state of an RNN, and $\\bar{A}$ functions as the weight matrix for the recurrent layer.\n\n\n> [!TIP]\n> \n> **What do these formulas represent?**\n> \n> These formulas aim to convert a continuous-time system into its discrete-time equivalent, where the components represent:\n> \n> - **$A$**: Describes the internal dynamics of the system, akin to the \"natural evolution rules\" or \"intrinsic characteristics\" of the system. For instance, it defines how the system evolves in the absence of external influences.\n> - **$B$**: Describes how external inputs affect the system state, acting as the \"channel\" or \"method\" through which the system receives external information.\n> - **$C$**: Translates the internal state of the system into observable outputs, like a \"display\" showing the system's results.\n> - **$\\Delta$**: The time interval, indicating how often the system is observed or updated (e.g., once per second).\n> - **$I$**: The identity matrix, which leaves matrices unchanged and simplifies mathematical operations.\n> \n> By breaking down the formulas:\n> \n> - **$\\bar{A}$**\n> \n>   $$\n>   \\bar{A} = \\left( I - \\frac{\\Delta}{2} A \\right)^{-1} \\left( I + \\frac{\\Delta}{2} A \\right)\n>   $$\n> \n>   This formula converts the continuous-time state dynamics $A$ into its discrete-time version $\\bar{A}$. Intuitively:\n> \n>   - **$\\left( I + \\frac{\\Delta}{2} A \\right)$**: Makes a small forward prediction of how the system changes based on the current state.\n>   - **$\\left( I - \\frac{\\Delta}{2} A \\right)^{-1}$**: Corrects the forward prediction to ensure more accurate results.\n> \n>   Together, $\\bar{A}$ indicates how the system transitions from one time step to the next in discrete time.\n> \n> - **$\\bar{B}$**\n> \n>   $$\n>   \\bar{B} = \\left( I - \\frac{\\Delta}{2} A \\right)^{-1} \\Delta B\n>   $$\n> \n>   This formula converts the input matrix $B$ into its discrete-time version $\\bar{B}$, describing how inputs influence the system state at each time step.\n> \n>   - $\\Delta B$: Represents the direct impact of inputs over the time interval $\\Delta$.\n>   - $\\left( I - \\frac{\\Delta}{2} A \\right)^{-1}$: Adjusts this impact by considering the system's inherent dynamics, ensuring a more accurate representation of input effects in discrete time.\n> \n> - **$\\bar{C} = C$**\n> \n> The output matrix $C$ remains unchanged in this chosen discretization of the state equation.\n> \n> ---\n> \n> So, let's make a practical analogy to better understand these concepts.\n> \n> Imagine you’re driving, and the car’s state (e.g., speed and position) evolves over time.\n> \n> The continuous-time equations $A, B, C$ describe how the car’s dynamics change at every moment, but we can only observe and control the car at discrete intervals $\\Delta$ (e.g., every second).\n> \n> 1. **$\\bar{A}$**: Describes how the car’s inherent dynamics (e.g., inertia and natural deceleration) evolve the state from one time step to the next.\n> 2. **$\\bar{B}$**: Describes how the driver’s actions (e.g., pressing the accelerator or brake, as inputs) influence the car’s state at each time step.\n> 3. **$\\bar{C}$**: Describes the outputs we observe (e.g., speed or position via a speedometer or odometer), which remain unchanged in the discretized model.\n> \n\n\n### Convolutional Representation\n\nWhile the recursive formula above captures sequence relationships, its sequential nature makes it challenging to train efficiently on modern hardware like GPUs, as each step depends on the previous step's computation.\n\nTo overcome this, we transform the recursive formula into a convolutional form. Assuming the initial state $x_{-1} = 0$, the recursive formula unfolds as follows:\n\n$$\n\\begin{aligned}\nx_0 &= \\bar{B} u_0, \\\\\nx_1 &= \\bar{A} \\bar{B} u_0 + \\bar{B} u_1, \\\\\nx_2 &= \\bar{A}^2 \\bar{B} u_0 + \\bar{A} \\bar{B} u_1 + \\bar{B} u_2, \\\\\n&\\dots\n\\end{aligned}\n$$\n\nThe output $y_k$ is given by:\n\n$$\ny_k = \\bar{C} x_k,\n$$\n\nwhich expands to:\n\n$$\ny_k = \\bar{C} \\bar{A}^k \\bar{B} u_0 + \\bar{C} \\bar{A}^{k-1} \\bar{B} u_1 + \\cdots + \\bar{C} \\bar{B} u_k\n$$\n\nUpon expanding, we observe that this can be expressed in convolutional form:\n\n$$\ny = K * u,\n$$\n\nwhere:\n\n$$\nK = (\\bar{C} \\bar{B}, \\bar{C} \\bar{A} \\bar{B}, \\dots, \\bar{C} \\bar{A}^{L-1} \\bar{B})\n$$\n\nHere, $K$ represents the convolution kernel, which describes how the system's output is generated from the input as it propagates through the state matrices.\n\n## Defining the Problem\n\n\n> [!TIP]\n> \n> We can finally return to the main focus of the paper—what a journey!\n\n\nThe authors clearly state at the outset that the core goal of this paper is to address the efficiency bottlenecks in sequence models when handling **Long-Range Dependencies (LRDs)**. Specifically, the focus is on the computational and memory challenges faced by existing models when processing long sequences.\n\nAt the time of publication, many sequence models struggled with **tens of thousands of time steps**. For example, the Path-X task has length 16,384; the prior models in the paper's LRA comparison did not beat random guessing on it. This describes that benchmark and comparison, rather than a fixed sequence-length limit for all models.\n\nAlthough traditional models—such as CTMs, RNNs, CNNs, and Transformers—have introduced specialized variants to tackle LRD, such as orthogonal RNNs, dilated convolutions, and efficient Transformers, these approaches still struggle on challenging benchmarks like LRA and raw audio classification.\n\nBeyond the mainstream techniques, **State Space Models (SSMs)** have theoretical potential but have long been difficult to apply to deep learning due to several limitations:\n\n- **Deep SSMs**: While theoretically capable of handling LRDs, their practical performance in real-world tasks has been limited.\n- **Linear State Space Layers (LSSLs)**: Although LSSLs can unify the strengths of CTMs, RNNs, and CNNs and demonstrate potential for addressing LRDs, they suffer from excessive computational and memory demands. Additionally, their practical application has been hindered by numerical instability, especially due to the high non-normality of the matrix $A$, which makes traditional algorithms difficult to apply stably.\n\nTo address these challenges, the authors propose a **Structured State Space Model (S4)**.\n\nThe goal of S4 is to significantly reduce computational complexity and memory requirements by re-parameterizing the state matrix $A$ and leveraging frequency-domain computations via generating functions, while maintaining numerical stability.\n\n## Solving the Problem\n\nIn discrete-time state space models (SSMs), direct computations involve repeated multiplications of the matrix $A$, which constitutes the primary computational bottleneck:\n\n- **Time Complexity**: For a sequence of length $L$, computing the formula requires $O(N^2L)$ operations.\n- **Space Complexity**: Storing all hidden states for training requires $O(NL)$ space. Streaming inference can retain only the current $O(N)$ state, aside from parameters and input/output storage.\n\nTo address this, the authors first analyze diagonalization of $A$, then explain why applying it directly to the HiPPO matrix fails numerically.\n\n\n> [!TIP]\n> \n> **Diagonalization** is a mathematical operation that transforms a matrix into a simpler form.\n> \n> The goal is to express a matrix $A$ as:\n> \n> $$\n> A = V \\Lambda V^{-1},\n> $$\n> \n> where:\n> \n> - **$\\Lambda$** is a diagonal matrix: its off-diagonal elements are zero.\n> - **$V$** is a matrix composed of the eigenvectors of $A$.\n> - **$V^{-1}$** is the inverse of $V$.\n> \n> Diagonalization makes operations like matrix multiplication or exponentiation much more efficient. For example, consider computing a high power $A^{10}$:\n> \n> - **Direct repeated multiplication**: Uses 9 matrix multiplications; exponentiation by squaring can use fewer.\n> - **With diagonalization**:\n>   $$\n>   A^{10} = (V \\Lambda V^{-1})^{10} = V \\Lambda^{10} V^{-1}.\n>   $$\n>   - Since $\\Lambda$ is a diagonal matrix, computing $\\Lambda^{10}$ involves raising each diagonal element to the 10th power, which is computationally cheap.\n>   - Only two additional matrix multiplications (with $V$ and $V^{-1}$) are required.\n> \n> Raising the diagonal entries to a power is cheap, but the basis transforms still have a cost. The useful question for S4 is whether this change of basis remains well-conditioned and helps repeated kernel computations.\n\n\nGiven the state space model $(A, B, C)$, conjugation transforms it into $(V^{-1}AV, V^{-1}B, CV)$.\n\nIf $A$ can be diagonalized stably, kernel evaluation becomes a Vandermonde matrix-vector product, for which the analyzed fast algorithm costs $O((N + L) \\log^2(N + L))$. The kernel $K$ remains a vector; it is not itself a Vandermonde matrix.\n\nHowever, for HiPPO matrices, direct diagonalization leads to numerical instability because the elements of the diagonalizing matrix $V$ grow exponentially large. This makes direct numerical computations infeasible.\n\n### S4 Parameterization\n\nThe term **Normal Plus Low-Rank (NPLR)** refers to a matrix decomposition combining a **normal matrix** with a **low-rank matrix**.\n\nIn the previous discussion, the authors concluded that a well-conditioned change of basis is needed. Ideally, matrix $A$ would be diagonalizable by a **unitary matrix** $V$, for which $V^*V=I$ and the 2-norm condition number is 1. A unitary matrix need not be the identity matrix $I$.\n\nAccording to the spectral theorem in linear algebra, matrices satisfying this condition are **normal matrices**, which fulfill $AA^* = A^*A$. However, this class of matrices is limited, and notably, HiPPO matrices do not belong to this category.\n\nAlthough HiPPO matrices are not normal, they can be decomposed into the sum of a **normal matrix** and a **low-rank matrix**. However, directly leveraging this decomposition is computationally inefficient because exponentiating such a decomposition remains slow and hard to optimize.\n\nTo overcome these challenges, the authors introduced three key techniques:\n\n- **Technique 1: Spectral Computation via Generating Functions**\n\n  Instead of directly computing $K$, they calculate its truncated generating function:\n\n  $$\n  \\sum_{j=0}^{L-1} K_j \\zeta^j\n  $$\n\n  at the roots of unity $\\zeta$. The convolution kernel $K$ is then recovered using **Inverse Fast Fourier Transform (IFFT)**.\n\n- **Technique 2: Matrix Resolvent and Woodbury Identity**\n\n  The generating function involves matrix inversion rather than exponentiation. The authors apply the **Woodbury identity** to express $(A + P Q^*)^{-1}$ in terms of $A^{-1}$, reducing the computation to the diagonal case efficiently:\n\n  $$\n  (A + P Q^*)^{-1} = A^{-1} - A^{-1}P (I + Q^*A^{-1}P)^{-1} Q^*A^{-1}.\n  $$\n\n- **Technique 3: Equivalence to Cauchy Kernel Computation**\n\n  For diagonal matrices, the computation reduces to calculating the **Cauchy kernel**:\n\n  $$\n  \\frac{1}{\\omega_j - \\zeta_k},\n  $$\n\n  a well-studied problem in numerical analysis with fast, stable algorithms that operate in near-linear time. These algorithms are detailed in works such as:\n\n  - [**Transformations of Matrix Structures Work Again**](https://arxiv.org/abs/1303.0353)\n  - [**Fast Approximate Computations with Cauchy Matrices and Polynomials**](https://arxiv.org/abs/1506.02285)\n\nThese techniques are broadly applicable to matrices that can be decomposed into the **Normal Plus Low-Rank (NPLR)** form.\n\n- **Theorem 1: NPLR Representation of HiPPO Matrices**\n\n  The authors formally state the first theorem of the paper:\n\n  The **HiPPO-LegS, LegT, and LagT matrices analyzed here** can be represented in the NPLR form:\n\n  $$\n  A = V \\Lambda V^* - P Q^\\top = V (\\Lambda - (V^*P) (V^*Q)^*) V^*,\n  $$\n\n  where:\n\n  - $V \\in \\mathbb{C}^{N \\times N}$ is a unitary matrix,\n  - $\\Lambda$ is a diagonal matrix,\n  - $P, Q \\in \\mathbb{R}^{N \\times r}$ are the low-rank correction factors, with $r=1$ or $2$ for these matrices.\n\n  This representation demonstrates that HiPPO matrices are well-structured and amenable to efficient computation using the NPLR framework.\n\n### S4 Complexity\n\nNPLR matrices can be transformed into a diagonal plus low-rank matrix form (DPLR), but it is important to note that their elements extend from $\\mathbb{R}$ to $\\mathbb{C}$.\n\nWhen matrix $A$ is expressed in the DPLR form, the theorems give optimal or near-optimal computational bounds for recurrence and convolution at fixed low rank $r$.\n\n- **Theorem and Efficiency of S4 Recurrence**\n\n  - **Theorem 2: Computational Efficiency of S4 Recurrence**\n\n    It is proven that for any given step size $\\Delta$, each step of the recurrence formula (3) can be computed in $O(N)$ operations, where $N$ is the size of the state dimension.\n\n- **Theorem and Efficiency of S4 Convolution**\n\n  - **Theorem 3: Computational Efficiency of S4 Convolution Filter**\n\n    It is proven that for any given step size $\\Delta$, the computation of the SSM convolution filter $K$ can be reduced to 4 Cauchy matrix multiplications, requiring only $\\tilde{O}(N + L)$ operations and $O(N + L)$ space.\n\n\n> [!TIP]\n> \n> The detailed proofs can be found in the paper. The content is extensive, so we encourage readers to refer to the original text.\n\n\nTheorem 3 represents the core technical contribution of this research, and its algorithm embodies the design motivation behind the NPLR S4 parameterization. The complete algorithm is outlined as follows:\n\n\n\n![algo1](/content/papers/assets/e29d2b995692fccfae496d3ae66b926b8867080cf757ac821e82476af4de8a81.jpg)\n\n\n\nThe recurrence bound is $O(N)$ per step, while the convolution-kernel bound is $\\tilde{O}(N + L)$, with logarithmic factors hidden by the tilde. These are theoretical bounds: the paper's actual GPU implementation uses a parallel $O(NL)$ Cauchy-kernel algorithm through PyKeOps, rather than the asymptotically fast method.\n\n### Architecture Details\n\nAt initialization, the matrix $A$ in one S4 state space model (SSM) is set to the HiPPO matrix. According to **Theorem 1**, a unitary change of basis gives $(\\Lambda - P Q^*, \\widetilde B, \\widetilde C)$. In the rank-one case, the diagonal of $\\Lambda$ and each of $P,Q,\\widetilde B,\\widetilde C$ have $N$ complex entries. This is the paper's $5N$ count for **one SSM**, not the entire deep layer with feature mixing and step sizes.\n\nThe deep SSM uses $H$ independent copies of the SSM, each with its own parameters, then mixes their features through position-wise linear layers. This lets S4 handle multiple feature channels while state transitions still connect time steps. Nonlinear activations between layers make the full network nonlinear. The paper counts about $O(HN)+O(H^2)$ parameters per layer.\n\nThe overall architecture outputs sequences in a shape consistent with other sequence models like Transformers, RNNs, and CNNs: (batch size, sequence length, hidden dimension).\n\nCompared to other models, S4 shares similarities with convolutional neural networks (CNNs). While the S4 core module is a linear transformation, the overall deep SSM becomes nonlinear through the nonlinear transformations across layers. Additionally, the broadcasting of features across $H$ dimensions in the S4 layer resembles **depthwise-separable convolutions**, but S4’s convolution kernels are global.\n\nThe following table compares the computational complexities of the S4 layer and other sequence models:\n\n\n\n![table1](/content/papers/assets/888db61b6c722ecf0060092b3cc4269edcd723c5f15f180d70c33eb2f6390b60.jpg)\n\n\n\n## Discussion\n\n### Efficiency Benchmarks\n\n\n\n![efficiency](/content/papers/assets/148289469e1bd813ce2d4e8aa2a288ba55aefff77b5aee85204622cdacf62c44.jpg)\n\n\n\nTo evaluate the training speed and resource efficiency of S4, the authors conducted efficiency benchmarks, starting with a comparison against LSSL.\n\nAt dimensions 128, 256, and 512 in the table, S4's training steps are respectively 1.9, 6.7, and 29.6 times faster than LSSL, and its allocated memory is 42, 133, and 392 times lower. The gain varies with layer size.\n\nNext, the authors compared S4 with efficient Transformer variants such as Linear Transformer and Performer. The results are shown in the table below. At sequence length 4096 with matched parameter counts, S4's speed and memory ratios relative to a standard Transformer are 5.19 and 0.091, close to Linear Transformer's 5.35 and 0.067.\n\n\n\n![transformer](/content/papers/assets/5cd0dd1969d68618bf02a3d00f75998872a2e02ae7003b04483353ed6f69e8ed.jpg)\n\n\n\n### Stability Benchmarks\n\n\n\n![lra](/content/papers/assets/21684fb491abe8e2e5aadec8104233ac94fc9b23973bcaf610707259e7ae0e81.jpg)\n\n\n\nThe authors further investigated S4's stability in long-range reasoning by comparing its performance with other models on challenging tasks such as LRA and raw speech classification.\n\nOn LRA, S4 outperforms the baselines in the displayed table. The original results average **80.48%**; the imported image shows the paper's later updated Table 2, with an **86.09%** average and **96.35%** on Path-X. The other models in that table average below 60%. The original and updated S4 figures come from different experimental versions and should not be read as the same row.\n\nOn the SC10 subset, S4 reaches **98.32%** accuracy on raw waveforms of length 16,000, above the listed raw-waveform baselines and models using shorter MFCC features.\n\n### Visualization\n\n\n\n![visualization](/content/papers/assets/86eedb9a9143dff790f0e1e5af878b5b3eb93e2b6ea2d3c788567363967af802.jpg)\n\n\n\nThe authors conducted a visualization analysis of S4's learned representations to further understand its performance.\n\nThe figure above visualizes convolution kernels from a trained S4 model on LRA Path-X. Each SSM kernel $K \\in \\mathbb{R}^{16384}$ is reshaped into a $128 \\times 128$ image.\n\nThe left image depicts an example from the Path-X task, where the model is required to determine whether two markers are connected by a path.\n\n- **Top two rows (First Layer Convolution Kernels)**: These kernels show local patterns concentrated in a small number of rows.\n\n- **Bottom two rows (Last Layer Convolution Kernels)**: These kernels show structure varying across columns and the full 16,384-pixel sequence, at different spatial frequencies.\n\nSome learned kernels display two-dimensional spatial structure. Whether the model handles long-range dependencies is best judged alongside its Path-X test result, not from the visualization alone.\n\n### A General Model?\n\nThe authors conducted a series of experiments to explore whether S4 can function as a general sequence model.\n\n---\n\n**Image Generation: CIFAR Density Estimation**\n\n\n\n![cifar](/content/papers/assets/1ff921c0257b6a51813746de55f54b3ea32fe894577fd5d6ba871aaa3dc8b33c.jpg)\n\n\n\nCIFAR density estimation is a popular benchmark for autoregressive image modeling. The images are flattened into a sequence of 3072 RGB subpixels, which are predicted one by one.\n\nDespite lacking a built-in two-dimensional image bias, S4 large reaches **2.85 bits per dimension (bpd)**, matching PixelSNAIL's 2.85 but trailing Sparse Transformer's 2.80. S4 base obtains 2.92 bpd; the figure's generation speeds also belong to their respective model sizes.\n\n---\n\n**Text Generation: WikiText-103**\n\n\n\n![wikitext](/content/papers/assets/768837f5a54acda275d8e8d8c7114f485477a4cd5ea826317b9dd733fa69bdc3.jpg)\n\n\n\nWikiText-103 is a classic benchmark for language modeling, requiring the model to predict tokens in a sequence based on contextual order.\n\nReplacing a Transformer's self-attention layers with S4 layers gives **20.95** test perplexity, versus **20.51** for the Transformer in the table, a difference of **0.44**. The next best listed attention-free model is at 23.3. In the paper's generation setup, S4 produces 48K tokens per second versus 0.8K for the Transformer; this speed comparison belongs to that setup.\n\n---\n\n**Time-Series Forecasting: Weather Data**\n\n![timeseries](/content/papers/assets/1a205cb532231780e434e22c2ad7d401818c142f9bb897718d0183bc7518e20b.jpg)\n\nS4 was applied to time-series forecasting tasks and compared with Informer, a model specifically designed for such problems.\n\nThe authors report S4 ahead of the comparison methods in 40 of 50 settings across five forecasting tasks. For Weather at a **720-step (30-day)** horizon, its MSE is **0.245**, versus Informer's **0.359**, a reduction of about **31.8%**. The paper's prose says 37%, which does not match those columns and is closer to the gap against LogTrans at 0.388.\n\n---\n\nThrough these experiments, S4 shows potential as a general sequence model across image, text, and time-series tasks. Its generation speed and ability to adapt to sampling rates were measured under particular settings, so their value still depends on the application.\n\n### Importance of HiPPO\n\nOne of the key design aspects of S4 is using the HiPPO matrix to initialize the SSM.\n\nThe authors conducted ablation studies to evaluate the importance of various components and addressed the following questions:\n\n1. How important is HiPPO initialization?\n2. Is training the SSM on top of HiPPO necessary?\n3. Are the benefits of S4 derived solely from the NPLR parameterization, independent of HiPPO?\n\nThese ablations use Sequential CIFAR-10 with at most 100K trainable parameters and a learning-rate schedule triggered by a validation plateau. The first two experiments use no regularization; the third adds 0.1 dropout. Their conclusions are bounded by this task and model size.\n\n---\n\n#### **Experiment 1: Unconstrained SSM Initialization**\n\n![exp1](/content/papers/assets/a07467449f3068da9e7444c056302697a090fd3f0c37a28c263dd52dd2a34eec.jpg)\n\n- **Comparison of Initialization Methods**\n  - **Random Gaussian Initialization**: Initializes matrix$A$ with a random Gaussian distribution.\n  - **HiPPO Initialization**: Initializes $A$ using the HiPPO matrix.\n  - **Random Diagonal Matrix**: Sets $A$ as a random diagonal matrix without applying S4's NPLR parameterization.\n  - Both freezing and training $A$ were tested for the above initialization methods.\n\nThe results show that training the SSM improves performance across all initialization methods, with the largest gains observed for randomly initialized models.\n\nThe three models with **trainable $A$** all approach perfect training accuracy, yet their validation accuracies differ by more than **15 percentage points**, with HiPPO initialization highest.\n\n---\n\n#### **Experiment 2: Combining NPLR Parameterization with HiPPO**\n\n\n\n![exp2](/content/papers/assets/6beeb4c6cb71b9dd2029ed7ee1d29148e8c219b47c442006ec17f54bf13bcec4.jpg)\n\n\n\nThis experiment tested whether HiPPO initialization is the primary driver of S4's success or if the benefits are derived solely from the NPLR parameterization.\n\nIn the plotted comparison with the same NPLR parameterization, the randomly initialized model's validation curve lies below the HiPPO-initialized one. This supports the role of HiPPO initialization in this ablation setting.\n\n---\n\n#### **Experiment 3: Regularization and Full S4 Performance**\n\n\n\n![exp3](/content/papers/assets/4855bb6c12483510cdfaad3c112fc8e6d2af4c9c6ce4200552222ff1bb49911b.jpg)\n\n\n\nThis experiment added lightweight regularization (Dropout = 0.1) to the main ablation studies, comparing the performance of S4 with HiPPO initialization to other initialization methods.\n\nIn the plotted **validation** curves with 0.1 dropout, HiPPO initialization remains highest. Separately, the paper reports **84.27% test accuracy** for full S4 (HiPPO + NPLR) with at most 100K trainable parameters.\n\n## Conclusion\n\nIn this paper, the authors introduced the \"S4\" sequence model, which leverages innovative parameterization of State Space Models (SSMs) by integrating continuous-time, recurrent, and convolutional perspectives. This approach provides an effective and principled solution to the Long-Range Dependency (LRD) problem.\n\nAcross a series of benchmarks, S4 demonstrated outstanding performance across various data modalities and model capabilities, showcasing its potential as a general solution for sequence modeling. It holds significant application value and research implications.\n\n\n> [!TIP]\n> \n> This paper is quite challenging for us, and we still cannot fully understand it after reading it.\n> \n> For the specific implementation and technical details of S4, we need further research and practice in the future.\n","imageSizes":{"/content/papers/assets/e29d2b995692fccfae496d3ae66b926b8867080cf757ac821e82476af4de8a81.jpg":{"width":1224,"height":368},"/content/papers/assets/888db61b6c722ecf0060092b3cc4269edcd723c5f15f180d70c33eb2f6390b60.jpg":{"width":1224,"height":296},"/content/papers/assets/148289469e1bd813ce2d4e8aa2a288ba55aefff77b5aee85204622cdacf62c44.jpg":{"width":960,"height":332},"/content/papers/assets/5cd0dd1969d68618bf02a3d00f75998872a2e02ae7003b04483353ed6f69e8ed.jpg":{"width":796,"height":368},"/content/papers/assets/21684fb491abe8e2e5aadec8104233ac94fc9b23973bcaf610707259e7ae0e81.jpg":{"width":1224,"height":424},"/content/papers/assets/86eedb9a9143dff790f0e1e5af878b5b3eb93e2b6ea2d3c788567363967af802.jpg":{"width":1224,"height":424},"/content/papers/assets/1ff921c0257b6a51813746de55f54b3ea32fe894577fd5d6ba871aaa3dc8b33c.jpg":{"width":912,"height":508},"/content/papers/assets/768837f5a54acda275d8e8d8c7114f485477a4cd5ea826317b9dd733fa69bdc3.jpg":{"width":824,"height":464},"/content/papers/assets/1a205cb532231780e434e22c2ad7d401818c142f9bb897718d0183bc7518e20b.jpg":{"width":1552,"height":304},"/content/papers/assets/a07467449f3068da9e7444c056302697a090fd3f0c37a28c263dd52dd2a34eec.jpg":{"width":1758,"height":444},"/content/papers/assets/6beeb4c6cb71b9dd2029ed7ee1d29148e8c219b47c442006ec17f54bf13bcec4.jpg":{"width":872,"height":432},"/content/papers/assets/4855bb6c12483510cdfaad3c112fc8e6d2af4c9c6ce4200552222ff1bb49911b.jpg":{"width":876,"height":444}}}
