File size: 9,147 Bytes
f52bbda
 
 
 
 
 
 
 
 
 
 
88aeef8
f52bbda
 
 
 
 
e4b1968
 
 
f52bbda
 
88aeef8
f52bbda
88aeef8
f52bbda
88aeef8
f52bbda
88aeef8
 
 
 
 
f52bbda
932bccf
 
88aeef8
932bccf
88aeef8
e4b1968
88aeef8
 
e4b1968
88aeef8
e4b1968
88aeef8
e4b1968
932bccf
e4b1968
932bccf
e4b1968
932bccf
e4b1968
932bccf
88aeef8
932bccf
88aeef8
 
 
 
932bccf
88aeef8
932bccf
88aeef8
932bccf
e4b1968
932bccf
e4b1968
 
 
 
 
88aeef8
932bccf
88aeef8
932bccf
 
 
e4b1968
f52bbda
88aeef8
f52bbda
88aeef8
 
f52bbda
e4b1968
f52bbda
e4b1968
f52bbda
e4b1968
f52bbda
e4b1968
f52bbda
e4b1968
 
 
 
 
 
 
 
 
 
 
 
 
f52bbda
88aeef8
f52bbda
88aeef8
 
 
 
 
 
f52bbda
88aeef8
e4b1968
 
f52bbda
e4b1968
f52bbda
88aeef8
 
 
 
f52bbda
88aeef8
e4b1968
 
 
 
f52bbda
88aeef8
f52bbda
88aeef8
f52bbda
e4b1968
88aeef8
e4b1968
 
88aeef8
 
 
f52bbda
 
88aeef8
f52bbda
 
88aeef8
 
 
f52bbda
 
88aeef8
 
 
f52bbda
 
88aeef8
f52bbda
 
88aeef8
f52bbda
 
88aeef8
 
 
 
 
 
 
 
f52bbda
88aeef8
f52bbda
88aeef8
f52bbda
88aeef8
e4b1968
88aeef8
 
 
 
 
 
e4b1968
88aeef8
f52bbda
88aeef8
f52bbda
88aeef8
f52bbda
88aeef8
f52bbda
88aeef8
e4b1968
88aeef8
e4b1968
88aeef8
e4b1968
 
 
 
 
88aeef8
 
 
 
 
e4b1968
 
f52bbda
 
 
e4b1968
88aeef8
e4b1968
88aeef8
e4b1968
 
 
 
f52bbda
88aeef8
f52bbda
e4b1968
88aeef8
 
 
 
 
 
f52bbda
88aeef8
e4b1968
88aeef8
 
 
 
f52bbda
e4b1968
f52bbda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4b1968
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
---
license: apache-2.0
base_model: Qwen/Qwen3.6-35B-A3B
base_model_relation: quantized
language:
  - en
pipeline_tag: text-generation
library_name: spiral
tags:
  - spiral
  - quantization
  - calibration-free
  - gguf
  - llama-cpp
  - qwen
  - qwen3.6
  - moe
  - apple-silicon
  - cuda
  - metal
---

# Qwen3.6-35B-A3B Spiral

**Release v0.3.0 β€” Spiral_4_5 scheme**

**Calibration-free 5 bpw compression of Qwen3.6-35B-A3B.** Competitive with unsloth Q4_K_M on HumanEval (91.5% vs 93.3% base pass@1) at similar artifact size β€” **without calibration data, without fine-tuning, without representative samples**. Production-stable on Apple Silicon (Metal) and NVIDIA H100 (CUDA). 91 tok/s decode on H100.

