File size: 10,185 Bytes
6a6caa8
 
 
 
 
 
 
 
 
 
 
 
 
 
e0b6120
 
 
 
 
 
 
6a6caa8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: other
task_categories: [other]
tags: [compression, hutter-prize, cmix, enwik9, mixture-of-experts]
---

# tte-cmix-residual-blocks

Per-coded-bit features from a **complete trace of cmix (the Hutter Prize record holder)
compressing enwik9**, sharded into contiguous blocks so each experiment pulls only what
it needs.

Built for a 6-arm sweep asking: *what can a small MLP extract from cmix's residual?*

> **UPLOAD STATUS.** `manifest.json`, `final_p_u16.bin`, `labels_u8.bin`, `bytes_ctx.bin` are
> **complete for all 48 blocks**. `experts_i8.bin` is complete for the **12 tranche-1 blocks**
> (`tranche1.json`: b000 b004 b005 b008 b018 b024 b025 b029 b037 b045 b046 b047 — 6 train /
> 3 val / 3 test, spanning frac 0.007→0.986, early **and** late). **Start on tranche 1 now.**
> The other 36 `experts_i8.bin` are uploading and land ~1 h later (home uplink is 2.2 MB/s;
> HF *downloads* are fast). Re-read `manifest.json` for the full set.

**Corpus**: 587,138,826 bytes = 4,697,110,608 coded bits. Bit order is **MSB-first**.
**cmix full-corpus anchor**: **1.484123 bits/byte** = 0.185515 bits/bit = 108.923279 MB.

---

## 1. Layout

48 blocks. Each block is **1 MiB (1,048,576 bytes) of contiguous corpus = 8,388,608 coded bits**
(`n = block_bits`). Every bit in a block is present — nothing is subsampled, so **row index
maps exactly to a corpus position** (see below).

```
manifest.json               # blocks, splits, byte ranges, scales, sha256s, per-block anchors
read_blocks.py              # the reader (below)
smoke_test.py               # RUN THIS AFTER PULLING, BEFORE BURNING GPU
blocks/bNNN/experts_i8.bin  # int8[n, 25]  the 25 usable expert stretches   209,715,200 B
blocks/bNNN/final_p_u16.bin # uint16[n]    cmix's final_p, P(1)=fp/65536     16,777,216 B
blocks/bNNN/labels_u8.bin   # uint8[n]     bit0 = coded bit (LABEL)           8,388,608 B
                            #              bit1 = cmix's lstm_override flag
blocks/bNNN/bytes_ctx.bin   # uint8[2 MiB] [1 MiB left context | 1 MiB block]  2,097,152 B
```

**Derived per-row, no column needed** (blocks are full and contiguous):
```
bitpos  = i % 8                          # 0 = MSB … 7 = LSB
byteoff = block["byte_start"] + i // 8   # absolute corpus offset  <-- use to detect front-loading
region  = block["frac"], block["half"]   # position in stream, "early" / "late"
```

### The 25 expert columns
Trace slots `0..22` are cmix's 23 `mixer_0` outputs; slot `24` is the lstm/byte-mixer;
slot `25` is the raw `mixer_1` output pre-Logistic. `manifest["expert_col_to_trace_slot"]`
= `[0..22, 24, 25]`.

**Slot 23 (fxcm) is dropped — it is identically zero in this trace** (loss exactly 1.0
bits/bit = a coin flip). There are **25 usable experts, not 26.**

All columns are in the **stretch / logit domain** (not probability): `p = sigmoid(x)`.

### int8 quantization
`x = int8_value * int8_scales[col]`. Scales are `bound/127` with
`bound = 12.203` for cols 0..23 and **`bound = 16.0` for col 24** (see Gotcha 1).
**Zero clipping occurred across all 402,653,184 rows x 25 cols.**

---

## 2. The split — contiguous blocks with real gaps

A random *row* split would manufacture fake headroom (Wikipedia has enormous local
dependence). So: **48 contiguous blocks, each separated from every other block by
≥ 11,183,482 bytes (≈10.1 MB even after the shipped 1 MiB context) of never-used corpus.**

|        | blocks | early | late |
|--------|--------|-------|------|
| train  | 32     | 16    | 16   |
| val    | 8      | 4     | 4    |
| test   | 8      | 4     | 4    |

Blocks are grouped 4 train / 1 val / 1 test, rotating, spread across the whole corpus
(`frac` 0.007 → 0.986). **Every split spans early AND late stream.**

### ⚠ FRONT-LOADING IS THE #1 WAY TO GET A FAKE RESULT
cmix is dramatically better late in the stream. Measured on these blocks:

| region | cmix bits/byte |
|--------|----------------|
| early (first half) | **1.801267** |
| late  (second half)| **1.082497** |
| all 48 blocks      | 1.441882 |
| full corpus (true) | 1.484123 |

That is a **1.66x** swing, and per-block it ranges from **2.11** (b004, frac 0.09) to
**0.46** (b045, frac 0.95) — a **4.6x** range. A prior experiment extrapolated from an
early prefix and **overstated its result by 27.5%**.

**Report your gain per-block and aggregate weighted by the FULL corpus, not by your
sample.** Use `byteoff` / `frac` / `half` to check that your gain is not concentrated
early. If your gain is much larger on early blocks, say so.

---

## 3. Reader (this is the whole API)

```python
import json, numpy as np
M = json.load(open("manifest.json")); B = M["blocks"][17]; n = M["block_bits"]
d = f"blocks/{B['id']}"
X  = np.fromfile(f"{d}/experts_i8.bin", np.int8).reshape(n, 25) \
     * np.array(M["int8_scales"], np.float32)          # (n,25) expert stretches (logit domain)
fp = np.fromfile(f"{d}/final_p_u16.bin", np.uint16).astype(np.float32) / 65536.0  # cmix P(bit=1)
fl = np.fromfile(f"{d}/labels_u8.bin",  np.uint8)
y  = (fl & 1).astype(np.float32)                       # THE LABEL: the coded bit
lstm_override = (fl >> 1) & 1
bitpos  = np.arange(n) % 8                             # 0 = MSB
byteoff = B["byte_start"] + np.arange(n) // 8          # absolute corpus offset
```

A head that *recalibrates* cmix should be parameterised as a **residual on cmix's own logit**:
`logit = log(fp/(1-fp)) + net(X, bitpos)`, so it starts exactly at cmix and gain > 0 is real.

**Smoke test before you train:** `python3 smoke_test.py . b005` — recomputes cmix's
bits/byte from your shards and checks it against the per-block anchor + sha256s.

---

## 4. What to pull (per-arm download sizes)

| profile | files | size |
|---|---|---|
| **bit-level head arm (r3, d3_80), full train+val+test** | `experts_i8` + `final_p_u16` + `labels_u8`, all 48 | **11.27 GB** |
| bit-level head arm, **val+test only** (eval / scoring) | same 3, 16 blocks | 3.76 GB |
| bit-level head arm, **test only** | same 3, 8 blocks | 1.88 GB |
| quick start / debug (tranche 1: 12 blocks, all splits, early+late) | same 3, 12 blocks | 2.82 GB |
| labels + final_p only (baselines, no experts) | 2 files x 48 | 1.21 GB |
| byte-level LM arm *(de-prioritised)* | `bytes_ctx` + `final_p` + `labels`, 48 | 1.31 GB |

Full repo ≈ **11.4 GB**. Pull only the blocks/files you need:

```bash
# one block, head-arm files only
for f in experts_i8.bin final_p_u16.bin labels_u8.bin; do
  wget -x -nH --cut-dirs=4 \
  https://huggingface.co/datasets/dfreelan/tte-cmix-residual-blocks/resolve/main/blocks/b005/$f
done
```
or `huggingface_hub.snapshot_download(repo_id=..., repo_type="dataset", allow_patterns=["manifest.json","blocks/b005/*"])`.

---

