Skip to content

h3: MiniMax-H3-Image's edits end to end: Qwen3-VL's vision tower with DeepStack (opt-in), tf-h3-image-vision, and the prompt tool's references - #2810

Open
ashhart wants to merge 14 commits into
mainfrom
lead/h3-image-edit
Open

ashhart wants to merge 14 commits into
mainfrom
lead/h3-image-edit

Conversation

@ashhart

@ashhart ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

What this changes

MiniMax-H3-Image's edits now run end to end with TensorFold's own tools. Before, an edit's prompt rows had to come from a reference pipeline's case, because Qwen3-VL's vision tower and its DeepStack features were not here. After:

Checks on this head

  • Head commit: 32e520d08f.
  • Lean checker: 386 on the base and 386 on this head, 0 new. tools/pr_check.py --base lead/h3-image-contract: 0 errors. Its 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-image-prompt test-h3-geometry compile-h3-image-vision compile-h3-image-prompt compile-h3-host: exit 0. This includes the tower's new host tests:

      • the DeepStack config is accepted by the opt-in and refused by parse, with bad lists refused;
      • the prefix is found in HF and MLX names;
      • with taps, the plan holds HF Qwen3-VL's 351 tensors; without taps, the plan is unchanged.
    • tf-h3-image-vision selftest on an M3 Ultra passes every gate. Its gates were fixed before its first run. It runs a synthetic HF-named tower under model.visual. (4 blocks of 144, taps after 0, 2 and 3, 54 tokens) through the real loader and patch path:

      Output Cosine Relative error Float32-sum host run
      Merged rows 0.9999825 5.92e-3 0.9999828, 5.87e-3
      DeepStack after block 0 0.9999949 3.20e-3 0.9999950, 3.17e-3
      DeepStack after block 2 0.9999838 5.69e-3 0.9999832, 5.80e-3
      DeepStack after block 3 0.9999841 5.64e-3 0.9999837, 5.71e-3
      • Each output is within twice a float32-sum host run's distance from float64, with cosine at least 0.999.
      • A second run is byte for byte the same.
      • The untapped run gives the same rows.
      • The same tower saved as vision_tower.* in MLX's Qwen3.5 layout gives the same rows through Tower.load and image().
    • Qwen3.5's tower unchanged:

      • the 27B tower's 333-tensor plan and bytes are the same (host test);
      • a harness, not committed, ran the old and new code at Qwen3.5's real widths (3 blocks, 256 tokens). The weight buffers and the rows from the old image(), the new image() and imageDeep(&.{}) were byte-identical;
      • test-flashnext-vision-memory-host passes.
    • tf-h3-image-prompt selftest: every gate passes. Its picture run now reads its vision rows back from a file, as --reference does.

    • zig fmt --check: clean.

  • CI: will run on this head.
  • Not run, and why:
    • The real text encoder's vision tower. The weights' download is on hold.
    • Because of that, the HF vision prefix and the DeepStack tensors' names and shapes are inferred from the model's structure, not read from a header. The loader refuses any count or shape that differs, so the first real load shows a mismatch.
    • The merger LayerNorm's eps (1e-6, as the tower's other norms) is assumed.

Owed device cells

  • With the weights: tf-h3-image-vision on a real reference against the reference pipeline's vision and DeepStack rows. Then an edit end to end on an M5.

Receipt

  • Main against branch: Qwen3.5's tower path is byte-identical (see above). No other token path changes.
  • Boxes it reaches: Metal. The vision and prompt tools run on any Apple GPU; the transformer on an M5.
  • New switch? tf-h3-image-prompt --reference FILE (repeatable) and --anchors PREFIX; the new tool tf-h3-image-vision; build steps tf-h3-image-vision and compile-h3-image-vision.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: 32e520d08f, Zig 0.17.0, macOS on an M3 Ultra. Synthetic checkpoints only.
  • Paths and platforms the change reaches, which I ran and which I could not: the selftests and host checks ran; real weights did not.
  • Exactness, decode and prompt speed: Qwen3.5's tower output is byte-identical. The vision tower's speed at the released size is not measured.
  • Licence of any new weights or drafter: n/a, no weights. The recipe notes the MiniMax-H3-Image Community License's excluded territories.

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 to the image tools. The one engine-side change, the tower's opt-in, keeps Qwen3.5's bytes.

@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner Author

/atc exchange 549959234cd65d08f3b00c1bee240540cfa752c8ca1b169defc4e411a26951eb

@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Rechecked against today's main: this head (32e520d) still merges cleanly, and the host steps pass on the merge: test-h3-image-prompt, test-h3-geometry, test-qwen-vl-shards-host, test-qwen-vision-weights-host and test-flashnext-vision-memory-host, plus the compile-only steps compile-h3-image-vision, compile-h3-image-prompt and compile-h3-host.

