cortiq
cmf
infosave commited on
Commit
a3f3939
·
verified ·
1 Parent(s): 8201c27

which quantization to take, and what each costs

Browse files
Files changed (1) hide show
  1. FORMATS.md +119 -0
FORMATS.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - cortiq
5
+ - cmf
6
+ - quantization
7
+ ---
8
+
9
+ # Which file to take — the CMF quantization ladder
10
+
11
+ Every `.cmf` on this account is the same model twice over: the same weights,
12
+ written at a different number of bits per weight. This page says what those
13
+ names mean, what each one costs you, and how to pick without downloading two.
14
+
15
+ Short version:
16
+
17
+ | suffix | bits/weight | take it when |
18
+ |---|---:|---|
19
+ | `f16` | 16 | you are checking a port against the reference |
20
+ | `q8` | 8.1 | quality is the whole point and the file still fits |
21
+ | `q4tp` | **4.17** | **the default.** Everything published here uses it |
22
+ | `q4t` | 4.50 | same values as `q4tp`, older scale layout |
23
+ | `q2tp` | 2.17 | the model is a MoE and you are trading experts for size |
24
+ | `q1t` | ~2.25 + overlay | a normal checkpoint pushed below q4, with calibration |
25
+ | `q1` | 1.5 | the model was *trained* at 1 bit (BitNet/Bonsai class) |
26
+ | `vbit` | 3–8, per row | one file has to fit an awkward memory budget exactly |
27
+
28
+ Normalization weights, biases and anything one-dimensional are **always f16**,
29
+ in every file. Compression buys nothing there and precision costs nothing.
30
+
31
+ ## q4tp, and why the scale is the interesting part
32
+
33
+ A four-bit quantizer stores a nibble per weight and a scale per group of 32.
34
+ At f16 that scale is 16 bits per 32 weights — **11% of the file**, spent on a
35
+ number that varies smoothly along a row.
36
+
37
+ `q4tp` keeps the nibbles byte-identical to `q4t` and replaces the scale with a
38
+ 5-bit rung on a per-row geometric ladder: `scale = 2^(lo + code·step)`, with
39
+ `lo` and `step` taken from the row's own min and max log-scale. A reader
40
+ expands one row's 32 rungs once and then reads scales by table lookup. The
41
+ file drops from 4.50 to **4.17 bits/weight** — 7.3% — for 1.14% RMS
42
+ perturbation of the weights, against the ~10% that four-bit quantization
43
+ itself already costs. It is, in short, free.
44
+
45
+ `q2tp` is the same ladder with a two-bit weight plane (8 bytes a group instead
46
+ of 16). One detail matters more than it sounds: a symmetric 4-level grid
47
+ cannot spell **zero**, so rung 0 is reserved to mean "this group is exactly
48
+ zero" and the geometric rungs start at 1. Without that a pruned or masked
49
+ group comes back as noise.
50
+
51
+ ## q1t — below four bits without training
52
+
53
+ `q1t` is ternary `{−s, 0, +s}`, packed base-3 at five values per byte
54
+ (3⁵ = 243 ≤ 256) for 2.25 bits/weight, plus a per-row overlay that keeps the
55
+ salient weights at f16. Two things make it work where plain 1-bit does not:
56
+ capturing the many near-zero weights *exactly* (the zero level is the win over
57
+ binary — measured ×7 better at matched budget), and choosing what to keep in
58
+ the overlay by `|W|·RMS(x)` — amplitude times activation, not amplitude alone.
59
+
60
+ It is calibration-driven, not a flag on `convert`: see
61
+ [`docs/Q1T_PTQ.md`](https://github.com/infosave2007/cmf/blob/master/docs/Q1T_PTQ.md).
62
+
63
+ ## q1 — only for models trained at one bit
64
+
65
+ For a BitNet-class checkpoint (Bonsai, and the 1-bit trained families) the
66
+ weights already sit on two levels per group, so 1.5 bits/weight is nearly
67
+ lossless. As post-training quantization of a normal checkpoint the same
68
+ encoding destroys the model. The converter therefore exposes it as an explicit
69
+ opt-in and never as a default.
70
+
71
+ ## What the packer decides for you in a video model
72
+
73
+ Text models are uniform: one dtype for every matrix. Generative containers are
74
+ not, and the choices are worth knowing because they are where the size goes.
75
+
76
+ **The modulation weight is a curve, not a matrix.** MiniMax-H3's
77
+ `adaln_proj.linear` is [96768, 2688] per block — 13 B parameters, 40% of the
78
+ released model — for a map whose input is one number, the timestep. `cortiq
79
+ animate-pack` collapses it onto a rank-24 basis of that curve plus a
80
+ [1025, 24] table to interpolate: rms 8.7e-5 on a signal of rms 0.46. This is
81
+ most of the difference between a 60 GB checkout and a 14 GB file, and it is
82
+ lossless in the way that matters — the map is genuinely one-dimensional.
83
+
84
+ **Some tensors are kept exact because nothing downstream blurs them.** In the
85
+ LTX-2.5 pack, three policies were found by the parity gate rather than by
86
+ taste: the adaLN-single projections stay high precision (q4tp put 3.6e-2 into
87
+ the first normalization of block 0), and the token table goes to q8 (q4tp put
88
+ 11% into every hidden state). A quantizer that is right for a 4096×4096
89
+ projection is wrong for a lookup table.
90
+
91
+ **A published dead end.** `mmh3-turbo-fl2va-q2tp.cmf` exists so that the
92
+ result is reproducible, not because you should render with it: two bits across
93
+ a dense video DiT changes the *subject* of the clip. The size class it was
94
+ aiming at is better served by the ClipProj build, which keeps four bits
95
+ everywhere and shrinks the prompt encoder instead.
96
+
97
+ ## Checking what you got
98
+
99
+ ```bash
100
+ cortiq verify model.cmf # per-tensor hashes — the file, not the download
101
+ cortiq info model.cmf # arch, parameter count, dtype per tensor family
102
+ ```
103
+
104
+ `verify` is the reason a truncated or mis-mirrored download cannot quietly
105
+ become a "bad model": every tensor carries its own hash, and the file says so
106
+ before the first kernel runs.
107
+
108
+ ## Where the ladder is honest
109
+
110
+ - `q4tp` numbers above are measured on the published containers, not
111
+ estimated: 4.17 vs 4.50 bits/weight is arithmetic, and the 1.14% RMS figure
112
+ is against the same weights encoded as q4t.
113
+ - Quality claims per model live in that model's card, with the corpus named.
114
+ Where a number was not measured, the card says so.
115
+ - The full dtype × execution-path matrix — which format is fast on which
116
+ backend, and where the honest gaps are — is
117
+ [`docs/QUANT_COVERAGE.ru.md`](https://github.com/infosave2007/cmf/blob/master/docs/QUANT_COVERAGE.ru.md).
118
+ - The normative layout of every dtype is §3.2 of
119
+ [`CMF_V2_SPEC.md`](https://github.com/infosave2007/cmf/blob/master/docs/CMF_V2_SPEC.md).