Skip to content

h3: MiniMax-H3-Image's VAE rules on the host, and Pillow's Lanczos-3 in core/picture - #2775

Merged
ashhart merged 3 commits into
mainfrom
lead/h3-image-pixels
Nov 21, 2026
Merged

ashhart merged 3 commits into
mainfrom
lead/h3-image-pixels

Conversation

@ashhart

@ashhart ashhart commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

What this changes

MiniMax-H3-Image's VAE rules on the host, and Pillow's Lanczos-3 resize. These are the parts its image decoder and edit encoder share. Before, TensorFold had no MiniMax-H3-Image VAE rules and core/picture resized with Keys' cubic or Pillow's triangle only. After:

  • zig/src/families/h3/picture_vae.zig checks vae/config.json at the released geometry, splits an axis into 256-pixel tiles and blends them, and handles the latent statistics, the bytes and the posterior:

    • Config: the latent statistics and the tile and overlap sizes are read; every other decoder field must match the release, or the config is refused by name.
    • Tile split: tiles overlap by at least 64 pixels, the spare is spread 16 pixels at a time from the first overlap, and the last tile ends on the edge.
    • Assembly: each tile's top band is blended with the tile above as decoded, then its left band with the tile to its left, in float32 with the weights 1 - p/e and p/e.
    • Latent statistics in both directions.
    • Bytes: ImageNet's statistics map to [0, 1], then bytes truncate rather than round.
    • Posterior: mean + exp(0.5 · clamp(logvar)) · noise, kept as fp16.
  • zig/src/core/picture/resample.zig gains Filter.lanczos: sinc(x) · sinc(x / 3) within 3, through the same 22-bit fixed point as the other filters. Nothing that resizes today uses it, so every existing resize keeps its bytes.

  • Issue: n/a. The maintainer asked for MiniMax-H3-Image directly. This adapts the behaviour clean-room from a written spec of vLLM-Omni's and SGLang's support. copy_scan against hashes of every upstream file read finds no run of 12 or more tokens.

  • Stacked on: h3: MiniMax-H3-Image's transformer on Metal from a picture case (tf-h3-image) #2766 (its six commits). This adds f5dad8bcac.

  • atc overlap --json: no open pull request touches zig/src/families/h3/ or zig/src/core/picture/resample.zig.

Checks on this head

  • Head commit: f5dad8bcac (on h3: MiniMax-H3-Image's transformer on Metal from a picture case (tf-h3-image) #2766's 9692b83d53, on main 14dea6c6ad).
  • Lean checker, python3 tools/zig/lean_check.py: 386 on the base and 386 on this head, 0 new. tools/pr_check.py: 0 errors (the one advisory warning is the Unreleased line, which the lead adds).
  • Tests run, with the command and pass, fail and skip counts:
    • zig build test-h3-geometry --summary all: 61 passed, 0 failed, 0 skipped. Five of them are new VAE-rule tests.
    • zig build test-picture-host --summary all: 26 passed, 0 failed, 4 skipped. The skips are the same four as on main.
    • zig build compile-h3-host: builds. zig fmt --check and git diff --check: clean.
  • CI: will run on this head.
  • Not run, and why: a byte comparison of the Lanczos filter with Pillow. This Mac has no Pillow. The tests check the filter's values and normalised taps, a flat picture staying flat, and a hard edge's ringing being symmetric and clamped in both passes. Pillow's own bytes are checked in h3: MiniMax-H3-Image's text to image end to end: the prompt tool writes the canvas and the seed's starting rows #2781 (fa0e45c77b): shrinking, enlarging, both at once and at a canvas's ratio, all byte-exact against Pillow 13.0.0.

Receipt

  • Main against branch: n/a. These are host rules beside the engine; no token path changes, and no existing resize changes its bytes.
  • Boxes it reaches: none until the decoder and encoder use them.
  • New switch? None.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: f5dad8bcac, Zig 0.17.0, host checks on macOS. The config fixture follows MiniMaxAI/MiniMax-H3-Image's vae/config.json at 492fd8c4ec.
  • Paths and platforms the change reaches, which I ran and which I could not: host only.
  • Exactness, decode and prompt speed: n/a.
  • Licence of any new weights or drafter: n/a, no weights.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

The inference checklist does not apply: these are host rules for a denoiser beside the engine.

@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Rebased onto today's main, on #2766's new head 3b73752aa4, so CI runs again (head ad173c6231). The earlier run on f5dad8bcac was cancelled before it finished; no job failed.

On the new head these pass: test-h3-geometry (61 passed), test-picture-host (26 passed, 6 skipped), test-h3-modulation-bf16 and compile-h3-host. Two of the six skips are main's new JPEG tests, which need a JPEG library; the other four are the usual ones. zig fmt --check and the lean checker are clean on the changed files.

What's left: #2766 lands first. No device run is owed here. These are host rules, and no existing resize changes its bytes.

  • Synthena (Ash's Agent)

…in core/picture

picture_vae.zig: the released VAE config, the tile split (256 pixels,
overlaps of at least 64 spread 16 at a time), the float32 band blend and
placement, the latent statistics, ImageNet pixels with truncating bytes,
and the fp16-kept posterior sample. resample.zig gains Pillow's LANCZOS
filter, sinc(x) sinc(x / 3) within 3.
…load's io, and H3's Metal tools in h3_metal.zig

Main moved H3's safetensors import into the core module (h3_core in metal_targets.zig, core in h3_host.zig). This
series came from before that move: tf-h3-image imported safetensors and checkpoint_fixture modules of their own. It
now imports core and reads both from it, since a file may sit in one module of a build only and core holds both.
Main's h3.Model.load also takes the process's io now, so tf-h3-image passes init.io as tf-h3-dit does.

Main's metal_targets.zig is at the 600-line cap, so tf-h3-image's target, and main's tf-h3-dit beside it, move to
h3_metal.zig with the H3 modules they share (and the kernel sources they take); metal_targets.zig calls it in one
line (589 lines). The steps and their modules are otherwise unchanged.
@ashhart
ashhart force-pushed the lead/h3-image-pixels branch from 9e7ac29 to c5d836b Compare November 21, 2026 14:47
@ashhart
ashhart merged commit e1aecf5 into main Nov 21, 2026
11 checks passed
@ashhart
ashhart deleted the lead/h3-image-pixels branch November 21, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant