lab

Tessera: Content-Adaptive Image Tokenization in FLUX.2 Latent Space

Status, 2026-11-23. All five curated-set arms and three of five held-out arms (R, RP, D) are measured and reported below. The other two held-out arms (S, DP) are pending and marked as such. Higher-resolution results (512 to 4096 px, measured on 2026-11-23) are in their own section. Companion pages: interactive demo · detailed lab report · original proposal.


Abstract

A standard grid VAE spends the same number of tokens on every image: 1,024 tokens for a 512 px picture in FLUX.2's 32×32 grid, whether the image is a flat blue sky, a Mondrian composition, or a Where's Waldo? page. Tessera replaces the uniform grid with a 2:1 k-d tree of rectangular tiles directly inside FLUX.2's frozen latent space (64×64×32 at 512 px). Every tile—whether 16×16 px or 256×256 px—emits one 128-float token, matching the exact vector width of a FLUX.2 grid token.

Rather than running a slow per-image search, Tessera uses a 1.05M-parameter one-pass router (LatentRouterRect, trained on just 306 labelled training images) paired with a lightweight Judge verification loop under a recalibrated, eye-checked perceptual bar (S15F+). On 45 calibration images disjoint from the router's labels and holdout set, router + verification passes 45/45 (100%) with 0 grid fallbacks, using 1.04–1.07× the tokens of full search at 2.8–3.3 Judge calls/image instead of 40 (~11× faster). On a 24-image curated development set under S15F+, the verified router averages 384.2 tokens (median 304, −62.5% vs the 1,024-token grid, 100% pass, 0/24 fallbacks, 1.3 s/image), compressing a clean Mondrian (wms_mondrian_6) to 61 tokens against 1,021–1,024 tokens for dense Waldo pages (16.7–16.8× same-resolution spread; 14.8× against the 5-Waldo mean of 902 tokens), and four flat or plain-colour images to 13–35 tokens (29–79×; the textured fs_sky photo takes 80). A zero-training rate–distortion dynamic programming tree (RD-tree) + verification also achieves 24/24 pass with 0 fallbacks at 413.6 mean tokens.

On the 90-image held-out set (10 per domain, never trained on or labelled) the verified router averages 369.6 tokens (median 248, −63.9% vs the grid, 100% pass, 0/90 fallbacks, 2.9 Judge calls/image). The verified router with pruning reaches 329.0 (median 213, −67.9%, 100% pass) at 163.9 calls/image, and the verified RD-tree averages 406.9 (100% pass, 1/90 grid fallback). Held-out search (S) and RD-tree with pruning (DP) are pending.

We report the exact split boundaries, denominators, perceptual bar, and a measured 512 to 4096 px resolution ladder, and what remains open: the two pending held-out arms, the limits of a frozen latent decoder on thin lines and colour drift, and our planned direct pixel-head successor.


1. The Idea: Variable-Size Rectangular Tiles, Fixed-Width Tokens

Fixed-grid visual tokenizers conflate spatial area with information density. A 128×128 px patch of clear sky receives 64 tokens; a 128×128 px patch of dense 11 px document text also receives 64 tokens.

Tessera keeps the frozen FLUX.2 VAE latent space (64×64×32 cells for a 512×512 image, where each 2×2 cell block is one 16×16 px grid token of 4 × 32 = 128 floats) and partitions the 64×64 latent canvas into a 2:1 k-d tree starting from four 32×32 roots. Each node either stays a leaf or splits horizontally or vertically ({leaf, split-H, split-V}) while keeping aspect ratios ≤ 2:1. That yields 13 tile shapes spanning 16×16 px (2×2 cells) up to 256×256 px (32×32 cells), including 2:1 and 1:2 rectangles that align cleanly with bars, margins, and horizons.

Token counts vs. labels vs. bitstream

To avoid ambiguity across tables in this article:

Quantity Meaning Typical value
Leaf token count (N) Number of 128-float tile tokens emitted for one 512 px image. Directly comparable to the FLUX.2 grid's 1,024 tokens. All ratios and tables report N. 4 – 1,024 tokens
Router label count Number of training images whose target k-d tree layouts were generated offline by Judge search to train LatentRouterRect. 306 images (34/domain)
Bitstream / container size Serialized payload (N × 128 floats: 256N bytes in fp16) plus the 2:1 k-d tree split header. A tree with N leaves has 2N-4 nodes from the 4 roots; coding each non-2×2 node's 3-way action takes ≤ 2 bits/node (≤ 4N bits, or ≤ 512 bytes even at N=1,024 — less than 1 fp32 token equivalent). 256N B (fp16) + ≤ 0.5N B header

Tessera optimizes token count (transformer sequence length), not entropy-coded bits per pixel.


2. The Perceptual Bar: Why We Recalibrated Judge v5 (S15F+)

Any adaptive tokenizer is only as honest as the quality bar that stops it from over-merging. Tessera uses Judge v5, which takes three images—the original, the FLUX.2 grid VAE decode, and Tessera's candidate—and measures excess degradation over the grid VAE across six families of metrics: LPIPS-VGG, DISTS texture, low-pass Lab colour (color_mean256, color_max256, color_max64, color_max16), fine-detail energy, inter-tile seams, and a per-32 px-window pixel-error gate (mae32).

