lab

Tessera v2 Lab Report: Pure-Latent 2:1 k-d Tree Codec, Trials, Failures, and Future Pixel Head

Status, 2026-11-23. Detailed companion to the article Tessera: Content-Adaptive Image Tokenization in FLUX.2 Latent Space. All five curated-set arms and three of five held-out arms (R, RP, D) are complete. Held-out search (S) and RD-tree + prune (DP) are pending. A 512 to 4096 px resolution ladder is measured in section 8. See also the interactive demo and the original proposal.


1. Executive Summary & Shipped Configuration

Tessera v2 replaces the v1 pixel-space quadtree prototype (fixed PCA/polynomial codes + FLUX 16 px fallback + 150-call merge search) with a pure-latent 2:1 k-d tree codec operating on frozen FLUX.2 VAE latents (64×64×32 at 512×512 px).

Frozen production checkpoint & operating point

Component Exact Specification Evidence / Provenance
Codec checkpoint phase3_large_tl/step_20000.pt (md5 fef118176592bdb1bd63a45f404a2b09, sha256 6b092cfc9806…) HF tensorkelechi/tessera-checkpoints/phase3_large_tl/step_20000.pt
Decoder (TileUp) 22.18M params, widths (160, 256, 384), 4 attention blocks, zero_mean_resid=True, ac_floor=0.26, ac_tau=0.2 out/phase3_large_tl/train.log
Encoder (RectTileDown) 4.55M params, td_c=160, td_hid=512, td_1d_pool=True, td_prof_c=16, td_prof_len=32, td_dc_lock=True out/phase3_large_tl/train.log
Basis + Lift (RectTileLift) 0.78M params (tl_hid=256, tl_rank=8, tl_prof_len=32) over orthonormal dc_pca96 / plane_pca32 basis (rect_basis_full.pt, fit on 2,700 images) out/tessera_full_stats.json
TileUp spike guard --tu_spike_k 3, min area ≥ 64 latent cells (8×8 and larger); DC correction OFF out/dc_correct/REPORT.md, out/judge_recal/REPORT.md
Lead encoder LatentRouterRect (1.05M params, width 96, dilations 1,2,4,8,2,1, 44-ch input) + Judge verify loop (8 rounds, all-2×2 fallback) out/router_pilot/run1/REPORT.md
Challenger encoder RD-tree exact bottom-up DP (β=3, τ=2.0, λ=0.002) + Judge verify loop (zero training) out/rd_tree/REPORT.md, out/final_eval/pod/cur_D/
Frozen Judge bar (S15F+) --judge_scale 1.0 --struct_scale 1.5 --color_floor_de 1.0 --color_max_floor_de 1.8 --tu_spike_k 3, mae32_limit = 3.75 out/judge_recal/REPORT.md, out/mae32_relax/REPORT.md

2. Dataset, Splits, Denominators, and Token vs. Bitstream Accounting

2.1 Dataset & split boundaries (tensorkelechi/tessera-latents512-full)

Built from tensorkelechi/tessera-imageset (WebP-lossless, filtered for RGB, short side ≥ 512 px, JPEG Q ≥ 85 [WikiArt ≥ 70 + blockiness check], 64-bit DCT pHash dedupe Hamming ≤ 4, and SHA-256/pHash exclusion of all evaluation images).

Domain Train (n_train) Holdout Full (n_holdout_full) Holdout Balanced (heldout.pt) heldout_90 (h90) Router Labels (306) Calib (calib.pt)
chart 17,337 342 125 10 34 5
document 19,296 419 125 10 34 5
painting 46,957 1,025 125 10 34 5
photo 58,061 1,095 125 10 34 5
pixelart 9,559 205 125 10 34 5
screenshot 15,535 298 125 10 34 5
synth_flat 6,000 200 125 10 34 5
synthetic 7,217 141 125 10 34 5
texture 7,052 142 125 10 34 5
Total 187,014 3,867 1,125 90 306 45

