SMR: State Memory Replay for Long Sequence Modeling (2024)

Abstract: Despite the promising performance of state space models (SSMs) in long sequence modeling, limitations still exist. Advanced SSMs like S5 and S6 (Mamba) in addressing non-uniform sampling, their recursive structures impede efficient SSM computation via convolution. To overcome compatibility limitations in parallel convolutional computation, this paper proposes a novel non-recursive non-uniform sample processing strategy. Theoretical analysis of SSMs through the lens of Event-Triggered Control (ETC) theory reveals the Non-Stable State (NSS) problem, where deviations from sampling point requirements lead to error transmission and accumulation, causing the divergence of the SSM’s hidden state. Our analysis further reveals that adjustments of input sequences with early memories can mitigate the NSS problem, achieving Sampling Step Adaptation (SSA). Building on this insight, we introduce a simple yet effective plug-and-play mechanism, State Memory Replay (SMR), which utilizes learnable memories to adjust the current state with multi-step information for generalization at sampling points different from those in the training data. This enables SSMs to stably model varying sampling points. Experiments on long-range modeling tasks in autoregressive language modeling and Long Range Arena demonstrate the general effectiveness of the SMR mechanism for a series of SSM models.

heading: 1 Introduction
text: Long sequence modeling has attracted extensive interest due to its broad prospects in natural language processing (Beltagy et al., 2020; Brown et al., 2020; Ouyang et al., 2022). The mainstream architectures for sequence modeling mainly focus on attention-based Transformers (Vaswani et al., 2017). However, the quadratic complexity of softmax attention brings a computational bottleneck
*Equal contributions. †Corresponding authors: Bowen Zhou and Ligang Wu.
(Choromanski et al., 2020; Wang et al., 2020; Beltagy et al., 2020), which makes attention-based architectures inefficient for handling long sequences. Although the introduction of linear attention (Wang et al., 2020) reduces the computational complexity, it cannot well approximate the performance of the vanilla Transformer. More importantly, purely attention-based architectures cannot capture longrange dependencies well. On the other hand, state space model (SSM)-based architectures (Gu et al., 2021a; Gupta et al., 2022) show superior performance on the Long Range Arena (LRA) (Tay et al., 2021) benchmark for long sequence modeling due to their linear computational complexity and excellent long-range dependency capturing ability. Existing SSM-based model architectures, such as S5 (Smith et al., 2023) and S6 (Gu and Dao, 2023), primarily rely on recursive structures to tackle the varying sampling step issue. S5 introduced learnable step sizes for each step to improve the Sampling Step Adaptation (SSA) capability of SSM. S6 (Mamba) introduced data-dependent parameter settings, which makes the state propagation of the SSM model more flexible. However, this restricts its inference computation to parallel scanning instead of the original efficient convolution mode, significantly hampering training efficiency and imposing a heavier inference burden when handling long inputs at once.
To address the mentioned issues, we aim to propose a method that goes beyond recursive constraints to improve SSA capability. This strategy seeks to enhance the SSM, making it more adaptable and flexible for various parallel convolution computation types, including advanced architectures like S4 (Gu et al., 2022), Mega (Ma et al., 2023), SPADE (Zuo et al., 2022), and more. Specifically, we leverage the Event-Triggered Control (ETC) Theory (Heemels et al., 2012; Tabuada, 2007) to provide the first demonstration of the NonStable State (NSS) problem in SSMs. We show
8102
that for a fixed-parameter SSM, varying sampling steps, deviating from the model’s sampling point requirements, triggers error propagation and accumulation, ultimately leading to the divergence of the hidden state. Our analysis further reveals that adjustments based on early memories of the input sequence can achieve SSA, effectively solving the NSS problem. Inspired by this finding, we propose a simple yet effective plug-and-play mechanism, State Memory Replay (SMR), it can significantly alleviate the NSS problem in SSMs by improving SSM the capability of SSA thus bring further sequence modeling capabilities. In particular, SMR can achieve better generalization ability at different sampling points, especially when dealing with the stochastic selected sampling points. We conduct experiments on autoregressive language modeling on Wikitext-103 (Merity et al., 2017) and long sequence modeling on LRA. The results show that the SMR mechanism can bring better performance to SSM-based model, on both autoregressive language modeling and long sequence modeling tasks. It can also further improve a series of competitive SSM-based models such as S5, SPADE, Mega, and S6, which verifies the generality and effectiveness of the proposed SMR mechanism. In summary, our main contributions are three folds:
• We are the first to identify the NSS issue in SSMs. We theoretically analyze and experimentally verify the issue from a novel perspective of ETC theory, demonstrating that inputs that do not satisfy the stability condition can lead to the divergence of the hidden states of SSMs and affect model performance.
• Based on our theoretical analysis and experimental results, we reveal that adjustment of the input sequence with early memory can achieve adaptive sampling adjustment capability to solve the NSS problem. Motivated by this, we propose the SMR mechanism.
• SMR is able to enhance the existing SSM series models to improve sampling point generalization and sequence modeling capabilities in some real-world tasks with varying design sampling points, including autoregressive language modeling and long sequence modeling, without affecting computational efficiency.

