Combining Recurrent, Convolutional, and Continuous-time Models with Linear State-Space Layers

Albert Gu, Isys Johnson, Karan Goel, Khaled Saab, Tri Dao, Atri Rudra, Christopher Ré

Introduction

A longstanding challenge in machine learning is efficiently modeling sequential data longer than a few thousand time steps. The usual paradigms for designing sequence models involve recurrence (e.g. RNNs), convolutions (e.g. CNNs), or differential equations (e.g. NDEs), which each come with tradeoffs. For example, RNNs are a natural stateful model for sequential data that require only constant computation/storage per time step, but are slow to train and suffer from optimization difficulties (e.g., the "vanishing gradient problem" ), which empirically limits their ability to handle long sequences. CNNs encode local context and enjoy fast, parallelizable training, but are not sequential, resulting in more expensive inference and an inherent limitation on the context length. NDEs are a principled mathematical model that can theoretically address continuous-time problems and long-term dependencies , but are very inefficient.

Ideally, a model family would combine the strengths of these paradigms, providing properties like parallelizable training (convolutional), stateful inference (recurrence) and time-scale adaptation (differential equations), while handling very long sequences in a computationally efficient way. Several recent works have turned to this question. These include the CKConv, which models a continuous convolution kernel ; several ODE-inspired RNNs, such as the UnICORNN ; the LMU, which speeds up a specific linear recurrence using convolutions ; and HiPPO , a generalization of the LMU that introduces a theoretical framework for continuous-time memorization. However, these model families come at the price of reduced expressivity: intuitively, a family that is both convolutional and recurrent should be more restrictive than either.

Our first goal is to construct an expressive model family that combines all 3 paradigms while preserving their strengths. The Linear State-Space Layer (LSSL) is a simple sequence model that maps a 1-dimensional function or sequence u(t)↦y(t)u(t)\mapsto y(t) through an implicit state x(t)x(t) by simulating a linear continuous-time state-space representation in discrete-time

where AA controls the evolution of the system and B,C,DB,C,D are projection parameters. The LSSL can be viewed as an instantiation of each family, inheriting their strengths (Fig. 1):

LSSLs are recurrent. If a discrete step-size Δt\Delta t is specified, the LSSL can be discretized into a linear recurrence using standard techniques, and simulated during inference as a stateful recurrent model with constant memory and computation per time step.

LSSLs are convolutional. The linear time-invariant systems defined by (1)+(2) are known to be explicitly representable as a continuous convolution. Moreover, the discrete-time version can be parallelized during training using convolutions .

LSSLs are continuous-time. The LSSL itself is a differential equation. As such, it can perform unique applications of continuous-time models, such as simulating continuous processes, handling missing data , and adapting to different timescales.

Surprisingly, we show that LSSLs do not sacrifice expressivity, and in fact generalize convolutions and RNNs. First, classical results from control theory imply that all 1-D convolutional kernels can be approximated by an LSSL . Additionally, we provide two results relating RNNs and ODEs that may be of broader interest, e.g. showing that some RNN architectural heuristics (such as gating mechanisms) are related to the step-size Δt\Delta t and can actually be derived from ODE approximations. As corollaries of these results, we show that popular RNN methods are special cases of LSSLs.

The generality of LSSLs does come with tradeoffs. In particular, we describe and address two challenges that naive LSSL instantiations face when handling long sequences: (i) they inherit the limitations of both RNNs and CNNs at remembering long dependencies, and (ii) choosing the state matrix AA and timescale Δt\Delta t appropriately are critical to their performance, yet learning them is computationally infeasible. We simultaneously address these challenges by specializing LSSLs using a carefully chosen class of structured matrices AA, such that (i) these matrices generalize prior work on continuous-time memory and mathematically capture long dependencies with respect to a learnable family of measures, and (ii) with new algorithms, LSSLs with these matrices AA can be theoretically sped up under certain computation models, even while learning the measure AA and timescale Δt\Delta t.

We empirically validate that LSSLs are widely effective on benchmark datasets and very long time series from healthcare sensor data, images, and speech.

On benchmark datasets, LSSLs obtain SoTA over recent RNN, CNN, and NDE-based methods across sequential image classification tasks (e.g., by over 10% accuracy on sequential CIFAR) and healthcare regression tasks with length-4000 time series (by up to 80% reduction in RMSE).

To showcase the potential of LSSLs to unlock applications with extremely long sequences, we introduce a new sequential CelebA classification task with length-38000 sequences. A small LSSL comes within 2.16 accuracy points of a specialized ResNet-18 vision architecture that has 10x more parameters and is trained directly on images.

Finally, we test LSSLs on a difficult dataset of high-resolution speech clips, where usual speech pipelines pre-process the signals to reduce the length by 100x. When training on the raw length-16000 signals, the LSSL not only (i) outperforms previous methods by over 20 accuracy points in 1/5 the training time, but (ii) outperforms all baselines that use the pre-processed length-160 sequences, overcoming the limitations of hand-crafted feature engineering.

We introduce Linear State-Space Layers (LSSLs), a simple sequence-to-sequence transformation that shares the modeling advantages of recurrent, convolutional, and continuous-time methods. Conversely, we show that RNNs and CNNs can be seen as special cases of LSSLs (Section 3).

We prove that a structured subclass of LSSLs can learn representations that solve continuous-time memorization, allowing it to adapt its measure and timescale (Section 4.1). We also provide new algorithms for these LSSLs, showing that they can be sped up computationally under an arithmetic complexity model Section 4.2.

Empirically, we show that LSSLs stacked into a deep neural network are widely effective on time series data, even (or especially) on extremely long sequences (Section 5).

Technical Background

We summarize the preliminaries on differential equations that are necessary for this work. We first introduce two standard approximation schemes for differential equations that we will use to convert continuous-time models to discrete-time, and will be used in our results on understanding RNNs. We give further context on the step size or timescale Δt\Delta t, which is a particularly important parameter involved in this approximation process. Finally, we provide a summary of the HiPPO framework for continuous-time memorization , which will give us a mathematical tool for constructing LSSLs that can address long-term dependencies.

Any differential equation x˙(t)=f(t,x(t))\dot{x}(t)=f(t,x(t)) has an equivalent integral equation x(t)=x(t0)+∫t0tf(s,x(s)) ⁣dsx(t)=x(t_{0})+\int_{t_{0}}^{t}f(s,x(s))\mathop{}\!ds. This can be numerically solved by storing some approximation for xx, and keeping it fixed inside f(t,x)f(t,x) while iterating the equation. For example, Picard iteration is often used to prove the existence of solutions to ODEs by iterating the equation xi+1(t):=xi(t0)+∫t0tf(s,xi(s)) ⁣dsx_{i+1}(t):=x_{i}(t_{0})+\int_{t_{0}}^{t}f(s,x_{i}(s))\mathop{}\!ds . In other words, it finds a sequence of functions x0(t),x1(t),…x_{0}(t),x_{1}(t),\dots that approximate the solution x(t)x(t) of the integral equation.

On the other hand, for a desired sequence of discrete times tit_{i}, approximations to x(t0),x(t1),…x(t_{0}),x(t_{1}),\dots can be found by iterating the equation x(ti+1)=x(ti)+∫titi+1f(s,x(s)) ⁣dsx(t_{i+1})=x(t_{i})+\int_{t_{i}}^{t_{i+1}}f(s,x(s))\mathop{}\!ds. Different ways of approximating the RHS integral lead to different discretization schemes. We single out a discretization method called the generalized bilinear transform (GBT) which is specialized to linear ODEs of the form (1). Given a step size Δt\Delta t, the GBT update is

Three important cases are: α=0\alpha=0 becomes the classic Euler method which is simply the first-order approximation x(t+Δt)=x(t)+Δt⋅x′(t)x(t+\Delta t)=x(t)+\Delta t\cdot x^{\prime}(t); α=1\alpha=1 is called the backward Euler method; and α=12\alpha=\frac{1}{2} is called the bilinear method, which preserves the stability of the system .

In Section 3.2 we will show that the backward Euler method and Picard iteration are actually related to RNNs. On the other hand, the bilinear discretization will be our main method for computing accurate discrete-time approximations of our continuous-time models. In particular, define A‾\overline{A} and B‾\overline{B} to be the matrices appearing in (3) for α=12\alpha=\frac{1}{2}. Then the discrete-time state-space model is

In most models, the length of dependencies they can capture is roughly proportional to 1Δt\frac{1}{\Delta t}. Thus we also refer to the step size Δt\Delta t as a timescale. This is an intrinsic part of converting a continuous-time ODE into a discrete-time recurrence, and most ODE-based RNN models have it as an important and non-trainable hyperparameter . On the other hand, in Section 3.2 we show that the gating mechanism of classical RNNs is a version of learning Δt\Delta t. Moreover when viewed as a CNN, the timescale Δt\Delta t can be viewed as controlling the width of the convolution kernel (Section 3.2). Ideally, all ODE-based sequence models would be able to automatically learn the proper timescales.

Linear State-Space Layers (LSSL)

We define our main abstraction, a model family that generalizes recurrence and convolutions. Section 3.1 first formally defines the LSSL, then discusses how to compute it with multiple views. Conversely, Section 3.2 shows that LSSLs are related to mechanisms of the most popular RNNs.

Given a fixed state space representation A,B,C,DA,B,C,D, an LSSL is the sequence-to-sequence mapping defined by discretizing the linear state-space model (1) and (2).

Computationally, the discrete-time LSSL can be viewed in multiple ways (Fig. 1).

For simplicity let the initial state be x−1=0x_{-1}=0. Then (4)+(5) explicitly yields

Then yy is simply the (non-circular) convolution y=KL(A‾,B‾,C)∗u+Duy=\mathcal{K}_{L}(\overline{A},\overline{B},C)\ast u+Du, where

We make a note that the bottleneck of (i) the recurrence view is matrix-vector multiplication (MVM) by the discretized state matrix A‾\overline{A} when simulating (4), and (ii) the convolutional view is computing the Krylov function KL\mathcal{K}_{L} (7). Throughout this section we assumed the LSSL parameters were fixed, which means that A‾\overline{A} and KL(A,B,C)\mathcal{K}_{L}(A,B,C) can be cached for efficiency. However, learning the parameters A‾\overline{A} and Δt\Delta t would involve repeatedly re-computing these, which is infeasible in practice. We revisit and solve this problem in Section 4.2.

2 Expressivity of LSSLs

For a model to be both recurrent and convolutional, one might expect it to be limited in other ways. Indeed, while also observe that certain recurrences can be replaced with a convolution, they note that it is not obvious if convolutions can be replaced by recurrences. Moreover, while the LSSL is a linear recurrence, popular RNN models are nonlinear sequence models with activation functions between each time step. We now show that LSSLs surprisingly do not have limited expressivity.

A well-known fact about state-space systems (1)+(2) is that the output yy is related to the input uu by a convolution y(t)=∫h(τ)u(t−τ)dτy(t)=\int h(\tau)u(t-\tau)d\tau with the impulse response hh of the system. Conversely, a convolutional filter hh that is a rational function of degree NN can be represented by a state-space model of size NN . Thus, an arbitrary convolutional filter hh can be approximated by a rational function (e.g., by Padé approximants) and represented by an LSSL.

In the particular case of LSSLs with HiPPO matrices (Sections 2 and 4.1), there is another intuitive interpretation of how LSSL relate to convolutions. Consider the special case when AA corresponds to a uniform measure (in the literature known as the LMU or HiPPO-LegT matrix). Then for a fixed dtdt, equation (1) is simply memorizing the input within sliding windows of 1Δt\frac{1}{\Delta t} elements, and equation (2) extracts features from this window. Thus the LSSL can be interpreted as automatically learning convolution filters with a learnable kernel width.