## 5. Sanity anchors (must reproduce)

- cmix full corpus: **1.484123 bits/byte**; mean coded bit = 0.4113.
- Per-block cmix bits/byte: `manifest["blocks"][i]["cmix_bits_per_byte"]`. These were
  cross-checked against the trace's own authoritative per-byte cost column — all 48 agree.
- On a uniform sample of the whole stream: final_p loss **0.1855 bits/bit**; the 23
  `mixer_0` experts land 0.1868–0.1890; slot 25 (raw mixer_1) 0.1863; slot 24 (lstm)
  **0.2213** (the weakest). Ordering: final < raw mixer_1 < mixer_0 experts << lstm.

### int8 quantization-loss check (done, passes)
- Round-trip: `max|float - dequant(int8)|` = exactly half a step per column
  (0.048 for the ±12.203 cols, 0.063 for col 24). No clipping anywhere.
- **Learned head (MLP 64, residual on cmix's logit, 6.4M train rows, 3 seeds), evaluated
  on the test blocks:**
  - float32 features: 0.1837512 ± 0.0000092 bits/bit
  - int8 features:    0.1837531 ± 0.0000135 bits/bit
  - **quantization cost = +0.0000018 bits/bit — 0.13x the seed-to-seed noise, i.e. BELOW
    the noise floor.** In corpus terms: **+0.0011 MB.**
- Worst case, using a quantized stretch *directly* as the logit with no learned
  recalibration: +0.000044 bits/bit (slot 25). Even this is <1% of any gain above
  0.0044 bits/bit.
- **Conclusion: int8 is not your bottleneck.** If your measured gain is below ~0.4 MB,
  ask the dataset builder for float16 shards (2x size) before trusting the last digit.

---

## 6. GOTCHAS — read these, they contradict the original brief

1. **Slot 25 (raw mixer_1) is NOT clamped to ±12.203.** Observed range **[-14.13, +13.23]**.
   Only slots 0..22 and 24 are clamped. A uniform ±12.203 int8 map would have *clipped*
   col 24. That is why col 24 uses `bound = 16.0`. **Use `manifest["int8_scales"]`, do not
   hardcode 12.203/127.**
2. **The brief's per-bit loss anchors (final 0.2296, experts 0.2306–0.2340, lstm 0.2722)
   are EARLY-PREFIX numbers, not full-corpus.** The true full-corpus figures are
   final **0.1855**, experts 0.1868–0.1890, lstm **0.2213** — and they reconcile exactly
   with the published 1.484123 bits/byte (÷8 = 0.185515). If your numbers look "too good"
   versus the brief, this is why.
3. **`record_base_FULL.cache`'s header field `bits_fixed` is garbage** in this file
   (it decodes to 2.5e7 bits/byte). Ignore it. The rest of that header is valid.
4. `bytes_ctx.bin` ships 1 MiB of **left context before** each block. It is for
   *conditioning only***never train or evaluate on the context half.** It lies inside
   the inter-block gap, so it never overlaps another block.

---

## 7. Provenance / source files (on the build box, not uploaded)

- Trace: `residual_trace_v1/enwik9_trace/enc.2074020.0.{res,bytes,meta}` — format `res_v3`,
  **56 B per coded bit**: `u16 final_p; u8 flags(bit0=coded bit, bit1=lstm_override);
  u8 reserved; f16[26]`. 263 GB, read-only.
- `record_base_FULL.cache` (9.39 GB): cmix's `final_p` for **all** coded bits —
  96 B header, then `uint16[8][span]` **level-major**, `q[L][pos - warmup]`, with
  `span = 587,136,778`, `warmup = 2048`. Verified: it equals the trace's `final_p`
  bit-for-bit. **Not uploaded** — the per-block `final_p_u16.bin` shards cover it at
  1/12th the size. Ask if you need the full cache.
- The corpus itself is already on HF as
  `dfreelan/tte-hutter-staging/input_ready_587M.bin.zst` (byte-identical to the trace's
  byte column). Not duplicated here.