Agent skill · software engineering · davila7
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.
Why this skill is useful
Adds a new state-space model architecture with O(n) complexity and specific implementation details that enhance AI's capabilities in sequence modeling.
What it needs
Requires causal-conv1d, mamba-ssm, torch installed locally. About 3k tokens when loaded. Last updated 2026-08-06. 30,138 stars on the source repository.
What this skill does
Mamba - Selective State Space Models Quick start 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): Common workflows Workflow 1: Language model with Mamba-2 Complete LM with generation: Workflow 2: Use pretrained Mamba models Load from HuggingFace: Available models: state-spaces/mamba-130m state-spaces/mamba-370m state-spaces/mamba-790m state-spaces/mamba-1.4b state-spaces/mamba-2.8b Workflow 3: Mamba-1 vs Mamba-2 Mamba-1 (smaller state): Mamba-2 (multi-head, larger state): Key differences: State size: Mamba-1 (dstate=16) vs Mamba-2 (dstate=128) Architecture: Mamba-2 has multi-head structure Normalization: Mamba-2 uses RMSNorm Distributed: Mamba-2 supports tensor parallelism Workflow 4: Benchmark vs Transformers Generation speed comparison: Expected results: Mamba: 5× faster inference Memory: No KV cache needed Scaling: Linear with sequence length When to use vs alternatives Use Mamba when: Need long sequences (100K+ tokens) Want faster inference than Transformers Memory-constrained (no KV cache) Building streaming applications Linear scaling important Advantages: O(n) complexity: Linear vs quadratic 5× faster inference: No attention overhead No KV cache: Lower memory usage Million-token sequences: Hardware-efficient Streaming: Constant memory per token Use alternatives instead: Transformers: Need best-in-class performance, have compute RWKV: Want RNN+Transformer hybrid RetNet: Need retention-based architecture Hyena: Want convolution-based approach Common issues 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.frompretrained (not AutoModel): Advanced topics Selective SSM: See references/selective-ssm.md for mathematical form …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills davila7/model-architecture-mamba