AndrewThompson1233 commited on
Commit
95db57a
·
1 Parent(s): cb2b0db
Files changed (3) hide show
  1. README.md +37 -66
  2. assets/architecture_comparison.svg +276 -0
  3. assets/logo.svg +1 -1
README.md CHANGED
@@ -2,91 +2,62 @@
2
  language:
3
  - en
4
  license: mit
5
- tags:
6
- - maba
7
- - maba-v1.5
8
- - recurrent
9
- - dgda
10
- - linear-attention
11
- - sparse-attention
12
- - maba-sa
13
- - mla
14
- - nope
15
  pipeline_tag: text-generation
16
  ---
17
 
18
- <p align="center">
19
- <img src="https://huggingface.co/AndrewThompson1233/maba-1.5-103m/resolve/main/assets/logo.svg" width="160" alt="Maba Logo" />
20
- </p>
21
 
22
  # Maba v1.5 (103.5M)
23
 
24
- Trained checkpoint built on the **[AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture)** reference architecture.
25
 
26
  * Base Architecture: [AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture)
27
- * Parameters: **103,520,911 (103.5M)**
28
- * Core Computation Ratio: **95.21%** (4.30% Vocab Tax)
29
- * Macro-Stack: **3:1** (15 DGDA Recurrence : 5 MABA-SA Dynamic Sparse Attention)
30
  * Positional Encoding: **Strict NoPE** (0 parameters)
31
- * Training Corpus: 3,044 dialogue pairs on NVIDIA L4 (bfloat16)
32
-
33
- ---
34
 
35
  ## Empirical Benchmark vs Qwen3.8-Flash-Next (101.7M)
36
 
37
- Evaluated under identical training budgets (3,044 dialogues, 15 epochs, bfloat16, NVIDIA L4):
38
-
39
- | Metric | Maba v1.5-exp | Qwen3.8-Flash-Next | Delta / Advantage |
40
  | :--- | :---: | :---: | :---: |
41
- | **Parameters** | **103,520,911 (103.5M)** | 101,701,120 (101.7M) | 0.2% parity |
42
- | **Architecture** | **75% DGDA + 25% MABA-SA** | 75% GDN + 25% QSA + MoE | Cyclic 3:1 |
43
- | **Positional Encoding** | **Strict NoPE (0 params)** | 25% Partial RoPE | Zero positional overhead |
44
- | **Contrastive Retrieval (MCQ)** | **87.5% (7/8)** | 75.0% (6/8) | **+12.5% accuracy** |
45
- | **Validation Loss** | **0.0697** | 0.0778 | **-10.4% entropy** |
46
- | **Validation Perplexity (PPL)** | **1.07** | 1.08 | **Maba wins** |
47
- | **Decode Throughput (L4)** | **7.0 tok/s** | 5.5 tok/s | **+27.3% faster generation** |
48
-
49
- <p align="center">
50
- <img src="https://huggingface.co/AndrewThompson1233/maba-1.5-103m/resolve/main/assets/empirical_benchmark.svg" width="920" alt="Maba v1.5 Empirical Benchmark" />
51
- </p>
52
 
53
- ---
54
-
55
- ## Attention Ablation Proof
56
 
57
- Empirical demonstration of the contribution of the 25% MABA-SA dynamic sparse attention layers against a pure linear recurrent baseline on the exact same checkpoint weights:
58
 
59
- | Model Variant | Attention Mechanism | Validation Loss | Perplexity (PPL) | Error Reduction |
60
- | :--- | :---: | :---: | :---: | :---: |
61
- | **Pure DGDA (Ablation)** | None (100% Linear Recurrence) | 3.9360 | 51.21 | Baseline |
62
- | **Qwen3.8-Flash-Next** | QSA (GQA + Micro-block Indexer) | 3.8772 | 48.29 | -5.7% vs Recurrence |
63
- | **Maba v1.5 Full** | **MABA-SA (MLA + Top-32 + HCA)** | **3.5903** | **36.24** | **-29.2% error drop** |
64
 
65
- ---
 
 
 
66
 
67
- ## Needle-In-A-Haystack & Centroid Retrieval (512 to 4096 Tokens)
 
68
 
69
- | Context Length | Needle Position | Needle Block | DG-Indexer (Hybrid Mean+Max) | Standard Pure Mean Pooling |
70
- | :---: | :---: | :---: | :---: | :---: |
71
- | **512 tokens** | 51 (10%) | Block #0 | **Retrieved (Top-32)** | Retrieved |
72
- | **512 tokens** | 256 (50%) | Block #4 | **Retrieved (Top-32)** | Retrieved |
73
- | **512 tokens** | 460 (90%) | Block #7 | **Retrieved (Top-32)** | Retrieved |
74
- | **1024 tokens** | 102 (10%) | Block #1 | **Retrieved (Top-32)** | Retrieved |
75
- | **1024 tokens** | 512 (50%) | Block #8 | **Retrieved (Top-32)** | Retrieved |
76
- | **1024 tokens** | 921 (90%) | Block #14 | **Retrieved (Top-32)** | Retrieved |
77
- | **2048 tokens** | 204 (10%) | Block #3 | **Retrieved (Top-32)** | Retrieved |
78
- | **2048 tokens** | 1024 (50%) | Block #16 | **Retrieved (Top-32)** | Retrieved |
79
- | **2048 tokens** | 1843 (90%) | Block #28 | **Retrieved (Top-32)** | Retrieved |
80
- | **4096 tokens** | 2048 (50% Lost-in-Middle) | Block #32 | **Retrieved (Top-32)** | **Diluted to 0.0 (Failed)** |
81
- | **4096 tokens** | 3686 (90%) | Block #57 | **Retrieved (Top-32)** | Retrieved |
82
 
