
mamba_block_mambapy
Language116 ops32.6K params
An attention-free sequence model built from blocks that wrap an input-dependent (selective) state space layer.
Language · 246 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
This model stacks two Mamba blocks, interleaved with normalization and residual connections.
About this model's family
Mamba is a sequence model built around a selective state space model (SSM) in place of attention. The paper starts from earlier subquadratic-time alternatives to the Transformer, which had not matched attention on modalities such as language, and traces the gap to their inability to reason based on content. Its remedy is to make the SSM parameters functions of the input, so the model can selectively propagate or forget information depending on the current token.
Input-dependent parameters rule out the efficient convolutions that earlier SSMs used, so the model is computed recurrently with a hardware-aware scan. The architecture is one block repeated, interleaved with normalization and residual connections. That block combines the H3 block, the basis of most earlier SSM architectures, with the MLP block of modern neural networks. Compared to the MLP block, it adds an SSM to the main branch. The activation inside it is SiLU / Swish.
The paper reports linear scaling in sequence length and 5× higher inference throughput than Transformers. On language modeling, it reports that its Mamba-3B model outperforms Transformers of the same size and matches Transformers twice its size.
Key idea. Mamba makes the parameters of a state space model depend on the input and builds these selective SSMs into a simplified architecture without attention or MLP blocks.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{gu2024mambalineartimesequencemodeling,
title={Mamba: Linear-Time Sequence Modeling with Selective State Spaces},
author={Albert Gu and Tri Dao},
year={2024},
eprint={2312.00752},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2312.00752},
}