voidstream commited on
Commit
23d844a
Β·
verified Β·
1 Parent(s): ebe7546

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +142 -0
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Zyphra/Zamba2-7B-instruct
4
+ tags:
5
+ - zamba2
6
+ - mamba
7
+ - hybrid
8
+ - compressed
9
+ - hxq
10
+ - helix-substrate
11
+ - vector-quantization
12
+ - helixcode
13
+ library_name: transformers
14
+ pipeline_tag: text-generation
15
+ model-index:
16
+ - name: zamba2-7b-instruct-hxq
17
+ results: []
18
+ ---
19
+
20
+ # Zamba2-7B-Instruct-HXQ
21
+
22
+ > **2.0x smaller from BF16. 81-layer hybrid Mamba2+Transformer. Largest HXQ hybrid model.**
23
+ >
24
+ > 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()`.
25
+
26
+ ## Install and Run
27
+
28
+ ```bash
29
+ pip install "helix-substrate[hf]"
30
+ ```
31
+
32
+ ```python
33
+ import helix_substrate # registers the HXQ quantizer with HuggingFace
34
+ from transformers import AutoModelForCausalLM, AutoTokenizer
35
+
36
+ model = AutoModelForCausalLM.from_pretrained("EchoLabs33/zamba2-7b-instruct-hxq")
37
+ tokenizer = AutoTokenizer.from_pretrained("EchoLabs33/zamba2-7b-instruct-hxq")
38
+
39
+ inputs = tokenizer("Explain the theory of relativity in simple terms:", return_tensors="pt")
40
+ outputs = model.generate(**inputs, max_new_tokens=128)
41
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
42
+ ```
43
+
44
+ That's it. `import helix_substrate` registers the quantizer. `from_pretrained()` handles the rest automatically.
45
+
46
+ ## Benchmark
47
+
48
+ | | Dense (BF16) | HXQ |
49
+ |---|---|---|
50
+ | **Size** | 14.7 GB | **7.5 GB** |
51
+ | **Perplexity** (WikiText-2) | pending | pending |
52
+ | **Compression ratio** | β€” | **2.0x** |
53
+ | **Compressed modules** | β€” | 213 HelixLinear layers |
54
+ | **Architecture** | Zamba2 (81 layers, Mamba2 + shared Transformer) | unchanged |
55
+
56
+ ## Verification Status
57
+
58
+ - **Compression receipt:** 213 compressed, 573 exact, 1425 total keys
59
+ - **Conversion receipt:** PASS (Gate 1 validated, SHA256 verified)
60
+ - **GPU eval receipt:** Awaiting GPU verification
61
+
62
+ ## Good to Know
63
+
64
+ - **GPU recommended** β€” 7.5 GB requires 10+ GB VRAM. Use `device_map="auto"` for multi-GPU.
65
+ - **Not fine-tunable** β€” compressed weights are read-only (`is_trainable = False`).
66
+ - **Requires `helix-substrate`** β€” the quantizer is not built into transformers. You need `pip install "helix-substrate[hf]"`.
67
+ - **Requires `transformers >= 4.45`** β€” for Zamba2 architecture support.
68
+ - **`mamba-ssm` recommended** β€” without it, falls back to a slower sequential code path.
69
+ - **PPL pending** β€” requires cloud GPU eval (model doesn't fit on 4 GB T2000).
70
+
71
+ ## What is HelixCode?
72
+
73
+ HelixCode is a universal weight compression codec based on vector quantization:
74
+
75
+ - Each weight matrix is replaced by a **256-entry codebook** (float32) + **uint8 index matrix** + optional **sidecar corrections** for outlier values
76
+ - The compressed form *is* the executable β€” `HelixLinear` performs `codebook[indices] @ x` directly, no decompression step
77
+ - Works on any `nn.Linear` regardless of architecture (Transformer, Mamba, MLP, CNN)
78
+ - **No calibration data required** β€” unlike GPTQ/AWQ, codebooks are fit from the weights alone
79
+
80
+ ## How It Works
81
+
82
+ 1. `import helix_substrate` registers the `hxq` quantizer with HuggingFace
83
+ 2. `from_pretrained()` reads `quantization_config.quant_method = "hxq"` from `config.json`
84
+ 3. The quantizer replaces 213 `nn.Linear` modules with `HelixLinear` shells before weight loading
85
+ 4. Safetensors populates the codebook, indices, and sidecar buffers directly
86
+ 5. The model runs in compressed form β€” no decompression needed
87
+
88
+ ## Architecture Details
89
+
90
+ Zamba2-7B-Instruct is a hybrid architecture with:
91
+ - **81 total layers** (Mamba2 + shared Transformer hybrid)
92
+ - **hidden_size=3584**, **attention_hidden_size=7168**, **32 attention heads**
93
+ - **mamba_d_state=64**, **mamba_d_conv=4**
94
+ - **vocab_size=32000**
95
+
96
+ 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.
97
+
98
+ ## Compression Receipt
99
+
100
+ ```
101
+ Compressed modules: 213
102
+ Exact tensors: 573 (norms, embeddings, conv1d, A_log, D, dt_bias, LoRA)
103
+ Skip tensors: 243 (from original model)
104
+ Total keys: 1425
105
+ Dense size: 14.7 GB (BF16)
106
+ Compressed size: 7.5 GB
107
+ Compression ratio: 2.0x
108
+ PPL delta: pending (cloud GPU eval)
109
+ Gate 1: PASS (structural validation + SHA256)
110
+ ```
111
+
112
+ ## Companion Models
113
+
114
+ Same codec, same `pip install`, multiple architectures:
115
+
116
+ | Model | Architecture | Ratio | PPL Delta |
117
+ |-------|-------------|-------|-----------|
118
+ | [qwen2.5-14b-instruct-helix](https://huggingface.co/EchoLabs33/qwen2.5-14b-instruct-helix) | Transformer | 3.4x | pending |
119
+ | [qwen2.5-7b-instruct-helix](https://huggingface.co/EchoLabs33/qwen2.5-7b-instruct-helix) | Transformer | 2.2x | +6.34% |
120
+ | [qwen2.5-3b-instruct-helix](https://huggingface.co/EchoLabs33/qwen2.5-3b-instruct-helix) | Transformer | 1.6x | +0.69% |
121
+ | [qwen2.5-coder-3b-helix](https://huggingface.co/EchoLabs33/qwen2.5-coder-3b-helix) | Transformer (code) | 1.6x | +1.92% |
122
+ | [qwen2.5-coder-1.5b-helix](https://huggingface.co/EchoLabs33/qwen2.5-coder-1.5b-helix) | Transformer (code) | 1.5x | +1.73% |
123
+ | [tinyllama-1.1b-helix](https://huggingface.co/EchoLabs33/tinyllama-1.1b-helix) | Transformer | 4.0x | +0.78% |
124
+ | [zamba2-2.7b-instruct-helix](https://huggingface.co/EchoLabs33/zamba2-2.7b-instruct-helix) | Hybrid (Mamba2+Transformer) | 1.8x | +6.59% |
125
+ | [zamba2-1.2b-helix](https://huggingface.co/EchoLabs33/zamba2-1.2b-helix) | Hybrid (Mamba2+Transformer) | 1.7x | +2.90% |
126
+ | [mamba2-1.3b-helix](https://huggingface.co/EchoLabs33/mamba2-1.3b-helix) | Pure SSM (Mamba2) | 2.1x | +8.0% |
127
+ | [mamba-130m-helix](https://huggingface.co/EchoLabs33/mamba-130m-helix) | Pure SSM | 3.8x | +18.4% |
128
+
129
+ ## Citation
130
+
131
+ ```bibtex
132
+ @software{helix_substrate_2026,
133
+ title={Helix Substrate: Universal Weight Compression via HelixCode},
134
+ author={EchoLabs},
135
+ year={2026},
136
+ url={https://github.com/echo313unfolding/helix-substrate}
137
+ }
138
+ ```
139
+
140
+ ## License
141
+
142
+ Apache 2.0 (inherited from [Zyphra/Zamba2-7B-instruct](https://huggingface.co/Zyphra/Zamba2-7B-instruct)).