voidstream commited on
Commit
dd754d3
Β·
verified Β·
1 Parent(s): 08e5d0c

fix: model card metadata (language, results, branding, ratios)

Browse files
Files changed (1) hide show
  1. README.md +75 -141
README.md CHANGED
@@ -1,4 +1,5 @@
1
  ---
 
2
  license: apache-2.0
3
  base_model: Zyphra/Zamba2-7B-instruct
4
  tags:
@@ -9,192 +10,125 @@ tags:
9
  - hxq
10
  - helix-substrate
11
  - vector-quantization
12
- - 2d-vq
13
- - 12bit-packing
14
  library_name: transformers
15
  pipeline_tag: text-generation
16
  model-index:
17
  - name: zamba2-7b-instruct-hxq
18
- results:
19
- - task:
20
- type: text-generation
21
- dataset:
22
- name: WikiText-2
23
- type: wikitext
24
- metrics:
25
- - name: Perplexity
26
- type: perplexity
27
- value: 3.8454
28
- - task:
29
- type: text-generation
30
- dataset:
31
- name: HellaSwag
32
- type: hellaswag
33
- metrics:
34
- - name: acc_norm
35
- type: acc_norm
36
- value: 0.8106
37
- - task:
38
- type: text-generation
39
- dataset:
40
- name: ARC-Challenge
41
- type: ai2_arc
42
- metrics:
43
- - name: acc_norm
44
- type: acc_norm
45
- value: 0.5811
46
- - task:
47
- type: text-generation
48
- dataset:
49
- name: ARC-Easy
50
- type: ai2_arc
51
- metrics:
52
- - name: acc_norm
53
- type: acc_norm
54
- value: 0.8190
55
  ---
56
 
57
  # Zamba2-7B-Instruct-HXQ
58
 