2.2 Label counts vs. tile token counts vs. bitstream

  1. Label count (306): Number of training images whose ground-truth shape_map [2, 64, 64] was generated by Judge search (qtok/label_rect.py) to supervise LatentRouterRect (split 279 train / 27 val).
  2. Tile / leaf token count (N): Number of leaves in the 2:1 k-d tree partition of the 64×64 latent grid. Every leaf emits exactly one 128-float vector (TOK = 32 × 4 = 128), matching one 2×2 FLUX.2 grid token. All compression ratios and Waldo/Mondrian spreads use N against the 1,024-token grid denominator.
  3. Serialized bitstream overhead: Starting from the four 32×32 roots, a binary k-d tree with N leaves has N-4 internal split nodes and 2N-4 total nodes. Each non-2×2 node encodes a 3-way choice {leaf, split-H, split-V} (≤ 2 bits/node, or log2 3 ≈ 1.585 bits entropy-coded). Even at worst-case N=1,024, the tree topology takes ≤ 4,096 bits = 512 bytes (≤ 1 fp32 token equivalent, or 2 fp16 tokens), compared to N × 256 bytes of fp16 token payload (262 KB at N=1,024; 15.6 KB at N=61). Container metadata adds a fixed header of a few dozen bytes.

3. Architecture & Training Progression

3.1 4k-step architecture ablation (out/ablation_4k/, RunPod A5000, ~$0.76)

Three variants were trained for 4,000 steps (pixel_every=1, crop=32, bs=32, ~41 min each) to test whether TileUp width and RectTileLift mattered:

Variant Final val_lat val_judge heldout_90 mean tokens (J3.0) Pass % Takeaway
ablate_med_lin 0.2206 18.52 416 100% Baseline medium TileUp, linear lift only
ablate_med_tl 0.2205 18.63 410 100% TileLift marginal at 4k (−6 tok)
ablate_large_tl 0.2186 18.22 401 100% Best across all three metrics; selected for 20k run

3.2 Full 20k-step training (phase3_large_tl, RunPod A5000, ~7.9 h)


4. Trials, Diagnostics, and Failures (Complete Log)

This section documents every diagnostic investigation and negative result that shaped the final codec.

Trial 1: --split_rank (ranked top-down splitting) — DROPPED

Trial 2: --prune_fast silent early-exit bug — DIAGNOSED

Trial 3: Encoder-side per-tile DC colour correction (dc_correct) — PROVEN, HELD OFF

Trial 4: Eval-time pixel-scale AC gate — FAILED

Trial 5: Large-tile residual gain vs. per-tile spike clamp (--tu_spike_k 3) — CLAMP ADOPTED

Trial 6: Anti-spike TileUp fine-tune (ft_antispike) — NO-GO AT STEP 500

Trial 7: Judge recalibration & blind eye check (out/judge_recal/REPORT.md) — ADOPTED (S15F+)

Trial 8: Mondrian gap diagnosis & mae32 relaxation (out/mondrian_gap/, out/mae32_relax/) — RELAXATION REJECTED

Trial 9: Edge-priority split search — MIXED, DROPPED

Trial 10: RD-tree λ-only cliff & noise-floor τ fix (out/rd_tree/REPORT.md) — CHALLENGER ADOPTED

Trial 11: Stage-2 Router pilot & infrastructure incidents (out/router_pilot/run1/REPORT.md)


5. Complete Final Evaluation Tables (S15F+)

5.1 Curated 24-image set (cur, n=24)

arm n pass fallback tok mean tok med calls/img s/img PSNR/SSIM/LPIPS/DISTS vs grid vs orig
S 24 100.0% 0/24 348.7 233 171.0 72.5 37.81/0.9560/0.0194/0.0432 32.38/0.9333/0.0293/0.0623
R 24 100.0% 0/24 384.2 304 2.7 1.3 42.43/0.9622/0.0150/0.0353 33.20/0.9384/0.0253/0.0554
RP 24 100.0% 0/24 347.1 236 168.7 69.4 37.91/0.9554/0.0195/0.0437 32.46/0.9328/0.0295/0.0630
D 24 100.0% 0/24 413.6 390 2.8 1.3 45.65/0.9683/0.0135/0.0320 33.26/0.9427/0.0235/0.0525
DP 24 100.0% 0/24 356.4 275 172.3 53.6 37.89/0.9578/0.0182/0.0420 32.41/0.9346/0.0281/0.0613

Per-image tokens (Judge calls in parentheses; every image passes in every arm):

image S R RP D DP
c03d56fb9e5fe67f 428 (266) 440 (2) 427 (258) 499 (3) 432 (259)
flat_blue_50_150_220 4 (2) 16 (1) 4 (4) 4 (1) 4 (2)
fs_Mondrian_Composition_B144 374 (265) 467 (3) 339 (259) 456 (2) 355 (258)
fs_Piet_Composition 222 (214) 268 (4) 199 (193) 331 (3) 205 (182)
fs_plain-blue 22 (27) 35 (2) 23 (32) 34 (2) 24 (28)
fs_sky 50 (64) 80 (6) 68 (64) 102 (4) 79 (85)
fs_waldo3 996 (265) 997 (2) 995 (258) 1002 (2) 994 (258)
j5_00_Composition__1921_-Piet_Mondrian_ 230 (221) 410 (3) 224 (219) 407 (2) 276 (258)
j5_01_Piet_Mondriaan__1930_-_Mondrian_C 236 (226) 281 (3) 248 (239) 315 (2) 235 (216)
j5_02__Composition__by_Piet_Mondrian__1 283 (264) 355 (2) 278 (258) 407 (3) 286 (249)
j5_39_waldo_altdorfer_crucifixion 704 (265) 750 (2) 699 (258) 842 (2) 748 (258)
j5_40_waldo_costumes_station_crowd 637 (265) 716 (2) 616 (258) 730 (3) 636 (259)
j5_41_waldo_book_page_user 1023 (265) 1024 (2) 1023 (258) 1024 (2) 1023 (258)
j5_mondrian_5 69 (58) 84 (4) 69 (55) 99 (5) 75 (67)
j5_mondrian_7 102 (85) 116 (4) 100 (75) 142 (5) 104 (83)
j5_photo_mondrian_4 181 (175) 237 (2) 206 (182) 498 (2) 278 (258)
j5_photo_mondrian_5 269 (247) 327 (3) 280 (259) 373 (3) 274 (253)
j5_rock_00_Cross_rock_texture_2012_G1 988 (265) 1013 (2) 987 (258) 1006 (2) 989 (258)
j5_text_slide_sans 357 (265) 368 (2) 346 (258) 413 (4) 343 (260)
mr_simple_plain_blue 20 (26) 29 (2) 21 (27) 32 (1) 22 (19)
waldo2 1021 (265) 1021 (2) 1021 (258) 1024 (2) 1021 (258)
wms_mondrian_2 102 (75) 113 (4) 98 (71) 115 (5) 96 (71)
wms_mondrian_6 47 (33) 61 (4) 56 (42) 67 (5) 51 (37)
wms_sky_0 4 (2) 13 (1) 4 (5) 4 (1) 4 (2)

5.2 Held-out 90-image set (heldout_90, n = 90, 10/domain)

Snapshot of out/final_eval/pod/h90_* taken 2026-11-23. Every row is a complete 90-image run. Arms with no completed run are marked pending.

arm n pass fallback tok mean tok med calls/img s/img PSNR/SSIM/LPIPS/DISTS vs grid vs orig
S pending
R 90 100.0% 0/90 369.6 248 2.9 1.5 35.22/0.9640/0.0209/0.0276 32.14/0.9389/0.0296/0.0445
RP 90 100.0% 0/90 329.0 213 163.9 57.1 33.46/0.9516/0.0290/0.0367 31.21/0.9288/0.0371/0.0509
D 90 100.0% 1/90 406.9 258 3.3 1.6 37.05/0.9719/0.0165/0.0226 32.51/0.9453/0.0256/0.0408
DP pending

FLUX.2 Grid (1,024 tokens) vs Original on heldout_90: 35.50 dB PSNR / 0.9657 SSIM / 0.0109 LPIPS / 0.0263 DISTS.

Mean tokens (pass rate) per domain:

domain S R RP D DP
chart pending 158 (100%) 121 (100%) 167 (100%) pending
document pending 484 (100%) 431 (100%) 510 (100%) pending
painting pending 689 (100%) 619 (100%) 767 (100%) pending
photo pending 635 (100%) 575 (100%) 687 (100%) pending
pixelart pending 278 (100%) 244 (100%) 364 (100%) pending
screenshot pending 180 (100%) 166 (100%) 198 (100%) pending
synth_flat pending 85 (100%) 62 (100%) 90 (100%) pending
synthetic pending 80 (100%) 62 (100%) 89 (100%) pending
texture pending 737 (100%) 680 (100%) 790 (100%) pending