What still stands before this lands:

  1. It goes last in its stack, after h3: MiniMax-H3-Image's transformer on Metal from a picture case (tf-h3-image) #2766, h3: MiniMax-H3-Image's VAE rules on the host, and Pillow's Lanczos-3 in core/picture #2775, h3: MiniMax-H3-Image's edit encoder on Metal in fp32 (tf-h3-image-encoder) #2778, h3: MiniMax-H3-Image's prompt path on Metal: Qwen3-VL to layer 50 and the token refiner (tf-h3-image-prompt) #2779, h3: MiniMax-H3-Image's image decoder on Metal in bf16 (tf-h3-image-decoder) #2780, h3: MiniMax-H3-Image's text to image end to end: the prompt tool writes the canvas and the seed's starting rows #2781 and kernel contract: MiniMax-H3-Image's 19 Metal kernels, 31 registrations and 34 planted controls; the prompt path's attention keeps an infinite last value #2808, in that order.
  2. Some jobs in the last CI runs on h3: MiniMax-H3-Image's transformer on Metal from a picture case (tf-h3-image) #2766, h3: MiniMax-H3-Image's VAE rules on the host, and Pillow's Lanczos-3 in core/picture #2775 and h3: MiniMax-H3-Image's edit encoder on Metal in fp32 (tf-h3-image-encoder) #2778 were cancelled before they finished (pytest, zig-windows and benchmark-clients on all three, and more on h3: MiniMax-H3-Image's VAE rules on the host, and Pillow's Lanczos-3 in core/picture #2775 and h3: MiniMax-H3-Image's edit encoder on Metal in fp32 (tf-h3-image-encoder) #2778), so those three need a fresh run first. This head's own CI, which carries every commit of the stack, is green.
  3. The real-weights check is still owed once the weights are available: tf-h3-image-vision on a real reference against the reference pipeline's vision and DeepStack rows, then one edit end to end on an M5.
  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the lead/h3-image-edit branch 5 times, most recently from 94db89a to d35f5d2 Compare November 22, 2026 02:56
…trations and ten planted controls; four kernels reserve their group sizes
…istrations and fourteen planted controls; hp_attention's padded last key is a known finding
…infinite last value stays infinite; its contract entries lose their known finding and gain a control
… float64 reference of the tower

Config.parseDeepStack reads Qwen3-VL's deepstack_visual_indexes (rising,
below the depth, at most four); Config.parse still refuses them. With
taps, the weights add each deepstack_merger_list merger and the tower
runs each one after its block: LayerNorm over the merged width, fc1,
exact GELU and fc2. Tower.loadAt and shards.headersAt take the tensors'
prefix, and shards.findPrefix finds an HF checkpoint's. A tower without
taps loads the same tensors under vision_tower. and runs the same
kernels in the same order.

reference.zig runs the whole tower on the host in float64 or float32
sums at the Metal tower's bf16 rounding points. qwen_vl_tools.zig roots
the tower, its settings, shards, reference and core's pictures in one
module for tools beside the engine.
…tack rows on Metal, and its selftest

tf-h3-image-vision TEXT_ENCODER_DIR MODEL_DIR reference out.safetensors
reads the picture upright in RGB, makes its Qwen copy (qwen_copy.zig,
picture_prompt's rule moved to a file of its own), cuts the processor's
patches and runs core's tower with DeepStack under the checkpoint's own
prefix. It writes grid, rows [tokens, 5120] and deepstack [3, tokens,
5120] in bf16, aligned.

`selftest` writes a tiny Qwen3-VL tower in HF's names and layouts and
loads it as a run does. Each output (the merged rows and each tap's) must
sit within twice a float32-sum host run's distance from a float64
reference of the whole tower, with cosine at least 0.999; a second run,
an untapped run and the same tower in MLX's Qwen3.5 layout through
Tower.load must give the same bytes.

The tool's modules: one core root for the tower and pictures, which
qwen_copy.zig also reads as its picture module, so no file is in two
modules. zig/build/h3_image_vision.zig adds the tool, a host compile and
the tower's host tests in test-h3-image-prompt.
--reference vision.safetensors (repeatable, in upload order) reads
tf-h3-image-vision's rows: the prompt gains each reference's label and
vision block, the pads take M-RoPE positions from its grid, and the
encoder places its rows and adds its DeepStack rows after layers 0 to 2.
With a size, --anchors OUT_PREFIX writes tf-h3-image-encoder's grid and
anchor rows as the case's references and anchors, so an edit's case is
whole. Text-only runs are unchanged.

The selftest's picture run now reads its rows back from a file as
--reference does.
… recipe

An edit runs in five tools: the edit encoder's anchors, tf-h3-image-vision,
tf-h3-image-prompt with --reference and --anchors, the transformer and
the decoder. The vision tower's section gives what runs, the checkpoint's
inferred names, its precision, why Qwen3.5 is unchanged, and the
selftest's gates and results on an M3 Ultra.
…ugh core

The macOS dev-tools job failed to compile tf-h3-image-prompt: h3_image_files.zig and h3_image_prompt_edit.zig
import `checkpoint_fixture`, a module only tf-h3-image-vision's build registers. The prompt tool reads the fixture
through `core`, whose root imports checkpoint_fixture.zig, so a second module rooted at that file would own it twice.
The tool now registers `checkpoint_fixture` as h3_image_prompt_fixture.zig, which re-exports core's Entry and image.
…s H3 Metal tools

The stack's h3_metal.zig registered tf-h3-dit and tf-h3-image itself; main's
h3_host.zig metalTools now registers those two, so the restack kept main's call
and h3_metal.zig was left unused. Its three image tools join metalTools and the
file goes.
Main's cf37b2a (glm metal: prompt.zig and the Metal contract main back to 600 lines after main's #3920) already has the supplied one-line limits gate. Keep that gate, put the three H3 suites and their defers on one source line, and join the limits accumulator to the gate so the suite registrations preserve main's 600-line ceiling.

This branch has not been deployed

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