Mamba SSM - State Space Models optimized for Apple Silicon
Reason this release was yanked:
wrong version
Project description
Mamba SSM for macOS Apple Silicon
Mamba 1 and Mamba 2 State Space Models for Apple Silicon
Training and inference of Mamba 1 & 2 on Apple Silicon with MPS acceleration. Works without CUDA/Triton. Supports CLI, Python API, and interactive demos.
Installation
pip install mamba-ssm-macos
Or install from source:
git clone https://github.com/purohit10saurabh/mamba-ssm-macos.git
cd mamba-ssm-macos
uv sync # or: pip install -r requirements.txt
Quick Start
python -m scripts.download_models mamba1 # Mamba 1 (493MB)
python -m scripts.download_models mamba2 # Mamba 2 (493MB)
make run-mamba1 # Quick Mamba 1 demo
make run-mamba2 # Quick Mamba 2 demo
Prerequisites: macOS 12.3+ with Apple Silicon, Python 3.10+, 8GB+ RAM recommended.
Usage
Text Generation
python -m scripts.run_models mamba1 --prompt "The future of AI" --max-length 50
python -m scripts.run_models mamba2 --prompt "The future of AI" --max-length 30
python -m scripts.run_models mamba1 --prompt "Once upon a time" --temperature 0.8
python -m examples.02_text_generation --interactive
Examples
python -m examples.01_core_modules # Core modules usage
python -m examples.02_text_generation # Text generation demo
python -m examples.03_training # Training example
Makefile Commands
make download-models # Download both models
make run-mamba1 # Quick Mamba 1 demo
make run-mamba2 # Quick Mamba 2 demo
make test-quick # Fast integration test
make test # Full test suite
Training
See examples/03_training.py for a full example. Snippet:
import torch
from torch import nn
from mamba_ssm.modules.mamba2 import Mamba2
model = nn.Sequential(nn.Embedding(1000, 128), *[Mamba2(d_model=128, d_state=64, d_conv=4, expand=2, headdim=64, ngroups=1, chunk_size=256, device='mps') for _ in range(2)], nn.LayerNorm(128), nn.Linear(128, 1000, bias=False)).to('mps')
optimizer = torch.optim.AdamW(model.parameters(), lr=1e-4)
criterion = nn.CrossEntropyLoss()
for input_ids, labels in dataloader:
optimizer.zero_grad()
logits = model(input_ids)
loss = criterion(logits.view(-1, logits.size(-1)), labels.view(-1))
loss.backward()
optimizer.step()
Repository Structure
mamba-ssm-macos/
├── mamba_ssm/ # Core library (models, modules, ops, utils)
├── scripts/ # download_models.py, run_models.py
├── tests/ # unit/, integration/, run_unit_tests.py
├── examples/ # 01_core_modules, 02_text_generation, 03_training
├── Makefile
└── pyproject.toml
Troubleshooting
"Model files not found" — Run make download-models or python -m scripts.download_models mamba1|mamba2.
"MPS not available" — Check with python -c "import torch; print(torch.backends.mps.is_available())". Falls back to CPU automatically.
Import errors — Use module syntax: python -m examples.02_text_generation.
Citation
Also available via GitHub's "Cite this repository" button (CITATION.cff).
@software{purohit2026mamba_ssm_macos,
title={Mamba SSM for macOS Apple Silicon},
author={Purohit, Saurabh},
year={2026},
url={https://github.com/purohit10saurabh/mamba-ssm-macos}
}
Original Mamba papers
@article{gu2023mamba,
title={Mamba: Linear-Time Sequence Modeling with Selective State Spaces},
author={Gu, Albert and Dao, Tri},
journal={arXiv preprint arXiv:2312.00752},
year={2023}
}
@article{dao2024transformers,
title={Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality},
author={Dao, Tri and Gu, Albert},
journal={arXiv preprint arXiv:2405.21060},
year={2024}
}
References
- state-spaces/mamba — Original implementation
- state-spaces/mamba1-130m — Mamba 1 130M Pre-trained model
- state-spaces/mamba2-130m — Mamba 2 130M Pre-trained model
Contributing
Contributions are welcome — bug fixes, performance improvements, docs, and new features. Open an issue or submit a PR.
git clone https://github.com/purohit10saurabh/mamba-ssm-macos.git
cd mamba-ssm-macos
uv sync --extra dev
make test
License
Apache 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mamba_ssm_macos-0.0.0.tar.gz.
File metadata
- Download URL: mamba_ssm_macos-0.0.0.tar.gz
- Upload date:
- Size: 118.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb7a12aa033f40b1b9c81963c7e7b8c89088b26f0ae3976056c7318a63275b1e
|
|
| MD5 |
e629190c6b444ec0a536706c34e685e0
|
|
| BLAKE2b-256 |
a167016436f2afdc652a5ec5cd86bea37a4adbae8e1a43f4285ac6cb6b149f8a
|
Provenance
The following attestation bundles were made for mamba_ssm_macos-0.0.0.tar.gz:
Publisher:
publish.yml on purohit10saurabh/mamba-ssm-macos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mamba_ssm_macos-0.0.0.tar.gz -
Subject digest:
cb7a12aa033f40b1b9c81963c7e7b8c89088b26f0ae3976056c7318a63275b1e - Sigstore transparency entry: 962585152
- Sigstore integration time:
-
Permalink:
purohit10saurabh/mamba-ssm-macos@df357eaabcee3e2d01cc3790db458330fc53591c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/purohit10saurabh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df357eaabcee3e2d01cc3790db458330fc53591c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mamba_ssm_macos-0.0.0-py3-none-any.whl.
File metadata
- Download URL: mamba_ssm_macos-0.0.0-py3-none-any.whl
- Upload date:
- Size: 33.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb89bca69a7e155f94d4cbe8dee369e6a856b817ff5c19121b92ac8a2499a182
|
|
| MD5 |
1916704eea06df90c741806240793b8e
|
|
| BLAKE2b-256 |
96a9feb478aacfda5d540fc744f55dc3cf52671820013df8b3ec23df8aa47b46
|
Provenance
The following attestation bundles were made for mamba_ssm_macos-0.0.0-py3-none-any.whl:
Publisher:
publish.yml on purohit10saurabh/mamba-ssm-macos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mamba_ssm_macos-0.0.0-py3-none-any.whl -
Subject digest:
bb89bca69a7e155f94d4cbe8dee369e6a856b817ff5c19121b92ac8a2499a182 - Sigstore transparency entry: 962585153
- Sigstore integration time:
-
Permalink:
purohit10saurabh/mamba-ssm-macos@df357eaabcee3e2d01cc3790db458330fc53591c -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/purohit10saurabh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@df357eaabcee3e2d01cc3790db458330fc53591c -
Trigger Event:
push
-
Statement type: