Model reference · open weights
mamba is an open-weight language model from state-spaces. mamba-1.4b-hf (FP32) weighs 2.7 GB; the smallest configuration that runs it is RTX 3060 12 GB.
Summary of the state-spaces/mamba-130m-hf model card, 2026-10-01. The estimate below is for another build of the family.
What it is
| Released by | state-spaces |
|---|---|
| Released | 2024-03-06 |
| Parameters | 129M |
| VRAM | 2.7 GB for the weights |
What it runs on
| Card | Requests at once | Context max | Memory | |
|---|---|---|---|---|
| 8K each | 32K each | |||
| RTX 3060 12 GB | 557 | 557 | 128K | 11.6 GB |
| RTX 4060 Ti 16 GB | 810 | 810 | 128K | 15.4 GB |
| RTX 3090 24 GB | 1000+ | 1000+ | 128K | 23.4 GB |
| RTX 4090 24 GB | 1000+ | 1000+ | 128K | 23.4 GB |
| RTX 5090 32 GB | 1000+ | 1000+ | 128K | 31.0 GB |
| L40S 48 GB | 1000+ | 1000+ | 128K | 44.0 GB |
| A100 80 GB | 1000+ | 1000+ | 128K | 78.2 GB |
| H100 80 GB | 1000+ | 1000+ | 128K | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | 1000+ | 1000+ | 128K | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | 1000+ | 1000+ | 128K | 107 GB |
| H200 141 GB | 1000+ | 1000+ | 128K | 138 GB |
| B200 180 GB | 1000+ | 1000+ | 128K | 176 GB |
| Requests at once | 8K tokens each | 32K tokens each |
|---|---|---|
| 1 | 3.3 GB | 3.3 GB |
| 5 | 3.4 GB | 3.4 GB |
| 8 | 3.4 GB | 3.4 GB |
| 16 | 3.5 GB | 3.5 GB |
| 32 | 3.8 GB | 3.8 GB |
| 64 | 4.2 GB | 4.2 GB |
One card, with vLLM's small-card settings.
Builds
| Build | Params | Precision | Weights | Smallest setup |
|---|---|---|---|---|
| mamba-130m-hf ↗ | 129M | FP32 | 258 MB | RTX 3060 12 GB |
| mamba-2.8b-hf ↗ | 2.8B | FP32 | 5.5 GB | RTX 3060 12 GB |
| mamba-1.4b-hf (above) ↗ | 1.4B | FP32 | 2.7 GB | RTX 3060 12 GB |
| mamba-370m-hf ↗ | 372M | FP32 | 743 MB | RTX 3060 12 GB |
| mamba-790m-hf ↗ | 793M | FP32 | 1.6 GB | RTX 3060 12 GB |
From the model card
This repository contains the transfromers compatible mamba-2.8b. The checkpoints are untouched, but the full config.json and tokenizer are pushed to this repo.
You need to install transformers from main until transformers=4.39.0 is released.
pip install git+https://github.com/huggingface/transformers@main
We also recommend you to install both causal_conv_1d and mamba-ssm using:
pip install causal-conv1d>=1.2.0
pip install mamba-ssm
If any of these two is not installed, the "eager" implementation will be used. Otherwise the more optimised cuda kernels will be used.
You can use the classic generate API:
>>> from transformers import MambaConfig, MambaForCausalLM, AutoTokenizer
>>> import torch
>>> tokenizer = AutoTokenizer.from_pretrained("state-spaces/mamba-130m-hf")
>>> model = MambaForCausalLM.from_pretrained("state-spaces/mamba-130m-hf")
>>> input_ids = tokenizer("Hey how are you doing?", return_tensors="pt")["input_ids"]
>>> out = model.generate(input_ids, max_new_tokens=10)
>>> print(tokenizer.batch_decode(out))
["Hey how are you doing?\n\nI'm so glad you're here."]
In order to finetune using the peft library, we recommend keeping the model in float32!
from datasets import load_dataset
from trl import SFTTrainer
from peft import LoraConfig
from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments
tokenizer = AutoTokenizer.from_pretrained("state-spaces/mamba-130m-hf")
model = AutoModelForCausalLM.from_pretrained("state-spaces/mamba-130m-hf")
dataset = load_dataset("Abirate/english_quotes", split="train")
training_args = TrainingArguments(
output_dir="./results",
num_train_epochs=3,
per_device_train_batch_size=4,
logging_dir='./logs',
logging_steps=10,
learning_rate=2e-3
)
lora_config = LoraConfig(
r=8,
target_modules=["x_proj", "embeddings", "in_proj", "out_proj"],
task_type="CAUSAL_LM",
bias="none"
)
trainer = SFTTrainer(
model=model,
tokenizer=tokenizer,
args=training_args,
peft_config=lora_config,
train_dataset=dataset,
dataset_text_field="quote",
)
trainer.train()
Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.