83
- ---
 
 
84
 
85
- ## KV-Cache Footprint at 4k Context
 
 
 
 
86
 
87
- | Context Length | Dense Attention (Baseline) | Qwen3.8-Flash-Next | Maba v1.5 (MLA + Top-32) | Memory Reduction vs Dense |
88
- | :---: | :---: | :---: | :---: | :---: |
89
- | **512 tokens** | 25.00 MB | 1.00 MB | **0.62 MB** | **-97.5%** |
90
- | **1,024 tokens** | 50.00 MB | 2.00 MB | **1.25 MB** | **-97.5%** |
91
- | **2,048 tokens** | 100.00 MB | 4.00 MB | **2.50 MB** | **-97.5%** |
92
- | **4,096 tokens** | 200.00 MB | 8.00 MB | **2.50 MB** | **-98.8%** |
 
2
  language:
3
  - en
4
  license: mit
 
 
 
 
 
 
 
 
 
 
5
  pipeline_tag: text-generation
6
  ---
7
 
8
+ <p align="center"><img src="assets/logo.svg" width="160" alt="Logo" /></p>
 
 
9
 
10
  # Maba v1.5 (103.5M)
11
 
12
+ Trained checkpoint built on [AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture).
13
 
14
  * Base Architecture: [AndrewThompson1233/maba-v1.5-exp-architecture](https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture)
15
+ * Parameters: **103.5M**
16
+ * Core Ratio: **95.21%** (4.30% Vocab Tax)
17
+ * Macro-Stack: **3:1** (15 DGDA Recurrence : 5 MABA-SA Attention)
18
  * Positional Encoding: **Strict NoPE** (0 parameters)
19
+ * Trained on: 3,044 dialogues on NVIDIA L4 (bfloat16)
 
 
20
 
21
  ## Empirical Benchmark vs Qwen3.8-Flash-Next (101.7M)
22
 
23
+ | Metric | Maba v1.5-exp | Qwen3.8-Flash-Next | Delta |
 
 
24
  | :--- | :---: | :---: | :---: |
25
+ | **Retrieval Accuracy (MCQ)** | **87.5% (7/8)** | 75.0% (6/8) | **+12.5%** |
26
+ | **Validation Loss** | **0.0697** | 0.0778 | **-10.4%** |
27
+ | **Perplexity (PPL)** | **1.07** | 1.08 | **Maba wins** |
28
+ | **Decoding Speed (L4)** | **7.0 tok/s** | 5.5 tok/s | **+27.3% faster** |
 
 
 
 
 
 
 
29
 
30
+ <p align="center"><img src="assets/architecture_comparison.svg" width="920" alt="Benchmark" /></p>
 
 
31
 
32
+ ## How to Use
33
 
34
+ ```python
35
+ import sys, subprocess, torch
36
+ from huggingface_hub import hf_hub_download
37
+ from safetensors.torch import load_file
38
+ from transformers import AutoTokenizer
39
 
40
+ tokenizer = AutoTokenizer.from_pretrained('gpt2')
41
+ if 'maba-v1.5-exp-architecture' not in sys.path:
42
+ subprocess.run(['git', 'clone', 'https://huggingface.co/AndrewThompson1233/maba-v1.5-exp-architecture'], check=False)
43
+ sys.path.insert(0, 'maba-v1.5-exp-architecture')
44
 
45
+ from maba_sparse.config import MabaSparseConfig
46
+ from maba_sparse.model import MabaSparseForCausalLM
47
 
48
+ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
49
+ cfg = MabaSparseConfig(vocab_size=len(tokenizer), dim=640, d_emb=128, intermediate_size=1248, n_layers=20)
50
+ model = MabaSparseForCausalLM(cfg).to(device)
 
 
 
 
 
 
 
 
 
 
51
 
52
+ weights_path = hf_hub_download(repo_id='AndrewThompson1233/maba-1.5-103m', filename='model.safetensors')
53
+ model.load_state_dict(load_file(weights_path))
54
+ model.eval()
55
 
56
+ prompt = 'User: tell me a joke\\nAssistant: '
57
+ ids = tokenizer.encode(prompt, return_tensors='pt').to(device)
58
+ with torch.no_grad():
59
+ with torch.amp.autocast('cuda', dtype=torch.bfloat16):
60
+ out = model.generate(ids, max_new_tokens=35, temperature=0.0)
61
 
62
+ print(tokenizer.decode(out[0][ids.shape[1]:], skip_special_tokens=True).strip())
63
+ ```
 
 
 
 
assets/architecture_comparison.svg ADDED
assets/logo.svg CHANGED