Repository navigation
Conversation
ashhart
force-pushed
the
lead/h3-image-decoder
branch
from
November 10, 2026 17:33
0c0be0c to
9eb514c
Compare
This was referenced Nov 10, 2026
Owner
Author
|
Rebased onto today's main, on #2779's new head, so the stack's CI runs on one base (head On the new head these pass: What's left:
|
ashhart
force-pushed
the
lead/h3-image-decoder
branch
from
November 12, 2026 14:29
9eb514c to
325bd04
Compare
Merged
4 tasks done
ashhart
force-pushed
the
lead/h3-image-decoder
branch
2 times, most recently
from
November 21, 2026 11:13
7f886d8 to
7c81c81
Compare
Each text segment is tokenised on its own and cut to 4,096 tokens; references enter as a label and a vision block whose rows are tagged 0. Positions follow Qwen-VL's M-RoPE, and the rotary table rounds to bf16. The Qwen copy of a reference keeps or scales its short edge to 1,024 with Pillow's LANCZOS. The text encoder's and the refiner's configs are checked at the released geometry.
tf-h3-image-prompt turns a prompt into the text rows tf-h3-image reads: Qwen3-VL's text model to the hidden state leaving layer index 49, then condition_proj, the two token-refiner blocks over every row and the final norm. Weights are bf16 read in place; products run in simdgroup matrices with fp32 sums, so chips without tensor units run it too. The encoder also takes a reference's vision rows and DeepStack features at their image pads, ready for the edit's tower. Its selftest writes a tiny synthetic checkpoint, loads it as a real run does, and gates each kernel alone and each whole run against a float64 host reference with the same bf16 rounding points.
… its fixture through core, as main does prompt.zig pulls in tensors.zig, which on main reads core.safetensors, so the tool's prompt module imports core. A file may sit in one module of a build only, and core already holds picture.zig, qwen_vl/rope.zig and checkpoint_fixture.zig, so picture_prompt.zig, its test and the tool read them through core, and the build's own picture, rope and fixture modules go. test-h3-image-prompt's root imports core in their place.
…d rotary table, unpatchify image_decoder.zig: the 297 decoder tensors MiniMax-H3-Image's VAE file holds (F32, checked by name and shape, decoder.mask_token left unread), their places in one bf16 buffer, a tile's sequence (its cells, 4 registers, one zero token), the 2D rotary ids in bf16 arithmetic and their angles, the proj_out rows unpatchified to pixels, and the tile geometry the attention holds (at most 16 cells a side). Host tests run in test-h3-geometry.
… on the host image_decoder_metal.zig runs the VAE's 2D ViT decoder on a batch of tiles a command buffer, on any Apple GPU (its kernels compile from source at load, no tensor units): post_quant_conv and x_embedder, the 24 blocks (RMSNorm, grouped q | k | v, q and k normed and turned half-style over their first 32 dims, softmax attention at 1/8, LayerScale residuals, the gated SiLU FFN), norm_out in fp32 and proj_out. Products are bf16 with fp32 sums, rounded where the reference rounds. decode() blends the tiles in fp32 with picture_vae's Assembler. image_decoder_reference.zig is the same forward on the host with float64 sums, for the self-test.
…self-test tf-h3-image-decoder MODEL_DIR latent.f32 ROWS COLUMNS out.png [WIDTHxHEIGHT] reads vae/config.json and the decoder's tensors, denormalises the latent, decodes it in tiles of up to 16 a pass, blends them, truncates to bytes, resizes with Pillow's LANCZOS when asked and writes a PNG. `selftest` runs the kernels on synthetic weights against the float64 host reference: the embedding and proj_out within 1 bf16 ULP, each block teacher-forced, two and all 24 blocks chained, batched decodes bit-identical to the staged tiles, and the picture's bytes. It exits 1 past a bound. zig build tf-h3-image-decoder builds it (shaders compile at load); compile-h3-image-decoder-host compiles it without the Metal compiler and joins the macOS nightly host checks. picture_writer.zig roots MOSS-Image's PNG writer and core's resampler in one module for tools beside the engine.
… main does image_decoder.zig pulls in geometry.zig, which on main reads core.safetensors, and image_decoder_test.zig runs in test-h3-geometry, whose module imports core alone, so the decoder's files read st from core.safetensors. The tool also writes PNGs with MOSS-Image's writer, whose test reads core/picture/png.zig by path, and a file may sit in one module of a build only. So the tool's core is h3_decoder_core.zig, one module holding safetensors, core's pictures and that writer, in place of picture_writer.zig; it resamples through core.picture.
ashhart
force-pushed
the
lead/h3-image-decoder
branch
from
November 22, 2026 02:48
7c81c81 to
43fa93e
Compare
Owner
Author
|
Closing this one: all of its work is on main, some of it moved or renamed since this branch was cut, so nothing is left to merge.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
MiniMax-H3-Image's image decoder runs on Metal. Before,
tf-h3-image's latent could only be decoded by the reference pipeline. After,tf-h3-image-decoderturns the latent into a PNG on any Apple GPU.It is the VAE's 2D ViT decoder: 24 blocks of 1,024 width, 16 heads of 64, and 4 register tokens. It runs in 256-pixel tiles, blended in float32, with ImageNet pixels and truncating bytes. When the requested size differs from the canvas, it resizes back with Pillow's LANCZOS.
Host rules (
image_decoder.zig), with tests:The GPU side (
image_decoder_metal.zigand 8 kernels inimage_decoder.metal):proj_out.A float64 host reference with the same rounding points (
image_decoder_reference.zig), fortf-h3-image-decoder selftest.zig/src/picture_writer.zig: a three-line module root that gives the tool MOSS-Image's PNG writer and core's resampler.Issue: n/a. The maintainer asked for MiniMax-H3-Image directly. This is adapted clean-room from a written spec of vLLM-Omni's and SGLang's support.
copy_scanagainst hashes of every upstream file read finds no run of 12 or more tokens.Stacked on: h3: MiniMax-H3-Image's prompt path on Metal: Qwen3-VL to layer 50 and the token refiner (tf-h3-image-prompt) #2779, then h3: MiniMax-H3-Image's edit encoder on Metal in fp32 (tf-h3-image-encoder) #2778, 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 transformer on Metal from a picture case (tf-h3-image) #2766. Land it last of the four. This adds
c492a11a21,dcf64e1121,f75ebc1fecand9eb514c504, rebased onto h3: MiniMax-H3-Image's prompt path on Metal: Qwen3-VL to layer 50 and the token refiner (tf-h3-image-prompt) #2779 with the three tools' build lines and test includes side by side.atc overlap --json: no open pull request touches the new files.Checks on this head
Head commit:
9eb514c504. On the whole stack:zig build test-h3-geometry test-h3-image-prompt test-picture-host compile-h3-host compile-h3-image-encoder compile-h3-image-prompt compile-h3-image-decoder-host --summary allgives 18 of 18 steps, 116 passed and 4 skipped (the usual four), and all three tools build.Lean checker: 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 compile-h3-host compile-h3-image-decoder-host test-picture-host --summary all: 11 of 11 steps.test-h3-geometryhas 68 tests, 7 of them new.compile-h3-image-decoder-hostis added to host CI's macOS list.zig fmt --checkandgit diff --check: clean.tf-h3-image-decoder selfteston an M3 Ultra, with synthetic weights against the float64 reference. The bounds were set from the host reference's own float32-against-float64 spread before the GPU ran.norm_out+proj_out24 blocks take 13.4 ms a 16 x 16 tile, about 1.6 s of GPU time for a 2048 x 2048 canvas.
A run of the whole tool on all-zero weights at the released shapes (built from the published header) writes a uniform picture of the ImageNet mean, as it should.
CI: will run on this head.
Not run, and why: the comparison with the release's decoder (PSNR ≥ 45 dB, ≥ 99% of bytes within ±1). It needs the weights, and their download is on hold.
Open point for that comparison: attention keeps its probabilities in float32 for the value product. The reference's fused attention may round them to bf16 first.
Receipt
tf-h3-image-decoder.0c0be0c438, Zig 0.17.0, an M3 Ultra under macOS. Shapes fromMiniMaxAI/MiniMax-H3-Imageat492fd8c4ec.Kernel contract
tf-h3-image-decoder selftestagainst a float64 reference, not yet registered withtf-kernel-contract.Checklist
The inference checklist does not apply: this decodes a denoiser's latent, beside the engine.