Skip to content

Add the latent-contracts research memo - #40

Merged
IonDen merged 3 commits into
mainfrom
docs/paper-latent-contracts
Sep 10, 2026
Merged

IonDen merged 3 commits into
mainfrom
docs/paper-latent-contracts

Conversation

@IonDen

@IonDen IonDen commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

This adds the first research memo to docs/papers/: The latent in the callback is not the latent the decoder wants.

The memo reads nine mflux image models at the public v.0.19.1 tag and records what each one hands its in-loop callback: the tensor layout, the spatial divisor, where the 2×2 sub-pixel unpack happens, and which component applies the normalization. Four of those models decode through the same VAE class, and the Hub confirms two of them ship byte-identical weights, yet they arrive in three layouts and two normalization schemes. FLUX.2 Klein and Ideogram 4 fold the sub-pixels into the packed channel axis in different orders, and a synthetic latent pushed through both orders shows the plausible-looking scramble that produces. The memo also records that a Hugging Face mirror of the taew2.1 tiny decoder differs from the canonical file in 87% of its values while matching it in size, tensor names, shapes and dtype, which is why every weight source in this library is pinned by digest.

Nothing was generated or benchmarked for it. Every per-model claim is read from pinned source; two file-level checks (Hub digests, the weight comparison) are dated in the text. The README gains a short "Research notes" section linking the memo. No package code changes.

A follow-up commit, after review, corrects one claim: the memo now states that mlx-taef applies the VAE's batch-norm inverse before TAEF2 while the reference wrapper and ComfyUI do not, and that which input domain the decoder expects has not been measured. That measurement is tracked separately.

Documents what mflux's in-loop callback hands a preview decoder for nine
image models across three VAE families: the packing, the sub-pixel fold
order, the spatial divisor and the normalization all live in the generator,
so sharing a VAE, even byte-identical weights, does not mean sharing a latent
contract. Includes a synthetic-latent figure of the FLUX.2 and Ideogram 4 fold
orders with its generator script, a hash table for the shared VAE files, and a
README link.
@IonDen IonDen added the documentation Improvements or additions to documentation label Sep 10, 2026
@IonDen IonDen self-assigned this Sep 10, 2026
@IonDen IonDen added the documentation Improvements or additions to documentation label Sep 10, 2026
Sorted imports, type annotations and a docstring on the two helpers, one
statement per line. The rendered figure is byte-identical.
The memo no longer asserts that TAEF2 was distilled on the raw latent:
mlx-taef applies the batch-norm inverse before it, the reference wrapper and
ComfyUI do not, and the repository has not measured which is right. The
identity-BN degradation is described as documented rather than observed, the
canonical taew2.1 link is pinned to a commit, the Klein row and one line
anchor are corrected, and the README summary matches the memo.
@IonDen
IonDen merged commit 9be7e61 into main Sep 10, 2026
7 checks passed
@IonDen
IonDen deleted the docs/paper-latent-contracts branch September 10, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant