## Enhanced Structured State Space Models via Grouped FIR Filtering and Attention Sink Mechanisms

Tian Meng 1 † Yang Tao 1 University of Manchester †

2 † Wuliang Yin 1 ∗ 2 Mettler Toledo Safeline ∗ Project Lead

Joint First Author

## Abstract

Structured State Space Models (SSMs) have emerged as compelling alternatives to Transformer architectures, offering linear-time complexity and superior performance in various sequence modeling tasks. Despite their advantages, SSMs like the original Mamba-2 face training difficulties due to the sensitivities introduced by the extended series of recurrent matrix multiplications. In this paper, we propose an advanced architecture that mitigates these challenges by decomposing A-multiplications into multiple groups and optimizing positional encoding through Grouped Finite Impulse Response (FIR) filtering. This new structure, denoted as Grouped FIR-enhanced SSM (GFSSM), employs semiseparable matrices for efficient computation. Furthermore, inspired by the 'attention sink' phenomenon identified in streaming language models, we incorporate a similar mechanism to enhance the stability and performance of our model over extended sequences. Our approach further bridges the gap between SSMs and Transformer architectures, offering a viable path forward for scalable and highperforming sequence modeling.

successor Mamba-2 [2] represent significant strides in this direction, implementing SSMs that utilize selective state updates to efficiently process long sequences. Despite these advancements, Mamba-2 still encounters certain obstacles, primarily due to the sensitivity of the recurrent weight multiplications, which can complicate training. These sensitivities arise from a long sequence of multiplications, making the model potentially unstable and difficult to optimize effectively.

## 1. Introduction

In recent years, the field of deep learning has been revolutionized by the introduction of the Transformer architecture and its attention mechanism [3-5, 11, 13], which have become the backbone of most state-of-the-art models across various domains, including natural language processing (NLP), computer vision, and speech recognition. However, these architectures are not without limitations. Specifically, the quadratic time and memory complexity of the self-attention mechanism pose significant challenges when handling long sequences. To address these issues, several subquadratic-time architectures have been proposed, among which Structured State Space Models (SSMs) [2, 6, 7, 10] have garnered considerable interest due to their linear-time complexity and promising performance. Mamba [6] and its

To alleviate these issues, we propose a novel architecture that reimagines the positional encoding mechanism within the SSM framework. Our innovation revolves around decomposing the recurrent multiplications into smaller, more manageable groups and employing Finite Impulse Response (FIR) filters [8, 12] to enhance positional encoding. This modification not only improves the sensitivity issues but also leveraging semiseparable matrices, which can be calculated with reduced complexity. Additionally, inspired by recent insights from the domain of streaming language models, we integrate an attention sinks mechanism [1, 14, 15] within our architecture. Previous studies have highlighted the importance of retaining initial tokens as 'sinks' that stabilize the attention mechanism over extended sequences. By incorporating a similar mechanism, our model benefits from improved stability and enhanced performance, particularly for tasks involving long-range dependencies.

We denote our new architecture as Grouped FIRenhanced Structured State Space Model (GFSSM). GFSSM represents a dual-pronged improvement over traditional SSMs: first, by mitigating the training difficulties associated with long recurrent multiplications, and second, by incorporating attention sinks to handle extended sequences more effectively. In summary, our contributions can be outlined as follows:

- 1. We introduce the Grouped FIR filter to optimize the positional encoding within SSMs, thereby addressing the sensitivity and training difficulties associated with long sequences of multiplications.
- 2. We incorporate an attention sink mechanism to en-

hance model stability and performance over extended sequences, inspired by insights from streaming language models.

This paper is structured as follows: Section 2 provides a detailed overview of related work, including foundational models and their limitations. Section 3 presents the mathematical formulation and architectural details of GFSSM. Section 4 outlines our experimental setup and results, followed by an in-depth analysis. Finally, Section 5 concludes the paper and discusses potential avenues for future work.

## 2. Related Work

## 2.1. Structured State Space Models (SSMs)