We show two results about RNNs that may be of broader interest. Our first result says that the ubiquitous gating mechanism of RNNs, commonly perceived as a heuristic to smooth optimization , is actually the analog of a step size or timescale Δt\Delta t.

A (1-D) gated recurrence xt=(1−σ(z))xt−1+σ(z)utx_{t}=(1-\sigma(z))x_{t-1}+\sigma(z)u_{t}, where σ\sigma is the sigmoid function and zz is an arbitrary expression, can be viewed as the GBT(α=1\alpha=1) (i.e., backwards-Euler) discretization of a 1-D linear ODE x˙(t)=−x(t)+u(t)\dot{x}(t)=-x(t)+u(t).

Applying a discretization requires a positive step size Δt\Delta t. The simplest way to parameterize a positive function is via the exponential function Δt=exp⁡(z)\Delta t=\exp(z) applied to any expression zz. Substituting this into (3) with A=−1,B=1,α=1A=-1,B=1,\alpha=1 exactly produces the gated recurrence. ∎

While Lemma 3.1 involves approximating continuous systems using discretization, the second result is about approximating them using Picard iteration (Section 2). Roughly speaking, each layer of a deep linear RNN can be viewed as successive Picard iterates x0(t),x1(t),...x_{0}(t),x_{1}(t),... approximating a function x(t)x(t) defined by a non-linear ODE. This shows that we do not lose modeling power by using linear instead of non-linear recurrences, and that the nonlinearity can instead be “moved” to the depth direction of deep neural networks to improve speed without sacrificing expressivity.

(Infinitely) deep stacked LSSL layers of order N=1N=1 with position-wise non-linear functions can approximate any non-linear ODE x˙(t)=−x+f(t,x(t))\dot{x}(t)=-x+f(t,x(t)).

3 Deep LSSLs

The full LSSL architecture in a deep neural network is defined similarly to standard sequence models such as deep ResNets and Transformers, involving stacking LSSL layers connected with normalization layers and residual connections. Full architecture details are described in Appendix B, including the initialization of AA and Δt\Delta t, computational details, and other architectural details.

Combining LSSLs with Continuous-time Memorization

In Section 3 we introduced the LSSL model and showed that it shares the strengths of convolutions and recurrences while also generalizing them. We now discuss and address its main limitations, in particular handling long dependencies (Section 4.1) and efficient computation (Section 4.2).

The generality of LSSLs means they can inherit the issues of recurrences and convolutions at addressing long dependencies (Section 1). For example, viewed as a recurrence, repeated multiplication by A‾\overline{A} could suffer from the vanishing gradients problem . We confirm empirically that LSSLs with random state matrices AA are actually not effective (Section 5.4) as a generic sequence model.

However, one advantage of these mathematical continuous-time models is that they are theoretically analyzable, and specific AA matrices can be derived to address this issue. In particular, the HiPPO framework (Section 2) describes how to memorize a function in continuous time with respect to a measure ω\omega . This operator mapping a function to a continuous representation of its past is denoted hippo⁡(ω)\operatorname{\mathsf{hippo}}(\omega), and was shown to have the form of equation (1) in three special cases. However, these matrices are non-trainable in the sense that no other AA matrices were known to be hippo⁡\operatorname{\mathsf{hippo}} operators.

To address this, we theoretically resolve the open question from , showing that hippo⁡(ω)\operatorname{\mathsf{hippo}}(\omega) for any measure ω\omega To be precise, the measures that correspond to orthogonal polynomials . results in (1) with a structured matrix AA.

For an arbitrary measure ω\omega, the optimal memorization operator hippo⁡(ω)\operatorname*{hippo}(\omega) has the form x˙(t)=Ax(t)+Bu(t)\dot{x}(t)=Ax(t)+Bu(t) (1) for a low recurrence-width (LRW) state matrix AA.

For measures covering the classical orthogonal polynomials (OPs) (in particular, corresponding to Jacobi and Laguerre polynomials), there is even more structure.

For ω\omega corresponding to the classical OPs, hippo⁡(ω)\operatorname{\mathsf{hippo}}(\omega) is 33-quasiseparable.

Although beyond the scope of this section, we mention that LRW matrices are a type of structured matrix that have linear MVM . In Appendix D we define this class and prove Theorem 1. Quasi-separable matrices are a related class of structured matrices with additional algorithmic properties. We define these matrices in Definition 4 and prove Corollary 4.1 in Section D.3.

Theorem 1 tells us that a LSSL that uses a state matrix AA within a particular class of structured matrices would carry the theoretical interpretation of continuous-time memorization. Ideally, we would be able to automatically learn the best AA within this class; however, this runs into computational challenges which we address next (Section 4.2). For now, we define the LSSL-fixed or LSSL-f to be one where the AA matrix is fixed to one of the HiPPO matrices prescribed by .

2 Theoretically Efficient Algorithms for the LSSL

Although AA and Δt\Delta t are the most critical parameters of an LSSL which govern the state-space (c.f. Section 4.1) and timescale (Sections 2 and 3.2), they are not feasible to train in a naive LSSL. In particular, Section 3.1 noted that it would require efficient matrix-vector multiplication (MVM) and Krylov function (7) for A‾\overline{A} to compute the recurrent and convolutional views, respectively. However, the former seems to involve a matrix inversion (3), while the latter seems to require powering A‾\overline{A} up LL times.

In this section, we show that the same restriction of AA to the class of quasiseparable (Corollary 4.1), which gives an LSSL the ability to theoretically remember long dependencies, simultaneously grants it computational efficiency.

First of all, it is known that quasiseparable matrices have efficient (linear-time) MVM . We show that they also have fast Krylov functions, allowing efficient training with convolutions.

We remark that Theorem 2 is non-obvious. To illustrate, it is easy to see that unrolling (7) for a general matrix AA takes time LN2LN^{2}. Even if AA is extremely structured with linear computation, it requires LNLN operations and linear depth. The depth can be reduced with the squaring technique (batch multiply by A,A2,A4,…A,A^{2},A^{4},\dots), but this then requires LNLN intermediate storage. In fact, the algorithm for Theorem 2 is quite sophisticated (Appendix E) and involves a divide-and-conquer recursion over matrices of polynomials, using the observation that (7) is related to the power series C(I−Ax)−1BC(I-Ax)^{-1}B .

Unless specified otherwise, the full LSSL refers to an LSSL with AA satisfying Corollary 4.1. In conclusion, learning within this structured matrix family simultaneously endows LSSLs with long-range memory through Theorem 1 and is theoretically computationally feasible through Theorem 2. We note the caveat that Theorem 2 is over exact arithmetic and not floating point numbers, and thus is treated more as a proof of concept that LSSLs can be computationally efficient in theory. We comment more on the limitations of the LSSL in Section 6.

Empirical Evaluation

We test LSSLs empirically on a range of time series datasets with sequences from length 160 up to 38000 (Sections 5.1 and 5.2), where they substantially improve over prior work. We additionally validate the computational and modeling benefits of LSSLs from generalizing all three main model families (Section 5.3), and analyze the benefits of incorporating principled memory representations that can be learned (Section 5.4).

Our tasks have extensive prior work and we evaluate against previously reported best results. We highlight our primary baselines, three very recent works explicitly designed for long sequences: CKConv (a continuous-time CNN) , UnICORNN (an ODE-inspired RNN) , and Neural Controlled/Rough Differential Equations (NCDE/NRDE) (a sophisticated NDE) . These are the only models we are aware of that have experimented with sequences of length >10k.

1 Image and Time Series Benchmarks

We test on the sequential MNIST, permuted MNIST, and sequential CIFAR tasks (Fig. 3), popular benchmarks which were originally designed to test the ability of recurrent models to capture long-term dependencies of length up to 1k . LSSL sets SoTA on sCIFAR by more than 10 points. We note that all results were achieved with at least 5x fewer parameters than the previous SoTA (Appendix F).

We additionally use the BDIMC healthcare datasets (Fig. 3), a suite of widely studied time series regression problems of length 4000 on estimating vital signs. LSSL reduces RMSE by more than two-thirds on all datasets.

2 Speech and Image Classification for Very Long Time Series

Raw speech is challenging for ML models due to high-frequency sampling resulting in very long sequences. Traditional systems involve complex pipelines that require feeding mixed-and-matched hand-crafted features into DNNs . Table 2 reports results for the Speech Commands (SC) dataset for classification of 1-second audio clips. Few methods have made progress on the raw speech signal, instead requiring pre-processing with standard mel-frequency cepstrum coefficients (MFCC). By contrast, LSSL sets SoTA on this dataset while training on the raw signal. We note that MFCC extracts sliding window frequency coefficients and thus is related to the coefficients x(t)x(t) defined by LSSL-f (Section 2, Section 4.1, , Appendix D). Consequently, LSSL may be interpreted as automatically learning MFCC-type features in a trainable basis.

To stress-test the LSSL’s ability to handle extremely long sequences, we create a challenging new sequential-CelebA task, where we classify 178×218178\times 218 images = 38000-length sequences for 4 facial attributes: Attractive (Att.), Mouth Slightly Open (MSO), Smiling (Smil.), Wearing Lipstick (WL) . We chose the 4 most class-balanced attributes to avoid well-known problems with class imbalance. LSSL-f comes close to matching the performance of a specialized ResNet-18 image classification architecture that has 10×10\times the parameters (Table 1). We emphasize we are the first to demonstrate that this is possible to do with a generic sequence model.

3 Advantages of Recurrent, Convolutional, and Continuous-time Models

We validate that the generality of LSSLs endows it with the strengths of all three families.

Convergence Speed. As a recurrent and NDE model that incorporates new theory for continuous-time memory (Section 4.1), the LSSL has strong inductive bias for sequential data, and converges rapidly to SoTA results on our benchmarks. With its convolutional view, training can be parallelized and it is also computationally efficient in practice. Table 3 compares the time it takes the LSSL-f to achieve SoTA, in either sample (measured by epochs) or computational (measured by wall clock) complexity. In all cases, LSSLs reached the target in a fraction of the time of the previous model.

Timescale Adaptation. Table 2 also reports the results of continuous-time models that are able to handle unique settings such as missing data in time series, or test-time shift in timescale (we note that this is a realistic problem, e.g., when deployed healthcare models are tested on EEG signals that are sampled at a different rate ). We note that many of these baselines were custom designed for such settings, which is of independent interest. On the other hand, LSSLs perform timescale adaptation by simply changing its Δt\Delta t values at inference time, while still outperforming the performance of prior methods with no shift. Additional results on the CharacterTrajectories dataset from prior work are in Appendix F, where LSSL is competitive with the best baselines.

4 LSSL Ablations: Learning the Memory Dynamics and Timescale

We demonstrate that the Δt\Delta t and AA parameters, which LSSLs are able to automatically learn in contrast to prior work, are indeed critical to the performance of these continuous-time models. We note that learning Δt\Delta t adds only O(H)O(H) parameters and learning AA adds O(N)O(N) parameters, adding less than 1% parameter count compared to the base models with O(HN)O(HN) parameters.

Memory dynamics AA. We validate that vanilla LSSLs suffer from the modeling issues described in Section 4. We tested that LSSLs with random AA matrices (normalized appropriately) perform very poorly (e.g., 62% on pMNIST). Further, we note the consistent increase in performance from LSSL-f to LSSL despite the negligible parameter difference. These ablations show that (i) incorporating the theory of Theorem 1 is actually necessary for LSSLs, and (ii) further training the structured AA is additionally helpful, which can be interpreted as learning the measure for memorization (Section 4.1).

Timescale Δt\Delta t. Section 3.2 showed that LSSL’s ability to learn Δt\Delta t is its direct generalization of the critical gating mechanism of popular RNNs, which previous ODE-based RNN models cannot learn. We note that on sCIFAR, LSSL-f with poorly-specified Δt\Delta t gets only 49.3%49.3\% accuracy. Additional results in Appendix F show that learning Δt\Delta t alone provides an orthogonal boost to learning AA, and visualizes the noticeable change in Δt\Delta t over the course of training.

Discussion

In this work we introduced a simple and principled model (LSSL) inspired by a fundamental representation of physical systems. We showed theoretically and empirically that it generalizes and inherits the strengths of the main families of modern time series models, that its main limitations of long-term memory can be resolved with new theory on continuous-time memorization, and that it is empirically effective on difficult tasks with very long sequences.

Related work. The LSSL is related to several rich lines of work on recurrent, convolutional, and continuous-time models, as well as sequence models addressing long dependencies. Appendix A provides an extended related work connecting these topics.

Tuning. Our models are very simple, consisting of identical L(inear)SSL layers with simple position-wise non-linear modules between layers (Appendix B). Our models were able to train at much higher learning rates than baselines and were not sensitive to hyperparameters, of which we did light tuning primarily on learning rate and dropout. In contrast to previous baselines , we did not use hyperparameters for improving stability and regularization such as weight decay, gradient clipping, weight norm, input dropout, etc. While the most competitive recent works introduce at least one hyperparameter of critical importance (e.g. depth and step size , α\alpha and Δt\Delta t , ω0\omega_{0} ) that are difficult to tune, the LSSL-fixed has only Δt\Delta t, which the full LSSL can even learn automatically (at the expense of speed).

Limitations. Sections 1, 3 and 1 mention that a potential benefit of having the recurrent representation of LSSLs may endow it with efficient inference. While this is theoretically possible, this work did not experiment on any applications that leverage this. Follow-up work showed that it is indeed possible in practice to speed up some applications at inference time.

Theorem 2’s algorithm is sophisticated (Appendix D) and was not implemented in the first version of this work. A follow-up to this paper found that it is not numerically stable and thus not usable on hardware. Thus the algorithmic contributions in Theorem 2 serve the purpose of a proof-of-concept that fast algorithms for the LSSL do exist in other computation models (i.e., arithmetic operations instead of floating point operations), and leave an open question as to whether fast, numerically stable, and practical algorithms for the LSSL exist.

As described in Appendix B, by freezing the AA matrix and Δt\Delta t timescale, the LSSL-fixed is able to be computed much faster than the full LSSL, and is comparable to prior models in practice (Table 3). However, beyond computational complexity, there is also a consideration of space efficiency. Both the LSSL and LSSL-fixed suffer from a large amount of space overhead (described in Appendix B) – using O(NL)O(NL) instead of O(L)O(L) space when working on a 1D sequence of length LL – that essentially stems from using the latent state representation of dimension NN. Consequently, the LSSL can be space inefficient and we used multi-GPU training for our largest experiments (speech and high resolution images, Tables 2 and 1).

These fundamental issues with computation and space complexity were revisited and resolved in follow-up work to this paper, where a new state space model (the Structured State Space) provided a new parameterization and algorithms for state spaces.

Conclusion and future work. Modern deep learning models struggle in applications with very long temporal data such as speech, videos, and medical time-series. We hope that our conceptual and technical contributions can lead to new capabilities with simple, principled, and less engineered models. We note that our pixel-level image classification experiments, which use no heuristics (batch norm, auxiliary losses) or extra information (data augmentation), perform similar to early convnet models with vastly more parameters, and is in the spirit of recent attempts at unifying data modalities with a generic sequence model . Our speech results demonstrate the possibility of learning better features than hand-crafted processing pipelines used widely in speech applications. We are excited about potential downstream applications, such as training other downstream models on top of pre-trained state space features.

We thank Arjun Desai, Ananya Kumar, Laurel Orr, Sabri Eyuboglu, Dan Fu, Mayee Chen, Sarah Hooper, Simran Arora, and Trenton Chang for helpful feedback on earlier drafts. We thank David Romero and James Morrill for discussions and additional results for baselines used in our experiments. This work was done with the support of Google Cloud credits under HAI proposals 540994170283 and 578192719349. AR and IJ are supported under NSF grant CCF-1763481. KS is supported by the Wu Tsai Neuroscience Interdisciplinary Graduate Fellowship. We gratefully acknowledge the support of NIH under No. U54EB020405 (Mobilize), NSF under Nos. CCF1763315 (Beyond Sparsity), CCF1563078 (Volume to Velocity), and 1937301 (RTML); ONR under No. N000141712266 (Unifying Weak Supervision); ONR N00014-20-1-2480: Understanding and Applying Non-Euclidean Geometry in Machine Learning; N000142012275 (NEPTUNE); the Moore Foundation, NXP, Xilinx, LETI-CEA, Intel, IBM, Microsoft, NEC, Toshiba, TSMC, ARM, Hitachi, BASF, Accenture, Ericsson, Qualcomm, Analog Devices, the Okawa Foundation, American Family Insurance, Google Cloud, Salesforce, Total, the HAI-AWS Cloud Credits for Research program, the Stanford Data Science Initiative (SDSI), and members of the Stanford DAWN project: Facebook, Google, and VMWare. The Mobilize Center is a Biomedical Technology Resource Center, funded by the NIH National Institute of Biomedical Imaging and Bioengineering through Grant P41EB027060. The U.S. Government is authorized to reproduce and distribute reprints for Governmental purposes notwithstanding any copyright notation thereon. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views, policies, or endorsements, either expressed or implied, of NIH, ONR, or the U.S. Government.

References

Appendix A Related Work

We provide an extended related work comparing the LSSL to previous recurrent, convolutional, and continuous-time models.

The LSSL is most closely related to the HiPPO framework for continuous-time memory and its predecessor, the Legendre Memory Unit (LMU) . The HiPPO-RNN and the LMU define dynamics of the form of equation (1), and incorporate it into an RNN architecture. A successor to the LMU, the LMU-FFT keeps the original linear dynamics, allowing the LMU to be computed with a cached convolution kernel.

These methods all suffer from two main limitations. First, the state matrix AA and discretization timescale Δt\Delta t cannot be trained due to both limitations in theoretical understanding of which AA matrices are effective, as well as computational limitations. Second, (1) is a 1-D to NN-D map, requiring states to be projected back down to 1-D. This creates an overall 1-D bottleneck in the state, limiting the expressivity of the model.

Compared to these, the LSSL does not use a conventional RNN architecture, instead keeping the linear recurrence (4) and downprojecting it with the second part of the state space representation (5). To avoid the 1-D feature bottlneck, it simply computes HH copies of this 1-D to 1-D independently, creating an overall HH-dimensional sequence-to-sequence model. However, this exacerbates the computational issue, since the work is increased by a factor of HH.

This work resolves the expressivity issue with new theory. Compared to HiPPO and the LMU, LSSL allows training the AA matrix by showing generalized theoretical results for the HiPPO framework, showing that there is a parameterized class of structured state spaces that are HiPPO operators.

The LSSL makes progress towards the second issue with new algorithms for these structured matrices (Theorem 2). However, as noted in Sections 4.2 and 6, the algorithm presented in Theorem 2 was later found to be not practical, and an improved representation and algorithm was found in subsequent work.

The connection from RNNs to continuous-time models have been known since their inception, and recent years have seen an explosion of CT-RNN (continuous-time RNN) models based on dynamical systems or ODEs. We briefly mention a few classic and modern works along these lines, categorizing them into a few main topics.

First are theoretical works that analyze the expressivity of RNNs from a continuous-time perspective. The connection between RNNs and dynamical systems has been studied since the 90s , fleshing out the correspondence between different dynamical systems and RNN architectures . Modern treatments have focused on analyzing the stability and dynamics of RNNs.

Second, a large class of modern RNNs have been designed that aim to combat vanishing gradients from a dynamical systems analysis. These include include the AntisymmetricRNN , iRNN , and LipschitzRNN , which address the exploding/vanishing gradient problem by reparatermizing the architecture or recurrent matrix based on insights from an underlying dynamical system.

Third is a class of models that are based on an explicit underlying ODE introduced to satisfy various properties. This category includes the UnICORNN and its predecessor coRNN which discretize a second-order ODE inspired by oscillatory systems. Other models include the Liquid Time-Constant Networks (LTC) and successor CfC , which use underlying dynamical systems with varying time-constants with stable behavior and provable rates of expressivity measured by trajectory length. The LTC is based on earlier dynamic causal models (DCM) , which are a particular ODE related to state spaces with an extra bilinear term. Finally, the LMU and HiPPO also fall in this category, whose underlying ODEs are mathematically derived for continuous-time memorization.

Fourth, the recent family of neural ODEs , originally introduced as continuous-depth models, have been adapted to continuous-time, spawning a series of “ODE-RNN” models. Examples include the ODE-RNN , GRU-ODE-Bayes , and ODE-LSTM , which extend adjoint-based neural ODEs to the discrete input setting as an alternative to standard RNNs. Neural Controlled Differential Equations (NCDE) and Neural Rough Differential Equations (NRDE) are memory efficient versions that integrate observations more smoothly and can be extended to very long time series.

As a special case of continuous-time RNNs, some works have observed the relation between gating mechanisms and damped dynamical systems . Some examples of continuous-time RNNs based on such damped dynamical systems include the LTC and iRNN . Compared to these, Lemma 3.1 shows a stronger result that sigmoid gates are not just motivated by being an arbitrary monotonic function with range (0,1)(0,1), but the exact formula appears out of discretizing a damped ODE.

Appendix B Model Details

Section 3.1 noted that some of the computations for using the LSSL are expensive to compute. When the LSSL fixes the AA and Δt\Delta t parameters (e.g. when they are not trained, or at inference time), these computational difficulties can be circumvented by caching particular computations. In particular, this case applies to the LSSL-f. Note that in this case, the other state-space matrices CC and DD comprise the O(HN)O(HN) trainable parameters of the fixed-transition LSSL.

In particular, we assume that there is a black-box inference algorithm for this system, i.e. matrix-vector multiplication by A‾\overline{A} (an example of implementing this black box for a particular structured class is in Section E.2). We then compute and cache

the transition matrix A‾\overline{A}, which is computed by applying the black-box A‾\overline{A} MVM algorithm to the identity matrix II.

which is computed in a parallelized manner by the squaring technique for exponentiation, i.e. batch multiply by A‾,(A‾)2,(A‾)4,…\overline{A},(\overline{A})^{2},(\overline{A})^{4},\dots.

At inference time, the model can be unrolled recurrently with A‾\overline{A}. At training time, the convolutional filter KL(A‾,B‾,C)K_{L}(\overline{A},\overline{B},C) (equation (7)) is computed with a matrix multiplication C⋅K(A‾,B‾)C\cdot K(\overline{A},\overline{B}) before convolving with the input uu.

Table 5 provides more detailed complexity of this version of the LSSL with fixed A,ΔtA,\Delta t.

Note that as mentioned in Section 6, this cached algorithm is fairly fast, but the main drawback is that materializing the Krylov matrix (8) requires O(NL)O(NL) instead of O(L)O(L) space.

B.2 Initialization of A𝐴A

Note that the LSSL-f is the LSSL with a non-trainable AA (and Δt\Delta t), so that AA is fixed to the above matrix.

B.3 Initialization of Δ​tΔ𝑡\Delta t

One distinction between the LSSL and the most related prior work is that the inclusion of the projection (2) makes the layer a 1-dimensional to 1-dimensional map, instead of 1-D to NN-D . This enables us to concatenate HH copies of this map (at the expense of computation, cf. Sections 4.2 and D). Even when Δt\Delta t is not trained as in the LSSL-f, these HH copies allow multiple timescales to be considered by setting Δt\Delta t differently for each copy.

