Mamba Selective State Space (S6) Engine

Pretrained weights and linear-time sequence inference engine implementing the Mamba Selective Structured State Space Architecture (S6) (Gu & Dao, 2023).

Mathematical Formulation

Continuous state space representation: hβ€²(t)=Ah(t)+Bx(t),y(t)=Ch(t)+Dx(t)h'(t) = A h(t) + B x(t), \quad y(t) = C h(t) + D x(t)

Discretized via Zero-Order Hold (ZOH) with dynamic input-dependent step sizes $\Delta_t = \text{softplus}(\text{Linear}(x_t))$: AΛ‰t=exp⁑(Ξ”tA),BΛ‰t=(Ξ”tA)βˆ’1(exp⁑(Ξ”tA)βˆ’I)(Ξ”tBt)β‰ˆΞ”tBt\bar{A}_t = \exp(\Delta_t A), \quad \bar{B}_t = (\Delta_t A)^{-1}(\exp(\Delta_t A) - I)(\Delta_t B_t) \approx \Delta_t B_t ht=AΛ‰thtβˆ’1+BΛ‰txt,yt=Ctht+Dxth_t = \bar{A}_t h_{t-1} + \bar{B}_t x_t, \quad y_t = C_t h_t + D x_t

Computational Advantages

  • $O(L)$ Linear Time Complexity: Eliminates the $O(L^2)$ quadratic bottleneck of Transformer self-attention.
  • $O(1)$ Memory per Step: Zero KV-cache footprint during autoregressive text generation (evaluates at $\approx 0.076\text{ ms/token}$).
  • Selective Content-Based Filtering: Dynamically resets memory states on distractor noise while retaining crucial associative tokens across thousands of context steps.

Architecture Specifications

Hyperparameter Value Description
Model Dimension $d_{\text{model}}$ 64 Sequence feature embedding width
Inner Dimension $d_{\text{inner}}$ 128 Expansion factor $E = 2$
State Dimension $d_{\text{state}}$ 16 Latent continuous state channels
Convolution Width $d_{\text{conv}}$ 4 1D causal depthwise convolution
$\Delta$ Rank 4 Low-rank projection for dynamic time delta
Model Format model.safetensors Native zero-copy binary weights (131.5 KB)

Quickstart

import json
import numpy as np
from safetensors.numpy import load_file
from mamba_s6 import MambaS6Block

# Load weights and configuration
tensors = load_file("model.safetensors")
with open("config.json", "r") as f:
    config = json.load(f)

model = MambaS6Block(tensors, config)

# Sequence processing: (L=256, d_model=64)
L, d_model = 256, 64
u = np.random.randn(L, d_model).astype(np.float32)

y, h_final = model.forward_sequence(u)
print("Output sequence shape:", y.shape)
print("Final hidden state matrix:", h_final.shape)

Attribution & Links

Downloads last month
22
Safetensors
Model size
32.7k params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including At1uri/mamba-s6-selective-state-space-engine

Evaluation results

  • Associative Recall Accuracy on mamba-long-context-recall-benchmarks
    self-reported
    0.994