heading: 2 Preliminaries: State Space Models
text: The state space model is formally defined by eq.(1) and eq.(2):
ẋ(t) = Ax(t) +Bu(t), (1)
y(t) = Cx(t) +Du(t), (2)
where A ∈ Rn×n, B ∈ Rn×m, C ∈ Rm×n, D ∈ Rm×m, u(·) : R 7→ Rm denotes the input sequence with dimension m, and x(·) : R 7→ Rn is the latent state.
S4 Previous works (Gu et al., 2021b, 2022) formed the S4 model, which constructed a set of Structured State-Space Sequence Model (S4) parameters for each dimension of the input u to construct an Single-Input, Single-Output (SISO) system, i.e., for an input u : R → Rm, the same set of SSM parameters is broadcasted to each dimension u(p) : R → R. Specifically, they employed the bilinear method to perform discretization:
xk = Axk−1 +Bu (p) k , (3)
yk = Cxk, (4)
where A = (I−∆t/2 ·A)−1(I+∆t/2 ·A), B = (I −∆t/2 ·A)−1∆B ∈ Rn×1, C = C ∈ Rn×1. The matrix D is omitted here because it can be viewed as a residual connection. For each element u(p), p ∈ 1, 2, . . .m, t is a fixed discretization step, the same for each step. Then, the S4 became a parameterized model with trainable parameters A, B, C, and ∆t. By assuming x0 = 0, we can obtain:
yk = CA k−1
Bu1 + · · ·+CABuk−1 +CBuk, (5)
thus the output could be calculated efficiently by convolution y = K ∗ u, where
K ∈ RL := KL(A,B,C) := ( CA i B ) i∈[L−1]
= ( CB,CAB, . . . ,CA L−1 B ) ,
(6) is the convolution kernel and L is the sequence length. With their proposed Normal Plus LowRank (NPLR) parameterization, the S4 Convolution could be calculated in Õ(L+m) operations.
S5 Given the uniform time step employed by S4 for each time interval, it encounters difficulties when confronted with irregularly sampled data. To
overcome this limitation, S5 (Smith et al., 2023) introduced adaptive and learnable step sizes for each time step, enhanced its capability to effectively handle irregularly sampled data. Furthermore, S5 extended the S4-established Single-Input Single-Output (SISO) system to a more versatile Multiple-Input, Multiple-Output (MIMO) system. Specifically, by diagonalizing the SSM dynamics, they reparameterized matrix A as a diagonal matrix. Simultaneously, B ∈ Rn×m and C ∈ Rn×m are configured as matrices rather than the vectorized B and C settings used in S4. However, introducing variable step sizes for different time steps constrains the efficient convolutional computation of the SSM, forcing it to resort to a slower recurrentbased computation. Even with the diagonalized state transition matrix setting, the computational complexity can only be reduced to O(mL), thereby restricted the training efficiency of the SSM.
S6 (Mamba) The SSM parameters in S4 and S5 are fixed after training, making them dataindependent. This somewhat restricts the flexibility of both models. In contrast, S6, as known as Mamba (Gu and Dao, 2023), overcomes this limitation by introducing data-dependent S4 parameters. It achieves this by employing trainable linear layers to maps the input to each step’s B, C, and time step ∆t in S4. Additionally, S6 extended its parameters to be time-variant, transforming from a timeinvariant system (as in S4 and S5) to a time-variant one. This enhancement allows S6 to conduct more flexible sequence modeling. However, due to its time-dependent parameterization, S6 cannot efficiently perform SSM computations using convolution, maintaining a computational complexity of O(mL) resulting in slower training compared to S4.

heading: 3 SSA via State Memory Replay
text: In this section, we aim to reveal the problem of NSS in SSM caused by changes in sampling points through ETC theory (Heemels et al., 2012; Tabuada, 2007) (Section 3.1). We demonstrate that unstable hidden states lead to errors in SSM (Section 3.2). Furthermore, through the analysis based on ETC theory, we propose a simple but effective step-size adaptation mechanism, SMR, to enhance the model’s SSA capability thus alleviate the NSS problem in SSM with fixed step setting (Section 3.3). Experimental results indicate that the SMR mechanism can not only enhance the SSA capabil-
ity of SSM with fixed parameters but can also be extended to other SSM-based models, improving their SSA capabilities (Section 3.4).