In particular, we initialize Δt\Delta t log-uniformly in a range Δtmin,Δtmax\Delta t_{min},\Delta t_{max} (i.e., Δt\Delta t is initialized within this range, such that log⁡Δt\log\Delta t is uniformly distributed). The maximum and minimum values were generally chosen to be a factor of 100100 apart such that the length of the sequences in the dataset are contained in this range. Specific values for each model and dataset are in Appendix F. We did not search over these as a hyperparameter, but we note that it can be tuned for additional performance improvements in our experiments.

B.4 Deep Neural Network Architecture

The Deep LSSL models used in our experiments simply stack together LSSL layers in a simple deep neural network architecture. We note the following architecture details.

We call MM the number of channels in the model.

There are two drawbacks with the current definition of LSSL:

They are defined by running HH independent copies of a state-space model, which means the HH input features do not interact at all.

If the channel dimension is M>1M>1, then the LSSL is a map from dimension 11 to MM, which means residuals cannot be applied.

These are both addressed by introducing a position-wise feedforward layer after the LSSL of shape H⋅M→HH\cdot M\to H. This simultaneously mixes the hidden features, and projects the output back to dimension 11 if necessary. There is also an optional non-linearity in between the LSSL and this feedforward projection; we fix it to the GeLU activation function in our models.

We note that this factorization of parallel convolutions on the HH features followed by a position-wise linear map is very similar to depth-wise separable convolutions .

To stack multiple layers of LSSLs together, we use very standard architectures for deep neural networks. In particular, we use residual connections and a layer normalization (either pre-norm or post-norm) in the style of standard Transformer architectures. Whether to use pre-norm or post-norm was chosen on a per-dataset basis, and depended on whether the model overfit; recent results have shown that pre-norm architectures are more stable , so we used it on harder datasets with less overfitting. We note that we could have additionally inserted MLP modules in between LSSL layers, in the style of Transformers , but did not experiment with this.

The overall parameter count of an LSSL model is M⋅H⋅(H+N)M\cdot H\cdot(H+N).

We primarily used two model sizes in our experiments, which were chosen simply to produce round numbers of parameters:

LSSL small (≈200K\approx 200K parameters): 66 layers, H=128,N=128,M=1H=128,N=128,M=1.

LSSL large (≈2M\approx 2M parameters): 44 layers, H=256,N=256,M=4H=256,N=256,M=4.

We did not search over additional sizes, but for some datasets reduced the model size for computational reasons.

Appendix C LSSL Proofs

This section gives refinements of the statements in Section 3, additional results, and proofs of all results.

Section C.1 has a more detailed (and self-contained) summary of basic methods in ODE approximation which will be used in the results and proofs.

Section C.2 give more general statements and proofs of Lemma 3.1 and Lemma 3.2 in Lemma C.1 and Theorem 4, respectively.

We consider the standard setting of a first-order initial value problem (IVP) ordinary differential equation (ODE) for a continuous function f(t,x)f(t,x)

This differential form has an equivalent integral form

Sections C.1.1 and C.1.2 overview the Picard theorem and first-order numerical integration methods, which apply to any IVP (9). Section C.1.3 then shows how to specialize it to linear systems as in equation (1).

At a high level, the basic approximation methods considered here use the integral form (10) and approximate the integral in the right-hand side by simple techniques.

The Picard-Lindelöf Theorem gives sufficient conditions for the existence and uniqueness of solutions to an IVP. As part of the proof, it provides an iteration scheme to compute this solution.

In the IVP (9), if there is an interval around t0t_{0} such that ff is Lipschitz in its second argument, then there is an open interval I∋t0I\ni t_{0} such that there exists a unique solution x(t)x(t) to the IVP in II. Furthermore, the sequence of Picard iterates x(0),x(1),…x^{(0)},x^{(1)},\dots defined by

C.1.2 Numerical Integration Methods

Many methods for numerical integration of ODEs exist, which calculate discrete-time approximations of the solution. We discuss a few of the simplest methods, which are first-order methods with local error O(h2)O(h^{2}) .

These methods start by discretizing (10) into the form

Here we assume a sequence of discrete times t0,t1,t2,…t_{0},t_{1},t_{2},\dots is fixed. For convenience, let xkx_{k} denote x(tk)x(t_{k}) and let Δtk:=tk−tk−1\Delta t_{k}:=t_{k}-t_{k-1}. The goal is now to approximate the integral in the RHS of (11).

The Euler method approximates (11) by holding the left endpoint constant throughout the integral (i.e., the “rectangle rule” with left endpoint), f(s,x(s))≈f(tk−1,x(tk−1))f(s,x(s))\approx f(t_{k-1},x(t_{k-1})). The discrete-time update becomes

The backward Euler method approximates (11) by holding the right endpoint constant throughout the integral (i.e., the “rectangle rule” with right endpoint), f(s,x(s))≈f(tk,x(tk))f(s,x(s))\approx f(t_{k},x(t_{k})). The discrete-time update becomes

C.1.3 Discretization of State-Space Models

In the case of a linear system, the IVP is specialized to the case

Note that here uu is treated as a fixed external input, which is constant from the point of view of this ODE in xx. Let uku_{k} denote the average value in each discrete time interval,

The integral equation (11) can be specialized to this case, and more generally a convex combination of the left and right endpoints can be taken to approximate the integral, weighing them by 1−α1-\alpha and α\alpha respectively. Note that the case α=0,1\alpha=0,1 are specializations of the forward and backward Euler method, and the case α=12\alpha=\frac{1}{2} is the classic “trapezoid rule” for numerical integration.

This derives the generalized bilinear transform (GBT) . The bilinear method is the case α=12\alpha=\frac{1}{2} of special significance, and was numerically found to be better than the forward and backward Euler methods α=0,1\alpha=0,1 both in synthetic function approximation settings and in end-to-end experiments [24, Figure 4].

C.2 RNNs are LSSLs: Proof of Results in Section 3.2

We provide more detailed statements of Lemmas 3.1 and 3.2 from Section 3.2. In summary, LSSLs and popular families of RNN methods all approximate the same continuous-time dynamics

by viewing them with a combination of two techniques.

We note that these results are about two of the most commonly used architecture modifications for RNNs. First, the gating mechanism is ubiquitous in RNNs, and usually thought of as a heuristic for smoothing optimization . Second, many of the effective large-scale RNNs use linear (gated) recurrences and deeper models, which is usually thought of as a heuristic for computational efficiency . Our results suggest that neither of these are heuristics after all, and arise from standard ways to approximate ODEs.

Non-linear RNNs discretize the dynamics (14) by applying backwards Euler discretization to the linear term, which arises in the gating mechanism of RNNs (Section C.2.2, Lemma C.1).

A special case of LSSLs approximates the dynamics (14) (in continuous-time) by applying Picard iteration to the non-linear term (Section C.2.3, Theorem 4).

Deep linear RNNs approximate the dynamics (14) with both Picard iteration in the depth direction to linearize the non-linear term, and discretization (gates) in the time direction to discretize the equation (Section C.2.4, Corollary C.3).

In the remainder of this section, we assume that there is an underlying function x(t)x(t) that satisfies (14) on some interval for any initial condition, and that ff is continuous and Lipschitz in its second argument. Our goal is to show that several families of models approximate this in various ways.

We sketch the idea of how LSSLs capture popular RNNs. More precisely, we will show how approximating the dynamics (14) in various ways lead to types of RNNs and LSSLs.

The first step is to look at the simpler dynamics

where there is some input u(t)u(t) that is independent of xx. (In other words, in (14), the function f(t,x)f(t,x) does not depend on the second argument.)

By directing applying the GBT discretization with α=1\alpha=1, this leads to a gated recurrence (Lemma 3.1).

The second step is that by applying the backwards Euler discretization more directly to (14), this leads to a gated RNN where the input can depend on the state (Lemma C.1).

Alternatively, we can apply Picard iteration on (14), which says that the iteration

Differentiating, this equation is the ODE

To move to discrete-time, this continuous-time layer can be discretized with gates as in Lemma 3.1, leading to deep linear RNNs such as the QRNN, or with the bilinear discretization, leading to the discrete-time LSSL. We note again that in the discrete-time LSSL, A‾\overline{A} and B‾\overline{B} play the role of the gates σ,1−σ\sigma,1-\sigma.

C.2.2 Capturing gates through discretization

where f‾(k,x)\overline{f}(k,x) is an arbitrary function that is Lipschitz in its second argument (e.g., it may depend on an external input uku_{k}).

Then equation (15) is a discretization of the dynamics (14) with step sizes Δtk=exp⁡(zk)\Delta t_{k}=\exp(z_{k}), i.e. xk≈x(tk)x_{k}\approx x(t_{k}) where tk=∑i=1kΔtit_{k}=\sum_{i=1}^{k}\Delta t_{i}.

Apply the backwards Euler discretization (13) to equation (14) to get

Note that Δtk1+Δtk=ezk1+ezk=11+e−zk\frac{\Delta t_{k}}{1+\Delta t_{k}}=\frac{e^{z_{k}}}{1+e^{z_{k}}}=\frac{1}{1+e^{-z_{k}}} and 11+Δtk=1−Δtk1+Δtk\frac{1}{1+\Delta t_{k}}=1-\frac{\Delta t_{k}}{1+\Delta t_{k}}, thus

Here we are denoting f‾(k,x)=f(tk,x)\overline{f}(k,x)=f(t_{k},x) to be a discrete-time version of ff evaluatable at the given timesteps tkt_{k}. ∎

Note that a potential external input function u(t)u(t) or sequence uku_{k} is captured through the abstraction f(t,x)f(t,x). For example, a basic RNN could define f‾(k,x)=f(tk,x)=tanh(Wx+Uuk)\overline{f}(k,x)=f(t_{k},x)=\text{tanh}(Wx+Uu_{k}).

C.2.3 Capturing non-linearities through Picard iteration

The main result of this section is Theorem 4 showing that LSSLs can approximate the same dynamics as the RNNs in the previous section. This follows from a technical lemma.

Let f(t,x)f(t,x) be any function that satisfies the conditions of the Picard-Lindelöf Theorem (Theorem 3).

A (continuous-time) deep LSSL with order N=1N=1 and A=−1,B=1,C=1,D=0A=-1,B=1,C=1,D=0 approximates the non-linear dynamics (14).

Applying the definition of an LSSL (equations (1)+(2)) with these parameters results in a layer mapping u(t)↦y(t)u(t)\mapsto y(t) where yy is defined implicitly through the ODE

This can be seen since the choice of C,DC,D implies y(t)=x(t)y(t)=x(t) and the choice of A,BA,B gives the above equation.

Consider the deep LSSL defined by alternating this LSSL with position-wise (in time) non-linear functions

(and z0=z(t0)=x(t0)=x0z_{0}=z(t_{0})=x(t_{0})=x_{0}). Note that

Since ff satisfies the conditions of the Picard Theorem (i.e., is continuous in the first argument and Lipschitz in the second), so does the function gg where g(t,x):=e−Atf(t,eAtx)g(t,x):=e^{-At}f(t,e^{At}x) for some interval around the initial time.

C.2.4 Capturing Deep, Linear, Gated RNNs

We finally note that several types of RNNs exist which were originally motivated by approximating linearizing gated RNNs for speed. Although these were treated as a heuristic for efficiency reasons, they are explained by combining our two main technical results.

Lemma C.1 shows that a single-layer, discrete-time, non-linear RNN approximates the dynamics (14) through discretization, which arises in the gating mechanism.

Theorem 4 shows that a deep, continuous-time, linear RNN approximates (14) through Picard iteration, where the non-linearity is moved to the depth direction.