Structured State Space Models (SSMs) [2, 6, 7, 9, 10] have attracted attention for their ability to offer linear-time complexity while maintaining competitive performance. Among these, the Mamba architecture [6] represents a significant advancement. Mamba leverages selective state updates to efficiently handle long sequences, making it a viable alternative to Transformers. However, despite its linear complexity, Mamba's performance has been limited by the sensitivity and difficulty in training due to extended sequences of recurrent multiplications. Mamba-2 [2] improved upon its predecessor by introducing a more structured approach, leveraging the State Space Duality (SSD) framework. By restricting the SSM parameters further and employing structured decompositions of semiseparable matrices, Mamba-2 achieved enhanced computational efficiency and performance. Nevertheless, the core challenge of training sensitivity due to recurrent dynamics remained an open problem.

## 2.2. Finite Impulse Response (FIR) Filters

FIR filters [8, 12] have been widely used in signal processing for their stability and straightforward implementation. Recent works have explored their potential in the context of machine learning, particularly for optimizing convolutional neural networks (CNNs) [6]. These filters can be tuned to emphasize specific frequencies, making them useful for various signal processing tasks. In the context of SSMs, deploying FIR filters can help mitigate sensitivity issues by effectively smoothing positional encodings.

## 2.3. Attention Sinks

The concept of attention sinks, as explored by [1, 14, 15], addresses some unique challenges in deploying large language models (LLMs) for streaming applications. By retaining key-value (KV) states of initial tokens, attention sinks stabilize the attention mechanism, thereby enabling LLMs to generalize to sequences much longer than those encountered during training. This insight is particularly relevant for our work, as it offers a potential solution to im- prove stability and performance over extended sequences in SSMs.

## 3. Methodology

This section outlines the theoretical foundations and architectural innovations of the Grouped FIR-enhanced Structured State Space Model (GFSSM). We begin by revisiting the fundamental principles and equations that underpin our approach, followed by detailed explanations of the grouped FIR filtering and the integration of attention sinks. Finally, we discuss the integration of these components into the overall GFSSM architecture.

## 3.1. Fundamentals of State Space Duality (SSD)

In the Mamba-2 SSD framework, the forward pass is governed by the following equations:

$$h _ { t } & = A _ { t } h _ { t - 1 } + B _ { t } x _ { t } \\ y _ { t } & = C _ { t } ^ { \top } h _ { t },$$

where h t denotes the hidden state at time t , x t is the input, and y t represents the output. A t is a scalar times identity matrix, denoted as a t , which simplifies the recurrent computation. B t and C t are matrices that define the state space dynamics, which can vary over time. By definition, h 0 = B x 0 0 . By induction, the h t can be obtained as:

$$\text{le} \\ \text{i-} \\ \text{ge} \\ \text{ed} \\ \text{$=} 0 \\ \end{array} \quad & h _ { t } & = a _ { t } a _ { t - 1 } \cdots a _ { 1 } B _ { 0 } x _ { 0 } + a _ { t } a _ { t - 1 } \cdots a _ { 2 } B _ { 1 } x _ { 1 } + \cdots \\ \text{ge} \\ & \quad + a _ { t } a _ { t - 1 } B _ { t - 2 } x _ { t - 2 } + a _ { t } B _ { t - 1 } x _ { t - 1 } + B _ { t } x _ { t } \\ \text{ed} \\ & = \sum _ { s = 0 } ^ { t } a _ { t ; s } ^ { \times } B _ { s } x _ { s },$$

where a × t s : denotes the product of a terms from s + 1 to t . When multiplied by C t to produce y t and vectorized over t ∈ [ T ] , the matrix transformation form of SSD becomes:

$$y _ { t } & = \sum _ { s = 0 } ^ { t } a _ { t \colon s } ^ { \times } C _ { t } ^ { \top } B _ { s } x _ { s }, \\ y & = ( L \circ C ^ { \top } B ) x = M x,$$

where L is represented as L ji = a j · · · a i +1 :

