Zahid2005 commited on
Commit
2155933
·
verified ·
1 Parent(s): b423e33

Add authentic research paper preprint DOI citation (Zenodo: 10.5281/zenodo.22747827)

Browse files
Files changed (1) hide show
  1. README.md +165 -158
README.md CHANGED
@@ -1,159 +1,166 @@
1
- ---
2
- language:
3
- - en
4
- license: mit
5
- tags:
6
- - pytorch
7
- - causal-lm
8
- - 1b
9
- - edge-ai
10
- - hypergqe
11
- - dynamic-attention
12
- - grouped-query-attention
13
- - text-generation
14
- pipeline_tag: text-generation
15
- inference: false
16
- ---
17
-
18
- # Maria-1B (20B Tokens Pretrained from Scratch)
19
-
20
- **Maria-1B** is a compact 1.07B parameter causal language model pretrained from scratch on a **20 Billion token budget**. It introduces **HyperGQE** (Dynamic Query Adaptation), a novel sparse attention architecture that breaks the traditional trade-off between KV-cache compression and query representational collapse.
21
-
22
- Unlike static Grouped Query Experts (GQE) which permanently drop unselected query heads, Maria dynamically conditions query projections using a lightweight context hypernetwork. This enables the model to achieve **higher throughput and lower memory usage than Dense GQA** while **surpassing Dense GQA in classification accuracy and STEM reasoning**.
23
-
24
- ---
25
-
26
- ## Model Specifications
27
-
28
- | Parameter | Value |
29
- | :--- | :--- |
30
- | **Total Instantiated Parameters** | **1,073,515,904 (1.074 Billion)** |
31
- | **Active Parameters per Token** | **1,016,878,976 (1.017 Billion)** |
32
- | **Sparsity per Block** | 12 out of 16 query expert heads dropped per layer (56.6M inactive params) |
33
- | **Pretraining Token Budget** | **20 Billion Tokens** (Trained from scratch) |
34
- | **Hidden Dimension ($d_{\text{model}}$)** | 2,048 |
35
- | **Number of Layers** | 18 Transformer Blocks |
36
- | **Query Heads ($N_{\text{heads}}$)** | 16 (4 groups $\times$ 4 expert heads per group) |
37
- | **Key-Value Heads ($N_{\text{kv}}$)** | 4 (Grouped-Query Attention 4:1 compression) |
38
- | **Intermediate Size (FFN)** | 5,632 (SwiGLU gating) |
39
- | **Vocabulary Size** | 128,256 (Llama-3 BPE Tokenizer) |
40
- | **Context Length ($L_{\text{max}}$)** | 8,192 tokens with RoPE ($\theta = 500,000$) |
41
- | **Weight Precision** | `bfloat16` (~2.1 GB storage / ~650 MB quantized Q4_K_M) |
42
-
43
- ---
44
-
45
- ## Hardware Profiling & Latency Benchmarks
46
-
47
- Measured on identical NVIDIA hardware comparing **Maria (HyperGQE)** against **Dense GQA** and **Static GQE**:
48
-
49
- ### Throughput & Latency Comparison
50
-
51
- | Batch Size ($b$) | Sequence Length ($s$) | Dense GQA Latency | Static GQE Latency | **Maria (HyperGQE)** Latency | **Maria vs. Dense GQA Speedup** |
52
- | :---: | :---: | :---: | :---: | :---: | :---: |
53
- | 1 | 512 | 103.50 ms | 90.47 ms | **106.55 ms** | Competitive |
54
- | 1 | 1024 | 227.76 ms | 161.53 ms | **204.36 ms** | **+10.3% faster** |
55
- | 8 | 512 | 763.26 ms | 591.01 ms | **716.07 ms** | **+6.2% faster** |
56
- | 8 | 1024 | 1,750.23 ms | 1,161.57 ms | **1,421.50 ms** | **+18.8% faster** |
57
- | 16 | 512 | 1,475.45 ms | 1,114.95 ms | **1,361.72 ms** | **+7.7% faster** |
58
- | **16** | **1024 (Heavy Load)** | **3,526.88 ms** | **2,333.79 ms** | **3,049.37 ms** | **+13.5% FASTER** |
59
-
60
- ### VRAM & Throughput (Heavy Load: $b=16, s=1024$)
61
-
62
- | Architecture | Peak VRAM | Throughput | Theoretical FLOPs |
63
- | :--- | :---: | :---: | :---: |
64
- | **Dense GQA Baseline** | 4,181.55 MB | 4,645 tokens/s | $3.60 \times 10^{13}$ |
65
- | **Static GQE (Sparse)** | 2,456.19 MB | 7,020 tokens/s | $3.31 \times 10^{13}$ |
66
- | **Maria (HyperGQE)** | **3,354.19 MB** *(827 MB less)* | **5,372 tokens/s** *(+15.6% higher)* | **$3.60 \times 10^{13}$** |
67
-
68
- > **Key Hardware Takeaway:** Under maximum sequence and batch workloads, Maria is **13.5% faster** than Dense GQA while consuming **827 MB less VRAM**, maintaining an identical FLOP budget.
69
-
70
- ---
71
-
72
- ## Downstream Accuracy Benchmarks
73
-
74
- While static query routing (GQE) suffers from severe information loss due to hard-dropping query heads, Maria's dynamic hypernetwork compensates for unselected heads:
75
-
76
- ### 1. Fine-Tuned Sentiment Classification (SST-2)
77
-
78
- | Architecture | Total Parameters | Active Parameters | SST-2 Accuracy | Margin vs. Dense |
79
- | :--- | :---: | :---: | :---: | :---: |
80
- | **GQE (Static Sparse)** | 875.39 M | 875.39 M | 75.92% | -4.24% *(Degradation)* |
81
- | **Dense GQA Baseline** | 946.04 M | 946.04 M | 80.16% | Baseline |
82
- | **Maria (HyperGQE)** | **924.13 M** | **843.35 M** | **80.85%** | **+0.69% HIGHER** |
83
-
84
- *Maria completely eliminates the 4.24% sparsity collapse of static GQE and pushes past the dense baseline by +0.69%.*
85
-
86
- ### 2. Zero-Shot STEM Domain Recovery (16 Benchmarks)
87
-
88
- When compared against static sparse routing, Maria demonstrates pronounced accuracy gains in knowledge-intensive STEM domains:
89
-
90
- | Domain / Task | Static GQE Accuracy | Maria (HyperGQE) Accuracy | Net Margin ($\Delta$) |
91
- | :--- | :---: | :---: | :---: |
92
- | **MMLU: College Chemistry** | 19.0% | **28.0%** | **+9.0%** |
93
- | **MMLU: College Biology** | 22.2% | **26.3%** | **+4.1%** |
94
- | **MMLU: High School Biology** | 21.0% | **25.8%** | **+4.8%** |
95
- | **MMLU: High School Chemistry** | 19.2% | **22.7%** | **+3.5%** |
96
- | **MMLU: Medical Genetics** | 23.0% | **27.0%** | **+4.0%** |
97
- | **MMLU: Virology** | 24.1% | **28.3%** | **+4.2%** |
98
- | **ARC (Challenge)** | 21.8% | **23.3%** | **+1.5%** |
99
- | **ARC (Easy)** | 41.5% | **42.9%** | **+1.4%** |
100
- | **BoolQ** | 57.0% | **58.2%** | **+1.2%** |
101
-
102
- ---
103
-
104
- ## Quickstart Usage
105
-
106
- You can load and run Maria directly with Hugging Face `transformers` using `trust_remote_code=True`:
107
-
108
- ```python
109
- import torch
110
- from transformers import AutoModelForCausalLM, AutoTokenizer
111
-
112
- model_id = "your-username/Maria-1B-20Btokens"
113
-
114
- tokenizer = AutoTokenizer.from_pretrained(model_id)
115
- model = AutoModelForCausalLM.from_pretrained(
116
- model_id,
117
- torch_dtype=torch.bfloat16,
118
- device_map="auto",
119
- trust_remote_code=True
120
- )
121
-
122
- prompt = "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\nYou are Maria, a helpful AI assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>\nWhat is the capital of France?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n"
123
-
124
- inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
125
-
126
- with torch.inference_mode():
127
- outputs = model.generate(
128
- **inputs,
129
- max_new_tokens=60,
130
- temperature=0.15,
131
- do_sample=True,
132
- pad_token_id=tokenizer.eos_token_id
133
- )
134
-
135
- print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
136
- # Output: The capital of France is Paris.
137
- ```
138
-
139
- ---
140
-
141
- ## Quantization & Edge Deployment
142
-
143
- Because Maria has dense FFNs and structured query sparsity, it is an optimal model for on-device and mobile deployment:
144
- * **4-bit Quantization (GGUF / Q4_K_M)**: Compresses the model to **~650 MB**.
145
- * **RAM Requirement**: Requires only **~800 MB of RAM**, running at 45–60 tokens/sec on mobile Snapdragon/MediaTek/Apple Silicon chips with zero cloud API costs.
146
-
147
- ---
148
-
149
- ## Citation
150
-
151
- If you use Maria or the HyperGQE architecture in your research, please cite:
152
-
153
- ```bibtex
154
- @article{maria2026hypergqe,
155
- title={HyperGQE: Dynamic Query Adaptation for Knowledge Recovery in Compressed Attention Models},
156
- author={Yadki Zahid Ahmed and Contributors},
157
- year={2026}
158
- }
159
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ tags:
6
+ - pytorch
7
+ - causal-lm
8
+ - 1b
9
+ - edge-ai
10
+ - hypergqe
11
+ - dynamic-attention
12
+ - grouped-query-attention
13
+ - text-generation
14
+ pipeline_tag: text-generation
15
+ inference: false
16
+ ---
17
+
18
+ # Maria-1B (20B Tokens Pretrained from Scratch)
19
+
20
+ **Maria-1B** is a compact 1.07B parameter causal language model pretrained from scratch on a **20 Billion token budget**. It introduces **HyperGQE** (Dynamic Query Adaptation), a novel sparse attention architecture that breaks the traditional trade-off between KV-cache compression and query representational collapse.
21
+
22
+ Unlike static Grouped Query Experts (GQE) which permanently drop unselected query heads, Maria dynamically conditions query projections using a lightweight context hypernetwork. This enables the model to achieve **higher throughput and lower memory usage than Dense GQA** while **surpassing Dense GQA in classification accuracy and STEM reasoning**.
23
+
24
+ * **Research Paper Preprint**: [https://doi.org/10.5281/zenodo.22747827](https://doi.org/10.5281/zenodo.22747827)
25
+ * **Author**: Yadki Zahid Ahmed
26
+
27
+ ---
28
+
29
+ ## Model Specifications
30
+
31
+ | Parameter | Value |
32
+ | :--- | :--- |
33
+ | **Total Instantiated Parameters** | **1,073,515,904 (1.074 Billion)** |
34
+ | **Active Parameters per Token** | **1,016,878,976 (1.017 Billion)** |
35
+ | **Sparsity per Block** | 12 out of 16 query expert heads dropped per layer (56.6M inactive params) |
36
+ | **Pretraining Token Budget** | **20 Billion Tokens** (Trained from scratch) |
37
+ | **Hidden Dimension ($d_{\text{model}}$)** | 2,048 |
38
+ | **Number of Layers** | 18 Transformer Blocks |
39
+ | **Query Heads ($N_{\text{heads}}$)** | 16 (4 groups $\times$ 4 expert heads per group) |
40
+ | **Key-Value Heads ($N_{\text{kv}}$)** | 4 (Grouped-Query Attention 4:1 compression) |
41
+ | **Intermediate Size (FFN)** | 5,632 (SwiGLU gating) |
42
+ | **Vocabulary Size** | 128,256 (Llama-3 BPE Tokenizer) |
43
+ | **Context Length ($L_{\text{max}}$)** | 8,192 tokens with RoPE ($\theta = 500,000$) |
44
+ | **Weight Precision** | `bfloat16` (~2.1 GB storage / ~650 MB quantized Q4_K_M) |
45
+
46
+ ---
47
+
48
+ ## Hardware Profiling & Latency Benchmarks
49
+
50
+ Measured on identical NVIDIA hardware comparing **Maria (HyperGQE)** against **Dense GQA** and **Static GQE**:
51
+
52
+ ### Throughput & Latency Comparison
53
+
54
+ | Batch Size ($b$) | Sequence Length ($s$) | Dense GQA Latency | Static GQE Latency | **Maria (HyperGQE)** Latency | **Maria vs. Dense GQA Speedup** |
55
+ | :---: | :---: | :---: | :---: | :---: | :---: |
56
+ | 1 | 512 | 103.50 ms | 90.47 ms | **106.55 ms** | Competitive |
57
+ | 1 | 1024 | 227.76 ms | 161.53 ms | **204.36 ms** | **+10.3% faster** |
58
+ | 8 | 512 | 763.26 ms | 591.01 ms | **716.07 ms** | **+6.2% faster** |
59
+ | 8 | 1024 | 1,750.23 ms | 1,161.57 ms | **1,421.50 ms** | **+18.8% faster** |
60
+ | 16 | 512 | 1,475.45 ms | 1,114.95 ms | **1,361.72 ms** | **+7.7% faster** |
61
+ | **16** | **1024 (Heavy Load)** | **3,526.88 ms** | **2,333.79 ms** | **3,049.37 ms** | **+13.5% FASTER** |
62
+
63
+ ### VRAM & Throughput (Heavy Load: $b=16, s=1024$)
64
+
65
+ | Architecture | Peak VRAM | Throughput | Theoretical FLOPs |
66
+ | :--- | :---: | :---: | :---: |
67
+ | **Dense GQA Baseline** | 4,181.55 MB | 4,645 tokens/s | $3.60 \times 10^{13}$ |
68
+ | **Static GQE (Sparse)** | 2,456.19 MB | 7,020 tokens/s | $3.31 \times 10^{13}$ |
69
+ | **Maria (HyperGQE)** | **3,354.19 MB** *(827 MB less)* | **5,372 tokens/s** *(+15.6% higher)* | **$3.60 \times 10^{13}$** |
70
+
71
+ > **Key Hardware Takeaway:** Under maximum sequence and batch workloads, Maria is **13.5% faster** than Dense GQA while consuming **827 MB less VRAM**, maintaining an identical FLOP budget.
72
+
73
+ ---
74
+
75
+ ## Downstream Accuracy Benchmarks
76
+
77
+ While static query routing (GQE) suffers from severe information loss due to hard-dropping query heads, Maria's dynamic hypernetwork compensates for unselected heads:
78
+
79
+ ### 1. Fine-Tuned Sentiment Classification (SST-2)
80
+
81
+ | Architecture | Total Parameters | Active Parameters | SST-2 Accuracy | Margin vs. Dense |
82
+ | :--- | :---: | :---: | :---: | :---: |
83
+ | **GQE (Static Sparse)** | 875.39 M | 875.39 M | 75.92% | -4.24% *(Degradation)* |
84
+ | **Dense GQA Baseline** | 946.04 M | 946.04 M | 80.16% | Baseline |
85
+ | **Maria (HyperGQE)** | **924.13 M** | **843.35 M** | **80.85%** | **+0.69% HIGHER** |
86
+
87
+ *Maria completely eliminates the 4.24% sparsity collapse of static GQE and pushes past the dense baseline by +0.69%.*
88
+
89
+ ### 2. Zero-Shot STEM Domain Recovery (16 Benchmarks)
90
+
91
+ When compared against static sparse routing, Maria demonstrates pronounced accuracy gains in knowledge-intensive STEM domains:
92
+
93
+ | Domain / Task | Static GQE Accuracy | Maria (HyperGQE) Accuracy | Net Margin ($\Delta$) |
94
+ | :--- | :---: | :---: | :---: |
95
+ | **MMLU: College Chemistry** | 19.0% | **28.0%** | **+9.0%** |
96
+ | **MMLU: College Biology** | 22.2% | **26.3%** | **+4.1%** |
97
+ | **MMLU: High School Biology** | 21.0% | **25.8%** | **+4.8%** |
98
+ | **MMLU: High School Chemistry** | 19.2% | **22.7%** | **+3.5%** |
99
+ | **MMLU: Medical Genetics** | 23.0% | **27.0%** | **+4.0%** |
100
+ | **MMLU: Virology** | 24.1% | **28.3%** | **+4.2%** |
101
+ | **ARC (Challenge)** | 21.8% | **23.3%** | **+1.5%** |
102
+ | **ARC (Easy)** | 41.5% | **42.9%** | **+1.4%** |
103
+ | **BoolQ** | 57.0% | **58.2%** | **+1.2%** |
104
+
105
+ ---
106
+
107
+ ## Quickstart Usage
108
+
109
+ You can load and run Maria directly with Hugging Face `transformers` using `trust_remote_code=True`:
110
+
111
+ ```python
112
+ import torch
113
+ from transformers import AutoModelForCausalLM, AutoTokenizer
114
+
115
+ model_id = "your-username/Maria-1B-20Btokens"
116
+
117
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
118
+ model = AutoModelForCausalLM.from_pretrained(
119
+ model_id,
120
+ torch_dtype=torch.bfloat16,
121
+ device_map="auto",
122
+ trust_remote_code=True
123
+ )
124
+
125
+ prompt = "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\nYou are Maria, a helpful AI assistant.<|eot_id|><|start_header_id|>user<|end_header_id|>\nWhat is the capital of France?<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n"
126
+
127
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
128
+
129
+ with torch.inference_mode():
130
+ outputs = model.generate(
131
+ **inputs,
132
+ max_new_tokens=60,
133
+ temperature=0.15,
134
+ do_sample=True,
135
+ pad_token_id=tokenizer.eos_token_id
136
+ )
137
+
138
+ print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
139
+ # Output: The capital of France is Paris.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  ```
141
+
142
+ ---
143
+
144
+ ## Quantization & Edge Deployment
145
+
146
+ Because Maria has dense FFNs and structured query sparsity, it is an optimal model for on-device and mobile deployment:
147
+ * **4-bit Quantization (GGUF / Q4_K_M)**: Compresses the model to **~650 MB**.
148
+ * **RAM Requirement**: Requires only **~800 MB of RAM**, running at 45–60 tokens/sec on mobile Snapdragon/MediaTek/Apple Silicon chips with zero cloud API costs.
149
+
150
+ ---
151
+
152
+ ## Citation
153
+
154
+ If you use Maria-1B or build upon the architecture in your research, please cite the official research paper preprint:
155
+
156
+ `ibtex
157
+ @article{yadki2026sparseattention,
158
+ title={CAN WE IMPROVE THE PERFORMANCE OF SPARSE ATTENTION IN GROUPED QUERY EXPERTS WITHOUT INCREASING EXPERTS?},
159
+ author={Yadki, Zahid Ahmed},
160
+ journal={Zenodo},
161
+ year={2026},
162
+ month={September},
163
+ doi={10.5281/zenodo.22747827},
164
+ url={https://doi.org/10.5281/zenodo.22747827}
165
+ }
166
+ `