Combining these two results leads to Corollary C.3, which says that a deep, discrete-time, linear RNN can also approximate the same dynamics (14).

This is a discretization of the dynamics (14) with step sizes Δtk=exp⁡(zk)\Delta t_{k}=\exp(z_{k}), i.e. xk≈x(tk)x_{k}\approx x(t_{k}) where tk=∑i=1kΔtit_{k}=\sum_{i=1}^{k}\Delta t_{i}.

By Lemma C.1, the first equation is a discretization of the continuous-time equation

uses the continuous-time version ff of f‾\overline{f}. But by Lemma C.2, this is an approximation of the dynamics (14) using Picard iteration. ∎

Notable examples of this type of model include the Quasi-RNN or QRNN and the Simple Recurrent Unit (SRU) , which are among the most effective models in practice. We remark that these are the closest models to the LSSL and suggest that their efficacy is a consequence of the results of this section, which shows that they are not heuristics.

We note that there are many more RNN variants that use a combination of these gating and linearization techniques that were not mentioned in this section, and can be explained similarly.

Appendix D LSSL Proofs and Algorithms

This section proves the results in Section 4.1, and is organized as follows:

Section D.1 gives a self-contained synopsis of the HiPPO framework .

Section D.2 proves Theorem 1, which shows that the hippo⁡\operatorname{\mathsf{hippo}} operators for any measure lead to a simple linear ODE of the form of equation (1).

Section D.3 proves Corollary 4.1, including a formal definition of quasiseparable matrices (i.e., how LSSL matrices are defined) in Definition 4.

This section is technically involved and we adopt notation to simplify reasoning about the shapes of objects. In particular, we use bold capitals (e.g. A\mathbf{A}) to denote matrices and bold lowercase (e.g. b\mathbf{b}) to denote vectors. For example, equation (1) becomes x˙=Ax+bu\dot{x}=\mathbf{A}x+\mathbf{b}u. These conventions are adopted throughout Appendices D and E.

D.1 Preliminaries: HiPPO Framework and Recurrence Width

This section summarizes technical preliminaries taken directly from prior work. We include this section so that this work is self-contained and uses consistent notation, which may deviate from prior work. For example, we use modified notation from Gu et al. in order to follow conventions in control theory (e.g., we denote input by uu and state by xx as in (1)).

Section D.1.1 formally defines the HiPPO operator mathematically as in [24, Section 2.2], and Section D.1.2 overviews the steps to derive the HiPPO operator as in [24, Appendix C]. Section D.1.3 defines the class of Low Recurrence Width (LRW) matrices, which is the class of matrices that our generalization of the HiPPO results (Theorem 1) uses.

projt\mathsf{proj}_{t} takes a function uu restricted up to time tt, u≤t:=u(x)∣x≤tu_{\leq t}:=u(x)|_{x\leq t}, and maps it to a polynomial g(t)∈Gg^{(t)}\in\mathcal{G}, that minimizes the approximation error ∥u≤t−g(t)∥L2(μ(t))\|u_{\leq t}-g^{(t)}\|_{L_{2}(\mu^{(t)})}.

D.1.2 HiPPO Framework for Deriving the HiPPO Operator

The main ingredients of HiPPO consists of an approximation measure and an orthogonal polynomial basis. We recall how they are defined in (we note that compared to Gu et al. , our notation has changed from input f(t)f(t) coefficients (state) c(t)c(t) to input u(t)u(t) and coefficients (state) x(t)x(t), following conventions in controls).

At every tt, the approximation quality is defined with respect to a measure μ(t)\mu^{(t)} supported on (−∞,t](-\infty,t]. We assume that the measures μ(t)\mu^{(t)} have densities ω(t,Y):= ⁣dμ(t) ⁣dY\omega(t,Y):=\frac{\mathop{}\!d\mu^{(t)}}{\mathop{}\!dY}. Note that this implies that integrating with respect to  ⁣dμ(t)\mathop{}\!d\mu^{(t)} is the same as integrating with respect to ω(t,Y) ⁣dY\omega(t,Y)\mathop{}\!dY.

In the general framework, HiPPO does not require an orthogonal polynomial basis as the selected basis. The choice of basis is generalized by tilting with χ\chi.

We express the coefficients xn(t)x_{n}(t) calculated by the HiPPO framework as:

To use this to derive x˙n(t)\dot{x}_{n}(t), let h(t,Y)=u(Y)pn(t,Y)ω(t,Y)h(t,Y)=u(Y)p_{n}(t,Y)\omega(t,Y). We see that

This allows x˙n(t)\dot{x}_{n}(t) to be written as

Although Gu et al. describe the framework in the full generality above and use χ\chi as another degree of freedom, in their concrete derivations they always fix χ=ω\chi=\omega. Our general results also use this setting. For the remainder of this section, we assume the “full tilting” case χ=ω\chi=\omega. In particular, this means that in Eq. 18, we essentially substitute ω\omega above with 11 and divide each term by the inverse square root of our normalization constant, ζ\zeta, to get the coefficient dynamics that we will use in our arguments:

Now, if we can show that each of the integrated terms in (18) are linear combinations of xn(t)x_{n}(t), this would be the same as saying that x˙n(t)=A(t)x(t)+b(t)u(t)\dot{x}_{n}(t)=\mathbf{A}(t)x(t)+\mathbf{b}(t)u(t) for some A(t)\mathbf{A}(t). Therefore, the incremental update operation would be bounded by the runtime of the matrix-vector operation A(t)x(t)\mathbf{A}(t)x(t).

D.1.3 Recurrence Width

An N×NN\times N matrix A\mathbf{A} has recurrence width tt if the polynomials ai(X)=∑j=0N−1A[i,j]Xja_{i}(X)=\sum_{j=0}^{N-1}\mathbf{A}[i,j]X^{j} satisfy deg⁡(ai)≤i\deg(a_{i})\leq i for i<ti<t, and

D.2 Proof of Theorem 1

This section proves Theorem 1, which is restated formally in Corollary D.4. Section D.2.1 proves some results relating orthogonal polynomials to recurrence width (Section D.1.3). Section D.2.2 proves Corollary D.4. Sections D.2.3 and D.2.4 provides examples showing how Corollary D.4 can be specialized to exactly recover the HiPPO-LegT, HiPPO-LagT, HiPPO-LegS methods .

Next we introduce the following lemma, which will be useful in our arguments:

For any nn, there exists ordered sets of coefficients αn={αn,i},βn={βn,i}\alpha_{n}=\{\alpha_{n,i}\},\beta_{n}=\{\beta_{n,i}\},

pn′(Z)=∑i=0n−1αn,ipi(Z)p^{\prime}_{n}(Z)=\sum_{i=0}^{n-1}\alpha_{n,i}p_{i}(Z)

Zpn′(Z)=∑i=0n−1βn,ipi(Z)Zp^{\prime}_{n}(Z)=\sum_{i=0}^{n-1}\beta_{n,i}p_{i}(Z)

Follows from the fact that pi(z)p_{i}(z) for 0≤i<N0\leq i<N forms a basis and the observation of the degrees of the polynomials on the LHS. ∎

Let S\mathbf{S} be the “right shift" matrix, i.e. for any matrix M\mathbf{M}, MS\mathbf{M}\mathbf{S} has the columns of M\mathbf{M} shifted to right by one. Note that ST\mathbf{S}^{T} corresponds to the “left shift" matrix.

Recall that P\mathbf{P} has the coefficients of the OP polynomials p0(Z),…,pN−1(Z)p_{0}(Z),\dots,p_{N-1}(Z) as its rows. Then note that

The claim on the structure of D2\mathbf{D}_{2} then follows from the above expression. The claim on runtime of computing D2z\mathbf{D}_{2}\mathbf{z} follows from essentially the same argument as for D1z\mathbf{D}_{1}\mathbf{z}.

Finally, we make the following observation:

Let A′\mathbf{A}^{\prime} and B′\mathbf{B}^{\prime} be defined such that A′[n,i]=αn,i\mathbf{A}^{\prime}[n,i]=\alpha_{n,i} and B′[n,i]=βn,i\mathbf{B}^{\prime}[n,i]=\beta_{n,i}. Then both A′\mathbf{A}^{\prime} and B′\mathbf{B}^{\prime} are both products of three matrices: two of which have recurrence width at most 22 and the third is the inverse of a matrix that has recurrence width 22.

D.2.2 HiPPO for General Measures

From the definition of zz, we see that Y−t=(z−1)θ(t)2{Y}-t=\frac{(z-1)\theta(t)}{2}. Then

Additionally, given a measure ω\omega on and OP family p0(Y), p1(Y),…p_{0}({Y}),\ p_{1}({Y}),\dots such that for all i≠ji\neq j,

If we let α(t)=t−θ(t)\alpha(t)=t-\theta(t) and β(t)=t\beta(t)=t, then applying the Leibniz rule to (23) we get:

Because deg⁡(pn′(z))≤n−1\deg\left({p^{\prime}_{n}(z)}\right)\leq n-1 and deg⁡((z−1)pn′(z))≤n\deg\left({(z-1)p^{\prime}_{n}(z)}\right)\leq n, they can be written as a linear combination of {pi′}i≤n\{p^{\prime}_{i}\}_{i\leq n}. Let us define {αn,j}\{\alpha_{n,j}\}, {βn,j}\{\beta_{n,j}\} such that