$$\text{an} _ { - } \\ \text{re} _ { - } \text{ } L = \begin{bmatrix} 1 & & & \\ a _ { 1 } & 1 & & \\ a _ { 2 } a _ { 1 } & a _ { 2 } & 1 & \\ \vdots & \vdots & \ddots & \ddots \\ a _ { T - 1 } \cdots a _ { 1 } & a _ { T - 1 } \cdots a _ { 2 } & \cdots & a _ { T - 1 } & 1 \end{bmatrix}. \ ( 4 )$$

The potential limitation of the extended series of a i multiplications arises when dealing with long text sequences.

The matrix L ji can decay to 0 or explode, resulting in numerical instability. Furthermore, any intermediate poorly conditioned a i will have a prolonged adverse impact, propagating across subsequent tokens. For instance, if a i is 0 at an initial position, all following states will remain 0. This extended multiplication series also complicates training, as noted in Mamba-2: higher precision for the main model parameters may be necessary due to the sensitivity of SSDs to recurrent dynamics. Parameter storage in fp32 can improve stability by mitigating these recurrent sensitivities.

## 3.2. Grouped FIR Filtering

In GFSSM, we address the sensitivity and training difficulties inherent in SSMs by optimizing the computation of the hidden states and refining the positional encoding mechanism. The sensitivity in training SSMs arises primarily from the extended series of recurrent multiplications. To mitigate this issue, we decompose recurrent multiplications into smaller, more manageable groups and employ Finite Impulse Response (FIR) filters to enhance the positional encoding.

For simplicity, we illustrate the method using four groups with a 4th-order FIR filter. However, this can be easily generalized to any Q groups with an n -th order FIR filter. The new recurrent form is:

$$s _ { t } & = k _ { 0 } B _ { t } x _ { t } + k _ { 1 } B _ { t - 1 } x _ { t - 1 } \\ & + k _ { 2 } B _ { t - 2 } x _ { t - 2 } + k _ { 3 } B _ { t - 3 } x _ { t - 3 }$$

̸

$$\begin{cases} h _ { t } ^ { i } = A _ { t } h _ { t - 1 } ^ { i } + s _ { t }, \quad i = \bmod ( t, Q ) \\ h _ { t } ^ { i } = h _ { t - 1 } ^ { i }, \quad i \neq \bmod ( t, Q ) \end{cases}$$

$$y _ { t } = C _ { t } \sum _ { i = 0 } ^ { Q - 1 } h _ { t } ^ { i }$$

where s t is the filtered output, and k , k 0 1 , k 2 , k 3 are learnable filter coefficients.

The core idea of GFSSM is to split the long input sequence into Q groups, each with its corresponding hidden state. This way, the recurrent multiplications of a i are reduced to 1 /Q of their original length, thereby mitigating their potential to cause numerical instability. Finally, the output y t is computed by summing the contributions from all grouped states. One potential problem arises from splitting tokens into different groups: if tokens x i and x j belong to different groups, they will never be directly correlated. To address this issue, we introduce a computationally efficient solution by adding a FIR filter that processes the B x t t sequence. This enables tokens in different groups to be indirectly correlated, thereby preserving the overall coherence of the encoded sequence. To provide further clarity, we present the structure of matrix L for GFSSM, focusing on the first 13 elements, as shown in Figure 1. The ap-

Figure 1. The matrix L for GFSSM

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00244v1-figure-27039c68-9cff-4171-98dd-54509aa2d220.jpg)

plication of FIR filters facilitates smoother transitions and correlations between grouped states, ultimately rendering the model more robust and easier to train. By combining grouped FIR filtering and robust matrix computations, GFSSM offers a viable solution for the inherent challenges of traditional SSM architectures, providing improved performance and stability over extended sequences.

## 3.3. Integration of Attention Sink Mechanisms

Inspired by the attention sink phenomenon observed in streaming language models, we incorporate a similar mechanism within GFSSM to improve stability and performance over extended sequences. The attention sink mechanism ensures that the initial tokens in a sequence serve as stable reference points, effectively acting as 'sinks' that help maintain the model's focus and coherence over long dependencies. Additionally, it addresses the absence of initial states, thereby ensuring no information is lost from the initial a 0 to a Q .