This is the v0.3.0 release of Spiral compression applied to [Qwen/Qwen3.6-35B-A3B](https://huggingface.co/Qwen/Qwen3.6-35B-A3B) β€” the hybrid MoE + DeltaNet architecture from Qwen.

**v0.3.0 supersedes v0.2.0** (the prior INT3 release). The new release is a different point in the quality/size Pareto: cleaner inference, parity with Q4-class quants on coding benchmarks, and cross-platform shipping.

![Qwen3.6-35B-A3B Spiral v0.3.0 release results](spiral_release_slide.svg)

---

## What's new vs v0.2.0

| Aspect | v0.2.0 | v0.3.0 (this release) |
|---|---|---|
| Average compression | 3.5 bpw | ~5.0 bpw |
| NLL vs bf16 | +0.113 nats | ~0 nats |
| HumanEval pass@1 | not measured | 0.915 base / 0.866 plus |
| Multi-turn on Mac | broken | works |
| CUDA support | not shipped | shipped |
| Calibration data | not required | not required |
| Production status | research preview | shippable |

---

## Quality

### HumanEval pass@1

Measured on H100 with llama-server + evalplus, greedy decoding (`temp=0`), thinking mode disabled:

| Method | bpw | Calibration data | HumanEval base | HumanEval+ |
|---|---|---|---|---|
| **Spiral_4_5 (this model)** | **~5.0** | **None** | **0.915** | **0.866** |
| unsloth Q4_K_M (reference) | 4.6 | Yes (imatrix) | 0.933* | 0.902* |

\* Q4_K_M reference numbers from [unsloth's community leaderboard submission](https://github.com/evalplus/evalplus/issues/299).

Spiral_4_5 is **1.8 percentage points behind Q4_K_M on base HumanEval, 3.6 points behind on HumanEval+** β€” and is calibration-free. K-quants require representative data to construct importance matrices for outlier handling; Spiral derives its compression analytically. The model's coding capability is preserved within striking distance of one of the strongest community quantization schemes, without the calibration overhead.

### Perplexity (wikitext-2-raw-v1)

| Method | bpw | NLL (nats/token) | Gap vs bf16 |
|---|---|---|---|
| bf16 (reference) | 16.0 | 1.8968 | β€” |
| unsloth Q8_0 | 8.5 | 1.8962 | βˆ’0.0006 |
| unsloth Q4_K_XL | 5.2 | 1.8976 | +0.0008 |
| **Spiral_4_5** | **~5.0** | **β‰ˆ1.8929** | **β‰ˆβˆ’0.004** |

Spiral_4_5 is competitive with Q4_K_XL on perplexity.

---

## Cross-platform validation

The same artifact runs on both Metal (Apple Silicon) and CUDA (NVIDIA H100). Output equivalence has been validated by side-by-side comparison on identical greedy prompts:

- Short prompts: byte-identical outputs across both platforms
- Long generations: semantically equivalent reasoning, with minor token-level drift from fp16 ordering differences in the deep stack

HumanEval is measured on H100 CUDA. Mac inference produces equivalent quality (validated by cross-platform diff) but has not been benchmarked separately on HumanEval; expect within 1-2 percentage points of the H100 number.

---

## Performance

### Apple M2 Max

| Configuration | Decode | Prefill |
|---|---|---|
| f16 KV + flash attention | ~30 tok/s | ~80 tok/s |

### NVIDIA H100 80GB

| Configuration | Decode | Prefill |
|---|---|---|
| f16 KV + flash attention + CUDA graphs | ~91 tok/s | 100-220 tok/s |

---

## Memory footprint

Qwen3.6-35B-A3B weights + 8K context KV cache:

| Method | Total |
|---|---|
| **Spiral_4_5** | **~20.2 GB** |
| Q4_K_XL | ~21.2 GB |
| Q8_0 | ~37.2 GB |
| bf16 | ~70.2 GB |

Fits comfortably in 24 GB of VRAM / unified memory for the 8K-context shipping config.

---

## Files

| File | Size |
|---|---|
| `Qwen3.6-35B-A3B-Spiral_4_5.gguf` | ~20 GB |
| `Qwen3.6-35B-A3B-Spiral_4_5.spiralcb` | 28 MB |

Both files are required. The `.spiralcb` sidecar is loaded by the Spiral runtime alongside the GGUF.

---

## Quick start

Spiral ships with three wrappers β€” `spiral-download`, `spiral-chat`, `spiral-serve` β€” that handle the model fetch and inference flags.

### Install

```bash
brew install reinforceai/spiral/spiral
```

The brew formula installs the Spiral fork of `llama.cpp` plus the wrappers. Standard upstream `llama.cpp` will not load Spiral-compressed models.

### Interactive chat

```bash
spiral-chat --model qwen-36-35b-spiral
```

First run auto-downloads the GGUF and codebook to `~/.spiral/models/qwen-36-35b-spiral/`. Subsequent runs use the local cache.

### Single prompt

```bash
spiral-chat --model qwen-36-35b-spiral \
    --prompt "Write a Python function to compute Fibonacci numbers iteratively" \
    --greedy
```

### OpenAI-compatible API server

```bash
spiral-serve --model qwen-36-35b-spiral --port 8080
```

```bash
curl http://localhost:8080/v1/chat/completions \
    -H 'Content-Type: application/json' \
    -d '{
      "messages": [{"role": "user", "content": "Hello"}],
      "chat_template_kwargs": {"enable_thinking": false}
    }'
```

`enable_thinking: false` disables Qwen's thinking-block emission β€” matches how the HumanEval scores in this README were measured. Omit it for full thinking traces.

### Build from source

For CUDA, or to develop against the framework:

```bash
git clone https://github.com/ReinforceAI/spiral
cd spiral
cmake -B build -DGGML_METAL=ON   # or -DGGML_CUDA=ON
cmake --build build -j
```

Then `spiral-download` and `spiral-chat` from the build directory, or call `llama-cli` directly with `SPIRAL_CODEBOOK_PATH` set to the codebook file.

---

## How it works

Spiral applies a dense rotation to weight matrices before scalar quantization. The rotation produces near-Gaussian weight distributions with equalized variance, eliminating outlier channels β€” the primary source of quantization error in coder models. Quantization in the rotated space is then much more efficient than in the original basis.

Spiral_4_5 uses mixed bit depth across MoE expert tensors, with higher precision allocated to a subset of layers identified through per-layer sensitivity analysis. Attention and embedding weights remain in higher precision.

**No calibration data is required.** The compression is derived analytically from the model's own weights β€” no representative samples, no importance matrix construction, no fine-tuning.

Full method description is in development. Source: [github.com/ReinforceAI/spiral](https://github.com/ReinforceAI/spiral)

---

## Limitations

- **KV cache compression not in this release.** Long-context use cases that would benefit from KV compression are not addressed by v0.3.0; future releases will revisit.
- **HumanEval measured on H100 only.** Mac HumanEval is expected within 1-2pp based on cross-platform diff validation.
- **Custom llama.cpp build required.** Stock upstream `llama.cpp` does not load Spiral models.
- **Coding benchmarks only.** HumanEval is the primary evaluation. MBPP, LiveCodeBench, SWE-bench have not been measured in this release.
- **Research-grade release.** APIs may change before 1.0.

---

## Methodology

### HumanEval
- evalplus 0.3.1, llama-server on H100 80GB, CUDA backend
- Greedy decoding (`temperature=0`)
- Thinking mode disabled (`enable_thinking: false`)
- 164 problems, single sample per problem

### Perplexity
- wikitext-2-raw-v1, HF AutoTokenizer
- 64 sequences Γ— 2048 tokens = 131,008 tokens
- Cross-method protocol: same tokenizer source across all comparisons, no GGUF tokenizer invocation for K-quants (avoids tokenizer mismatch as a confound)

### Cross-platform validation
- Side-by-side `llama-cli` with identical greedy prompts on Mac (M2 Max, Metal) and H100 (CUDA)
- Same `.gguf` + `.spiralcb` on both platforms

Reproduction scripts: [github.com/ReinforceAI/spiral](https://github.com/ReinforceAI/spiral)

---

## Acknowledgments

- **[llama.cpp](https://github.com/ggerganov/llama.cpp)** β€” inference engine, GGUF format, Metal and CUDA backends.
- **[unsloth](https://huggingface.co/unsloth)** β€” high-quality GGUF quantizations of Qwen3.6-35B-A3B and many other models, used as the reference comparison point in this release (Q4_K_M, Q4_K_XL, Q8_0).
- **Qwen Team** β€” Qwen3.6-35B-A3B under Apache 2.0.
- The broader open-source ML community β€” quantization theory, rotation methods, and product quantization research laid the groundwork.

---

## Citation

```bibtex
@misc{spiral2026,
  title={Spiral: Geometric Compression of Rotated Transformers},
  author={Deshwal, Viraj},
  year={2026},
  publisher={ReinforceAI},
  url={https://github.com/ReinforceAI/spiral}
}
```

## License

- Inference engine: Based on llama.cpp (MIT)
- Spiral compression framework: ReinforceAI
- Model weights: Apache 2.0 (inherited from Qwen3.6-35B-A3B)