heading: 3.1 Non-Stable-States Phenomenon
text: With the help of the ETC theory, we provide a simple example to elucidate the phenomenon of NSS. In this context, ETC theory ensures the system’s states remain stable by sampling the input control signal using triggered events. To maintain stability, the selection of sampling points, such as t1, t2, . . . , must meet specific criteria. Typically, a Lyapunov function LV is employed to assess stability (Heemels et al., 2012), outside the stable point, it is monotonically decreasing, and the minimum value of 0 is achieved at the stable point. Sampling points that result in a decreasing trend of LV are selected to ensure system stability. Specifically, consider the linear system described in eq.(1). Assuming the input control signal satisfies the linearity u(t) = Tx(t), where T ∈ Rm×n, then eq.(1) becomes:
ẋ(t) = Ax(t) +BTx(t). (7)
It can be easily verified that LV (t) = xTPx is a Lyapunov function, where symmetric positive definite matrix P ∈ Rn×n satisfies:
(A+BT )⊤P + P (A+BT ) = −M , (8)
to keep dLV (t)dt ≤ 0,∀x, where M ∈ Rn×n is also a symmetric positive definite matrix. Note that the actual sampled input u(ti) is sampled at the sampling points {ti}i∈N, we denote the sampling error:
e(t) = x(ti)−x(t), ∀t ∈ [ti, ti+1), i ∈ N, (9)
then eq.(7) could be reformulated as:
ẋ(t) = Ax(t) +BT (x(t) + e(t)). (10)
Taking the derivative of LV , we have: d
dt LV (t) = −x(t)TMx(t) + 2x(t)⊤PBTe(t).
(11) Therefore, set t0 = 0, we have the following triggering condition to ensure system stability:
ti+1 = inf { t ∈ R | t > ti ∧ κx(t)⊤Mx(t)
−2x(t)⊤PBTe(t−) ≤ 0 } ,
(12)
where κ ∈ (0, 1) is a optional constant, e(t−) represents the left-hand limit of error e at point t. In other words, new control signals are inputted just before the system becomes unstable. In this way, the sampled input control sequence obtained can ensure exponential stability of the system:
LV (t) ≤ LV (0)e(κ−1)ιt, (13)
where ι is an positive constant. More specifically, we provide an example of a 1-D input where the selected parameters are as follows:
A = [ 0 1 2 −3 ] ,M = [ 0.5 0.25 0.25 1.5 ] ,
P =
[ 1 0.25
0.25 1
] ,B = [ 0 1 ] ,T = [ 1 −4 ] ,
The selected time window is [0, 10], with a time grid width of 0.01. Subsequently, we conduct simulation experiments on the system, and the results is shown in the leftmost of Fig.1, the triggering moment is marked with a gray dashed line. Under the sampled input obtained from ETC, the system’s state eventually reaches the stabilization.
NSS: Instability Arising from sampling Grid variation. To further substantiate this conclusion, we present an illustrative example. Specifically, we introduce minor perturbations to the sampled data points, strictly constrained within the temporal grid width. The second plot in Fig.1 illustrates the comparison between the perturbed input and the original input, where the disturbance is almost imperceptible. When utilizing the unaltered sampled data points obtained prior to perturbation as input, the third figure in Fig.1 visually represents the system’s sustained stability. Nevertheless, upon the introduction of perturbated sampled data points into the system, as depicted in the rightmost in Fig.1, it becomes apparent that the system’s stability cannot be guaranteed, leading to an exponential growth in magnitude reaching 106. This means that when the actual sampling points do not align with
the desired sampling grid, it will result in highly unstable states. For SSM models formulated as in eq.(1) and eq.(2), encountering such an issue would lead to unavoidable numerical errors (Proposition 1).