In our GFSSM architecture, we initialize the state using learnable prompts that serve as stand-ins for the first few tokens. This initialization is critical for ensuring meaningful state updates from the beginning of the sequence. Formally, we define the state updates incorporating the attention sink mechanism as follows, beginning with the initialization using learnable prompts. For initialization, we start with:

$$\circ \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \cdots \colon \\ h _ { \text{init} } ^ { i } & = 0, \\ & y = ( L \circ C ^ { \top } B ) \left [ \begin{matrix} x _ { - Q } \\ x _ { - Q + 1 } \\ \vdots \\ x _ { - 1 } \\ x _ { 0 } \\ x _ { 1 } \\ \vdots \\ \end{matrix} \right ] + P \cdot 0 \quad \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \$$

where the initial sequence { x -Q , x -Q +1 , . . . , x -1 } consists of Q learnable prompts. For continued state updates, the state initialization incorporates the cached prior hidden state:

$$Y & = ( L \circ C ^ { \top } B ) \begin{bmatrix} x _ { - Q + 1 } \\ x _ { - Q + 2 } \\ \vdots \\ x _ { 0 } \\ x _ { 1 } \\ \vdots \end{bmatrix} + P \begin{bmatrix} h _ { - Q } \\ h _ { - Q } ^ { 2 } \\ h _ { - Q } ^ { 3 } \\ h _ { - Q } ^ { 4 } \\ c o u \\ \end{bmatrix} \quad ( 9 ) & \text{pos} \\ & \text{and} \\ & \text{cou} \\ & \text{the} \\ & \text{phe} \end{bmatrix}$$

