Downloads · 30 days
261
19% of all-time downloads
AndrewThompson1233/maba-v1-architecture
maba-v1-architecture is a machine learning model from AndrewThompson1233. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as mit.
<p align="center" <img src="https://huggingface.co/AndrewThompson1233/maba-v1-architecture/resolve/main/assets/logo.svg" width="160" alt="Maba Logo" / </p
Downloads · 30 days
261
19% of all-time downloads
All-time downloads
1.4K
Public
Repo size
—
Likes
8
Public
Click a slice to open those files.
.svg160 KB · 52%
From the Hugging Face model README
Official specification, scaling topology, and reference implementation of the Maba neural network architecture. Maba combines Gated DeltaNet linear recurrence (GDN-2) with Grouped-Query Attention (GQA), 2-pass physical block recycling, and native multi-token prediction (MTP) speculative decoding.
Note: For the sparse latent-attention iteration with million-token context, see Maba v2 Architecture.
Checkpoint weights and benchmark evaluations (ARC, HellaSwag, Story Cloze) are published at AndrewThompson1233/maba-101m.
Standard transformers scale at O(N^2) memory and compute with sequence length. Pure linear RNNs and state-space models scale at O(1) state memory but struggle with associative recall across long token horizons.
Maba resolves this trade-off through a 3:1 macro-interleaved block structure:
| Component | Sub-Layers | Exact Parameters | % of Total | Function |
|---|---|---|---|---|
| Factorized Embedding | W_emb (32,768 x 128) | 4,194,304 | 4.15% | Token lookup table |
| Embedding Projections | W_proj_in + W_proj_out | 163,840 | 0.16% | Rank 128 <-> Dim 640 |
| Embedding Subtotal | Vocab Tax | 4,358,144 | 4.31% | Static parameter overhead |
| 15 GDN-2 Blocks | Recurrence + SwiGLU FFN | 74,803,200 | 73.93% | Linear O(1) recurrence |
| 5 GQA Blocks | Attention + SwiGLU FFN | 21,523,840 | 21.27% | Quadratic routing |
| Computation Core | All 20 Physical Blocks | 96,327,040 | 95.21% | Core sequence modeling |
| Final RMSNorm | Layer normalization gain | 640 | <0.01% | Final feature variance scale |
| MTP Auxiliary Head | k=2 projection and norm | 492,160 | 0.49% | Native speculative decoding |
| Total Architecture | Full Model Parameters | 101,177,984 | 100.00% | Exact parameter count |
| Precision | Bytes per Parameter | Model Weights VRAM | Memory Footprint Notes |
|---|---|---|---|
| FP32 (Full Precision) | 4 bytes | 385.96 MB | Default PyTorch weights |
| BF16 / FP16 (Half Precision) | 2 bytes | 192.98 MB | Standard inference and training |
| INT8 (Quantized) | 1 byte | 96.49 MB | Edge devices and embedded systems |
| INT4 (GPTQ / AWQ) | 0.5 bytes | 48.25 MB | Microcontroller and mobile inference |
Maba separates state memory into constant recurrent state (GDN-2) and compressed quadratic attention cache (GQA 4:1):
| Context Length (Tokens) | Maba v1.1 GQA Cache | Maba v1.1 GDN-2 State | Maba v1.1 Total Cache | Pure Attention Baseline | Memory Reduction |
|---|---|---|---|---|---|
| 1,024 (1k) | 2.50 MB | 1.17 MB (Fixed) | 3.67 MB | 10.50 MB | -65.0% |
| 2,048 (2k) | 5.00 MB | 1.17 MB (Fixed) | 6.17 MB | 21.00 MB | -70.6% |
| 4,096 (4k) | 10.00 MB | 1.17 MB (Fixed) | 11.17 MB | 42.00 MB | -73.4% |
| 8,192 (8k) | 20.00 MB | 1.17 MB (Fixed) | 21.17 MB | 84.00 MB | -74.8% |
| 16,384 (16k) | 40.00 MB | 1.17 MB (Fixed) | 41.17 MB | 168.00 MB | -75.5% |
| 32,768 (32k) | 80.00 MB | 1.17 MB (Fixed) | 81.17 MB | 336.00 MB | -75.8% |
| 65,536 (64k) | 160.00 MB | 1.17 MB (Fixed) | 161.17 MB | 672.00 MB | -76.0% |
| 131,072 (128k) | 320.00 MB | 1.17 MB (Fixed) | 321.17 MB | 1,344.00 MB | -76.1% |
| Metric | Maba v1.1 | Qwen 3.8 | Qwen 3.8 Flash Next | MiniCPM5 |
|---|---|---|---|---|
| Parameter Budget | ~101M | ~101M | ~101M | ~101M |
| Core Computation Ratio | 95.21% | 75.00% | 74.99% | 79.20% |
| Recurrence Share | 75% (GDN-2) | 75% (GDN) | 75% (GDN) | 0% (Pure Attention) |
| Quadratic Attention Share | 25% (GQA) | 25% (GQA) | 25% (QSA Sparse) | 100% (GQA) |
| Physical Blocks | 20 blocks | 20 blocks | 20 blocks | 28 blocks |
| Effective Layer Depth | 40 layers | 20 layers | 20 layers | 28 layers |
| KV-Cache Footprint (4k) | 10.0 MB (-76.2%) | 10.0 MB (-76.2%) | 2.5 MB (-94.0%) | 42.0 MB (Baseline) |
| Speculative Heads | Built-in MTP (k=2) | Built-in MTP (k=2) | Built-in MTP (k=2) | None |
The Maba architecture scales systematically from on-device 100M to large-scale 30B parameters, supporting context horizons up to 131k tokens.
For complete multi-scale topology configurations, closed-form parameter derivation equations, and architectural audits against 2026 foundation models (Qwen3.5, Muse-30B, Gemma4), see the dedicated scaling specification:
To avoid vocabulary parameters consuming core computation capacity, Maba factorizes the embedding matrix:
The Gated DeltaNet layer computes an input-dependent recurrent update over state matrix S of size (d_head x d_head):
Every fourth block (blocks 3, 7, 11, 15, 19) is a Grouped-Query Attention block:
Each block contains an intermediate SwiGLU FFN:
Instead of fixed addition, residual streams use a learned gating mechanism:
The repository includes a standalone C++ inference implementation in cpp/:
Build instructions:
cd cpp
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . -j$(nproc)
./test_numerical
The architecture includes automated device detection and distributed execution in maba/hardware.py:
Check hardware status:
python3 -m maba.cli hardware
Run tests:
pytest tests/
git clone https://github.com/ivan-dev35/maba-v1-architecture.git
cd maba-v1-architecture
pip install -e .
import torch
from maba.config import Config
from maba.model import Model
# Initialize 101M reference architecture
cfg = Config.from_preset("100M")
model = Model(cfg)
# Forward pass
tokens = torch.randint(0, cfg.vocab_size, (1, 64))
outputs = model(tokens)
logits = outputs["logits"]
print(f"Logits shape: {logits.shape}") # [1, 64, 32768]
from maba.generate import spec_gen
from maba.tokenizer import Tokenizer
tok = Tokenizer()
output_text, acceptance_rate, steps = spec_gen(
model,
tok,
prompt="Artificial intelligence architecture design",
max_new_tokens=64
)