heading: 3.2 Theoretical Understanding of NSS
text: Based on the aforementioned considerations and insights, our understanding of the NSS problem in SSM models is as follows: For SSM models with fixed parameters, the NSS problem may arise when the input does not satisfy stability conditions. Once the sampling error propagates over an extended period along with the hidden states, numerical errors inevitably occur, as affirmed by Proposition 1.
Proposition 1 Given bounded inputs satisfying ∥u∥ ≤ ζ, ∥C∥ ≤ c and ∥B∥ < b, and defining the observation error caused by sampling points as εi = u′i − ui, it can be concluded that when limt→∞ ∥xt∥ > bζ1−|λmax| , where λmax represents the largest eigenvalue of matrix A, the prediction error ∥y′t − yt∥ will accumulate over time steps. To ascertain the presence of an NSS issue within the SSM model, we devise a simple sequence modeling task. We sample 100 equidistant points from the function sin(5πt) to serve as input u. Then, we employ a single-layer S4 model for fitting, which underwent training for 2000 epochs, yielding the results displayed in the leftmost in Fig.2. Following
a methodology akin to the previous example, we apply perturbations smaller than the sampling window width to the sampled points {ti}i∈[99]. Subsequently, we conduct sampling on the perturbed points {t′i}i∈[99].
This process generates a set of perturbed inputs, denoted as u′, as illustrated in the second figure in Fig.2, where the sampling points underwent slight alterations. Subsequently, we employ the trained S4 model to predict u′, resulting in a numerical instability, as evident in the third figure in Fig.2.
We graphically represent the latent states before and after perturbation in the rightmost figure in Fig.2. In both instances, unstable states were observed, and notably, the total magnitude of the state increased following the perturbation. We extend this verification to a 5-layer S4 model and observe analogous findings. The outcomes are detailed in Appendix A.2.
Therefore, as our analysis reveals, SSMs indeed exhibit the issue of NSS, leading to larger errors when confronted with data exhibiting changes in sampling points. While S5, employing a strategy of assigning different step sizes at each step, can adapt to irregularly sampled data, the fixed SSM parameters during the inference phase still fail to ensure adaptive adjustments to various sampling data, thereby not completely avoiding NSS problems. On the other hand, S6 introduces data-dependent SSM parameterization, ensuring adaptive adjustments during the state transition process. However, this constraint limits S6 from efficiently computing in a convolutional form. In the subsequent analysis, we leverage ETC theory to provide insights and propose a strategy for adaptively adjusting inputs, aiming to address the NSS problem in SSM.

heading: 3.3 State Memory Replay Mechanism
text: We initiate our investigation by conducting a preliminary analysis rooted in ETC theory to derive insights for formulating adjust strategies. We examine an input perturbation denoted as ε at the sampling point, where u(t+tε) = u(t)+u̇(t)tε+o(tε). Assuming a tiny perturbation ε(t), we have u′(t) = u(t) + ε(t). Hence, the observed state z(t) can be expressed as z(t) = x(t) − e(t), and we also define the discrepancy between the observed state and the actual state as the error e(t) = x(t)− z(t).
Drawing inspiration from ETC theory, the Lyapunov function L is utilized as an indicator of observation error stability in the system. A smaller absolute value of e(t) indicates a reduced impact
of noise and uncertainty on system performance, as demonstrated in (Vallarella and Haimovich, 2019). Then, we have Theorem 1.
Theorem 1 For the input reply factor hτ (t) = h([t − τ, t]) : [t − τ, t] → R, the adjusted input uadj(t) = hτ (t)u(t), where z(t) is the state value of observer, considering the Lyapunov function Le(t) = e⊤(t)Pe(t), we have:
dLe(t) dt
≤ e⊤(t) ( PA+A⊤P ) e(t)
+ 2ℏ(t) (∫ t
0 ∥k(t− l)∥ |ε(l)| dl + ∥B∥ |ε(t)|
) ,
(14) where ℏ(t) = ∥hτ∥∞ ∥e(t)∥ and P is a positive definite symmetric matrix and k(·) : R → Rn is a fixed coefficient function determinded by the SSM parameters.
Remark 1. Theorem 1 suggests that imposing additional constraints on the input controller hτ can improve the convergence of the system. In particular, when hτ (·) ≡ 1 (which corresponding to S4), we have ∥hτ∥∞ = 1. The control factor hτ is required to incorporate information from the time interval [t−τ, t]. To accomplish this, a convolution Convτ with a kernel of length τ , denoted as Kτ , can be utilized. Moreover, an activation function, denoted as σ, can be employed to ensure that the condition ∥hτ∥∞ = ∥σ ◦ Convτ∥∞ < 1 is satisfied. This condition contributes to the enhancement of system stability.
To meet this need, considering the analysis in Remark 1, we propose the design of a convolutional learnable variables that incorporates multi input states, enabling adaptive learning and refinement.
Building upon Theorem 1, we understand the importance of having learnable variables that can incorporate multi input states to control how sam-
pling information behaves, allowing for automatic adjustments. To fulfill this requirement, considering the analysis in Remark 1, we propose the SMR mechanism aimed at addressing the NSS problem caused by variations in sampling points. The SMR mechanism incorporates learnable memories to enhance the SSM model with multiple memory steps, through a convolutional learnable variables that incorporates multi input steps, enabling adaptive learning and refinement, as depicted in Fig.3. Formally,our proposed SMR mechanism can be formulated as:
xk = Axk−1+
BukσSig(Kτ ∗ (u1, . . . , u1︸ ︷︷ ︸ τ , . . . , uT ))k, (15)
where τ represents the convolutional kernel length, and σSig(·) refers to the Sigmoid function. In particular, integrating SMR into S4 ensures the efficient computation of SSM through convolutional operations. Simultaneously, it introduces enhanced flexibility to the SSM, enabling it to adapt to diverse sampling intervals and changing sample points. To validate the efficacy of SMR in mitigating NSS issues in SSMs, we conduct training and testing by incorporating SMR into the 1-layer S4 model, following the previously mentioned experimental configurations. The results are presented in Fig.4. The model’s fitting results on u′ is displayed in the left of Fig.4, demonstrating the successful mitigation of unstable numerical outputs and a substantial reduction in prediction errors. The results illustrate in the second figure of Fig.4 clearly indicate that the latent states of S4+SMR have achieved stability, characterized by a significantly reduced total volume of the absolute state values, shrinking from 2 × 102 as shown in Fig.2 to 7.98. This implies that the integration of SMR significantly addresses the NSS issues in S4. Furthermore, experiments conducted on a 5-layer S4+SMR architecture also showed alleviation of NSS issues and improved predictive accuracy on perturbed data, the detailed results are presented in Appendix A.2. By incorporating the SMR (as its code shown in the code in List 1) into the SSMs at the positions indicated in Fig. 5, it is easily to integrate the SMR into a variety of SSMs.

