# Mamba and state space models vs transformers: where they help

- URL: https://bodhamlabs.com/research/state-space-models
- Theme: Sequence models & real-time systems
- Area: STATE SPACE MODELS · MAMBA
- Status: EXPLORING — Research and design notes.
- Period: Mar–Oct 2026
- Updated: 2026-10-12
- Author: Prabhakar Chandra, Bodham Labs

## Question

When does a state space model's fixed-size memory beat a transformer's growing one: for an always-on agent, a fast live stream, or short texts on a phone?

## Summary

From an always-on agent design to a Mamba run that diverged to a shipped app that said no: what a fixed-size state buys, and what it costs.

## What we built

- A GPU Mamba (S6) context model, running in a container on 11 Mar 2026.
- Before that, a component we called an "SSM" that was in fact a GRU PPO actor-critic exported to OpenVINO. We ran a 3-config tournament: 2×256, 1×512 and 3×128.
- A data integrity audit of the model's inputs.
- A documented next design, "Mamba-4": a Micro-Jamba hybrid with 24–36M parameters planned. It is not built. Its status reads "PRE-DEVELOPMENT (Phase 0)".
- The test bed was live market data streams, in paper mode only, with no real money.

## Evidence

| What | Value | Where it was recorded |
| --- | --- | --- |
| Hidden state after 1,024 steps | about ±10¹⁵ | data integrity audit, Mar 2026 |
| GPU memory of the running S6 model | 396 MiB | container log, 11 Mar 2026 |
| Raw EMA input values (not normalised) | around 69,000 | data integrity audit, Mar 2026 |
| One "z-score" input | 86.74 | data integrity audit, Mar 2026 |
| How far it drowned out 14 other features | about 10¹³ | data integrity audit, Mar 2026 |
| Features that were always zero | 3 | data integrity audit, Mar 2026 |
| Earlier GRU hidden-state norm, n = 100 to 96,900 | constant at 1.3850 | model run log |

## How the work unfolded

- **Early 2026 — A recurrent model we called an SSM.** An early component labelled "SSM" was really a GRU actor-critic. Its hidden-state norm stayed at 1.3850 from step 100 to 96,900: the state was stuck, and the log showed it.
- **10 Mar 2026 — A hybrid design for an always-on agent.** A written trade-off for our RAMU agent: a state space model (Mamba or RWKV) runs the always-on loop, a transformer is called only for hard decisions, and hard facts go to external memory because an SSM's details fade.
- **10 Mar 2026 — A Mamba encoder with an actor-critic head.** A small PyTorch model: one Mamba block (d_model 128, d_state 64) feeding an actor-critic head. Code only; it was never trained, and we report no results from it.
- **11 Mar 2026 — The first GPU run, and why it diverged.** A Mamba (S6) model ran on live data streams in paper mode. Inputs were not normalised, and the hidden state reached about ±10¹⁵ within 1,024 steps.
- **Late Mar 2026 — "Mamba-4": a staged design.** Nine design phases for a 24–36M-parameter hybrid: a Micro-Jamba core, Hopfield-style recall, sleep-time consolidation, BitNet compression, an MoE overlay and safety gates. Status: pre-development.
- **12 Oct 2026 — A shipped app says no.** Our voice-memo app, Mementos (codename), considered SSMs to save memory and dropped them: a model's memory is mostly its size, and an SSM only saves memory on very long texts. Memos are short.

## Where it led

- The model ran, but the inputs were not normalised. EMA values were around 69,000. The hidden state grew to about ±10¹⁵ over 1,024 steps and drowned out 14 other features. Three features were always zero.
- Our earlier "SSM" was not an SSM at all. It was a GRU. Its hidden-state norm stayed at exactly 1.3850 from step 100 to step 96,900, which means the state was stuck. Reading the norm in the log is what showed us.
- Neither failure tells us yet whether the model idea works. Both were found in the data and the logs. The lesson: check input ranges and the hidden-state norm before judging the model.
- The next design adds shadow-mode gates. If the model underperforms in shadow mode for two weeks, we revisit the architecture and do not go live. It is a staged evaluation, not a result.
- On a phone the question changed. A model's memory is mostly its weights, and an SSM's flat state saves memory only on very long texts. Voice memos are short, so our app dropped SSMs. The rule we keep: SSMs for long streams, not for short texts.

## Open questions

- With normalised inputs, does a small Mamba model beat a simple baseline on the same stream?
- Is a hybrid (some attention layers, some SSM layers, like Jamba) worth the extra complexity at 24–36M parameters?
- How long a context does a fast stream actually need?

## Next step (not done yet)

Normalise every input, log the hidden-state norm from the first step, and re-run the S6 model against a simple baseline before building Mamba-4.

## Related notes

- [Where state space models help, and where they don't](https://bodhamlabs.com/notes/where-state-space-models-help)
- [Our Mamba model's hidden state reached 10¹⁵. Normalise your inputs.](https://bodhamlabs.com/notes/mamba-hidden-state-exploded)

## References

- [Mamba: Linear-Time Sequence Modeling with Selective State Spaces (Gu & Dao, 2023, arXiv:2312.00752)](https://arxiv.org/abs/2312.00752)
- [Jamba: A Hybrid Transformer-Mamba Language Model (AI21, 2024, arXiv:2403.19887)](https://arxiv.org/abs/2403.19887)
- [RWKV: Reinventing RNNs for the Transformer Era (Peng et al., 2023, arXiv:2305.13048)](https://arxiv.org/abs/2305.13048)
