Repository navigation
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
Merged
Conversation
This was referenced Nov 10, 2026
Owner
Author
|
/atc exchange 0331ecd2ba125a05807e7fe49d5e94936ceafe7013e5437501c00df501c42894 |
4 tasks done
Owner
Author
5 of 8 tasks
ashhart
force-pushed
the
lead/h3-image-contract
branch
4 times, most recently
from
November 22, 2026 02:53
22f10f2 to
415c826
Compare
5 tasks done
ashhart
force-pushed
the
lead/h3-image-contract
branch
from
November 23, 2026 19:24
415c826 to
7c83c8b
Compare
This was referenced Nov 24, 2026
…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.
…er (suites to come)
…trations and nine planted controls
…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
Format only: combine the existing mixed-kernel predicates after main filled the runner. The short-circuit and append behavior are unchanged.
ashhart
force-pushed
the
lead/h3-image-contract
branch
from
November 24, 2026 12:36
7c83c8b to
d19fc5c
Compare
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 19 Metal kernels now register with the kernel contract, so they meet the rule every GPU kernel meets before it lands. Before, they were gated only by each tool's own
selftest. After:h3_image_encoder.metal, fp32 with precise functions). Four kernels in eight registrations, with nine controls:h3_prompt.metal). Seven kernels in fourteen registrations, with fifteen controls:attention_range's bound;image_decoder.metal, bf16). Eight kernels in nine registrations, with ten controls:Each output is checked against float64 at the kernel's own rounding points. Gate 4 uses integer stress inputs wherever a kernel sums. Every control is a one-place edit of the source that a named gate must catch.
Other changes:
Launch records. The records are in
contract/h3_image_records.zig, joined intoall_metal, under the resolver branchminimax image. Each launch reserves its group size in its source. Four decoder kernels gainmax_total_threads_per_threadgroupat the size their launcher already uses.A runner that needs no Metal compiler.
zig build h3-image-contract(tf-h3-image-contract [--only TEXT] [--seed N] [--no-limits]) compiles these kernels at load with their tools' options and runs gates 1-4, the controls, and gate 5 for their records.tf-kernel-contractruns the same suites with everything else.One fault found and fixed. The prompt path's attention filled a row's last block of 4 keys with its last key at weight 0, so an infinite value there gave 0 x Inf = NaN where float64 keeps the infinity.
knownand then removed by the fix. A control that restores the old padding goes red at gate 1.Docs.
docs/kernel-contract.mdgains the coverage, and the recipe gains a "Kernel contract" section.Issue: n/a. This is the registration owed by the MiniMax-H3-Image stack. The suites are written from our own kernels and launchers.
copy_scanagainst hashes of every upstream file the spec's reader read finds no run of 12 or more tokens.Stacked on: h3: MiniMax-H3-Image's text to image end to end: the prompt tool writes the canvas and the seed's starting rows #2781, then h3: MiniMax-H3-Image's image decoder on Metal in bf16 (tf-h3-image-decoder) #2780, 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 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 after 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 before 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 (the edits, stacked on this).
2621ddbc23,b53ff3c48c,b505a8e6ca,42ade52d1e,f910fef300and8e31db2282.fa0e45c77btonight, its Pillow LANCZOS goldens.atc overlap --json: incomplete under its API limits (myPullRequestsLimit,pullFilesLimit); most overlaps reportconflict: unknown. The files other open pull requests share here arebuild.zig,metal_main.zig,metal_limits.zig,registry_joins.zig,kernel_contract.ziganddocs/kernel-contract.md. This change adds lines to each.Checks on this head
8e31db2282.tools/pr_check.py --base lead/h3-image-t2i: 0 errors. Its one advisory warning is the Unreleased line, which the lead adds.tf-h3-image-contracton an M3 Ultra:H3_IMAGE_SUMMARY 31 kernels: 31 pass gates 1-4, 0 fail, 0 known findings; 34 controls: 34 red as planted, 0 missed; 0 limit problems.zig build test-kernel-contract: exit 0. The records' family test is included.zig build test-metal-launch-map-host: 719 registered launches (700 before), 0 missing.tf-h3-image-prompt selftestafter the attention fix: every gate passes, with the same numbers as before.tf-h3-image-decoder selftestafter the four thread attributes: every gate passes.zig fmt --check: clean.tf-kernel-contractitself: this Mac has no offline Metal compiler. The suites import onlymetal,contract,rig.zigand the three kernel-source modules, which its build now provides.--offlinecompiles: every launch reserves its threads in its source instead.Owed device cells
zig build kernel-contract -Dcpu=apple_m1on a Mac with Xcode's Metal toolchain, to run the full runner with these suites. Any chip will do.Receipt
tf-h3-image-contractandh3-image-contract.8e31db2282, Zig 0.17.0, macOS on an M3 Ultra. No checkpoint: synthetic inputs.Checklist
The inference checklist does not apply: these are tools for a denoiser beside the engine.