During development on our 20k-step checkpoint (phase3_large_tl/step_20000.pt), blind visual checks revealed that our earlier single-scalar judge_scale=3.0 (J3.0) setting was miscalibrated in both directions:

  1. Too loose on structure: At J3.0, mae32 sat at 7.5 RGB levels (3× looser than eye-checked J1.0), letting smeared text pass inside oversized tiles.
  2. Sub-JND on flat colour: Conversely, the raw color_mean256 tolerance was 0.097 ΔE at J1.0 and 0.291 ΔE at J3.0—far below human just-noticeable colour difference (~1–2 ΔE). Tiny systematic colour drift from the frozen VAE decoder shattered completely clean blue skies and flat panels into 500–800 tiles.
  3. Deterministic TileUp spike on large flat tiles: Once colour floors unlocked 8×8 to 16×16 latent tiles, we discovered a single positional dark dot + pale halo at in-tile cell (2, 2) caused by the training high-pass RMS loss being minimized by a concentrated 2×2 spike rather than spread grain. Clamping the TileUp high-pass residual at k = 3 standard deviations on tiles of area ≥ 64 latent cells (--tu_spike_k 3) eliminated the dot leaves (7 → 0 across the 11-image pilot) with zero retraining.

We therefore froze the S15F+ operating point for all final evaluations and router labelling:

On the 143-case perceptual control bank, S15F rejects 84/94 synthetic damage cases, matching strict J1.0 on glyph damage (5/5), blur (15/15), seam (14/15), and hue (14/20), with 9/12 on mesh damage. In blinded native-resolution crop checks, the author confirmed that S15F+ kept text slides readable, eliminated the blue-gradient dots, and gave appropriate sky layouts.


3. Fast Encoding Without Slow Search: Router + Verify vs. RD-Tree

Full top-down search + 32-call sibling pruning under S15F+ averages ~40 Judge calls/image (~7.9 s/image on an RTX A4000). We evaluated two fast front-ends paired with an iterative verify loop (up to 8 rounds of splitting only the leaves touching failing bad8 cells, with an all-2×2 grid fallback if still failing):

  1. Learned Router (LatentRouterRect, 1.05M params): A dilated FCN over 44 input channels (normalized latent + 12 per-shape RectTileDown lift-error maps) with box-pooled node features and a log-shape MLP predicting {leaf, split-H, split-V}. Trained in 472 seconds on 306 balanced training images (34/domain from train_*_00000.pt, 279 train / 27 val).
  2. Zero-Training RD-Tree (qtok/rd_tree.py): Exact bottom-up dynamic programming over the 2:1 k-d tree using a noise-floored lift-error objective D = ReLU(mean + β · max - τ) + λ (arm A: β=3, τ=2.0, λ=0.002).

Calibration benchmark (45 disjoint train-shard images, 5/domain, S15F+)

Encoder arm (S15F+, calib.pt, n=45) Pass % Grid fallback Mean tokens vs. Search Judge calls/img Latency (ms/img)
Search + prune (cap 32, reference) 100.0% 0/45 343.1 1.00× 40.0 7,931
Router alone (leaf_bias = 0.0) 4.4% 0/45 347.2 1.01× 1.0 283
Router alone (leaf_bias = 1.0) 0.0% 0/45 310.8 0.91× 1.0 272
Router + Verify (leaf_bias = 0.0) 100.0% 0/45 367.3 1.07× 2.8 636
Router + Verify (leaf_bias = 0.5) 100.0% 0/45 361.2 1.05× 3.0 682
Router + Verify (leaf_bias = 1.0) 100.0% 0/45 358.0 1.04× 3.3 731
RD-tree one-shot (τ=2.0) 0.0% 0/45 277.3 0.81× 1.0 263
RD-tree one-shot (τ=1.5) 35.6% 0/45 431.4 1.26× 1.0 266
RD-tree one-shot (τ=1.0) 75.6% 0/45 517.1 1.51× 1.0 262

Key takeaway: Neither the 306-label router nor the RD-tree is reliable Judge-free (one-shot pass is 0–4.4% for the router and 0–75.6% for RD-tree only at a 1.51× token penalty). However, Router + Verify hits 100% pass with 0/45 fallbacks, landing within 4–7% of full search tokens while cutting Judge calls by 12–14× (40 → 2.8–3.3) and wall time by ~11×. That result was strong enough to skip the planned 2,000-image labelling run.


4. Results

Data splits and evaluation sets

Every dataset and benchmark in this report has a distinct role:

Curated 24-image benchmark under frozen S15F+

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

FLUX.2 Grid (1,024 tokens) vs Original on cur (n=24): 36.87 dB PSNR / 0.9637 SSIM / 0.0095 LPIPS / 0.0204 DISTS.

Dynamic range: Waldo vs. Mondrian and flat/sky spreads (cur, S15F+)

