File size: 7,437 Bytes
be36c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5db3a88
828d859
be36c98
 
 
 
 
 
 
5db3a88
 
be36c98
 
 
 
 
 
 
76598a1
 
 
be36c98
828d859
76598a1
5db3a88
76598a1
5db3a88
be36c98
5db3a88
 
 
 
be36c98
76598a1
be36c98
5db3a88
be36c98
5db3a88
 
 
 
 
be36c98
5db3a88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
be36c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9fef2ee
 
 
 
 
 
 
 
 
 
 
 
 
 
be36c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5db3a88
be36c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: other
license_name: lfm-open-license
license_link: https://huggingface.co/LiquidAI/LFM2-1.2B-Extract/blob/main/LICENSE
base_model: LiquidAI/LFM2-1.2B-Extract
base_model_relation: quantized
pipeline_tag: text-generation
library_name: cascadia
inference: false
tags:
  - cascadia
  - lut
  - compression
  - spline
  - ternary
  - quantization
  - cpu
  - edge
  - lfm2
language:
  - en
---

# ZTFlynn/LFM2-1.2B-Extract-Cascadia-ternary3

[`LiquidAI/LFM2-1.2B-Extract`](https://huggingface.co/LiquidAI/LFM2-1.2B-Extract) compressed to **774 MB**
with Cascadia β€” a spline manifold plus per-band lookup tables at **0.660 bytes
per weight** β€” and executable on CPU by a C runtime whose entire dependency
list is libc, libm and libgomp.

| | |
|---|---|
| Base model | [`LiquidAI/LFM2-1.2B-Extract`](https://huggingface.co/LiquidAI/LFM2-1.2B-Extract) |
| Parameters | 16 layers, hidden 2048 |
| Checkpoint β†’ package | 2.23 GB β†’ **774 MB** (3.03x) |
| Bits per weight | 5.28 |
| Tensors compressed | 16 |
| Architecture | 16 blocks, GQA 32q/8kv, gated short convolutions |

## Quality

| | perplexity |
|---|---:|
| `LiquidAI/LFM2-1.2B-Extract` (bf16) | 253.46 |
| This package (ternary-3) | 253.34 |
| **Result** | **no detectable cost** (95% CI [0.9899x, 1.0104x], t = +0.02) |


65,408 paired tokens of FineWeb-Edu in **127 independent
512-token windows**. Both models score identical tokens and are
compared per token, which cuts the standard error 15.7x versus
two independent means.

The window is the unit of inference, not the token: tokens inside one window
share a context, and counting them as independent samples inflates the
t-statistic several-fold. Resolving a difference of a few percent takes
hundreds of windows.

The difference does not resolve. Stated precisely: this measurement bounds the perplexity change to within **1.0%** and cannot distinguish it from zero β€” which is a limit on the evidence, not a proof that the cost is zero. Reconstruction fidelity below is measured directly and carries no such uncertainty.

### Reconstruction fidelity

Perplexity measures how good a model is on a corpus, not how faithful a copy
is, and the two disagree here: models compressed to identical reconstruction
error differ by 16 percentage points of measured perplexity. Fidelity has no
sampling uncertainty and no dependence on corpus domain, so it is measured
directly and reported alongside.

| | |
|---|---:|
| Relative L2 error vs the bf16 checkpoint | **0.0553** |
| Systematic gain (1.0000 is faithful) | 0.9993 |
| Measured over | 93 of 93 tensors, 100% of parameters |

By tensor class:

| class | rel L2 | share of model |
|---|---:|---:|
| linear | 0.0576 | 1,036M params |
| embedding | 0.0265 | 134M params |

The tied embedding, the tensor whose error reaches the logits undamped, reconstructs at **0.0265**.

### Where the compression cost comes from

The cost is concentrated in one tensor. The tied embedding, which also
serves as `lm_head`, is compressed by a single global codebook β€” no bands,
no spline manifold, no exact outliers β€” while every linear tensor gets 32
bands, a spline, and 0.5% of its weights kept exact. Its error is the only
error in the model that reaches the logits with nothing downstream to
absorb it.

Measured on LFM2-350M, relative L2 reconstruction error:

| tensor | codebook | rel L2 |
|---|---:|---:|
| tied embedding, 27 entries | 27 | 0.078 |
| tied embedding, 81 entries | 81 | **0.027** |
| a typical linear (32 bands x 27) | 864 | 0.057 |

At 27 entries the embedding is the worst-reconstructed tensor in the model.
This package uses **81** entries for it, which costs about 6% in size and
makes it the best-reconstructed tensor instead.

## Usage

Executed by the [Cascadia](https://github.com/EntroMorphic/cassie) C runtime.
This is a compressed package, not a `transformers` checkpoint.

```bash
git clone https://github.com/EntroMorphic/cassie && cd cassie
cmake -S src/c -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build -j

huggingface-cli download ZTFlynn/LFM2-1.2B-Extract-Cascadia-ternary3 --local-dir ./pkg
./build/cascadia_generate ./pkg 512 --chat "Explain gradient descent."
```

Sampling is `--temp` / `--top-k` / `--top-p` / `--seed`; the default is greedy
and seed-reproducible. Generation stops at `<|im_end|>`, so `max_new` is a
ceiling.

### On an NVIDIA GPU

The same package runs entirely on the GPU, with byte-identical output and
roughly 14-16x the throughput. Opt-in, so the default build is unchanged:

```bash
cmake -S src/c -B build -DCASCADIA_CUDA=ON -DCMAKE_BUILD_TYPE=Release \
    && cmake --build build -j
./build/cascadia_generate_cuda ./pkg 512 --chat "Explain gradient descent."
```

Same arguments, same tokens. Needs CUDA and sm_75 or newer.


### Python

```python
from transformers import AutoModelForCausalLM
from cascadia import load_compressed

model = AutoModelForCausalLM.from_pretrained("LiquidAI/LFM2-1.2B-Extract", dtype="bfloat16")
model, stats = load_compressed(model, "./pkg", model_id="LiquidAI/LFM2-1.2B-Extract")
```

## Sample output

Prompt: *"How many eggs are in a baker's dozen?"*

```
{
  "baker_dozen_eggs": 12
}
```

Greedy, generated to natural completion.

## Package contents

| file | size |
|---|---|
| `weights.bin` | 772 MB |
| `manifest.json` | per-tensor geometry and offsets |
| `aux.bin` | RMSNorm scales, conv kernels, architecture constants |
| `tokenizer.bin` | vocabulary, merges, Unicode tables |

Format specified in
[docs/package_format.md](https://github.com/EntroMorphic/cassie/blob/main/docs/package_format.md)
and machine-verified against every package.

## How it works

A B-spline surface is fitted to each weight matrix to capture large-scale
structure. Each weight is assigned to one of 32 bands by its spline value,
and a k-means codebook is learned per band over the residuals. The top 0.5%
of errors are kept exactly as f32. Codebook indices pack in base 3, five
trits per byte, since 3⁡ = 243 fits a byte.

Reconstruction is `W = spline(j,c) + codebook[band][index]`, evaluated inside
the matvec so no dense weight matrix is ever built. Because the spline
carries dynamic range, the residual tables need **no per-block scale
factors**.

## Limitations

- Runs under the Cascadia C runtime rather than `transformers` directly.
- The runtime executes ternary-3 packages; other presets convert but are not
  yet supported by the kernel.
- Batch-1 CPU inference, suited to edge and batch workloads.
- Greedy and sampled decoding; no beam search.

## Acknowledgements

Deeply inspired by
[**Magneato/deepseek-r1-qwen-7b-lutc**](https://huggingface.co/Magneato/deepseek-r1-qwen-7b-lutc),
which demonstrated LUT-cascade compression of a 7B model at 5.45 bits per
weight. The Guanaco LUT cascade β€” no-scale residuals, variable bit rate, and
f32 outlier preservation β€” is the foundation this builds on. Cascadia adds a
spline manifold for band selection and a Harmonic Collapse step that removes
per-block scale factors entirely. Our thanks to Magneato for publishing both
the approach and the weights that made it concrete.

Base model by [Liquid AI](https://huggingface.co/LiquidAI), used under the
LFM Open License.

## Citation

```bibtex
@software{cascadia,
  title  = {Cascadia: Spline Manifold LUT Compression for Language Models},
  author = {Josserand-Austin, Tripp},
  year   = {2026},
  url    = {https://github.com/EntroMorphic/cassie}
}
```