---|---|---|---|---|---|---|---|---|---| | S | not run | | | | | | | | | | R | 90 | 100.0% | 0/90 | 369.6 | 248 | 2.9 | 1.5 | 35.22/0.9640/0.0209/0.0276 | 32.14/0.9389/0.0296/0.0445 | | RP | not run | | | | | | | | | | D | 90 | 100.0% | 1/90 | 406.9 | 258 | 3.3 | 1.6 | 37.05/0.9719/0.0165/0.0226 | 32.51/0.9453/0.0256/0.0408 | | DP | not run | | | | | | | | |


6. Future Architecture: Direct Pixel Head

Almost every stubborn failure in Trials 3–8 traces back to forcing variable-size coarse tiles through a frozen 8×-downsampled VAE decoder (AutoencoderKLFlux2):

Pure-latent bottleneck (v2) Root mechanism How a direct Pixel Head resolves it
Flat-tile colour drift (1–4 RGB, shattering skies without colour floors) Dec(E[z]) ≠ E[Dec(z)] through non-linear VAE GroupNorm/SiLU layers Direct RGB prediction with explicit per-tile mean-colour supervision in pixel space; zero VAE nonlinearity between token DC and decoded RGB
Positional dark dot / spike exploit (43× HP energy at cell (2,2)) Latent-space HP RMS loss can be cheated by a single 2×2 latent spike that decodes to a localized RGB dot Direct pixel-space perceptual + adversarial (PatchGAN) + local block-energy loss; seeded noise injection for matched film grain
1 px bar overshoot & text softness (forcing wms_mondrian_2 to ~100–113 tok under mae32=3.75) 8× latent spatial quantization + frozen VAE decoder blurs or overshoots sub-cell sharp edges Pixel-space upsampling head with direct 1 px edge/stroke gradients and neighbour context across tile seams
Verify-loop latency (~1.3 s/img for 2.7–3.3 calls) Each Judge check requires running the full FLUX.2 VAE decoder Lightweight pixel head decodes in milliseconds; optionally supports localized partial-canvas re-decode during verification

Proposed hybrid pixel-head design (v3 roadmap)

  1. Keep the 2:1 k-d tree, 128-float token interface, and LatentRouterRect: Downstream generative models (BreadthGenRect, packed FlexAttention + 2D center RoPE) see the exact same variable-length sequence of 128-float tokens.
  2. Decode directly to RGB: Replace TileUp → Frozen FLUX.2 VAE Decoder with a multiscale ConvNeXt/attention Pixel Head that takes the lifted tile canvas (plus shape-embedding & seeded grain channels) and outputs RGB directly, while optionally retaining a lightweight residual skip from the FLUX.2 decoder on 2×2 passthrough leaves or training the pixel head end-to-end to match/beat FLUX.2 on 16 px tiles as well.
  3. Train against S15F+-aligned pixel objectives: Direct Lab colour-mean loss on coarse tiles, multi-scale LPIPS + DISTS + PatchD, and per-window mae32 hinge loss so training and Judge verification optimize the exact same perceptual surface.
  4. Higher resolution: sections 1–7 are measured at 512 px; the blockwise 512 to 4096 px ladder is in section 8. Whole-image (cross-block) coding and verification remain untested.

7. Blind comparison on the four curated Mondrians

One reviewer rated the verified router and the FLUX.2 grid equally close to the displayed source on all four curated Mondrians. The adaptive layouts used 61–116 tokens and the grid used 1,024. Each sheet independently shuffled the reconstruction labels.

Sheet Image Tessera column Tessera tokens Verdict
1 wms_mondrian_2 A 113 Tie
2 j5_mondrian_5 B 84 Tie
3 wms_mondrian_6 A 61 Tie
4 j5_mondrian_7 B 116 Tie

8. Higher resolution: 512 to 4096 px

Everything above is at 512 px. The following measures the same public tessera CLI (router mode, strict S15F+ Judge, verify on) on the same kinds of picture at 512, 1024, 2048 and 4096 px. The CLI itself is 512 px only, so every larger image is cut into independent 512×512 blocks; each block is encoded and Judge-verified on its own (369 of 369 blocks in the five classes below pass, 0 grid fallbacks). The baseline is the blockwise FLUX.2 grid: 1,024 tokens per block.