heading: 3.4 Empirical Validation of SMR for SSA
text: To further investigate the impact of the SMR mechanism on enhancing the SSM model’s SSA capability, we utilize a Pendulum dataset (Schirmer et al.,
2022; Smith et al., 2023) characterized by irregularly sampled points and varying sampling intervals, to construct a regression task. The dataset comprises sequences of pendulum images with a length of L = 50 as input. Each image, sized 24× 24, is sampled at non-uniform time intervals ranging from T = 0 to T = 100. Notably, the sampling points for each data instance exhibit variability. Some images in the sequence are intentionally corrupted by random noise, introducing "occlusion" and resulting in more irregular sampling trajectories. The prediction target ytar ∈ R50×2 is the sine and cosine values corresponding to the position of the pendulum in each image of the input sequence u ∈ R50×576. Examples of this dataset can be found in Appendix A.3.
To prevent model overfitting at each time point due to an excessive amount of constructed training data, ensuring that only models with strong generalization capabilities for changing sample points can effectively handle the task, we opt for a more challenging setup compared to the setting in (Schirmer et al., 2022) with 2000 training data and 1000 testing data points. Specifically, we allocate 500 training data sequences and 200 testing data sequences to make the task more challenging. In this task, we conduct comparative experiments with S4, both with and without the SMR mechanism. Additionally, to explore the generalization of our SMR mechanism to a broader range of SSM-based models, we include the more flexible SSM models, S5 and S6, in the comparison. Furthermore,
we select two models that combine Attention with convolution-based SSM, Mega (Ma et al., 2023) and SPADE (Zuo et al., 2022), known for their competitive language modeling and long sequence modeling capabilities. We integrate SMR before Mega’s EMA operation and before SPADE’s S4 module to investigate the impact of SMR on various structures of SSMs.
For the given model M, we choose the Mean Squared Error (MSE) computed on the test set V , i.e., 1|V| ∑ {u,ytar}∈V (M(u)− ytar)2, as the evaluation criterion. We report the best result obtained throughout 100 training epochs in Tab.1. The integration of SMR brings about a significant improvement in S4’s SSA capability. Notably, this enhancement is not exclusive to S4, even S5 shows a considerable performance boost upon incorporating SMR. To be more specific, the test MSE decreases by 8.31 for S5, indicating that SMR significantly improves S5’s capability to handle variations in sampling points. Additionally, S6, SPADE, and Mega all demonstrate a decrease in Test MSE after integrating SMR. This suggests that our proposed SMR not only assists convolution-based SSMs in enhancing its SSA capability but also generalizes to recurrence-based SSMs, offering widespread improvements.