59
- > **2D Vector Quantization (k=4096) with 12-bit packed indices. 81-layer hybrid Mamba2+Transformer. Faster than dense at 60% less VRAM.**
60
-
61
- Zamba2-7B-Instruct compressed with HXQ 2D VQ and 12-bit index packing (6 bits/weight). Beats bnb 4-bit NF4 on quality, speed, and requires no calibration data.
62
-
63
- ## Benchmark: Native HelixLinear Inference on RTX 3090
64
-
65
- All numbers from a single session, same GPU, same WikiText-2 test set (50 chunks x 512 tokens).
66
-
67
- | Method | PPL | Throughput | VRAM (load) | VRAM (peak) | Bits/weight |
68
- |--------|-----|------------|-------------|-------------|-------------|
69
- | Dense BF16 | 4.82 | 1,446 tok/s | 14,032 MB | 14,686 MB | 16 |
70
- | bnb 8-bit | 4.85 | 515 tok/s | 7,831 MB | 8,635 MB | 8 |
71
- | bnb 4-bit NF4 | 5.07 | 1,579 tok/s | 5,129 MB | 5,904 MB | 4 |
72
- | **HXQ 12-bit packed** | **5.02** | **1,764 tok/s** | **5,657 MB** | **6,511 MB** | **6** |
73
-
74
- ### Cross-GPU Confirmation (RTX 4090)
75
-
76
- | Method | Throughput | VRAM (load) | VRAM (peak) | GPU |
77
- |--------|------------|-------------|-------------|-----|
78
- | **HXQ 12-bit packed** | **1,827 tok/s** | **5,692 MB** | **6,886 MB** | RTX 4090 |
79
-
80
- Independently reproduced on 2026-04-03. Receipt: [`triton_gather_speed_4090_fast.json`](https://huggingface.co/EchoLabs33/zamba2-7b-instruct-hxq/blob/main/triton_gather_speed_4090_fast.json).
81
-
82
- **Profiled breakdown (512-token prefill):**
83
- - HelixLinear (gather + matmul): 43% of forward time
84
- - Mamba SSM + attention + norms: 57% of forward time
85
- - Per-layer overhead: 0.66ms avg (gather 0.21ms + cuBLAS 0.32ms)
86
-
87
- ### Why HXQ wins
88
-
89
- - **Faster than dense** (1,764 vs 1,446 tok/s) -- fused Triton gather kernel eliminates memory bottleneck
90
- - **60% less VRAM** than dense (5.7 GB vs 14.0 GB)
91
- - **Better quality than bnb 4-bit** (5.02 vs 5.07 PPL) at comparable VRAM
92
- - **No calibration data required** -- unlike GPTQ, AWQ, or bnb, HXQ compresses from weights alone
93
-
94
- ## Downstream Task Evaluation (lm-eval-harness v0.4.11)
95
-
96
- Same GPU (RTX 3090), same harness, same settings. All metrics are `acc_norm`.
97
-
98
- | Task | Dense BF16 | HXQ 2D VQ | Delta |
99
- |------|-----------|-----------|-------|
100
- | **HellaSwag** | 80.79% | 81.06% | +0.27% |
101
- | **ARC-Challenge** | 59.39% | 58.11% | -1.28% |
102
- | **ARC-Easy** | 83.21% | 81.90% | -1.31% |
103
-
104
- Compression preserves task performance within noise. HellaSwag (commonsense reasoning) is slightly *better* under compression. ARC drops are within 1.3%.
105
 
106
  ## Install and Run
107
 
108
  ```bash
109
- pip install "helix-substrate>=0.3.3"
110
  ```
111
 
112
  ```python
113
- import helix_substrate # registers the HXQ quantizer
114
  from transformers import AutoModelForCausalLM, AutoTokenizer
115
 
116
- model = AutoModelForCausalLM.from_pretrained(
117
- "EchoLabs33/zamba2-7b-instruct-hxq",
118
- trust_remote_code=True,
119
- )
120
- tokenizer = AutoTokenizer.from_pretrained(
121
- "EchoLabs33/zamba2-7b-instruct-hxq",
122
- trust_remote_code=True,
123
- )
124
-
125
- inputs = tokenizer("The capital of France is", return_tensors="pt").to(model.device)
126
- outputs = model.generate(**inputs, max_new_tokens=32)
127
  print(tokenizer.decode(outputs[0], skip_special_tokens=True))
128
  ```
129
 
130
- **Important:** Requires `mamba-ssm` and `causal-conv1d` for full speed. Without these, Mamba2 layers fall back to a naive implementation (~9x slower). Install from source:
131
 
132
- ```bash
133
- pip install causal-conv1d
134
- pip install "mamba-ssm @ git+https://github.com/state-spaces/mamba.git@v2.2.2" --no-build-isolation
135
- ```
 
 
 
 
 
 
 
136
 
137
- Tested with `transformers>=4.46,<5.0` and `helix-substrate>=0.3.3`.
 
 
 
 
 
138
 
139
- ## Codec Details
140
 
141
- | Property | Value |
142
- |----------|-------|
143
- | **Quantization** | 2D Vector Quantization |
144
- | **Codebook size (k)** | 4,096 |
145
- | **Vector dimension** | 2 (pairs of adjacent weights) |
146
- | **Bits per weight** | 6 effective (12-bit packed index / 2 weights) |
147
- | **Index packing** | 12-bit (3 bytes per 2 indices, lossless) |
148
- | **Compressed modules** | 213 HelixLinear layers |
149
- | **Exact tensors** | 573 (norms, embeddings, conv1d, A_log, D, dt_bias) |
150
- | **Sidecar corrections** | Yes (sparse outlier compensation) |
151
- | **Calibration data** | None required |
152
- | **HXQ storage** | 5.7 GB (12-bit packed) |
153
- | **Dense BF16** | 14.0 GB |
154
 
155
- ### Why 2D VQ
 
 
 
156
 
157
- Standard scalar VQ assigns one codebook entry per weight. 2D VQ groups pairs of adjacent weights and clusters in R^2 -- the codebook captures the joint distribution. With k=4096 and 12-bit index packing, each pair of weights costs 12 bits = 6 bits per weight. This beats scalar k=256 (8 bits/weight) on both quality and compression.
158
 
159
- On Zamba2-7B, 2D VQ k=4096 achieves PPL 3.8454 vs the scalar baseline's higher PPL on this architecture. SSM and hybrid architectures benefit from 2D VQ more than pure Transformers.
 
 
 
 
160
 
161
- ## Architecture
162
 
163
- Zamba2-7B-Instruct is a hybrid architecture:
164
- - **81 total layers** (Mamba2 + shared Transformer)
165
  - **hidden_size=3584**, **attention_hidden_size=7168**, **32 attention heads**
166
  - **mamba_d_state=64**, **mamba_d_conv=4**
167
  - **vocab_size=32000**
168
 
169
- 213 linear layers compressed (Mamba projections, attention/MLP, LoRA adapters). Normalization layers, embeddings, conv1d, and Mamba-specific parameters stored at full precision.
170
 
171
- ## Verification
172
 
173
- - **RTX 3090 benchmark:** [`zamba2_7b_comparison.json`](https://huggingface.co/EchoLabs33/zamba2-7b-instruct-hxq/blob/main/zamba2_7b_comparison.json) -- 1,764 tok/s, 2026-04-02
174
- - **RTX 4090 confirmation:** [`triton_gather_speed_4090_fast.json`](https://huggingface.co/EchoLabs33/zamba2-7b-instruct-hxq/blob/main/triton_gather_speed_4090_fast.json) -- 1,827 tok/s, 2026-04-03
175
- - **Conversion receipt:** [`conversion_receipt.json`](https://huggingface.co/EchoLabs33/zamba2-7b-instruct-hxq/blob/main/conversion_receipt.json) -- Gate 1 PASS
176
- - **helix-substrate version:** 0.3.3 (12-bit packing, fused Triton gather)
 
 
 
 
 
 
 
177
 
178
  ## Companion Models
179
 
180
- | Model | Architecture | PPL Delta |
181
- |-------|-------------|-----------|
182
- | [qwen2.5-14b-instruct-hxq](https://huggingface.co/EchoLabs33/qwen2.5-14b-instruct-hxq) | Transformer | pending |
183
- | [qwen2.5-7b-instruct-hxq](https://huggingface.co/EchoLabs33/qwen2.5-7b-instruct-hxq) | Transformer | +6.34% |
184
- | [qwen2.5-3b-instruct-hxq](https://huggingface.co/EchoLabs33/qwen2.5-3b-instruct-hxq) | Transformer | +0.69% |
185
- | [zamba2-2.7b-instruct-hxq](https://huggingface.co/EchoLabs33/zamba2-2.7b-instruct-hxq) | Hybrid | +6.59% |
186
- | [zamba2-1.2b-hxq](https://huggingface.co/EchoLabs33/zamba2-1.2b-hxq) | Hybrid | +2.90% |
187
- | [mamba2-1.3b-hxq](https://huggingface.co/EchoLabs33/mamba2-1.3b-hxq) | Pure SSM | +8.0% |
188
- | [tinyllama-1.1b-hxq](https://huggingface.co/EchoLabs33/tinyllama-1.1b-hxq) | Transformer | +0.78% |
 
 
 
 
 
189
 
190
  ## Citation
191
 
192
  ```bibtex
193
  @software{helix_substrate_2026,
194
- title={Helix Substrate: Universal Weight Compression via HXQ},
195
  author={EchoLabs},
196
  year={2026},
197
- url={https://pypi.org/project/helix-substrate/}
198
  }
199
  ```
200
 
 
1
  ---
2
+ language: en
3
  license: apache-2.0
4
  base_model: Zyphra/Zamba2-7B-instruct
5
  tags:
 
10
  - hxq
11
  - helix-substrate
12
  - vector-quantization
13
+ - helixcode
 
14
  library_name: transformers
15
  pipeline_tag: text-generation
16
  model-index:
17
  - name: zamba2-7b-instruct-hxq
18
+ results: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ---
20
 
21
  # Zamba2-7B-Instruct-HXQ
22
 
23
+ > **2.0x smaller from BF16. 81-layer hybrid Mamba2+Transformer. Largest HXQ hybrid model.**
24
+ >
25
+ > Zamba2-7B-Instruct compressed from 14.7 GB (BF16) to 7.5 GB. 213 linear layers compressed, 573 exact tensors preserved. No calibration data. Just `pip install` and `from_pretrained()`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  ## Install and Run
28
 
29
  ```bash
30
+ pip install "helix-substrate[hf]"
31
  ```
32
 
33
  ```python
34
+ import helix_substrate # registers the HXQ quantizer with HuggingFace
35
  from transformers import AutoModelForCausalLM, AutoTokenizer
36
 
37
+ model = AutoModelForCausalLM.from_pretrained("EchoLabs33/zamba2-7b-instruct-hxq")
38
+ tokenizer = AutoTokenizer.from_pretrained("EchoLabs33/zamba2-7b-instruct-hxq")
39
+
40
+ inputs = tokenizer("Explain the theory of relativity in simple terms:", return_tensors="pt")
41
+ outputs = model.generate(**inputs, max_new_tokens=128)
 
 
 
 
 
 
42
  print(tokenizer.decode(outputs[0], skip_special_tokens=True))
43
  ```
44
 
45
+ That's it. `import helix_substrate` registers the quantizer. `from_pretrained()` handles the rest automatically.
46
 
47
+ ## Benchmark
48
+
49
+ | | Dense (BF16) | HXQ |
50
+ |---|---|---|
51
+ | **Size** | 14.7 GB | **7.5 GB** |
52
+ | **Perplexity** (WikiText-2) | pending | pending |
53
+ | **Compression ratio** | β€” | **2.0x** |
54
+ | **Compressed modules** | β€” | 213 HelixLinear layers |
55
+ | **Architecture** | Zamba2 (81 layers, Mamba2 + shared Transformer) | unchanged |
56
+
57
+ ## Good to Know
58
 
59
+ - **GPU recommended** β€” 7.5 GB requires 10+ GB VRAM. Use `device_map="auto"` for multi-GPU.
60
+ - **Not fine-tunable** β€” compressed weights are read-only (`is_trainable = False`).
61
+ - **Requires `helix-substrate`** β€” the quantizer is not built into transformers. You need `pip install "helix-substrate[hf]"`.
62
+ - **Requires `transformers >= 4.45`** β€” for Zamba2 architecture support.
63
+ - **`mamba-ssm` recommended** β€” without it, falls back to a slower sequential code path.
64
+ - **PPL pending** β€” requires cloud GPU eval (model doesn't fit on 4 GB T2000).
65
 
66
+ ## What is HelixCode?
67
 
68
+ HelixCode is a universal weight compression codec based on vector quantization:
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ - Each weight matrix is replaced by a **256-entry codebook** (float32) + **uint8 index matrix** + optional **sidecar corrections** for outlier values
71
+ - The compressed form *is* the executable β€” `HelixLinear` performs `codebook[indices] @ x` directly, no decompression step
72
+ - Works on any `nn.Linear` regardless of architecture (Transformer, Mamba, MLP, CNN)
73
+ - **No calibration data required** β€” unlike GPTQ/AWQ, codebooks are fit from the weights alone
74
 
75
+ ## How It Works
76
 
77
+ 1. `import helix_substrate` registers the `hxq` quantizer with HuggingFace
78
+ 2. `from_pretrained()` reads `quantization_config.quant_method = "hxq"` from `config.json`
79
+ 3. The quantizer replaces 213 `nn.Linear` modules with `HelixLinear` shells before weight loading
80
+ 4. Safetensors populates the codebook, indices, and sidecar buffers directly
81
+ 5. The model runs in compressed form β€” no decompression needed
82
 
83
+ ## Architecture Details
84
 
85
+ Zamba2-7B-Instruct is a hybrid architecture with:
86
+ - **81 total layers** (Mamba2 + shared Transformer hybrid)
87
  - **hidden_size=3584**, **attention_hidden_size=7168**, **32 attention heads**
88
  - **mamba_d_state=64**, **mamba_d_conv=4**
89
  - **vocab_size=32000**
90
 
91
+ 213 linear layers compressed (162 Mamba projections, 38 attention/MLP, 26 LoRA adapters). Normalization layers, embeddings, conv1d, and Mamba-specific parameters (A_log, D, dt_bias) are stored at full precision.
92
 
93
+ ## Compression Receipt
94
 
95
+ ```
96
+ Compressed modules: 213
97
+ Exact tensors: 573 (norms, embeddings, conv1d, A_log, D, dt_bias, LoRA)
98
+ Skip tensors: 243 (from original model)
99
+ Total keys: 1425
100
+ Dense size: 14.7 GB (BF16)
101
+ Compressed size: 7.5 GB
102
+ Compression ratio: 2.0x
103
+ PPL delta: pending (cloud GPU eval)
104
+ Gate 1: PASS (structural validation + SHA256)
105
+ ```
106
 
107
  ## Companion Models
108
 
109
+ Same codec, same `pip install`, multiple architectures:
110
+
111
+ | Model | Architecture | Ratio | PPL Delta |
112
+ |-------|-------------|-------|-----------|
113
+ | [qwen2.5-14b-instruct-helix](https://huggingface.co/EchoLabs33/qwen2.5-14b-instruct-helix) | Transformer | 3.4x | pending |
114
+ | [qwen2.5-7b-instruct-helix](https://huggingface.co/EchoLabs33/qwen2.5-7b-instruct-helix) | Transformer | 2.2x | +6.34% |
115
+ | [qwen2.5-3b-instruct-helix](https://huggingface.co/EchoLabs33/qwen2.5-3b-instruct-helix) | Transformer | 1.6x | +0.69% |
116
+ | [qwen2.5-coder-3b-helix](https://huggingface.co/EchoLabs33/qwen2.5-coder-3b-helix) | Transformer (code) | 1.6x | +1.92% |
117
+ | [qwen2.5-coder-1.5b-instruct-helix](https://huggingface.co/EchoLabs33/qwen2.5-coder-1.5b-instruct-helix) | Transformer (code) | 2.4x | +1.63% |
118
+ | [tinyllama-1.1b-helix](https://huggingface.co/EchoLabs33/tinyllama-1.1b-helix) | Transformer | 4.0x | +0.78% |
119
+ | [zamba2-2.7b-instruct-helix](https://huggingface.co/EchoLabs33/zamba2-2.7b-instruct-helix) | Hybrid (Mamba2+Transformer) | 1.8x | +6.59% |
120
+ | [zamba2-1.2b-helix](https://huggingface.co/EchoLabs33/zamba2-1.2b-helix) | Hybrid (Mamba2+Transformer) | 1.7x | +2.90% |
121
+ | [mamba2-1.3b-helix](https://huggingface.co/EchoLabs33/mamba2-1.3b-helix) | Pure SSM (Mamba2) | 2.1x | +8.0% |
122
+ | [mamba-130m-helix](https://huggingface.co/EchoLabs33/mamba-130m-helix) | Pure SSM | 3.8x | +18.4% |
123
 
124
  ## Citation
125
 
126
  ```bibtex
127
  @software{helix_substrate_2026,
128
+ title={Helix Substrate: Universal Weight Compression via HelixCode},
129
  author={EchoLabs},
130
  year={2026},
131
+ url={https://github.com/echo313unfolding/helix-substrate}
132
  }
133
  ```
134