Compression ratio against the FLUX grid for five image classes, 512 to 4096 pixels, log scales
Compression ratio against the FLUX grid for five image classes, 512 to 4096 pixels, log scales

Compression ratio against the blockwise FLUX.2 grid, one line per image class. RTX 4090 and RTX 4000 Ada runs of the public CLI in router mode at S15F+, every 512 px block verified. Waldo and the painting end at 4096×2048 and 4096×2560.

image class 512² 1024² 2048² 4096²
FLUX grid tokens 1,024 4,096 16,384 65,536
Smooth sky (synthetic) 69 (14.8×) 102 (40.2×) 270 (60.7×) 825 (79.4×)
Clean Mondrian (synthetic) 120 (8.5×) 295 (13.9×) 837 (19.6×) 2,253 (29.1×)
Text slide 368 (2.8×) 980 (4.2×) 2,057 (8.0×) 4,283 (15.3×)
Dense painting (Veronese) 629 (1.6×) 2,431 (1.7×) 10,309 (1.6×) 26,537 (1.5×)
Where's Waldo (4K page) 1,023 (1.0×) 4,065 (1.0×) 15,783 (1.0×) 30,904 (1.1×)

Tokens (× fewer than the blockwise FLUX.2 grid). Flat blue, not drawn, is 64× at every size (16 tokens per block). The painting's 4096 rung is 4096×2560 (grid 40,960) and Waldo's is 4096×2048 (grid 32,768) because both source pages are wider than tall; sky and Mondrian are 4096×4096. Mondrian, sky and the slide are rendered natively at each size (features scale with the image); the painting is native 1:1 crops of a 4,214 px file; Waldo 512–2048 are Lanczos downscales of the central 2,304 px square of a 4K page and its 4096 rung is the native 4096×2048 band.

What it shows. Smooth and sparse content gets cheaper per pixel as the image grows: sky goes from 14.8× to 79.4×, the clean Mondrian from 8.5× to 29.1×, the results slide from 2.8× to 15.3×. Flat blue stays at 64×. Dense real images do not: the painting stays at 1.5–1.7× and the Waldo page at 1.0–1.1×.

Mondrian vs Waldo at matched sizes

At the same pixel size the same encoder gives a clean synthetic Mondrian and the Waldo page very different budgets:

size Mondrian tokens Waldo tokens Waldo ÷ Mondrian
512² 120 1,023 8.5×
1024² 295 4,065 13.8×
2048² 837 15,783 18.9×
4096×2048 1,317 30,904 23.5×
Tokens for a synthetic Mondrian and a Where's Waldo page at 512, 1024, 2048 and 4096 by 2048 pixels, with the ratio between them
Tokens for a synthetic Mondrian and a Where's Waldo page at 512, 1024, 2048 and 4096 by 2048 pixels, with the ratio between them

Same pixel size, same encoder and bar. The Mondrian is a ladder scene, not the curated 61-token one, and Waldo 512–2048 are downscales of a 4K page, so this is a scaling comparison, not the 512 px bounty number.

Latency per 512 block

Per 512×512 block, warm median of 3 on an RTX 4090: VAE encode about 14 ms, tokenise and error maps about 18 ms, router 13–24 ms, verify loop 0.06–0.28 s (1–4 Judge calls, depends on the picture), tile decode (TileUp + FLUX decoder) 45–56 ms against 39.5 ms for the plain FLUX grid decode.

Seam error (border step vs interior step, mean absolute level difference)

case, size Tessera border / interior blockwise FLUX border / interior native FLUX border / interior
sky 4096² 2.8 / 0.08 2.52 / 0.09 not run
Mondrian 4096² 2.89 / 0.06 2.52 / 0.03 0.12 / 0.06 (tiled)
Mondrian 4096×2048 2.29 / 0.08 1.78 / 0.05 0.09 / 0.06 (tiled)
slide 4096² 1.87 / 0.17 1.36 / 0.1 not run
painting 4096×2560 6.35 / 4.1 4.36 / 3.07 not run
Waldo 4096×2048 8.61 / 3.96 7.74 / 3.71 3.67 / 3.63 (tiled)

Border is the 1 px step across x or y = 512k, interior the same measure 256 px inside a block; a stitched codec without seams has border ≈ interior. Full tables: out/resolution_ladder/tables.md and ladder_summary.csv.

Caveats.