where A1(t)[n,k]={2αn,k+θ′(t)βn,k if k<nθ′(t)βn,n+θ′(t) if k=n0   otherwise \mathbf{A}_{1}(t)[n,k]=\begin{cases}2\alpha_{n,k}+\theta^{\prime}(t)\beta_{n,k}&\text{ if }k<n\\ \theta^{\prime}(t)\beta_{n,n}+\theta^{\prime}(t)&\text{ if }k=n\\ 0\ \ &\text{ otherwise }\end{cases} for αn,k\alpha_{n,k},βn,k\beta_{n,k} as defined in (25).

The matrix A1\mathbf{A}_{1} in Theorem 7 can be re-written as

In particular, both A′\mathbf{A}^{\prime} and B′\mathbf{B}^{\prime} both products of three matrices: two of which have recurrence width at most 22 and the third is the inverse of a matrix that has recurrence width 22.

Eq. 26 follows from Theorem 7 and defining A′\mathbf{A}^{\prime} and B′\mathbf{B}^{\prime} to contain the αn,k\alpha_{n,k} and βn,k\beta_{n,k} coefficients. ∎

D.2.3 Translated HiPPO (Sliding Windows)

The case when θ(t)=θ\theta(t)=\theta for all tt represents a constant-size sliding window, which Gu et al. denote as the “Translated HiPPO” case with instantiations such as HiPPO-LegT (Translated Legendre) and HiPPO-LagT (Translated Laguerre).

We now state a corollary of Theorem 7 for the case of θ(t)=θ\theta(t)=\theta for all t.

where A1[n,j]={2αn,k if k<n0   otherwise \mathbf{A}_{1}[n,j]=\begin{cases}2\alpha_{n,k}&\text{ if }k<n\\ 0\ \ &\text{ otherwise }\end{cases}.

to handle the u(t−θ)u(t-\theta) term in Corollary D.5.

where A=A1+2A2\mathbf{A}=\mathbf{A}_{1}+2\mathbf{A}_{2} for A1\mathbf{A}_{1} as defined in Corollary D.5 and A2[n,k]=pn(−1)pk(−1)\mathbf{A}_{2}[n,k]=p_{n}(-1)p_{k}(-1).

To approximate u(t−θ)u(t-\theta), we note that when Y=t−θ{Y}=t-\theta, z=−1z=-1. Then

We now show that the special case of Corollary D.6 for Legendre matches the results from .

Let pn(z)=(2n+12)1/2Pn(z)p_{n}(z)=\left({\frac{2n+1}{2}}\right)^{1/2}P_{n}(z) where Pn(z)P_{n}(z) are the Legendre polynomials. Then

and b[n]=(2n+12)12\mathbf{b}[n]=\left({\frac{2n+1}{2}}\right)^{\frac{1}{2}}.

where A=A1+2A2\mathbf{A}=\mathbf{A}_{1}+2\mathbf{A}_{2} for A1\mathbf{A}_{1} as defined in Corollary D.5 and A2[n,k]=pn(−1)pk(−1)\mathbf{A}_{2}[n,k]=p_{n}(-1)p_{k}(-1).

Then b[n]=(2n+12)12\mathbf{b}[n]=\left({\frac{2n+1}{2}}\right)^{\frac{1}{2}} follows from Corollary D.6 and (29).

From the following recurrence relations [1, Chapter 12]:

Recalling that A1[n,k]=2αn,k\mathbf{A}_{1}[n,k]=2\alpha_{n,k}.

We note that from (28), A2[n,k]=(2n+12)12(2k+12)12(−1)n(−1)k=(2n+1)12(2k+1)122(−1)n−k\mathbf{A}_{2}[n,k]=\left({\frac{2n+1}{2}}\right)^{\frac{1}{2}}\left({\frac{2k+1}{2}}\right)^{\frac{1}{2}}(-1)^{n}(-1)^{k}=\frac{\left({2n+1}\right)^{\frac{1}{2}}\left({2k+1}\right)^{\frac{1}{2}}}{2}(-1)^{n-k}.

Recalling A=A1+2A2\mathbf{A}=\mathbf{A}_{1}+2\mathbf{A}_{2}, we get:

D.2.4 Scaled HiPPO: Recovering HiPPO-LegS

We now use Theorem 7 to recover the HiPPO-LegS instantiation for the “Scaled Legendre” measure, the main method from Gu et al. .

Let pn(z)=(2n+12)1/2Pn(z)p_{n}(z)=\left({\frac{2n+1}{2}}\right)^{1/2}P_{n}(z) where Pn(z)P_{n}(z) are the Legendre polynomials and let δ(t)=t\delta(t)=t for all t. Then

and b[n]=(2n+12)12\mathbf{b}[n]=\left({\frac{2n+1}{2}}\right)^{\frac{1}{2}}.

Let θ(t)=t\theta(t)=t. By Theorem 7 and noting that θ(t)=1\theta(t)=1, we get:

for αn,k\alpha_{n,k},βn,k\beta_{n,k} as defined in (25).

Using the same arguments as in the proof of Corollary D.7, b[n]=(2n+12)12\mathbf{b}[n]=\left({\frac{2n+1}{2}}\right)^{\frac{1}{2}} follows from Corollary D.6 and (29). Also using similar arguments as the proof of Corollary D.7, we have

Including the normalization constant (2n+1)12(2n+1)^{\frac{1}{2}}, we note that (z−1)pn′(z)=(z+1)pn′(z)−2pn′(z)(z-1)p^{\prime}_{n}(z)=(z+1)p^{\prime}_{n}(z)-2p^{\prime}_{n}(z). Then we get

Recalling that the definition for A1\mathbf{A}_{1} from (30), we get:

D.3 Proof of Corollary 4.1: HiPPO for Classical Orthogonal Polynomials

This section proves Corollary 4.1, showing that the HiPPO matrices for measures corresponding to classical families of orthogonal polynomials are quasiseparable. We define quasi-separability in Section D.3.1. Theorem 8 proves the claimed result for Jacobi polynomials and Lemma D.11 proves the claimed result for Laguerre polynomials.

We note that there is a third family of classical OPs, the Hermite polynomials , which have a two-sided infinite measure. However, since HiPPO is about continuous-time memorization of a function’s history, it requires a one-sided measure and therefore the Hermite polynomials are not appropriate.

Every matrix contained strictly above the diagonal has rank at most pp.

Every matrix contained strictly below the diagonal has rank at most qq.

A (q,q)(q,q)-quasiseparable matrix is called qq-quasiseparable.

We are interested in showing the A\mathbf{A} matrices for a broad class of OPs in Corollary D.6 are O(1)O(1)-quasiseperable. We now state some properties of qq-quasiseparable matrices:

Let Q\mathbf{Q} be qq-quasiseparable. Then:

Any submatrix contained strictly below or above the diagonal in Q\mathbf{Q} has rank ≤q\leq q and its corresponding submatrix in Q′\mathbf{Q}^{\prime} also has rank ≤q′\leq q^{\prime}. This implies that the corresponding submatrix in Q±Q′\mathbf{Q}\pm\mathbf{Q}^{\prime} has rank ≤q+q′\leq q+q^{\prime}. Therefore Q±Q′\mathbf{Q}\pm\mathbf{Q}^{\prime} is (q+q′)(q+q^{\prime})-quasiseparable.

Let the r=rank(E)r=\text{rank}(\mathbf{E}). Thus any submatrix in E\mathbf{E} has rank ≤r\leq r. Then E\mathbf{E} is rr-quasiseparable.

Multiplication by diagonal matrices only scales the rows and columns, leaving the rank of each submatrix unchanged.

D.3.2 Jacobi Polynomials

The Jacobi polynomial of degree nn with parameters α,β>−1\alpha,\beta>-1 will be denoted Jnα,β(z){J_{n}^{\alpha,\beta}}\left({z}\right). The Jacobi polynomials are orthogonal with respect to measure ω(z)=(1−z)α(1+z)β\omega(z)=(1-z)^{\alpha}(1+z)^{\beta}. In particular, it is known from (eq. (4.3.3) from ) that

where Γ(⋅)\Gamma(\cdot) is the gamma function. Let

be our normalization constant. We note that the normalized Jacobi polynomials

We now discuss some useful properties of Jacobi polynomials. It is known that (, eq. (3.100)):

From (4.21.7) in , it is known that the derivative of Jnα,β(z){J_{n}^{\alpha,\beta}}\left({z}\right) is proportional to Jn−1α+1,β+1(z){J_{n-1}^{\alpha+1,\beta+1}}\left({z}\right):

Additionally, the Jacobi polynomials Jn−1α+1,β(z){J_{n-1}^{\alpha+1,\beta}}\left({z}\right) and Jn−1α,β+1(z){J_{n-1}^{\alpha,\beta+1}}\left({z}\right) can be written as sums of Jn−1α,β(z){J_{n-1}^{\alpha,\beta}}\left({z}\right) polynomials. In particular from (3.112) and (3.115),

Using (35) and (36) in (34) allows us to write ∂∂zJnα,β(z)\frac{\partial}{\partial z}{J_{n}^{\alpha,\beta}}\left({z}\right) as a sum of {Jkα,β(z)}k≤n\left\{{J_{k}^{\alpha,\beta}}\left({z}\right)\right\}_{k\leq n} as follows:

We use these properties to write ∂∂zpnα,β(z)\frac{\partial}{\partial z}{p_{n}^{\alpha,\beta}}\left({z}\right) as a sum of {pkα,β(z)}k≤n\left\{{p_{k}^{\alpha,\beta}}\left({z}\right)\right\}_{k\leq n}:

Let pnα,β(z){p_{n}^{\alpha,\beta}}\left({z}\right) and λnα,β\lambda^{\alpha,\beta}_{n} be as defined in (31).

Recall that Jnα,β(z)=λnα,βpnα,β{J_{n}^{\alpha,\beta}}\left({z}\right)=\lambda^{\alpha,\beta}_{n}{p_{n}^{\alpha,\beta}}. Then the claim follows from (\refeq:jnab−sum)(\ref{eq:jnab-sum}).

D.3.3 HiPPO for Jacobi Polynomials

Let pnα,β(z){p_{n}^{\alpha,\beta}}\left({z}\right) be defined as in (31) and ω(z)=(1−z)α(1+z)β\omega(z)=(1-z)^{\alpha}(1+z)^{\beta}. Then

where A\mathbf{A} is 33-quasiseperable.

where A=A1+2A2\mathbf{A}=\mathbf{A}_{1}+2\mathbf{A}_{2} for A1\mathbf{A}_{1} as defined in Corollary D.5 and A2[n,k]=pnα,β(−1)pnα,β(−1)\mathbf{A}_{2}[n,k]={p_{n}^{\alpha,\beta}}(-1){p_{n}^{\alpha,\beta}}(-1).

where D11,D12,D21,D22\mathbf{D}_{11},\mathbf{D}_{12},\mathbf{D}_{21},\mathbf{D}_{22} are the diagonal matrices such that

(39) makes use of the fact that (−1)n+k=(−1)n−k(-1)^{n+k}=(-1)^{n-k} along with the definitions above.

Any submatrix of Q1\mathbf{Q}_{1} below the diagonal contains all 11s, and submatrix of Q1\mathbf{Q}_{1} above the diagonal contains all s. Then any submatrix above or below the diagonal has rank 1. Therefore Q1\mathbf{Q}_{1} is 1-quasiseparable. Since Q1\mathbf{Q}_{1} is 1-quasiseparable and D11,D12,D21,D22\mathbf{D}_{11},\mathbf{D}_{12},\mathbf{D}_{21},\mathbf{D}_{22} are all diagonal matrices, part (iii) of Lemma D.9 implies that the matrices D11Q1D12\mathbf{D}_{11}\mathbf{Q}_{1}\mathbf{D}_{12} and D21Q1D22\mathbf{D}_{21}\mathbf{Q}_{1}\mathbf{D}_{22} are both 1-quasiseparable. Therefore part (i) of Lemma D.9 implies that A1\mathbf{A}_{1} is 2-quasiseparable.

From (4.1.1) and (4.1.4) in , it is known that

Then A2\mathbf{A}_{2} can be written D3Q2D4\mathbf{D}_{3}\mathbf{Q}_{2}\mathbf{D}_{4} where D3,D4\mathbf{D}_{3},\mathbf{D}_{4} are the diagonal matrices such that

where Q2[n,k]=1\mathbf{Q}_{2}[n,k]=1 for all 0≤n,k<N0\leq n,k<N. Q2\mathbf{Q}_{2} has rank 1, and D3,D4\mathbf{D}_{3},\mathbf{D}_{4} are diagonal matrices. Hence by part (ii) and (iii) Lemma D.9, A2\mathbf{A}_{2} is 1-quasiseparable.

Since A1\mathbf{A}_{1} is 2-quasiseparable and A2\mathbf{A}_{2} is 1-quasiseparable, part (i) of Lemma D.9 implies that A=A1+2A2\mathbf{A}=\mathbf{A}_{1}+2\mathbf{A}_{2} is 3-quasiseparable and the claim follows. ∎

D.3.4 HiPPO-LagT

The Laguerre polynomial of degree nn with parameters α>−1\alpha>-1 will be denoted Lnα(z)L^{\alpha}_{n}\left({z}\right). The Laguerre polynomials are orthogonal with respect to measure zαe−zz^{\alpha}e^{-z}. In particular, from (5.1.1) in we know that

Let λn=(Γ(n+1)Γ(n+α+1))12\lambda_{n}=\left({\frac{\Gamma(n+1)}{\Gamma(n+\alpha+1)}}\right)^{\frac{1}{2}} be our normalization constant. We note that the normalized Laguerre polynomials

Let pn(z)p_{n}(z) be defined as in (\refeq:lag)(\ref{eq:lag}). Then

We now show that A\mathbf{A} as defined in Theorem 9 is 11-quasiseperable.

Let A\mathbf{A} be defined as in Theorem 9. Then A\mathbf{A} is 11-quasiseperable.

Below the diagonal, all entries A[n,k]=1\mathbf{A}[n,k]=1. Then any submatrix below the diagonal has rank 1. Similarly, above the diagonal, all entries A[n,k]=0\mathbf{A}[n,k]=0. Then any submatrix above the diagonal also has rank 1. Then by Definition 4, the claim follows.

Appendix E LSSL Algorithms

Section E.1 proves Theorem 2, providing an algorithm to compute the Krylov function efficiently for LSSLs.

Section E.2 shows a further simplification of Corollary 4.1, presenting an even simpler class of structured matrices that we use in our implementation of LSSL.

Section E.3 provides technical details of the implementation of LSSL, in particular for computing the MVM black box (multiplication by A‾\overline{A}) and for computing gradients during backpropagation.

This section addresses the computational aspects of the LSSL. In particular, we prove Theorem 2 for the computational speed of computing the Krylov function (7) for quasiseparable matrices AA, by providing a concrete algorithm in Section E.1.1.

We call (7) the Krylov function following the notation of , since it can be written K(A,B)TC\mathcal{K}(A,B)^{T}C where K(A,B)\mathcal{K}(A,B) is the Krylov matrix defined in (8). Alternative naming suggestions are welcome.

We follow the similar problem of [17, Lemma 6.6] but track the dependence on LL and the log factors more precisely, and optimize it in the case of stronger structure than quasiseparability, which holds in our setting (particularly Theorem 11).

The first step is to observe that the Krylov function KL(A,B,C)\mathcal{K}_{L}(A,B,C) is actually the coefficient vector of C(I−Ax)−1B(modxL)C(I-Ax)^{-1}B\pmod{x^{L}} as a polynomial in xx. (Note that AxAx means simply multiplying every entry in AA by a scalar variable xx.) This follows from expanding the power series (I−Ax)−1=I+Ax+A2x2+…(I-Ax)^{-1}=I+Ax+A^{2}x^{2}+\dots. Thus we first compute C(I−Ax)−1BC(I-Ax)^{-1}B, which is a rational function of degree at most NN in the numerator and denominator (which can be seen by the standard adjoint formula for the matrix inverse).

The second step is simply inverting the denominator of this rational function (modxL)\pmod{x^{L}} and multiplying by the numerator, both of which are operations that need Llog⁡(L)L\log(L) time by standard results for polynomial arithmetic .

For the remainder of this section, we focus on computing the first part. We make two notational changes: First, we transpose C\mathbf{C} to make it have the same shape as B\mathbf{B}. We consider the more general setting where B\mathbf{B} and C\mathbf{C} have multiple columns; this can be viewed as handling a “batch” problem with several queries for B,C\mathbf{B},\mathbf{C} at the same time.

Let A\mathbf{A} be a qq-quasiseparable matrix. Then

is a k×kk\times k matrix of rational functions of degree at most NN, which can be computed in O(q3log⁡4N)O(q^{3}\log^{4}N) operations.

The main idea is that quasiseparable matrices are recursively “self-similar”, in that the principal submatrices are also quasiseparable, which leads to a divide-and-conquer algorithm. In particular, divide A=[A00A01A10A11]\mathbf{A}=\begin{bmatrix}\mathbf{A}_{00}&\mathbf{A}_{01}\\ \mathbf{A}_{10}&\mathbf{A}_{11}\end{bmatrix} into quadrants. Then by Definition 4, A00,A11\mathbf{A}_{00},\mathbf{A}_{11} are both qq-quasiseparable and A01,A10\mathbf{A}_{01},\mathbf{A}_{10} are rank qq. Therefore the strategy is to view I−Ax\mathbf{I}-\mathbf{A}x as a low-rank perturbation of smaller quasiseparable matrices and reduce the problem to a simpler one.

Over a commutative ring R\mathcal{R}, let A∈RN×N\mathbf{A}\in\mathcal{R}^{N\times N} and U,V∈RN×p\mathbf{U},\mathbf{V}\in\mathcal{R}^{N\times p}. Suppose A\mathbf{A} and A+UVT\mathbf{A}+\mathbf{U}\mathbf{V}^{T} are invertible. Then Ip+VTA−1U∈Rp×p\mathbf{I}_{p}+\mathbf{V}^{T}\mathbf{A}^{-1}\mathbf{U}\in\mathcal{R}^{p\times p} is invertible and

Suppose we know the expansions of each of

Then the final result can be computed by inverting I2t+M3\mathbf{I}_{2t}+\mathbf{M}_{3} (O(q3Nlog⁡(N))O(q^{3}N\log(N)) operations), multiplying by M2,M4\mathbf{M}_{2},\mathbf{M}_{4} (O((kq2+k2q)Nlog⁡(N))O((kq^{2}+k^{2}q)N\log(N)) operations), and subtracting from M1\mathbf{M}_{1} (O(k2Nlog⁡(N))O(k^{2}N\log(N)) operations). This is a total of O((q3+kq2+k2q)Nlog⁡(N))O((q^{3}+kq^{2}+k^{2}q)N\log(N)) operations. Note that when k=O(qlog⁡N)k=O(q\log N), this becomes O(q3Nlog⁡3N)O(q^{3}N\log^{3}{N}); we will use this in the analysis shortly.

To compute M1,M2,M3,M4\mathbf{M}_{1},\mathbf{M}_{2},\mathbf{M}_{3},\mathbf{M}_{4}, it suffices to compute the following:

But to compute those, it suffices to compute the following (k+t)×(k+t)(k+t)\times(k+t) matrices:

Since A00\mathbf{A}_{00} and A11\mathbf{A}_{11} have the same form as A\mathbf{A}, this is two recursive calls of half the size. Notice that the size of the other input (dimensions of B,C\mathbf{B},\mathbf{C}) is growing, but when the initial input is k=1k=1, it never exceeds 1+qlog⁡N1+q\log{N} (since they increase by qq every time we go down a level). Earlier, we noticed that when k=O(qlog⁡N)k=O(q\log N), the reduction step has complexity O(q3Nlog⁡3(N))O(q^{3}N\log^{3}(N)) for any recursive call. The recursion adds an additional log⁡N\log{N} multiplicative factor on top of this. ∎

Suppose that A\mathbf{A} is semiseparable instead of quasiseparable, and suppose qq is a small constant. Then the cost of Lemma E.2 is O(Nlog⁡2(N))O(N\log^{2}(N)) operations.

This follows from the fact that in the recursion (45) and (46), the U,V\mathbf{U},\mathbf{V} matrices do not have to be appended if they already exist in B,C\mathbf{B},\mathbf{C}. For intuition, this happens in the case when A\mathbf{A} is tridiagonal, so that U,VU,V have the structure (1,0,…,0)(1,0,\dots,0), or the case when the off-diagonal part of A\mathbf{A} is all 11 (such as the HiPPO-LegT matrix). The matrices in Section D.3 and Section E.2 (Theorems 8, 9 and 11) actually satisfy this stronger structure, so Corollary E.3 applies.

Combining everything, this proves Theorem 2 with the exact bound Nlog⁡2(N)+Llog⁡(L)N\log^{2}(N)+L\log(L) operations. The memory claim follows similarly, and the depth of the algorithm is log⁡2(N)+log⁡(L)\log^{2}(N)+\log(L) from the divide-and-conquer recursions.

E.1.2 Summary of Computation Speed for LSSLs and other Mechanisms

We provide a summary of complexity requirements for various sequence model mechanisms, including several versions of the LSSL. Note that these are over exact arithmetic as in Theorem 2.

First, the self-attention mechanism is another common sequence model that has an L2L^{2} dependence on the length of the sequence, so it is not suitable for the very long sequences we consider here. (We do note that there is an active line of work on reducing this complexity.)

Second, we include additional variants of the LSSL. In Table 5, LSSL-naive denotes learning AA and Δt\Delta t for unstructured AA; LSSL-fixed denotes not learning A,ΔtA,\Delta t (see Appendix B for details); LSSL denotes the learning AA and Δt\Delta t for the structured class AA.

We include brief explanations of these complexities for the LSSL variants.

Parameters: O(HN)O(HN) in the matrices B,CB,C and O(N2)O(N^{2}) in the matrix AA.

Training: O(HN3)O(HN^{3}) to invert compute the matrix A‾\overline{A} for all HH features. O(LHN2)O(LHN^{2}) to compute the Krylov matrix C,CA,…C,CA,\dots. O(BLlog⁡(L)HNO(BL\log(L)HN to multiply by BB and convolve with uu.

Memory: O(HN2)O(HN^{2}) to store A‾\overline{A}. O(LHN)O(LHN) to store the Krylov matrix. O(BLH)O(BLH) to store the inputs/outputs

Inference: O(HN2)O(HN^{2}) to for MVM by A‾\overline{A}.

Training: O(BLlog⁡(L)H)O(BL\log(L)H) to convolve with uu.

Memory: O(LHN)O(LHN) to store the Krylov matrix (but cached, so no backprop). O(BLH)O(BLH) for inputs/outputs.

Inference: O(HN2)O(HN^{2}) to for MVM by A‾\overline{A}.

Parameters: O(HN)O(HN) for A,B,C,ΔtA,B,C,\Delta t.

Memory: O(BHL)O(BHL) to store Krylov (and inputs/outputs).

Inference: O(HN)O(HN) to multiply xt[H,N]x_{t}[H,N] by A‾[H,N,N]\overline{A}[H,N,N]

E.2 Further Simplification with Tridiagonal Matrices

The algorithm for Theorem 2 for general quasiseparable matrices is still difficult to implement in practice, and we make a further simplification using a particular subclass of quasiseparable matrices.

The class of N×NN\times N matrices SN={P(D+T−1)Q}\mathcal{S}_{N}=\{P(D+T^{-1})Q\} with diagonal D,P,QD,P,Q and tridiagonal TT includes the original HiPPO-LegS, HiPPO-LegT, and HiPPO-LagT matrices .

Theorem 11 shows that a simple representation involving tridiagonal and diagonal matrices captures all of the original HiPPO matrices. In particular, our LSSL implementation initializes AA to be the HiPPO-LegS matrix (Appendix B) and learns within the class defined by Theorem 11.

We note that the matrices in Theorem 11 are all 1-quasiseparable and in particular also contain the HiPPO matrices for Gegenbauer and generalized Laguerre orthogonal polynomials derived in Theorem 9. In fact, the notion of semiseparability, which is closely related to (and actually is the predecessor of) quasiseparability, was originally motivated precisely to capture inverses of tridiagonal matrices. Thus the structured class in Theorem 11 can be viewed as an approximation of 33-quasiseparable matrices (Corollary 4.1) to 11-quasiseparable, which still contains many of the HiPPO families of interest.

We simply show that each of these specific matrices can be represented in the proposed form.

Let AA denote the HiPPO-LegT transition matrix. Up to row/column scaling (i.e. left- and right- multiplication by diagonal PP and QQ), we can write

This can be written as −PA′Q-PA^{\prime}Q where P=Q=diag⁡((2n+1)12)P=Q=\operatorname*{diag}((2n+1)^{\frac{1}{2}}) and

Finally, A′=D+T−1A^{\prime}=D+T^{-1} where D=−diag⁡(n2n+1)D=-\operatorname*{diag}(\frac{n}{2n+1}) and TT is the matrix with 11 on the main diagonal and −1-1 on the subdiagonal.

This can be written as −P(D+T−1)Q-P(D+T^{-1})Q where P=Q=IP=Q=I, D=−12ID=-\frac{1}{2}I, and TT is the same tridiagonal matrix as in the HiPPO-LegS case. ∎

E.3 Implementation Details

In this section we provide several implementation details that are useful for implementing LSSLs in practice.

Recall that one of the main primitives of LSSLs is the matrix-vector multiplication y=A‾xy=\overline{A}x (Section 3.1, Appendix B), where A‾\overline{A} is the state matrix AA discretized with step size Δt\Delta t using the bilinear method (Section C.1.3). In Section E.3.1, we describe how this MVM can be performed with simpler MVM primitives which we call the “forward difference” and “backward difference”.

However, if these MVM primitives are implemented in a specialized way for particular classes of AA matrices (i.e., not using atoms in a standard autograd framework), then we also need to calculate several additional gradients by hand. Section E.3.2 shows that calculating gradients to A,Δt,xA,\Delta t,x during backpropagation can actually be reduced to those same forward/backward difference primitives.

Finally, in the case when AA is the structured class of matrices in Theorem 11, Section E.2 shows how to efficiently calculate those primitives using a black-box tridiagonal solver. Our codeAvailable at https://github.com/HazyResearch/state-spaces implements all the algorithms in this section, with bindings to the cuSPARSE library for efficient tridiagonal solving on GPU.

The discrete state-space system is given by (4) and (5), re-written here for convenience

where A‾\overline{A} is a function of A,δtA,\delta_{t} and A‾\overline{A} is a function of A,B,δtA,B,\delta_{t}. In particular, we define A‾\overline{A} to be the matrix discretized using the bilinear method (Section C.1.3), and the system can be written explicitly:

We will call these functions the forward difference and backward difference maps, respectively. (The Euler and backward Euler discretizations (Section C.1.2) are also known as the “forward difference” and “backward difference” methods, which in the case of linear systems reduces down to the maps FF and BB.)

E.3.2 Gradients through the Forward/Backward Difference Primitives

In this section we will let y=F(A,Δt,x)y=F(A,\Delta t,x) or y=B(A,Δt,x)y=B(A,\Delta t,x) denote the computation of interest, L(y)L(y) denote a generic loss function, and dx,dy,…dx,dy,\dots denote gradients to x,y,…x,y,\dots (e.g., dx=∂L(y)∂xdx=\frac{\partial L(y)}{\partial x}).

First we have the standard ∂L(y)∂x=∂L(y)∂y∂y∂x=∂L(y)∂y(I+ΔtA)−1\frac{\partial L(y)}{\partial x}=\frac{\partial L(y)}{\partial y}\frac{\partial y}{\partial x}=\frac{\partial L(y)}{\partial y}(I+\Delta tA)^{-1}. This corresponds to matrix-vector multiplication by (I+ΔA)−T(I+\Delta A)^{-T}. In other words, it can be computed by the primitive B(AT,Δt,dy)B(A^{T},\Delta t,dy).

Similarly, in order to compute ∂L(y)∂Δt\frac{\partial L(y)}{\partial\Delta t} we require ∂y∂Δt\frac{\partial y}{\partial\Delta t}. We need the result ∂Y−1∂x=−Y−1∂Y∂xY−1\frac{\partial Y^{-1}}{\partial x}=-Y^{-1}\frac{\partial Y}{\partial x}Y^{-1}for an invertible matrix YY [41, equation (59)]. Then

We can summarize this as follows. Let y=B(A,Δt,x)=(I+ΔtA)−1xy=B(A,\Delta t,x)=(I+\Delta tA)^{-1}x and dy=∂L(y)/∂ydy=\partial L(y)/\partial y (as a column vector). Then

The forward case is simpler. Let y=F(A,Δt,x)=(I+ΔtA)xy=F(A,\Delta t,x)=(I+\Delta tA)x. Then ∂y∂x=I+ΔtA\frac{\partial y}{\partial x}=I+\Delta tA and ∂y∂Δt=Ax\frac{\partial y}{\partial\Delta t}=Ax. Thus

E.3.3 Computing the Forward/Backward Difference for Tridiagonal Inverse Matrices

Theorem 11 uses the classes of matrices A=P(D+T−1)QA=P(D+T^{-1})Q for diagonal D,P,QD,P,Q and tridiagonal TT. We describe how the forward and backward difference MVMs can be performed efficiently for this class of matrices by reducing to a black-box tridiagonal solver.

in terms of multiplication by diagonal matrices x↦Dxx\mapsto Dx and tridiagonal solving x↦T−1xx\mapsto T^{-1}x.

We will explicitly rewrite the inverse of the matrix G=I+Δt⋅P(D+T−1)QG=I+\Delta t\cdot P(D+T^{-1})Q.

The core observation is to multiply GG by a choice selection of matrices to cancel out the T−1T^{-1} term:

Now note that the matrix in the middle is tridiagonal. Hence we have reduced MVM by G−1G^{-1}, i.e. the backward difference problem, to a series of diagonal and tridiagonal MVMs (easy), and a tridiagonal inverse MVM (a.k.a. a tridiagonal solve).

Appendix F Additional Experiments and Experiment Details

We provide additional experiments and ablations in Section F.1. Section F.2 describes our training methodology in more detail for each dataset. The hyperparameters for all reported results are in Table 9.

Table 6 has results for a setting considered in previous work involving irregularly-sampled time series. LSSL is competitive with the best prior methods, some of which were specialized to handle this setting.

Tables 7 and 8 show results on SpeechCommands-Raw and a smaller model on sCIFAR, ablating that learning either the AA or Δt\Delta t parameters provides a consistent performance increase.

Finally, Fig. 4 plots the Δt\Delta t values at the beginning and end of training on the SpeechCommands-Raw dataset, confirming that training Δt\Delta t does noticeably change their values to better model the data. In particular, the Δt\Delta t values spread over time to cover a larger range of timescales.

F.2 Methodology

We describe our training procedure on each dataset for our model and any relevant baselines.

All models and datasets used the Adam optimizer with a LR decay scheduler that reduced LR by 5x upon validation plateau for 10 or 20 epochs. We fixed the batch size to 5050 for the MNIST/CIFAR datasets and 3232 for other datasets, reducing if necessary to fit in memory.

For all models, we chose the hyperparameters that achieved the highest validation accuracy/RMSE (values in Table 9).

We note that the results in Section 5 do not include standard deviations for formatting reasons, since most of the baselines were best results reported in previous papers without error bars. As Section 6 noted, the LSSL was actually quite stable in performance and not particularly sensitive to hyperparameters. We note that for every result in Section 5, the LSSL with error bars was at least one standard deviation above the baseline results.

F.2.1 Sequential and Permuted MNIST

The model architecture of LSSL(-f) was fixed to the small architecture with 200K parameters (Appendix B). Following , we fixed the learning rate scheduler to decay on plateau by with a factor of 0.20.2, and the number of epochs to 200. We searched hyperparameters over the product of the following learning rate values: {0.001,0.002,0.004,0.01}\{0.001,0.002,0.004,0.01\}, and dropout values: {0.1,0.2}\{0.1,0.2\}.

F.2.2 Sequential CIFAR

The model architecture of LSSL(-f) was fixed to the large architecture with 2M parameters (Appendix B). We searched over the product of the following learning rate values: {0.001,0.002,0.004,0.01,0.02}\{0.001,0.002,0.004,0.01,0.02\}, and dropout values: {0.2,0.3,0.4}\{0.2,0.3,0.4\}.

F.2.3 BIDMC Healthcare

The BIDMC tasks aim at predicting three vital signs of a patient, respiratory rate (RR), heart rate (HR), and oxygen saturation (SpO2), based on PPG and ECG signals. The clinical data is provided by the Beth Israel Deaconess Medical Center. The PPG and ECG signals were sampled at 125125Hz and have a sequence length of 40004000.

For this dataset, we fixed the small LSSL(-f) model (Appendix B). Following , we changed the scheduler to a multistep scheduler that decays on fixed epochs, and trained for 500 epochs.

For our methods, we searched over the product of the following learning rate values: {0.004,0.01,0.02}\{0.004,0.01,0.02\}, and dropout values: {0.1,0.2}\{0.1,0.2\}.

For CKConv, we searched over ω0∈\omega_{0}\in following the guidelines of Romero et al. (best value ω0=20\omega_{0}=20). Since we tuned the sensitive ω0\omega_{0}, we fixed the learning rate to 0.0010.001 and dropout to 0.10.1 which was the default used in .

The transformer model we used was a vanilla transformer with a hidden dimension of 256256, 88 attention heads, 44 layers, and a feedforward dimension of 10241024. We used a learning rate of 0.0010.001 and a dropout of . We tried a few variants, but no transformer model was effective at all.

F.2.4 CelebA

For these larger datasets, we reduced the size of the order NN and did not tie it to HH. These experiments were computationally heavy and we did not do any tuning (i.e., Table 9 are the only runs). The model size was picked to train in a reasonable amount of time, and the learning rate for the first attribute was picked based on general best hyperparameters for other datasets, and then reduced for subsequent experiments on the other attributes.

Baseline parameters. For ResNet-18, we used the standard implementation with a learning rate of 0.0010.001.

F.2.5 Speech Commands

For Speech Commands, we use the same dataset and preprocessing code from Kidger et al. , Romero et al. . We consider the two settings from Kidger et al. : SC-Raw uses very long time-series raw speech signals of 16000 timesteps each, while SC-MFCC uses standard MFCC features of 161 timesteps.

For our models trained over the raw data, we searched over the product of the following learning rate values: {0.002,0.004,0.01}\{0.002,0.004,0.01\}, and dropout values: {0.1,0.2}\{0.1,0.2\}. For our models trained over the MFCC features, we searched over the product of the following learning rate values: {0.0001,0.001,0.002,0.004,0.01}\{0.0001,0.001,0.002,0.004,0.01\}, and dropout values: {0.1,0.2,0.3,0.4}\{0.1,0.2,0.3,0.4\}.

Baseline parameters. To get more results for the strongest baselines on very long sequences in the literature, we ran the UniCORNN baseline on both Raw and MFCC variants, and the Neural Rough Differential Equations baseline on the Raw variant.

For UniCORNN trained over the raw data, we searched over multiple hyperparameters. Specifically, we searched over alpha: {0,10,20,30,40}\{0,10,20,30,40\}, Δt\Delta t values: {0.00001,0.0001,0.001,0.01}\{0.00001,0.0001,0.001,0.01\}, and learning rate values: {0.0001,0.0004,0.001,0.004}\{0.0001,0.0004,0.001,0.004\}. However, since the method was not able to generalize to the validation set for any hyperparameter combination, we used the authors’ reported hyperparameters for the Eigenworms dataset as it also contains very long sequences (≈18000\approx 18000). In particular, we used a learning rate of 0.020.02, hidden dimension of 256256, 33 layers with dt values [0.0000281,0.0343,0.0343][0.0000281,0.0343,0.0343], dropout of 0.10.1, and alpha of .

For UniCORNN trained over the MFCC features, we used the authors’ reported hyperparameters for the MNIST dataset (again due to similarly sized sequence lengths), and further tuned the learning rate over the values: {0.0001,0.001,0.005,0.01,0.02}\{0.0001,0.001,0.005,0.01,0.02\}, Δt\Delta t values: {0.01,0.1}\{0.01,0.1\}, and alpha values: {10,20,30}\{10,20,30\}.

The best model used a learning rate of 0.020.02, hidden dimension of 256256, 33 layers with dt values of 0.190.19, dropout of 0.10.1, and alpha of 30.6530.65.

For NRDE on SC-Raw, we used depth 22, step size 44, hidden dimension 3232, and 33 layers. Our results were better than unofficial numbers reported in correspondence with the authors, so we did not tune further.

F.2.6 Convergence Speed (Table 3)

The convergence table compared against logs directly from the corresponding baseline’s SoTA models , which were either released publicly or found in direct correspondence with the authors. To generate the wall clock numbers, we ran the baseline models on the same hardware as our models and extrapolated to the target epoch.

F.3 Hyperparameters

Best hyperparameters for all datasets are reported in Table 9.