How rishikksh20/mamba3-pytorch works
This repository is a readable PyTorch reference implementation of Mamba-3, supporting both sequence processing and autoregressive decoding, plus a stacked language model. The main workflow sends input through Mamba3 projections and an SSM scan to produce output; the scan implements either SISO or MIMO state updates, with rotary and trapezoidal features documented in the README. Decoding uses a separate single-token step and persistent inference state. The graph also preserves the documented residual-block and language-model layers. Internal links are limited to relationships stated in the README or visible in the excerpt; unsampled implementation details are not inferred.
Main entry points: mamba3.py Language model
Components 22
SSM Core
- Mamba3 mixer
mamba3.py - Input projection
mamba3.py - B/C RMSNorm
mamba3.py - Rotary embedding
mamba3.py - SSM scan
mamba3.py - SISO scan
mamba3.py - MIMO scan
mamba3.py - Mixer output
mamba3.py
Decode State
- Inference cache
mamba3.py - Decode state
mamba3.py - Single-token step
mamba3.py
Language Model
- Residual block
mamba3.py - Feed-forward layer
mamba3.py - Language model
mamba3.py - Model config
mamba3.py - Token embedding
mamba3.py - LM head
mamba3.py - Parameter counter
mamba3.py
Other components
- Model caller
- Sequence input
- Decode caller
- Token logits
Connections 22
- Model caller → Sequence input: supplies
README.md - Sequence input → Mamba3 mixer: passes to
README.md - Mamba3 mixer → Input projection: projects
README.md - Input projection → B/C RMSNorm: normalizes B/C
README.md - Input projection → Rotary embedding: rotates B/C
README.md - Input projection → SSM scan: provides projections
README.md - SSM scan → SISO scan: dispatches SISO
README.md - SSM scan → MIMO scan: dispatches MIMO
README.md - SSM scan → Mixer output: produces
README.md - Mamba3 mixer → Mixer output: projects output
README.md - Decode caller → Single-token step: provides token
README.md - Decode caller → Inference cache: allocates
README.md - Inference cache → Decode state: returns states
README.md - Decode state → Single-token step: updates across steps
README.md - Single-token step → Decode caller: returns output
README.md - Model config → Language model: configures
README.md - Language model → Token embedding: embeds tokens
README.md - Language model → Residual block: stacks blocks
README.md - Language model → Feed-forward layer: may include
README.md - Language model → LM head: projects logits
README.md - LM head → Token logits: produces
README.md - Model caller → Parameter counter: counts parameters
README.md