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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
task_categories: [other]
|
| 4 |
+
tags: [compression, hutter-prize, cmix, enwik9, mixture-of-experts]
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# tte-cmix-residual-blocks
|
| 8 |
+
|
| 9 |
+
Per-coded-bit features from a **complete trace of cmix (the Hutter Prize record holder)
|
| 10 |
+
compressing enwik9**, sharded into contiguous blocks so each experiment pulls only what
|
| 11 |
+
it needs.
|
| 12 |
+
|
| 13 |
+
Built for a 6-arm sweep asking: *what can a small MLP extract from cmix's residual?*
|
| 14 |
+
|
| 15 |
+
**Corpus**: 587,138,826 bytes = 4,697,110,608 coded bits. Bit order is **MSB-first**.
|
| 16 |
+
**cmix full-corpus anchor**: **1.484123 bits/byte** = 0.185515 bits/bit = 108.923279 MB.
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## 1. Layout
|
| 21 |
+
|
| 22 |
+
48 blocks. Each block is **1 MiB (1,048,576 bytes) of contiguous corpus = 8,388,608 coded bits**
|
| 23 |
+
(`n = block_bits`). Every bit in a block is present — nothing is subsampled, so **row index
|
| 24 |
+
maps exactly to a corpus position** (see below).
|
| 25 |
+
|
| 26 |
+
```
|
| 27 |
+
manifest.json # blocks, splits, byte ranges, scales, sha256s, per-block anchors
|
| 28 |
+
read_blocks.py # the reader (below)
|
| 29 |
+
smoke_test.py # RUN THIS AFTER PULLING, BEFORE BURNING GPU
|
| 30 |
+
blocks/bNNN/experts_i8.bin # int8[n, 25] the 25 usable expert stretches 209,715,200 B
|
| 31 |
+
blocks/bNNN/final_p_u16.bin # uint16[n] cmix's final_p, P(1)=fp/65536 16,777,216 B
|
| 32 |
+
blocks/bNNN/labels_u8.bin # uint8[n] bit0 = coded bit (LABEL) 8,388,608 B
|
| 33 |
+
# bit1 = cmix's lstm_override flag
|
| 34 |
+
blocks/bNNN/bytes_ctx.bin # uint8[2 MiB] [1 MiB left context | 1 MiB block] 2,097,152 B
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
**Derived per-row, no column needed** (blocks are full and contiguous):
|
| 38 |
+
```
|
| 39 |
+
bitpos = i % 8 # 0 = MSB … 7 = LSB
|
| 40 |
+
byteoff = block["byte_start"] + i // 8 # absolute corpus offset <-- use to detect front-loading
|
| 41 |
+
region = block["frac"], block["half"] # position in stream, "early" / "late"
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
### The 25 expert columns
|
| 45 |
+
Trace slots `0..22` are cmix's 23 `mixer_0` outputs; slot `24` is the lstm/byte-mixer;
|
| 46 |
+
slot `25` is the raw `mixer_1` output pre-Logistic. `manifest["expert_col_to_trace_slot"]`
|
| 47 |
+
= `[0..22, 24, 25]`.
|
| 48 |
+
|
| 49 |
+
**Slot 23 (fxcm) is dropped — it is identically zero in this trace** (loss exactly 1.0
|
| 50 |
+
bits/bit = a coin flip). There are **25 usable experts, not 26.**
|
| 51 |
+
|
| 52 |
+
All columns are in the **stretch / logit domain** (not probability): `p = sigmoid(x)`.
|
| 53 |
+
|
| 54 |
+
### int8 quantization
|
| 55 |
+
`x = int8_value * int8_scales[col]`. Scales are `bound/127` with
|
| 56 |
+
`bound = 12.203` for cols 0..23 and **`bound = 16.0` for col 24** (see Gotcha 1).
|
| 57 |
+
**Zero clipping occurred across all 402,653,184 rows x 25 cols.**
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## 2. The split — contiguous blocks with real gaps
|
| 62 |
+
|
| 63 |
+
A random *row* split would manufacture fake headroom (Wikipedia has enormous local
|
| 64 |
+
dependence). So: **48 contiguous blocks, each separated from every other block by
|
| 65 |
+
≥ 11,183,482 bytes (≈10.1 MB even after the shipped 1 MiB context) of never-used corpus.**
|
| 66 |
+
|
| 67 |
+
| | blocks | early | late |
|
| 68 |
+
|--------|--------|-------|------|
|
| 69 |
+
| train | 32 | 16 | 16 |
|
| 70 |
+
| val | 8 | 4 | 4 |
|
| 71 |
+
| test | 8 | 4 | 4 |
|
| 72 |
+
|
| 73 |
+
Blocks are grouped 4 train / 1 val / 1 test, rotating, spread across the whole corpus
|
| 74 |
+
(`frac` 0.007 → 0.986). **Every split spans early AND late stream.**
|
| 75 |
+
|
| 76 |
+
### ⚠ FRONT-LOADING IS THE #1 WAY TO GET A FAKE RESULT
|
| 77 |
+
cmix is dramatically better late in the stream. Measured on these blocks:
|
| 78 |
+
|
| 79 |
+
| region | cmix bits/byte |
|
| 80 |
+
|--------|----------------|
|
| 81 |
+
| early (first half) | **1.801267** |
|
| 82 |
+
| late (second half)| **1.082497** |
|
| 83 |
+
| all 48 blocks | 1.441882 |
|
| 84 |
+
| full corpus (true) | 1.484123 |
|
| 85 |
+
|
| 86 |
+
That is a **1.66x** swing, and per-block it ranges from **2.11** (b004, frac 0.09) to
|
| 87 |
+
**0.46** (b045, frac 0.95) — a **4.6x** range. A prior experiment extrapolated from an
|
| 88 |
+
early prefix and **overstated its result by 27.5%**.
|
| 89 |
+
|
| 90 |
+
**Report your gain per-block and aggregate weighted by the FULL corpus, not by your
|
| 91 |
+
sample.** Use `byteoff` / `frac` / `half` to check that your gain is not concentrated
|
| 92 |
+
early. If your gain is much larger on early blocks, say so.
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## 3. Reader (this is the whole API)
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
import json, numpy as np
|
| 100 |
+
M = json.load(open("manifest.json")); B = M["blocks"][17]; n = M["block_bits"]
|
| 101 |
+
d = f"blocks/{B['id']}"
|
| 102 |
+
X = np.fromfile(f"{d}/experts_i8.bin", np.int8).reshape(n, 25) \
|
| 103 |
+
* np.array(M["int8_scales"], np.float32) # (n,25) expert stretches (logit domain)
|
| 104 |
+
fp = np.fromfile(f"{d}/final_p_u16.bin", np.uint16).astype(np.float32) / 65536.0 # cmix P(bit=1)
|
| 105 |
+
fl = np.fromfile(f"{d}/labels_u8.bin", np.uint8)
|
| 106 |
+
y = (fl & 1).astype(np.float32) # THE LABEL: the coded bit
|
| 107 |
+
lstm_override = (fl >> 1) & 1
|
| 108 |
+
bitpos = np.arange(n) % 8 # 0 = MSB
|
| 109 |
+
byteoff = B["byte_start"] + np.arange(n) // 8 # absolute corpus offset
|
| 110 |
+
```
|
| 111 |
+
|
| 112 |
+
A head that *recalibrates* cmix should be parameterised as a **residual on cmix's own logit**:
|
| 113 |
+
`logit = log(fp/(1-fp)) + net(X, bitpos)`, so it starts exactly at cmix and gain > 0 is real.
|
| 114 |
+
|
| 115 |
+
**Smoke test before you train:** `python3 smoke_test.py . b005` — recomputes cmix's
|
| 116 |
+
bits/byte from your shards and checks it against the per-block anchor + sha256s.
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
|
| 120 |
+
## 4. What to pull (per-arm download sizes)
|
| 121 |
+
|
| 122 |
+
| profile | files | size |
|
| 123 |
+
|---|---|---|
|
| 124 |
+
| **bit-level head arm (r3, d3_80), full train+val+test** | `experts_i8` + `final_p_u16` + `labels_u8`, all 48 | **11.27 GB** |
|
| 125 |
+
| bit-level head arm, **val+test only** (eval / scoring) | same 3, 16 blocks | 3.76 GB |
|
| 126 |
+
| bit-level head arm, **test only** | same 3, 8 blocks | 1.88 GB |
|
| 127 |
+
| quick start / debug (tranche 1: 12 blocks, all splits, early+late) | same 3, 12 blocks | 2.82 GB |
|
| 128 |
+
| labels + final_p only (baselines, no experts) | 2 files x 48 | 1.21 GB |
|
| 129 |
+
| byte-level LM arm *(de-prioritised)* | `bytes_ctx` + `final_p` + `labels`, 48 | 1.31 GB |
|
| 130 |
+
|
| 131 |
+
Full repo ≈ **11.4 GB**. Pull only the blocks/files you need:
|
| 132 |
+
|
| 133 |
+
```bash
|
| 134 |
+
# one block, head-arm files only
|
| 135 |
+
for f in experts_i8.bin final_p_u16.bin labels_u8.bin; do
|
| 136 |
+
wget -x -nH --cut-dirs=4 \
|
| 137 |
+
https://huggingface.co/datasets/dfreelan/tte-cmix-residual-blocks/resolve/main/blocks/b005/$f
|
| 138 |
+
done
|
| 139 |
+
```
|
| 140 |
+
or `huggingface_hub.snapshot_download(repo_id=..., repo_type="dataset", allow_patterns=["manifest.json","blocks/b005/*"])`.
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
## 5. Sanity anchors (must reproduce)
|
| 145 |
+
|
| 146 |
+
- cmix full corpus: **1.484123 bits/byte**; mean coded bit = 0.4113.
|
| 147 |
+
- Per-block cmix bits/byte: `manifest["blocks"][i]["cmix_bits_per_byte"]`. These were
|
| 148 |
+
cross-checked against the trace's own authoritative per-byte cost column — all 48 agree.
|
| 149 |
+
- On a uniform sample of the whole stream: final_p loss **0.1855 bits/bit**; the 23
|
| 150 |
+
`mixer_0` experts land 0.1868–0.1890; slot 25 (raw mixer_1) 0.1863; slot 24 (lstm)
|
| 151 |
+
**0.2213** (the weakest). Ordering: final < raw mixer_1 < mixer_0 experts << lstm.
|
| 152 |
+
|
| 153 |
+
### int8 quantization-loss check (done, passes)
|
| 154 |
+
- Round-trip: `max|float - dequant(int8)|` = exactly half a step per column
|
| 155 |
+
(0.048 for the ±12.203 cols, 0.063 for col 24). No clipping anywhere.
|
| 156 |
+
- **Learned head (MLP 64, residual on cmix's logit, 6.4M train rows, 3 seeds), evaluated
|
| 157 |
+
on the test blocks:**
|
| 158 |
+
- float32 features: 0.1837512 ± 0.0000092 bits/bit
|
| 159 |
+
- int8 features: 0.1837531 ± 0.0000135 bits/bit
|
| 160 |
+
- **quantization cost = +0.0000018 bits/bit — 0.13x the seed-to-seed noise, i.e. BELOW
|
| 161 |
+
the noise floor.** In corpus terms: **+0.0011 MB.**
|
| 162 |
+
- Worst case, using a quantized stretch *directly* as the logit with no learned
|
| 163 |
+
recalibration: +0.000044 bits/bit (slot 25). Even this is <1% of any gain above
|
| 164 |
+
0.0044 bits/bit.
|
| 165 |
+
- **Conclusion: int8 is not your bottleneck.** If your measured gain is below ~0.4 MB,
|
| 166 |
+
ask the dataset builder for float16 shards (2x size) before trusting the last digit.
|
| 167 |
+
|
| 168 |
+
---
|
| 169 |
+
|
| 170 |
+
## 6. GOTCHAS — read these, they contradict the original brief
|
| 171 |
+
|
| 172 |
+
1. **Slot 25 (raw mixer_1) is NOT clamped to ±12.203.** Observed range **[-14.13, +13.23]**.
|
| 173 |
+
Only slots 0..22 and 24 are clamped. A uniform ±12.203 int8 map would have *clipped*
|
| 174 |
+
col 24. That is why col 24 uses `bound = 16.0`. **Use `manifest["int8_scales"]`, do not
|
| 175 |
+
hardcode 12.203/127.**
|
| 176 |
+
2. **The brief's per-bit loss anchors (final 0.2296, experts 0.2306–0.2340, lstm 0.2722)
|
| 177 |
+
are EARLY-PREFIX numbers, not full-corpus.** The true full-corpus figures are
|
| 178 |
+
final **0.1855**, experts 0.1868–0.1890, lstm **0.2213** — and they reconcile exactly
|
| 179 |
+
with the published 1.484123 bits/byte (÷8 = 0.185515). If your numbers look "too good"
|
| 180 |
+
versus the brief, this is why.
|
| 181 |
+
3. **`record_base_FULL.cache`'s header field `bits_fixed` is garbage** in this file
|
| 182 |
+
(it decodes to 2.5e7 bits/byte). Ignore it. The rest of that header is valid.
|
| 183 |
+
4. `bytes_ctx.bin` ships 1 MiB of **left context before** each block. It is for
|
| 184 |
+
*conditioning only* — **never train or evaluate on the context half.** It lies inside
|
| 185 |
+
the inter-block gap, so it never overlaps another block.
|
| 186 |
+
|
| 187 |
+
---
|
| 188 |
+
|
| 189 |
+
## 7. Provenance / source files (on the build box, not uploaded)
|
| 190 |
+
|
| 191 |
+
- Trace: `residual_trace_v1/enwik9_trace/enc.2074020.0.{res,bytes,meta}` — format `res_v3`,
|
| 192 |
+
**56 B per coded bit**: `u16 final_p; u8 flags(bit0=coded bit, bit1=lstm_override);
|
| 193 |
+
u8 reserved; f16[26]`. 263 GB, read-only.
|
| 194 |
+
- `record_base_FULL.cache` (9.39 GB): cmix's `final_p` for **all** coded bits —
|
| 195 |
+
96 B header, then `uint16[8][span]` **level-major**, `q[L][pos - warmup]`, with
|
| 196 |
+
`span = 587,136,778`, `warmup = 2048`. Verified: it equals the trace's `final_p`
|
| 197 |
+
bit-for-bit. **Not uploaded** — the per-block `final_p_u16.bin` shards cover it at
|
| 198 |
+
1/12th the size. Ask if you need the full cache.
|
| 199 |
+
- The corpus itself is already on HF as
|
| 200 |
+
`dfreelan/tte-hutter-staging/input_ready_587M.bin.zst` (byte-identical to the trace's
|
| 201 |
+
byte column). Not duplicated here.
|