heading: 4 Experiments
text: As stated previously, the integration of SMR further enhances SSM’s SSA capability, thereby providing increased flexibility in sequence modeling capabilities. To further assess the improvement in sequential modeling capacity brought about by SMR for SSM-based models, we have chosen two more practical sequence modeling tasks: autoregressive lan-
guage modeling and long-term dependency modeling. Our experimental setup follows that outlined in Section 3.4. For S4 (Gu et al., 2022), S5 (Smith et al., 2023), S6 (Gu and Dao, 2023), SPADE (Zuo et al., 2022) and Mega (Ma et al., 2023), we conducted ablation experiments with and without SMR inclusion to evaluate the generalizability benefits that the SMR mechanism confers upon SSM-based models in these sequence modeling tasks. To better illustrate the significance of the benefits brought by SMR, we introduced the comparative results on the respective tasks the Vanilla Transformer (Vaswani et al., 2017) and the state-of-the-art (on WikiText103) Transformer-based model, Transformer-LS (LS) (Zhu et al., 2021). All experiments were con-
Mode Model Text ListOps Retrieval Image Pathfinder AVG - Transformer 61.95 38.37 80.69 65.26 40.57 57.37 - LS 66.62 40.30 81.68 69.98 47.60 61.24
Convolution S4 86.47/89.09 57.06/59.01 86.74/89.28 87.20/88.97 85.99/89.01 80.69/83.07
Mega 89.97/90.36 57.67/59.45 90.17/90.64 86.82/88.21 93.40/93.78 83.61/84.49 SPADE 86.29/87.06 58.75/59.52 88.62/89.01 88.05/89.29 92.77/93.34 82.90/83.64
Recurrence S5 84.20/87.08 58.25/59.08 87.99/89.37 87.51/89.31 87.42/88.05 81.07/82.58S6 83.52/84.14 55.62/56.15 83.28/83.66 82.96/83.23 85.54/85.80 78.18/78.60
ducted on four Tesla A800 GPUs.

heading: 4.1 Autoregressive language modeling
text: To evaluate the ability of autoregressive language modeling, we conducted experiments on the WikiText-103 dataset (Merity et al., 2017). This dataset comprises 103 million word-level tokens extracted from Wikipedia articles. In accordance with (Qin et al., 2023), all models were trained on the WikiText-103 dataset for 50, 000 steps, using a learning rate of 5e − 4. The sequence length is set to 512, and weight decay is set to 0.1 for all models. Consistent with the configuration detailed in (Chen, 2021), all models were uniformly set up with six layers and a hidden dimension of 512. The performance of autoregressive language modeling is assessed by reporting perplexity (PPL) scores on both the validation and test sets. For more detailed information regarding the experiments, please refer to Appendix A.3.
Tab.2 showcases consistent improvements in both validation and test perplexity (PPL) for all SSM-based models subjected to the experiments after incorporating the SMR mechanism. While S4, due to its fixed parameters and constant time-step settings, faces limitations in language tasks, integrating SMR yields a significant reduction of 2.84 and 1.86 in validation and test PPL, respectively.
Notably, SMR incorporation in SPADE leads to a further 0.56 decrease in test PPL, even surpassing the performance of Transformer-LS. These findings solidify that the SMR mechanism enhances the flexibility of SSM models, ultimately contributing to advancements in the autoregressive language modeling capabilities of SSM-based architectures.

heading: 4.2 Long-range dependency modeling
text: To further assess the impact of SMR on long sequence modeling, we conducted experiments on five Long Range Arena (LRA) benchmark tasks: ListOps (Nangia and Bowman, 2018), Byte-level Text Classification (Maas et al., 2011), Byte-level Document Retrieval (Radev et al., 2013), Sequence CIFAR-10 (Krizhevsky and Hinton, 2009), and Pathfinder (Linsley et al., 2018). All models used consistent block and hidden dimension settings for each task. Detailed configurations in Appendix A.4. Results in Tab.3 demonstrate that SMR integration consistently improves the performance of various SSM-based models. Notably, SMR achieves an average performance gain of 2.38 and 1.51 on tasks S4 and S5, respectively. Furthermore, SMR contributes to performance improvements in models S6, Mega, and SPADE. These findings suggest that SMR universally enhances the long sequence modeling capabilities of SSM-based models.

heading: 4.3 The Impact of SMR on Training Speed
text: To propose a strategy that improves the flexibility of SSM without impacting their training efficiency, we investigated whether integrating the SMR mechanism could enhance sequence modeling capabilities while maintaining training speed. Therefore, we conducted experiments on the Wikitext-103 dataset, comparing the relative training speed ratios of various models with and without the SMR mechanism. Due to the fact that our implementation of S4 and S5 were solely based on torch without utilizing the acceleration provided by related CUDA extension, we included a version of S6 implemented purely with torch as a baseline (1.0× speed) for a more direct speed comparison between models. Experimental results, presented in Tab.4, demonstrate that SMR incorporation does not significantly decrease SSM training speed and preserves the relative speed relationships among different SSM-based models. This suggests SMR serves as an effective way to enhance the sequence modeling capabilities of SSM without compromising its training efficiency.

