mamba-architecture

Implements and benchmarks Mamba selective state-space models for linear-complexity sequence modeling.

5|2|Updated Aug 10, 2026
One-click install
npx skills add https://github.com/MedTiLab/Auto-meta-analysis --skill mamba-architecture-medtilab
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mamba-architecture
Source: https://github.com/MedTiLab/Auto-meta-analysis/tree/main/skills/model-architecture/mamba
Command: npx skills add https://github.com/MedTiLab/Auto-meta-analysis --skill mamba-architecture-medtilab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires mamba-ssm, torch, transformers, causal-conv1d, and includes references (resource) components.

What problem does it solve? Transformers scale quadratically with sequence length and require large KV caches, making long-context inference slow and memory-hungry. This Skill guides you through installing, configuring, training, and benchmarking Mamba state-space models that achieve O(n) linear complexity with no KV cache. ## Core Features & Use Cases - Model Setup & Generation: Build Mamba-1 and Mamba-2 language models with MambaLMHeadModel, or load pretrained checkpoints (130M to 2.8B) from HuggingFace for text generation. - Training & Distributed Workflows: Configure mixed-precision training, gradient checkpointing, DDP multi-GPU setups, and long-context sequence length progression. - Benchmarking vs Transformers: Compare inference throughput, latency, memory usage, and perplexity against Transformer baselines using provided benchmark scripts. - Use Case: You need to run inference on 100K+ token DNA sequences. Use this Skill to configure a Mamba-2 model with d_state=128, load a pretrained checkpoint, and generate outputs with constant per-token memory instead of an exploding KV cache. ## Quick Start Install mamba-ssm and causal-conv1d with pip, then ask the AI to create a Mamba language model and generate text from a prompt on a CUDA GPU.

Frequently Asked Questions about mamba-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I install and run a Mamba state-space model in Python?▼

Install mamba-ssm with pip, optionally adding causal-conv1d for efficiency. Then instantiate the Mamba block with d_model, d_state, d_conv, and expand parameters, and pass a CUDA tensor of shape (batch, length, dim) through the model.

What is the difference between Mamba-1 and Mamba-2?▼

Mamba-1 uses a state dimension of 16, while Mamba-2 uses d_state=128 with a multi-head structure, RMSNorm, and tensor parallelism support. Mamba-2 offers larger state capacity and better distributed training options.

Mamba vs Transformer: which is better for long sequences?▼

Mamba achieves O(n) linear complexity versus the Transformer's O(n²), delivering roughly 5× faster inference and no KV cache. Benchmarks show the speedup grows with sequence length, reaching over 10× at 8K tokens.

Can I load pretrained Mamba models from HuggingFace?▼

Yes, use MambaLMHeadModel.from_pretrained with checkpoints like state-spaces/mamba-2.8b rather than AutoModel. Pair it with a compatible tokenizer such as EleutherAI/gpt-neox-20b for text generation.

Why does Mamba installation fail or run slowly?▼

Mamba requires Linux, an NVIDIA GPU, PyTorch 1.12+, and CUDA 11.6+. Install binary wheels with pip install mamba-ssm --no-build-isolation and ensure causal-conv1d>=1.4.0 is installed separately if missing.

How do I fix CUDA out of memory errors when training Mamba?▼

Reduce the per-GPU batch size, shorten the sequence length, or enable gradient checkpointing on the model. Gradient checkpointing saves roughly 30-40% of activation memory with minimal speed impact.