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 through an implicit state by simulating a linear continuous-time state-space representation in discrete-time
where controls the evolution of the system and 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 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 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 and timescale 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 , 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 can be theoretically sped up under certain computation models, even while learning the measure and timescale .
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 , 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 has an equivalent integral equation . This can be numerically solved by storing some approximation for , and keeping it fixed inside while iterating the equation. For example, Picard iteration is often used to prove the existence of solutions to ODEs by iterating the equation . In other words, it finds a sequence of functions that approximate the solution of the integral equation.
On the other hand, for a desired sequence of discrete times , approximations to can be found by iterating the equation . 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 , the GBT update is
Three important cases are: becomes the classic Euler method which is simply the first-order approximation ; is called the backward Euler method; and 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 and to be the matrices appearing in (3) for . Then the discrete-time state-space model is
In most models, the length of dependencies they can capture is roughly proportional to . Thus we also refer to the step size 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 . Moreover when viewed as a CNN, the timescale 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 , 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 . Then (4)+(5) explicitly yields
Then is simply the (non-circular) convolution , where
We make a note that the bottleneck of (i) the recurrence view is matrix-vector multiplication (MVM) by the discretized state matrix when simulating (4), and (ii) the convolutional view is computing the Krylov function (7). Throughout this section we assumed the LSSL parameters were fixed, which means that and can be cached for efficiency. However, learning the parameters and 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 is related to the input by a convolution with the impulse response of the system. Conversely, a convolutional filter that is a rational function of degree can be represented by a state-space model of size . Thus, an arbitrary convolutional filter 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 corresponds to a uniform measure (in the literature known as the LMU or HiPPO-LegT matrix). Then for a fixed , equation (1) is simply memorizing the input within sliding windows of 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 .
A (1-D) gated recurrence , where is the sigmoid function and is an arbitrary expression, can be viewed as the GBT() (i.e., backwards-Euler) discretization of a 1-D linear ODE .
Applying a discretization requires a positive step size . The simplest way to parameterize a positive function is via the exponential function applied to any expression . Substituting this into (3) with 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 approximating a function 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 with position-wise non-linear functions can approximate any non-linear ODE .
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 and , 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 could suffer from the vanishing gradients problem . We confirm empirically that LSSLs with random state matrices 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 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 . This operator mapping a function to a continuous representation of its past is denoted , 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 matrices were known to be operators.
To address this, we theoretically resolve the open question from , showing that for any measure To be precise, the measures that correspond to orthogonal polynomials . results in (1) with a structured matrix .
For an arbitrary measure , the optimal memorization operator has the form (1) for a low recurrence-width (LRW) state matrix .
For measures covering the classical orthogonal polynomials (OPs) (in particular, corresponding to Jacobi and Laguerre polynomials), there is even more structure.
For corresponding to the classical OPs, is -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 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 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 matrix is fixed to one of the HiPPO matrices prescribed by .
2 Theoretically Efficient Algorithms for the LSSL
Although and 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 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 up times.
In this section, we show that the same restriction of 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 takes time . Even if is extremely structured with linear computation, it requires operations and linear depth. The depth can be reduced with the squaring technique (batch multiply by ), but this then requires 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 .
Unless specified otherwise, the full LSSL refers to an LSSL with 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 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 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 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 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 and 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 adds only parameters and learning adds parameters, adding less than 1% parameter count compared to the base models with parameters.
Memory dynamics . We validate that vanilla LSSLs suffer from the modeling issues described in Section 4. We tested that LSSLs with random 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 is additionally helpful, which can be interpreted as learning the measure for memorization (Section 4.1).
Timescale . Section 3.2 showed that LSSL’s ability to learn 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 gets only accuracy. Additional results in Appendix F show that learning alone provides an orthogonal boost to learning , and visualizes the noticeable change in 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 , and , ) that are difficult to tune, the LSSL-fixed has only , 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 matrix and 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 instead of space when working on a 1D sequence of length – that essentially stems from using the latent state representation of dimension . 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 and discretization timescale cannot be trained due to both limitations in theoretical understanding of which matrices are effective, as well as computational limitations. Second, (1) is a 1-D to -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 copies of this 1-D to 1-D independently, creating an overall -dimensional sequence-to-sequence model. However, this exacerbates the computational issue, since the work is increased by a factor of .
This work resolves the expressivity issue with new theory. Compared to HiPPO and the LMU, LSSL allows training the 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 , 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 and 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 and comprise the 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 (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 , which is computed by applying the black-box MVM algorithm to the identity matrix .
which is computed in a parallelized manner by the squaring technique for exponentiation, i.e. batch multiply by .
At inference time, the model can be unrolled recurrently with . At training time, the convolutional filter (equation (7)) is computed with a matrix multiplication before convolving with the input .
Table 5 provides more detailed complexity of this version of the LSSL with fixed .
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 instead of space.
B.2 Initialization of A𝐴A
Note that the LSSL-f is the LSSL with a non-trainable (and ), so that 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 -D . This enables us to concatenate copies of this map (at the expense of computation, cf. Sections 4.2 and D). Even when is not trained as in the LSSL-f, these copies allow multiple timescales to be considered by setting differently for each copy.
In particular, we initialize log-uniformly in a range (i.e., is initialized within this range, such that is uniformly distributed). The maximum and minimum values were generally chosen to be a factor of 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 the number of channels in the model.
There are two drawbacks with the current definition of LSSL:
They are defined by running independent copies of a state-space model, which means the input features do not interact at all.
If the channel dimension is , then the LSSL is a map from dimension to , which means residuals cannot be applied.
These are both addressed by introducing a position-wise feedforward layer after the LSSL of shape . This simultaneously mixes the hidden features, and projects the output back to dimension 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 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 .
We primarily used two model sizes in our experiments, which were chosen simply to produce round numbers of parameters:
LSSL small ( parameters): layers, .
LSSL large ( parameters): layers, .
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
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 such that is Lipschitz in its second argument, then there is an open interval such that there exists a unique solution to the IVP in . Furthermore, the sequence of Picard iterates 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 .
These methods start by discretizing (10) into the form
Here we assume a sequence of discrete times is fixed. For convenience, let denote and let . 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), . 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), . 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 is treated as a fixed external input, which is constant from the point of view of this ODE in . Let 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 and respectively. Note that the case are specializations of the forward and backward Euler method, and the case is the classic “trapezoid rule” for numerical integration.
This derives the generalized bilinear transform (GBT) . The bilinear method is the case of special significance, and was numerically found to be better than the forward and backward Euler methods 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 that satisfies (14) on some interval for any initial condition, and that 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 that is independent of . (In other words, in (14), the function does not depend on the second argument.)
By directing applying the GBT discretization with , 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, and play the role of the gates .
C.2.2 Capturing gates through discretization
where is an arbitrary function that is Lipschitz in its second argument (e.g., it may depend on an external input ).
Then equation (15) is a discretization of the dynamics (14) with step sizes , i.e. where .
Apply the backwards Euler discretization (13) to equation (14) to get
Note that and , thus
Here we are denoting to be a discrete-time version of evaluatable at the given timesteps . ∎
Note that a potential external input function or sequence is captured through the abstraction . For example, a basic RNN could define .
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 be any function that satisfies the conditions of the Picard-Lindelöf Theorem (Theorem 3).
A (continuous-time) deep LSSL with order and approximates the non-linear dynamics (14).
Applying the definition of an LSSL (equations (1)+(2)) with these parameters results in a layer mapping where is defined implicitly through the ODE
This can be seen since the choice of implies and the choice of gives the above equation.
Consider the deep LSSL defined by alternating this LSSL with position-wise (in time) non-linear functions
(and ). Note that
Since satisfies the conditions of the Picard Theorem (i.e., is continuous in the first argument and Lipschitz in the second), so does the function where 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 , i.e. where .
By Lemma C.1, the first equation is a discretization of the continuous-time equation
uses the continuous-time version of . 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 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. ) to denote matrices and bold lowercase (e.g. ) to denote vectors. For example, equation (1) becomes . 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 and state by 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.
takes a function restricted up to time , , and maps it to a polynomial , that minimizes the approximation error .
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 coefficients (state) to input and coefficients (state) , following conventions in controls).
At every , the approximation quality is defined with respect to a measure supported on . We assume that the measures have densities . Note that this implies that integrating with respect to is the same as integrating with respect to .
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 .
We express the coefficients calculated by the HiPPO framework as:
To use this to derive , let . We see that
This allows to be written as
Although Gu et al. describe the framework in the full generality above and use as another degree of freedom, in their concrete derivations they always fix . Our general results also use this setting. For the remainder of this section, we assume the “full tilting” case . In particular, this means that in Eq. 18, we essentially substitute above with and divide each term by the inverse square root of our normalization constant, , 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 , this would be the same as saying that for some . Therefore, the incremental update operation would be bounded by the runtime of the matrix-vector operation .
D.1.3 Recurrence Width
An matrix has recurrence width if the polynomials satisfy for , 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 , there exists ordered sets of coefficients ,
Follows from the fact that for forms a basis and the observation of the degrees of the polynomials on the LHS. ∎
Let be the “right shift" matrix, i.e. for any matrix , has the columns of shifted to right by one. Note that corresponds to the “left shift" matrix.
Recall that has the coefficients of the OP polynomials as its rows. Then note that
The claim on the structure of then follows from the above expression. The claim on runtime of computing follows from essentially the same argument as for .
Finally, we make the following observation:
Let and be defined such that and . Then both and are both products of three matrices: two of which have recurrence width at most and the third is the inverse of a matrix that has recurrence width .
D.2.2 HiPPO for General Measures
From the definition of , we see that . Then
Additionally, given a measure on and OP family such that for all ,
If we let and , then applying the Leibniz rule to (23) we get:
Because and , they can be written as a linear combination of . Let us define , such that
where for , as defined in (25).
The matrix in Theorem 7 can be re-written as
In particular, both and both products of three matrices: two of which have recurrence width at most and the third is the inverse of a matrix that has recurrence width .
Eq. 26 follows from Theorem 7 and defining and to contain the and coefficients. ∎
D.2.3 Translated HiPPO (Sliding Windows)
The case when for all 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 for all t.
where .
to handle the term in Corollary D.5.
where for as defined in Corollary D.5 and .
To approximate , we note that when , . Then
We now show that the special case of Corollary D.6 for Legendre matches the results from .
Let where are the Legendre polynomials. Then
and .
where for as defined in Corollary D.5 and .
Then follows from Corollary D.6 and (29).
From the following recurrence relations [1, Chapter 12]:
Recalling that .
We note that from (28), .
Recalling , 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 where are the Legendre polynomials and let for all t. Then
and .
Let . By Theorem 7 and noting that , we get:
for , as defined in (25).
Using the same arguments as in the proof of Corollary D.7, follows from Corollary D.6 and (29). Also using similar arguments as the proof of Corollary D.7, we have
Including the normalization constant , we note that . Then we get
Recalling that the definition for 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 .
Every matrix contained strictly below the diagonal has rank at most .
A -quasiseparable matrix is called -quasiseparable.
We are interested in showing the matrices for a broad class of OPs in Corollary D.6 are -quasiseperable. We now state some properties of -quasiseparable matrices:
Let be -quasiseparable. Then:
Any submatrix contained strictly below or above the diagonal in has rank and its corresponding submatrix in also has rank . This implies that the corresponding submatrix in has rank . Therefore is -quasiseparable.
Let the . Thus any submatrix in has rank . Then is -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 with parameters will be denoted . The Jacobi polynomials are orthogonal with respect to measure . In particular, it is known from (eq. (4.3.3) from ) that
where 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 is proportional to :
Additionally, the Jacobi polynomials and can be written as sums of polynomials. In particular from (3.112) and (3.115),
Using (35) and (36) in (34) allows us to write as a sum of as follows:
We use these properties to write as a sum of :
Let and be as defined in (31).
Recall that . Then the claim follows from .
D.3.3 HiPPO for Jacobi Polynomials
Let be defined as in (31) and . Then
where is -quasiseperable.
where for as defined in Corollary D.5 and .
where are the diagonal matrices such that
(39) makes use of the fact that along with the definitions above.
Any submatrix of below the diagonal contains all s, and submatrix of above the diagonal contains all s. Then any submatrix above or below the diagonal has rank 1. Therefore is 1-quasiseparable. Since is 1-quasiseparable and are all diagonal matrices, part (iii) of Lemma D.9 implies that the matrices and are both 1-quasiseparable. Therefore part (i) of Lemma D.9 implies that is 2-quasiseparable.
From (4.1.1) and (4.1.4) in , it is known that
Then can be written where are the diagonal matrices such that
where for all . has rank 1, and are diagonal matrices. Hence by part (ii) and (iii) Lemma D.9, is 1-quasiseparable.
Since is 2-quasiseparable and is 1-quasiseparable, part (i) of Lemma D.9 implies that is 3-quasiseparable and the claim follows. ∎
D.3.4 HiPPO-LagT
The Laguerre polynomial of degree with parameters will be denoted . The Laguerre polynomials are orthogonal with respect to measure . In particular, from (5.1.1) in we know that
Let be our normalization constant. We note that the normalized Laguerre polynomials
Let be defined as in . Then
We now show that as defined in Theorem 9 is -quasiseperable.
Let be defined as in Theorem 9. Then is -quasiseperable.
Below the diagonal, all entries . Then any submatrix below the diagonal has rank 1. Similarly, above the diagonal, all entries . 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 ) 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 , 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 where 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 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 is actually the coefficient vector of as a polynomial in . (Note that means simply multiplying every entry in by a scalar variable .) This follows from expanding the power series . Thus we first compute , which is a rational function of degree at most 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 and multiplying by the numerator, both of which are operations that need 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 to make it have the same shape as . We consider the more general setting where and have multiple columns; this can be viewed as handling a “batch” problem with several queries for at the same time.
Let be a -quasiseparable matrix. Then
is a matrix of rational functions of degree at most , which can be computed in 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 into quadrants. Then by Definition 4, are both -quasiseparable and are rank . Therefore the strategy is to view as a low-rank perturbation of smaller quasiseparable matrices and reduce the problem to a simpler one.
Over a commutative ring , let and . Suppose and are invertible. Then is invertible and
Suppose we know the expansions of each of
Then the final result can be computed by inverting ( operations), multiplying by ( operations), and subtracting from ( operations). This is a total of operations. Note that when , this becomes ; we will use this in the analysis shortly.
To compute , it suffices to compute the following:
But to compute those, it suffices to compute the following matrices:
Since and have the same form as , this is two recursive calls of half the size. Notice that the size of the other input (dimensions of ) is growing, but when the initial input is , it never exceeds (since they increase by every time we go down a level). Earlier, we noticed that when , the reduction step has complexity for any recursive call. The recursion adds an additional multiplicative factor on top of this. ∎
Suppose that is semiseparable instead of quasiseparable, and suppose is a small constant. Then the cost of Lemma E.2 is operations.
This follows from the fact that in the recursion (45) and (46), the matrices do not have to be appended if they already exist in . For intuition, this happens in the case when is tridiagonal, so that have the structure , or the case when the off-diagonal part of is all (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 operations. The memory claim follows similarly, and the depth of the algorithm is 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 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 and for unstructured ; LSSL-fixed denotes not learning (see Appendix B for details); LSSL denotes the learning and for the structured class .
We include brief explanations of these complexities for the LSSL variants.
Parameters: in the matrices and in the matrix .
Training: to invert compute the matrix for all features. to compute the Krylov matrix . to multiply by and convolve with .
Memory: to store . to store the Krylov matrix. to store the inputs/outputs
Inference: to for MVM by .
Training: to convolve with .
Memory: to store the Krylov matrix (but cached, so no backprop). for inputs/outputs.
Inference: to for MVM by .
Parameters: for .
Memory: to store Krylov (and inputs/outputs).
Inference: to multiply by
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 matrices with diagonal and tridiagonal 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 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 -quasiseparable matrices (Corollary 4.1) to -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 denote the HiPPO-LegT transition matrix. Up to row/column scaling (i.e. left- and right- multiplication by diagonal and ), we can write
This can be written as where and
Finally, where and is the matrix with on the main diagonal and on the subdiagonal.
This can be written as where , , and 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 (Section 3.1, Appendix B), where is the state matrix discretized with step size 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 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 during backpropagation can actually be reduced to those same forward/backward difference primitives.
Finally, in the case when 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 is a function of and is a function of . In particular, we define 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 and .)
E.3.2 Gradients through the Forward/Backward Difference Primitives
In this section we will let or denote the computation of interest, denote a generic loss function, and denote gradients to (e.g., ).
First we have the standard . This corresponds to matrix-vector multiplication by . In other words, it can be computed by the primitive .
Similarly, in order to compute we require . We need the result for an invertible matrix [41, equation (59)]. Then
We can summarize this as follows. Let and (as a column vector). Then
The forward case is simpler. Let . Then and . Thus
E.3.3 Computing the Forward/Backward Difference for Tridiagonal Inverse Matrices
Theorem 11 uses the classes of matrices for diagonal and tridiagonal . 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 and tridiagonal solving .
We will explicitly rewrite the inverse of the matrix .
The core observation is to multiply by a choice selection of matrices to cancel out the term:
Now note that the matrix in the middle is tridiagonal. Hence we have reduced MVM by , 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 or parameters provides a consistent performance increase.
Finally, Fig. 4 plots the values at the beginning and end of training on the SpeechCommands-Raw dataset, confirming that training does noticeably change their values to better model the data. In particular, the 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 for the MNIST/CIFAR datasets and 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 , and the number of epochs to 200. We searched hyperparameters over the product of the following learning rate values: , and dropout values: .
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: , and dropout values: .
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 Hz and have a sequence length of .
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: , and dropout values: .
For CKConv, we searched over following the guidelines of Romero et al. (best value ). Since we tuned the sensitive , we fixed the learning rate to and dropout to which was the default used in .
The transformer model we used was a vanilla transformer with a hidden dimension of , attention heads, layers, and a feedforward dimension of . We used a learning rate of 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 and did not tie it to . 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 .
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: , and dropout values: . For our models trained over the MFCC features, we searched over the product of the following learning rate values: , and dropout values: .
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: , values: , and learning rate values: . 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 (). In particular, we used a learning rate of , hidden dimension of , layers with dt values , dropout of , 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: , values: , and alpha values: .
The best model used a learning rate of , hidden dimension of , layers with dt values of , dropout of , and alpha of .
For NRDE on SC-Raw, we used depth , step size , hidden dimension , and 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.