File size: 3,559 Bytes
abb13ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
430691f
 
 
 
 
 
abb13ef
 
 
 
 
 
 
 
 
 
 
 
0bb451e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: apache-2.0
base_model: allenai/OLMoE-1B-7B-0125-Instruct
library_name: llama.cpp
tags: [mixture-of-experts, ternary, quantization, llama.cpp, tq1_0]
---
# trnr: OLMoE-1B-7B-0125-Instruct, expert weights at 1.6875 bits/weight

Post-training ternarization of the **expert weights only**: values in {-1, 0, +1} times one fp16
scale per 256 input columns, packed into llama.cpp's existing **TQ1_0** type. Attention,
embeddings, the output head and the router stay F16.

| | |
|---|---|
| expert weights | 1.359 GB at 1.6875 bits/weight, 46% exact zeros |
| full file | __SIZE__ GB |
| perplexity | __PPL__ (wikitext-2-raw, 8 x 512 tokens) |
| fp16 reference | 9.1512, same protocol and same pinned build |
| ratio | __RATIO__x |
| speed | ~16 tok/s on 4 CPU threads, no GPU, no custom kernels |

## Method
1. One dense random orthogonal rotation R, shared by all 16 layers, applied to the gate_up
   **input** only, with the router folded by the same R so routing is unchanged.
2. A per-256-block ternary scale fitted by a Hessian-weighted least-squares objective.
3. Canonical GPTQ error feedback across blocks, with a per-expert Hessian for down_proj.
4. Bytes packed into TQ1_0's layout, verified byte-identical to llama.cpp's own encoder.

## Downstream benchmarks
Not yet measured for THIS checkpoint. The 5-task lm-evaluation-harness set run earlier used a
different, gentler configuration (base model at 1.664x fp16 perplexity, against 3.08x here) and
gave 83.9% raw retention, ~67% after chance correction. Expect materially worse here, because
retention tracks the perplexity ratio. Numbers for this checkpoint will be added once measured.

## Requirements
Needs the companion fork **trnr.cpp** -- one commit over llama.cpp at __PIN8__ -- for the
rotation tensor. `trnr_rot.patch` is in this repo. Without it the model loads and produces
garbage.

## Honest limitations
- __RATIO__x fp16 perplexity, and that is the price of ternary itself: the scalar three-level
  optimum for Gaussian weights is 0.1903 NMSE and this pipeline measures 0.1954, i.e. it is
  **at the optimum for this alphabet**. The remaining gap is ternary, not the fitting.
- Perplexity is not quality. Downstream tasks degrade more than wikitext suggests.
- No fine-tuning was used.
- llama.cpp's stock TQ1_0 quantizer is unusable for this model: its absmax scale sends ~92% of
  weights to zero and yields ppl 5178. The learned per-block scale is what makes the format work.

## Requirements -- you MUST use the companion fork
The model stores a rotation tensor `trnr.rot` that upstream llama.cpp does not know about. The
companion fork **trnr.cpp** adds it: one commit over llama.cpp at 16f090f, which is a
`trnr.rot` ggml tensor plus one graph line in `src/models/olmoe.cpp`. **On stock llama.cpp the
model loads and then produces garbage**, because the expert input never gets rotated.

- fork: <your URL, or "not published yet -- trnr_rot.patch below is the whole fork">
- `trnr_rot.patch` (4 KB) is in this repo -- apply it to a clean checkout:
  `git clone ... && cd llama.cpp && git checkout 16f090f && git apply trnr_rot.patch`
- or use the prebuilt patched tree shipped as `trnr.cpp.tar.gz`
- build: `cmake -B build -DCMAKE_BUILD_TYPE=Release -DGGML_CUDA=OFF && cmake --build build -C Release -j --target llama-cli llama-perplexity`

Sanity check after building: this model must give ppl ~3.08x fp16 (28.23) on wikitext-2-raw at
8x512 tokens. If it gives thousands, the rotation tensor is not being read -- you are on stock
llama.cpp or the patch did not apply.