heading: 5 Conclusion
text: In this paper, we investigated the NSS issue in SSMs for long sequence modeling, we found that when input data deviates from the model’s sampling requirements, it leads to error accumulation and hidden state divergence. Our analysis further revealed that early memory adjustments in the input sequence can achieve adaptive sampling, effectively solving the NSS problem. Inspired by this, we proposed a simple yet efficient plug-and-play mechanism, SMR. Theoretical analysis and experiments demonstrated that SMR effectively alleviates NSS, enhancing the generalization ability of SSMs to diverse sampling points and leading to superior
1https://github.com/alxndrTL/mamba.py.git
sequence modeling performance. We evaluated SMR on various SSM-based models, including the convolution-based and recurrence-based SSMs, applying it to both autoregressive language modeling (on Wikitext-103) and the LRA benchmark. The results demonstrate that SMR significantly improves the performance of SSM-based models on these tasks, solidifying its effectiveness and broad applicability.

heading: 6 Limitations
text: This study investigates the NSS issue of SSMs for long sequence modeling from a novel theoretical perspective of ETC theory. We first conduct preliminary experimental analysis and theoretical verification to validate the existence of NSS. Inspired by the analysis, we design a simple yet effective SMR mechanism and verify its effectiveness on datasets with different sampling resolutions. Furthermore, experiments demonstrate significant improvements on convolution-based SSMs S4, Mega and SPADE, as well as recurrence-based SSMs S5 and S6 on benchmarks such as wikitext and LRA.
However, the current study is preliminary. In the future, we can extend this technology to interactive learning frameworks (Qi et al., 2024a), explore continual SSM frameworks (Qi et al., 2024b), and design more robust and secure models (Qi et al., 2024d; Gao et al., 2023; Qi et al., 2024c), applying them to scenarios such as knowledge discovery (Qi et al., 2023).
In conclusion, our research points out the NSS issue in SSMs and demonstrates that incorporating this factor into new long sequence model architectures is a promising direction that requires extensive exploration. We believe that these new findings can better promote the optimization and upgrading of SSM-based architectures.

heading: 7 Ethics Statement
text: The purpose of this paper is technical research, and the tasks, models, and datasets involved do not raise any ethical or moral concerns.

heading: 8 acknowledgement
text: This work was supported in part by the National Science and Technology Major Project (No. 20232D0121403). We extend our gratitude to the anonymous reviewers for their insightful feedback, which has greatly contributed to the improvement of this paper.

heading: A Appendix
text: A.1 Proofs Proof of Proposition 1 Denote the sampled u′t = ut + εt, where εt is the sampling error caused by variation in the sampling points. Consider the propagation of the error in the output values {yk}Lk=1:
  y′1 y′2 ... y′L   =   CB 0 · · · 0 CAB CB · · · 0 ... ... . . . ... CA T−1 B CA T−2 B · · · CB     u1 + ε1 u2 + ε2 ... uT + εt   , (16)
then
∥y′t − yt∥ = ∥∥∥CAt−1Bε1 +CAt−2Bε2 + · · ·+CBεt ∥∥∥
≤ ∥∥C ∥∥ ∥∥∥At−1 ∥∥∥ ∥∥B ∥∥ |ε1|+ ∥∥C ∥∥ ∥∥∥At−2 ∥∥∥ ∥∥B ∥∥ |ε2|+ · · ·+ ∥∥C ∥∥∥∥B ∥∥ |εt|
≤ |λmax|t−1 cbε1 + |λmax|t−2 cbε2 + · · ·+ cbεt.
(17)
Note that if λmax ≥ 1, limt→∞ ∥y′t − yt∥ becomes unbounded. If |λmax| < 1, then we have
∥xt∥ = ∥∥∥AL−1Bu1 +AL−2Bu2 + · · ·+But ∥∥∥
≤ ∥∥∥AL−1 ∥∥∥ ∥∥B ∥∥ |u1|+ ∥∥∥AL−2 ∥∥∥ ∥∥B ∥∥ |u2|+ · · ·+ ∥∥B ∥∥ |ut|
≤ |λmax|L−1 bζ + |λmax|L−2 bζ + · · ·+ bζ,
(18)
thus
lim t→∞ ∥xt∥ ≤ lim t→∞
( |λmax|L−1 bζ + |λmax|L−2 bζ + · · ·+ bζ ) =
bζ
1− |λmax| < lim t→∞ ∥xt∥, (19)
which contradicts the assumption, therefore there must be |λmax| >= 1, which also implies that limt→∞ ∥y′t − yt∥ is unbounded.
Remark Note that imposing the constraint |λmax| < 1 on the state space model will cause the initial input ut0 to tend to zero as it propagates (A
t−t0But0 −→t−t0→∞ 0). This causes all previous states to rapidly decay to 0 during the propagation, thus severely limits the long-term memory capacity of the model.
Proof of Theorem1 Taking into account the error propagation in latent states of the SSM model, the grid deviation error emerges from signal misalignment and can be considered as an additional disturbance term. Assuming that the actual sampled value, denoted as u′, satisfies the relationship u′t = ut+ εt, where εt represents the error term, we can have
  x1 x2 ...
