Optimized Mamba implementation with chunk processing and ONNX export
Project description
MambaX
PyTorch implementation of the Mamba architecture with enhanced production-ready features:
- ONNX Export - Full model export support for deployment
- Chunk Processing - Single-forwardpass chunk handling (no token loops)
- CPU-First - Optimized execution without CUDA dependencies
Installation
Install the package directly from PyPI:
pip install mambax
Key Advantages
- Production Ready: ONNX-compatible for serving
- No Token Loops: Processes entire chunks in single forward pass
- Hardware Agnostic: Runs equally well on CPU/GPU
Acknowledgements
Builds upon reference work from alxndrTL/mamba.py
Usage
1. Standard Forward Pass
import torch
import torch.nn as nn
from mambax import Mamba
# Initialize model
model = Mamba(
d_model=512,
d_inner=1024,
d_conv=4,
d_state=16,
dt_rank=64,
use_cuda=False
)
# Process full sequence
x = torch.rand(1, 128, 512) # (batch, seq_len, dim)
output = model(x) # single forward pass
2. Single Token Processing
x_token = torch.rand(1, 1, 512) # (batch, 1, dim)
output, new_state, new_conv = model(x_token, state_cache, conv_cache)
3. Chunk-Based Processing
# Initialize with empty caches
state_cache = torch.zeros(1, 1024, 16) # (batch, d_inner, d_state)
conv_cache = torch.zeros(1, 1024, 3) # (batch, d_inner, d_conv-1)
# Process chunks (e.g. 8 tokens at once)
x_chunk = torch.rand(1, 8, 512)
output, new_state, new_conv = model(x_chunk, state_cache, conv_cache)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mambax-0.3.0.tar.gz
(6.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mambax-0.3.0.tar.gz.
File metadata
- Download URL: mambax-0.3.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7e0aea985bd777be08ab43a6015ffd3a25b832641b72683d439907c73f5421a
|
|
| MD5 |
25e8d83f3863d0901b99f9318b4d7de4
|
|
| BLAKE2b-256 |
be2788b946638c19e2e2543fd46ca1e50bd82b0132dfba2fb101056b50ce88e2
|
File details
Details for the file mambax-0.3.0-py3-none-any.whl.
File metadata
- Download URL: mambax-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1787a15148dbf339a6adbfd3f229d0ce8a6de288de25ffe1006153f4b0d770a0
|
|
| MD5 |
78cdd558e0fe4edeee24601da06b3a4a
|
|
| BLAKE2b-256 |
35fa3dee266dc903b877e414727734eec9e0a9152043fdc76e6f71dce7358cd8
|