How shawn100907/mamba-minimal works
mamba-minimal is a single-file PyTorch implementation of the Mamba language model, prioritizing readable code over optimized execution. Its intended workflow is to load pretrained weights, tokenize a prompt, run the model to produce logits, and generate a completion; tokenization and generation are demonstrated as external tooling, not implemented here. The source excerpt identifies the model, residual blocks, Mamba block, selective scan, and normalization. Forward-pass details are partly omitted, so the graph avoids inferring internal call edges not shown in the excerpt.
Main entry points: model.py Mamba model
Components 11
Model implementation
- Mamba model
model.py - Model arguments
model.py - Residual block
model.py - Mamba block
model.py - Selective scan
model.py - RMS normalization
model.py
Pretrained loading
- Pretrained loader
model.py
Other components
- Prompt user
- Tokenizer
- Hugging Face weights
- Generated completion
Connections 10
- Prompt user → Tokenizer: provides prompt
README.md - Tokenizer → Mamba model: provides tokens
README.md - Mamba model → Generated completion: produces logits
README.md - Model arguments → Mamba model: configures
model.py - Mamba model → Residual block: constructs
model.py - Mamba model → RMS normalization: constructs
model.py - Residual block → Mamba block: constructs
model.py - Residual block → RMS normalization: constructs
model.py - Pretrained loader → Mamba model: builds
model.py - Pretrained loader → Hugging Face weights: loads config and weights
model.py