---
title: Locally Bi-Directional SSMs
url: https://www.emergentmind.com/topics/locally-bi-directional-state-space-models
type: topic
---

# Locally Bi-Directional SSMs

Locally Bi-Directional State-Space Models (LB-SSMs) are a class of neural architectures wherein state space models (SSMs) are endowed with local bi-directionality, enabling each token or location to aggregate contextual information from both forward and backward directions, but only within a restricted (local) window. Such models attain much of the empirical performance gain of bidirectional models, yet preserve the computational efficiency of unidirectional linear-time SSMs, circumventing the quadratic or double-pass cost associated with global bi-directional sweeps. This design is foundational to recent advances in vision, time series, remote sensing, and multivariate signal processing, offering linear complexity, improved receptive fields, and compatibility with modern GPU architectures [2506.15976][2509.03066][2501.15455][2410.05916].

## 1. Core Mathematical Structures of Locally Bi-Directional SSMs

LB-SSMs are generally formulated by augmenting a standard unidirectional selective SSM scan with a local backward recurrence, executed over small blocks (tiles) or patches. Let $x_t \in \mathbb{R}^E$ denote the $t$-th input, and $h_t^f$, $h_t^b$ the forward and backward hidden state vectors in $\mathbb{R}^N$, respectively.

### Selective SSM Parameters

At each position $t$, input-dependent parameters are computed:
\[
\Delta_t = \mathrm{softplus}(W_\Delta x_t), \quad
\bar{A}_t = \exp(\Delta_t A), \quad
\bar{B}_t = \Delta_t B(x_t), \quad
C_t = C(x_t)
\]
where $A \in \mathbb{R}^{E \times N}$ and $B(\cdot), C(\cdot)$ are linear maps [2506.15976].

### Forward and Local Backward Recurrences

Sequences are partitioned into blocks of size $M$ (e.g., $M = 4, 8, 16$), matching per-thread register tiles in parallel hardware. The forward scan is global, while the backward pass is restricted within each block:
\[
h^f_t = \bar{A}_t h^f_{t-1} + \bar{B}_t,\qquad   % Global (all $t$)
h^b_t =
\begin{cases}
0, & t \bmod M = 0\\
\bar{A}_t h^b_{t+1}, & \text{otherwise}
\end{cases}
\quad
h^b_t \leftarrow h^b_t+\bar{B}_t
\]
Fused output at each $t$:
\[
h_t = h_t^f + h_t^b - \bar{B}_t, \qquad y_t = C_t h_t + D x_t
\]

### Generalization

Extensions integrate bi-directionality through separate forward/backward SSM passes (with learned or tied parameters), local windowings, and gating mechanisms [2509.03066][2410.05916], in both temporal and spatial dimensions, plus multi-branch architectures for multi-channel or multi-sensor signals (e.g., ECG leads).

## 2. Efficient GPU Implementation and Linear Complexity

LB-SSM architectures are specifically tailored for modern GPU memory hierarchies. The backward scan is performed entirely in per-thread registers after the forward tile scan, requiring no extra global memory traffic or synchronization. This results in a minor arithmetic overhead ($\approx$27%) and a negligible wall-clock runtime increase ($\approx$2%), compared with single forward-scan SSMs, whereas a naïve full-sequence bi-directional approach would approximately double the time and bandwidth requirements [2506.15976].

The per-block pseudocode:
```c
// Forward scan (per block of length M)
for (i = 0; i < M; ++i)
    h_f[i] = A_bar[i] * h_f[i-1] + B_bar[i]
// Local backward scan
for (i = M-1; i >= 0; --i)
    h_b[i] = (i == M-1) ? 0 : A_bar[i] * h_b[i+1]
    h_b[i] += B_bar[i]
// Fusion and output
for (i = 0; i < M; ++i)
    y[i] = C[i] * (h_f[i] + h_b[i]) + D * x[i]
```

This register-only formulation ensures that both arithmetic cost and memory usage scale as $O(LN)$, with a small additive $O(MN)$ per-thread register footprint ($M \ll L$). This regime sharply contrasts with $O(L^2)$-scaling architectures such as transformers [2506.15976][2410.05916].

## 3. Architectural Variants and Application-Specific Instantiations

### Vision Backbones (LBVim)

LBVim alternates scan direction at the end of each LBMamba block: after every block, the sequence order is reversed. Stacking $U$ such blocks guarantees global receptive fields within $2U$ layers, with no global backward scan ever required. This strategy recovers information flow between all token pairs and avoids the throughput degradation typical of double-sweep bi-directional models [2506.15976].

### Multi-Lead and Multi-Branch Designs