Five distinct Waldos: j5_41_waldo_book_page_user (1,024), waldo2 (1,021 R / 1,024 D), fs_waldo3 (997 R / 1,002 D), j5_39_waldo_altdorfer_crucifixion (750 R / 842 D), j5_40_waldo_costumes_station_crowd (716 R / 730 D). Mean Waldo = 902 (R) / 924 (D); Max Waldo = 1,024.

Waldo pages: fs_waldo3, j5_39_waldo_altdorfer_crucifixion, j5_40_waldo_costumes_station_crowd, j5_41_waldo_book_page_user, waldo2.

arm max-Waldo mean-Waldo wms_mondrian_2 tok (x max / x mean) wms_mondrian_6 tok (x max / x mean) j5_mondrian_5 tok (x max / x mean) j5_mondrian_7 tok (x max / x mean) median x(max) count >=16x (max) >=16x (mean)
S 1023 876 102 (10.0 / 8.6) 47 (21.8 / 18.6) 69 (14.8 / 12.7) 102 (10.0 / 8.6) 12.4 1/4 1/4
R 1024 902 113 (9.1 / 8.0) 61 (16.8 / 14.8) 84 (12.2 / 10.7) 116 (8.8 / 7.8) 10.6 1/4 0/4
RP 1023 871 98 (10.4 / 8.9) 56 (18.3 / 15.5) 69 (14.8 / 12.6) 100 (10.2 / 8.7) 12.6 1/4 0/4
D 1024 924 115 (8.9 / 8.0) 67 (15.3 / 13.8) 99 (10.3 / 9.3) 142 (7.2 / 6.5) 9.6 0/4 0/4
DP 1023 884 96 (10.7 / 9.2) 51 (20.1 / 17.3) 75 (13.6 / 11.8) 104 (9.8 / 8.5) 12.1 1/4 1/4

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.

Honest reading of the 16× spread: Under the strict S15F+ bar without pruning, Tessera clears 16× on one clean synthetic Mondrian pair (waldo2 1,021 / wms_mondrian_6 61 = 16.7×; max-Waldo 1,024 / 61 = 16.8×), and reaches 29–79× (router) on flat and plain-colour images, up to 256× (4 tokens) with the search and RD-tree arms on a flat blue and a clean sky. Against the 5-Waldo mean (902), wms_mondrian_6 is 14.8×, and the median across all four clean Mondrians is 10.6× (1/4 ≥ 16×). (Under the looser legacy J3.0 bar with full pruning, 18/20 clean Mondrian × Waldo pairs cleared 16× with a 27.9× median and 39.9× on waldo2/mondrian_2, but J3.0 failed our blind text check and is not our shipping quality bar.) Photographed paintings with canvas weave stay at 2–4× because real canvas texture genuinely carries high-frequency detail. The table above gives the observed count at 16× for every curated arm: one of four Mondrians clears it against the max-Waldo in S, R, RP and DP, and none in D.

Held-out 90-image benchmark (heldout_90, 10/domain)

Snapshot of out/final_eval/pod/h90_* taken 2026-11-23. Every row below is a complete 90-image run under the frozen S15F+ bar. 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 (n = 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

Reading the held-out table:

---|---|---|---|---|---|---|---|---|---| | 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 | | | | | | | | |


5. What We Learned and What Comes Next: The Pixel Head

Building Tessera end to end exposed a structural ceiling in pure-latent decoding through a frozen VAE:

  1. Non-linear colour drift (Dec(E[z]) ≠ E[Dec(z)]): Averaging or projecting FLUX.2 latents over large tiles produces systematic 1–4 RGB colour shifts after the frozen VAE decoder, which is why colour gates initially shattered flat skies and why encoder-side DC correction had to invert the VAE numerically.
  2. Latent-space spike exploits: Optimizing high-pass variance in latent space lets a ConvNeXt decoder satisfy tile-level RMS with a single deterministic 2×2 spike rather than natural texture, requiring an eval-time spike clamp (--tu_spike_k 3).
  3. 1 px line overshoot on clean graphics: On clean Mondrians under S15F+, large leaves overshoot black bar edges by ~1 px, hitting mae32 = 3.75 and forcing ~100 tokens where ~25–50 would otherwise suffice.
  4. Verification latency: Even at 2.7–3.3 Judge calls/image, every verification round must run the full frozen FLUX.2 VAE decoder to reach pixel space (~1.3 s/image on an A4000).

The planned next architecture — a direct Pixel Head: Instead of decoding coarse tiles into FLUX.2 latent space and paying a full VAE decode pass for every refinement and verification step, a dedicated pixel-space decoder head (or hybrid pixel head alongside 16 px FLUX passthrough) can map variable-size tile tokens directly to RGB pixels with direct pixel-level colour, edge, and grain supervision. That removes the Dec(E[z]) nonlinearity, eliminates the latent high-pass spike pathology, sharpens 1 px strokes and small text, and cuts encode-time verification cost by an order of magnitude.


Higher resolution: 512 to 4096 px (measured)

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.

Caveats.


6. Open Items