xT
  =   B 0 · · · 0 AB B · · · 0 ... ... . . . ...
A T−1 B A T−2 B · · · B
    u1 + ε1 u2 + ε2
... uT + εt
  , (20)
observe that xt = A t−1 B(u1 + ε1) +A t−2 B(u2 + ε2) + · · ·+B(ut + εt)
= A t−1 Bu1 +A t−2 Bu2 + · · ·+But + L(ε1, ε2, . . . , εt), (21)
where L(ε1, ε2, . . . , εt) = A t−1 Bε1+A t−2
Bε2+ · · ·+Bεt. Consider its continuous form and drawing upon the controller concept in ETC theory, we consider the following state propagation:
ẋ(t) = A ( x(t) + ∫ t
0 k(t− l)ε(l)dl
) +Bu(t), (22)
where k is a coefficient matrix that varies over time, and has the same shape as B. Owing to the accumulation of errors in the time domain, we introduce a modifiable factor denoted as h([t− τ, t]) with backtracking capability to regulate the input. Specifically, the controlled input is defined as uadj(t) = h([l − τ, l])u(t). then we have
ẋ(t) = A ( x(t) + ∫ t
0 k(t− l)h([l − τ, l])ε(l)dl
) +Bh([t− τ, t])u(t), (23)
then hτ (t) has the ability to adjust the errors with coefficients carrying temporal phases. Taking into account the following observer used for sampling:
ż(t) = Az(t) +Bh([t− τ, t])(u(t) + ε(t)), (24)
denote e(t) = x(t)− z(t), we have
ė(t) = Ae(t) +A
∫ t
0 k(t− l)h([l − τ, l])ε(l)dl −Bh([t− τ, t])ε(t). (25)
Consider the Lyapunov function Le(t) = e⊤(t)Pe(t), where P is a positive definite symmetric matrix, we can obtain
dLe(t) dt = 2e⊤(t)P ė(t)
= 2e⊤(t)P ( Ae(t) +A ∫ t
0 k(t− l)h([l − τ, l])ε(l)dl −Bh([t− τ, t])ε(t)
)
= e⊤(t) ( PA+A⊤P ) e(t) + Λ(t),
(26)
where
Λ(t) = 2e⊤(t)A ∫ t
0 k(t− l)h([l − τ, l])ε(l)dl − e⊤(t)Bh([t− τ, t])ε(t)
= 2 ∥e(t)∥ ∥A∥ ∫ t
0 ∥k(t− l)∥ |h([l − τ, l])| |ε(l)| dl + ∥e(t)∥ ∥B∥ |h([t− τ, t])| |ε(t)|
≤ 2 ∥hτ∥ ∥e(t)∥ (∫ t
0 ∥k(t− l)∥ |ε(l)| dl + ∥B∥ |ε(t)|
) .
(27)
Hence, selecting a value of |h([t− τ, t])| < 1 strengthens the stability of the system, while h([t−τ, t]) ≡ 1 corresponds to the case without a controller. Additionally, choosing a larger τ value can further enhance the control performance.
A.2 NSS in 5-layers S4
Due to space constraints, we present the analysis of the deep S4 model here. Specifically, we conducted an experiment on a 5-layer S4 model, extending from the experiment described in Section 2.3. We plotted the results of the hidden states in the first layer and observed the presence of the NSS issue in the 5-layer S4 model, as depicted in Fig.6(b). Notably, the S4 model without SMR exhibited a significant NSS phenomenon. In contrast, the S4 model incorporated with SMR demonstrated highly stable hidden states, as illustrated in Fig.6(d). The sum of absolute values of the states at each time step decreased from 102 to 101, and the output error under perturbation was also reduced (Fig.6).
A.3 Example of Pendulum Dataset
We present the input examples of the pendulum dataset used in Section 3.4 in Fig.7. The sampling intervals are not constant but variable, and the introduction of random noise in the image sequence makes the actual sampling intervals even more ran-
dom. All models are uniformly adjusted to 4 blocks with a hidden dimension of 64, and optimized using the AdamW optimizer with a learning rate of 1e− 4.
A.4 Experiment Details Here, we provide specific configurations for the experiments mentioned in Section 4. The experimental settings for autoregressive language modeling are detailed in Tab.5, while the parameter configurations for various tasks on the LRA are presented in Tab.6.

heading: Future Work
text: In the future, we can extend this technology to interactive learning frameworks (Qi et al. , 2024a), explore continual SSM frameworks (Qi et al. , 2024b), and design more robust and secure models (Qi et al. , 2024d; Gao et al. , 2023; Qi et al. , 2024c), applying them to scenarios such as knowledge discovery (Qi et al. , 2023)