I built a Mamba1 variant I call SM1 with d_state=1 that runs on Blackwell in pure PyTorch [P]

· Source: Machine Learning · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Software Development & Engineering · Depth: Expert, quick

Summary

A new Mamba1 variant, SM1 (Scalar Mamba1), has been developed, featuring a d_state=1 architecture that runs efficiently on Blackwell GPUs using pure PyTorch. SM1 replaces the complex selective scan with an exact closed-form solution implemented via two native PyTorch operations: torch.cumprod and torch.cumsum. This design significantly reduces memory footprint, eliminating the S dimension from Mamba1 scan intermediates, leading to 16x less scan memory compared to a d_state=16 Mamba1. For a 130M parameter model, SM1's inference state is only 56 KB (14,080 floats), offering O(1) memory per token without a KV cache. The developer is currently training a 130M parameter model on 163K MIDI files (2.5B tokens), which fits comfortably within half of a 16 GB RTX 5060 Ti card. The approach suggests that a scalar d_state is sufficient when structural information is already encoded in tokens.

Key takeaway

For Machine Learning Engineers optimizing model deployment on consumer-grade GPUs, SM1 presents a compelling alternative to standard Mamba architectures. If you are struggling with memory constraints on cards like the RTX 5060 Ti, consider implementing d_state=1 Mamba variants. This approach significantly reduces inference state memory to O(1) per token, potentially enabling larger models to fit within your existing hardware without a KV cache. Explore the provided GitHub repository for a practical implementation.

Key insights

SM1 offers a memory-efficient Mamba1 variant with d_state=1 using native PyTorch for O(1) inference.

Principles

Method

SM1 implements the d_state=1 selective scan using torch.cumprod for L and torch.cumsum for h, followed by y = h * C, providing an exact closed-form solution.

In practice

Topics

Code references

Best for: Research Scientist, AI Scientist, Machine Learning Engineer, AI Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Machine Learning.