npx skills add ...
npx skills add firecrawl/ai-research-skills --skill mamba-architecture
State-space model with O(n) complexity vs Transformers' O(n²). 5× faster inference, million-token sequences, no KV cache. Selective SSM with hardware-aware design. Mamba-1 (d_state=16) and Mamba-2 (d_state=128, multi-head). Models 130M-2.8B on HuggingFace.
npx skills add firecrawl/ai-research-skills --skill mamba-architecture
Mamba is a state-space model architecture achieving O(n) linear complexity for sequence modeling.
Installation:
Prerequisites: Linux, NVIDIA GPU, PyTorch 1.12+, CUDA 11.6+
Basic usage (Mamba block):
Complete LM with generation:
Load from HuggingFace:
Available models:
state-spaces/mamba-130mstate-spaces/mamba-370mstate-spaces/mamba-790mstate-spaces/mamba-1.4bstate-spaces/mamba-2.8bMamba-1 (smaller state):
Mamba-2 (multi-head, larger state):
Key differences:
Generation speed comparison:
Expected results:
Use Mamba when:
Advantages:
Use alternatives instead:
Issue: CUDA out of memory
Reduce batch size or use gradient checkpointing:
Issue: Slow installation
Install binary wheels (not source):
Issue: Missing causal-conv1d
Install separately:
Issue: Model not loading from HuggingFace
Use MambaLMHeadModel.from_pretrained (not AutoModel):
Selective SSM: See references/selective-ssm.md for mathematical formulation, state-space equations, and how selectivity enables O(n) complexity.
Mamba-2 architecture: See references/mamba2-details.md for multi-head structure, tensor parallelism, and distributed training setup.
Performance optimization: See references/performance.md for hardware-aware design, CUDA kernels, and memory efficiency techniques.
Performance (vs Transformers):