In multi-sensor time series, each branch (e.g., ECG lead) uses independent bi-directional SSM blocks, followed by temporal and spatial fusion (e.g., SENet) modules. Long input sequences are tokenized into segments/patches, each processed locally in both directions. Outputs are gated, summed, and passed to higher-level fusion [2509.03066].

### Windowed and Locally Adaptive Scans

In remote sensing and imputation tasks, local windowing is combined with SSM scanning. CD-Lamba employs:
- Locally Adaptive State-Space Scan (LASS): partitions features spatially into dynamic blocks (via Gumbel-softmax selection).
- Cross-Temporal State-Space Scan (CTSS): interleaves pixels from co-located pre/post images into a bi-directional SSM scan.
- Window Shifting and Perception (WSP): shifts window assignment to ensure cross-boundary information flow [2501.15455].

In all settings, bi-directionality is realized via local or patchwise SSM reversals, preventing loss of context without global computation.

## 4. Comparative Computational and Empirical Properties

| Model         | Directionality | Complexity | Context Aggregation  | Efficiency    | Use Cases                                 |
|:------------- |:-------------:|:----------:|:--------------------|:-------------|:------------------------------------------|
| Mamba         | Unidirectional| $O(LN)$   | Past-only (forward) | High         | Vision, time series, WSI                  |
| Bi-Mamba      | Global Bi-dir | $O(2LN)$  | Full sequence       | Lower        | Vision, time series                       |
| LBMamba       | Local Bi-dir  | $O(1.27LN)$| Global (via alternation) | Highest plus broad context | Vision, WSI, real-time low-latency tasks |

Empirically, LBVim backbones built on LBMamba achieve $0.8$–$2.7$ percentage point (pp) higher accuracy on ImageNet-1K and ADE20K for the same throughput, with $+50$–$80$\% throughput compared to standard Vim backbones [2506.15976]. Similarly, S2M2ECG’s locally bi-directional SSMs deliver $1$–$3$ F1 point improvements in ECG tasks with $\approx 0.7$M parameters [2509.03066], and TIMBA imputation achieves consistent MAE/MSE reductions under high missingness in time-series data [2410.05916].

## 5. Methodological Insights and Domain-Specific Considerations

LB-SSMs exploit the inherent locality and sequentiality of specific domains. In vision, local backward scans within register tiles allow large-scale images (including gigapixel WSI) to be processed efficiently without global backward passes. In multi-channel ECG, patch-based bi-directional SSMs yield biologically relevant context aggregation (e.g., Q-T interval features) and robust generalization across databases [2509.03066]. For change detection, locality-preserving scans identify and separate foreground/background dynamics more effectively than conventional global scans [2501.15455]. In time series imputation, dual local S6 recurrences propagate gradients bidirectionally, mitigating vanishing/exploding phenomena and strengthening missing region reconstruction [2410.05916].

A plausible implication is that the degree and granularity of local bi-directionality (e.g., block size $M$, patch size $p$) should be tuned to match task-specific patterns—larger patches for long-range rhythm, smaller for localized morphology [2509.03066].

## 6. Current Limitations and Research Directions

While locally bi-directional SSMs restore reciprocal context with minimal overhead, some architectural tuning remains application-specific (e.g., block size, scan alternation frequency). For highly structured non-local phenomena, pure locality may be insufficient, requiring hierarchical or multi-scale scans (window shifting, cross-temporal fusions). Research is ongoing to generalize LBMamba block designs to video, multivariate anomaly detection, and cross-modal tasks; to learn adaptive segmentation for windowed processing rather than fixed-size tilings [2501.15455]. Another open area is extending $K$-way cross-temporal SSMs for multi-temporal inputs, and fully end-to-end differentiation of window and scan parameters.

## 7. Summary and Outlook

Locally bi-directional state-space models combine dynamic state transition modeling with efficient local-scope bi-directional aggregation. By restructuring forward SSM scans to embed lightweight, register-limited backward recurrences, these models achieve near-ideal efficiency-throughput trade-offs while effectively restoring bidirectional or even global receptive fields via alternation or cross-window fusion. Empirical results across vision, time series imputation, remote sensing, and multivariate biomedical signal processing consistently demonstrate improved accuracy, reduced latency, and strong generalization at parameter and time costs commensurate with or only marginally above unidirectional models. The LB-SSM paradigm thus defines a broad, efficient, and generalizable foundation for future state-space and hybrid sequence modeling architectures [2506.15976][2509.03066][2501.15455][2410.05916].

Source: https://www.emergentmind.com/topics/locally-bi-directional-state-space-models