![Image](https://ac.marcodsn.me/arxiv-markdown-images/2408.00244v1-figure-00cbd852-5339-4b90-a929-625d73cca667.jpg)

where the initial sequence { x -Q +1 , x -Q +2 , . . . , x 0 } is the preceding Q -1 input tokens, and h i -Q is the cached hidden state from the previous sequence.

This attention sink mechanism ensures that the initial tokens persist as stable anchors that maintain focus over the sequence's length, thus improving the robustness of our model. Combining grouped FIR filtering and the attention sink mechanism, our final GFSSM model effectively leverages semiseparable matrices within the broader SSD architecture, offering enhanced performance and stability over extended sequences.

## 3.4. Semiseparable Matrix Decomposition

A crucial component of our new structure is the decomposition of the recurrent update matrix into multiple semiseparable matrices. This decomposition enables efficient computation while maintaining the linear complexity of state updates. We denote the decomposed matrix as L , formulated as:

$$L = k _ { 0 } L _ { 0 } + k _ { 1 } L _ { 1 } + k _ { 2 } L _ { 2 } + k _ { 3 } L _ { 3 }, \quad ( 1 1 )$$

where each L i represents a semiseparable matrix that captures the contributions from different stages of the FIR filter. Semiseparable matrices are characterized by a structure that allows fast multiplications, like Mamba-2, significantly reducing computational overhead.

## 4. Conclusion and future work

In this paper, we introduced the Grouped FIR-enhanced Structured State Space Model (GFSSM) as an innovative extension to traditional SSM architectures. Our approach addresses critical training challenges posed by extended series of recurrent matrix multiplications, which often lead to instabilities and difficulties in optimization. By decomposing these multiplications into more manageable groups and incorporating Finite Impulse Response (FIR) filters, we could potentially improve the robustness and trainability of the system. Additionally, inspired by the 'attention sink' phenomenon observed in streaming language models, we

integrated a similar mechanism into GFSSM to enhance stability and performance over extended sequences.

While we have outlined the theoretical foundations and architectural details of GFSSM, empirical validations are essential to demonstrate the model's practical advantages. Therefore, future work will entail comprehensive experiments to evaluate the performance of GFSSM across various sequence modeling tasks, including but not limited to natural language processing, speech recognition, and genomics.

## References

- [1] Nicola Cancedda. Spectral Filters, Dark Signals, and Attention Sinks, 2024. arXiv:2402.09221 [cs]. 1, 2
- [2] Tri Dao and Albert Gu. Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality, 2024. arXiv:2405.21060 [cs]. 1, 2
- [3] Tri Dao, Dan Fu, Stefano Ermon, Atri Rudra, and Christopher R´ e. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness. Advances in Neural Information Processing Systems , 35:16344-16359, 2022. 1
- [4] Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 1 (Long and Short Papers) , pages 4171-4186, Minneapolis, Minnesota, 2019. Association for Computational Linguistics.
- [5] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale. 2020. 1
- [6] Albert Gu and Tri Dao. Mamba: Linear-Time Sequence Modeling with Selective State Spaces, 2024. arXiv:2312.00752 [cs]. 1, 2
- [7] Albert Gu, Karan Goel, and Christopher R´ e. Efficiently Modeling Long Sequences with Structured State Spaces, 2022. arXiv:2111.00396 [cs]. 1, 2
- [8] Tapio Saramaki. Finite Impulse Response Filter Design . 1993. Journal Abbreviation: Handbook for Digital Signal Processing Publication Title: Handbook for Digital Signal Processing. 1, 2
- [9] Jimmy T. H. Smith, Andrew Warrington, and Scott W. Linderman. Simplified State Space Layers for Sequence Modeling, 2023. arXiv:2208.04933 [cs]. 2
- [10] Yutao Sun, Li Dong, Shaohan Huang, Shuming Ma, Yuqing Xia, Jilong Xue, Jianyong Wang, and Furu Wei. Retentive Network: A Successor to Transformer for Large Language Models, 2023. arXiv:2307.08621 [cs]. 1, 2
- [11] Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timoth´ ee Lacroix, Baptiste Rozi` ere, Naman Goyal, Eric Hambro, Faisal Azhar, Aurelien Rodriguez, Armand Joulin, Edouard Grave, and Guillaume
- Lample. LLaMA: Open and Efficient Foundation Language Models, 2023. arXiv:2302.13971 [cs]. 1
- [12] Manish B. Trimale and Chilveri. A review: FIR filter implementation. In 2017 2nd IEEE International Conference on Recent Trends in Electronics, Information &amp; Communication Technology (RTEICT) , pages 137-141, 2017. 1, 2
- [13] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin. Attention is All you Need. In Advances in Neural Information Processing Systems . Curran Associates, Inc., 2017. 1
- [14] Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient Streaming Language Models with Attention Sinks, 2024. arXiv:2309.17453 [cs]. 1, 2
- [15] Zhongzhi Yu, Zheng Wang, Yonggan Fu, Huihong Shi, Khalid Shaikh, and Yingyan Celine Lin. Unveiling and Harnessing Hidden Attention Sinks: Enhancing Large Language Models without Training through Attention Calibration, 2024. arXiv:2406.15765 [cs]. 1, 2
Tian Meng Yang Tao Wuliang Yin
Enhanced Structured State Space Models via Grouped FIR Filtering and Attention Sink Mechanisms
Structured State Space Models (SSMs) have emerged as compelling alternatives
to Transformer architectures, offering linear-time complexity and superior
performance in various sequence modeling tasks. Despite their advantages, SSMs
like the original Mamba-2 face training difficulties due to the sensitivities
introduced by the extended series of recurrent matrix multiplications. In this
paper, we propose an advanced architecture that mitigates these challenges by
decomposing A-multiplications into multiple groups and optimizing positional
encoding through Grouped Finite Impulse Response (FIR) filtering. This new
structure, denoted as Grouped FIR-enhanced SSM (GFSSM), employs semiseparable
matrices for efficient computation. Furthermore, inspired by the "attention
sink" phenomenon identified in streaming language models, we incorporate a
similar mechanism to enhance the stability and performance of our model over
extended sequences. Our approach further bridges the gap between SSMs and
Transformer architectures, offering a viable path forward for scalable and
high-performing sequence modeling.