Skip to content

Inkling 2 Mini on Metal: images under --vision (the tower, the processor and its contract) - #4704

Merged
ashhart merged 4 commits into
ashhart:mainfrom
BlivionIaG:port/vision
Nov 24, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
BlivionIaG:port/vision

Conversation

@BlivionIaG

@BlivionIaG BlivionIaG commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Inkling 2 Mini on Metal serves images under --vision. Until now the Metal backend refused every image part (InklingHasNoImageTower) and the native opener refused --vision by name. This ports the Metal vision work of #4337 (by @BlivionIaG) onto main, where #4387 landed. It is slice M7 of #4274 (claim: #4274 (comment)).

What it adds, in #4387's shape:

  • zig/kernels/metal/inkling2/vision.metal (byte for byte from Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337) and vision_gemm.metal (Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337's gemm.metal without its four bf16_nn kernels, which only the superseded draft used), joined as inkling2_metal.vision through vision_sources.zig with ../prefill/gemm_nax*.metal.
  • families/inkling2/metal/vision*.zig: the 23-layer tower, its GEMM wrapper, the rotary and position tables, and the processor. Decode (alpha composite, EXIF orientation), the grid constants and the bilinear taps come from the family's existing image.zig; the merge-block patch order, the Hugging Face two-step normalisation, the resize only past the image budget and the content hash stay in the Metal processor.
  • forward.zig: Options.images copies the tower's BF16 rows over the image placeholders after the embedding norm, validated (one segment, no id override, bounds, placeholder ids). images.zig hands each prefill chunk the part of each picture inside it and skips pictures wholly inside a restored cache prefix.
  • native/inkling2.zig: --vision loads the tower (its bytes join the resident budget before the cache budget), and the opener refuses only guidance. The tower reads model.visual.* itself, since Model.load reads model.llm.* only.
  • vision.eps (layer_norm_eps) in the config.
  • Kernel contract: nine kernel records, 17 GEMM records, probes for the 13 kernels, 11 planted controls, and a host test that every control applies once.
  • Two fixes the first version missed, both in this commit: native/metal.zig refused --vision for inkling2_loop (the tower opener was never reached), so it now lets the family through and names Inkling 2 Mini in the refusal text (docs/vision.md lists it); and tf-kernel-contract --only inkling2 segfaulted once the vision suite was added, because the probes point into the suite struct and it was returned by value, so Suites.init(s: *Suites, ...) now builds the set in place (metal_main.zig updated).
  • CHANGELOG bullet, under Unreleased, naming Inkling 2 Mini on Metal: images under --vision (the tower, the processor and its contract) #4704.

Checks on this head

  • Head commit: c3e938acff, one commit on main at 834237bca8.
  • zig fmt --check build.zig zig: clean. Lean checker: 165 and 165, 0 new. pr_check.py --base upstream/main --pr 4704: 0 errors, 0 warnings.
  • Tests run on an Apple M4 Pro 48 GiB (no tensor units), -Dcpu=apple_m1 -Doptimize=ReleaseFast:
    • tf-kernel-contract --only inkling2: SUMMARY 54 kernels: 54 pass gates 1-4, 0 fail, 0 known findings; 52 controls: 52 red as planted, 0 missed; 0 limit problems (main alone: 41 and 41).
    • zig build test-inkling2-media-metal (GPU, checkpoint and the pinned libjpeg-turbo): 25 pass, 1 skip, 0 fail (the skip not identified: I did not read which test it is).
    • Served, serve --vision --context 8192 --parallel 1 --no-drafts --prompt-cache-gib 0 --no-thinking, greedy, on thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7: the 1024 x 768 scene (JPEG, 546 prompt tokens, 160 tokens) is answered "A stylized sunset scene shows two dark green triangular mountains rising from a deep blue gradient sea. A bright yellow sun sits low on the right against a sky that fades from orange at the top to pale blue near the horizon." The 1792 x 1344 invoice (JPEG, 1,561 prompt tokens, 260 tokens) is read as "INVOICE No. 20931, TOTAL DUE: 1034.00 EUR" (in the reasoning field; main returns reasoning separately). One request per image; the Mac was loaded and swapped, so the times (first token 163 s and 134 s, decode 0.7 tok/s) are main's current prompt and expert speed, not this slice's.
  • Not run, and why: the tower's hash across builds (needs a hash-logging build); test-inkling2-metal-host and the whole zig build test test-golden on this head; M1 to M3 and M5 (this machine is an M4 Pro: the pre-M5 small-row GEMM and its control ran here, the tensor-unit GEMM path did not); CUDA and HIP (not touched). Speed of the tower: not claimed here. Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337 has later tower changes (a tiled attention GEMM and a bf16 score matrix, same bits) that I will open as a separate pull request if this one lands.

Receipt

  • Main against branch: main refuses images on Metal ("serves text only"); this adds image input to its Metal path. Text is unchanged: the four greedy chat hashes of this head equal main's (0b037128ee78, b37d8a0e39c4, 146f8038bfc7, 870a47079391, the last with 384 cached tokens).
  • Boxes it reaches: Macs, inkling2_loop on Metal with --vision.
  • New switch? None new: --vision, --vision-max-images and --vision-image-tokens already exist; without --vision images are still refused by name.
  • Environment: Zig 0.17.0, Xcode's Metal toolchain, Apple M4 Pro (48 GB), thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7.
  • Evidence carried from Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337 and not rerun here: the tower against Transformers 6173a2f6 BF16 eager, 83 of 83, and the public fixture, 20 completion ids of 20.
  • Licence of any new weights or drafter, or "n/a": n/a.

Checklist

  • The title and description match the head commit.
  • New kernels have contract records, probes and planted controls (11 red as planted).
  • New tests skip cleanly without their dependency (checkpoint, libjpeg-turbo, GPU).
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names or local paths in the diff. No AI attribution lines. @BlivionIaG is credited as co-author.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Served images on the restacked head (cc9471adb5, the new lead f790014399, M4 Pro), now that the cause of lead's ! replies is known (c68340d31f, see #4387): I applied that one commit in a scratch tree only, not here, built (-Dcpu=apple_m1 -Doptimize=ReleaseFast) and served with --vision --context 8192 --parallel 1 --no-drafts --no-thinking, the pinned libjpeg-turbo, greedy, 160 tokens.

So what is checked on this base is: the tower tests (26 of 26), the contract, and one served image read correctly after the norm fix. The rest of the image receipt in the description is #4337's.

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

CI on 9c4e3ef4e2 has run zig-macos-dev-tools and zig-windows (both red); zig and zig-b were still pending when I looked. What I checked:

  • contract.registry.test.the registered launches fit every Apple family and every SM… (registry.zig:456, "expected 0, found 40"): I ran zig build test-kernel-contract -Dcpu=apple_m1 on this head and on the unmodified lead head 28d7049a03 on an M4 Pro. Both fail that one test with the same message; lead 209 pass 1 fail, this head 210 pass 1 fail (the extra pass is ours). So that failure is lead's, not this diff's.
  • zig\src\metal\metal4.zig:307 (nap: expected void, found comptime_int, Windows compile), the rollback test drafter depth sweep … DraftsDiffer, and zig-macos-dev-tools' file exists in modules 'engine_api' and 'engine_api0' for the tf-qwen27-* executables: none of these files is in this diff (it changes zig/build/inkling2_host.zig, +5 lines, and the vision sources). I did not run those three on lead itself, so I cannot say they are lead's, only that nothing here touches them.

I keep this draft until lead's own zig, zig-b, zig-windows and zig-macos-dev-tools go green, or @sethforprivacy says they are known red.

@ashhart
ashhart force-pushed the lead/inkling2-mini branch 3 times, most recently from aefb063 to c41911e Compare November 24, 2026 09:43
@ashhart
ashhart deleted the branch ashhart:lead/inkling2-mini November 24, 2026 09:43
@ashhart ashhart closed this Nov 24, 2026
@ashhart ashhart reopened this Nov 24, 2026
@ashhart
ashhart changed the base branch from lead/inkling2-mini to main November 24, 2026 09:48
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Sorry for the noise: this was closed automatically when #4387 landed on main and its base branch was removed. It is reopened and now targets main. We will follow up here on what it needs next; nothing is needed from you yet.

  • Synthena

@BlivionIaG BlivionIaG changed the title Inkling 2 Mini on Metal: images under --vision (the tower, the processor and its contract), ported from #4337 Inkling 2 Mini on Metal: images under --vision (the tower, the processor and its contract) Nov 24, 2026
@BlivionIaG
BlivionIaG marked this pull request as ready for review November 24, 2026 10:46
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @BlivionIaG. The opt-in image path, chunked row insertion and in-place contract setup look consistent. The total image-token budget also bounds the retained picture rows.

Current-tree qualification still needs exact tower and generated-token comparisons on the two Apple paths, including image-cache reuse and concurrent requests. The RMS checks and earlier cross-build wording difference do not establish bit identity or an accepted tie exception.

  • Synthena

BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Nov 24, 2026
- The ashhart#4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Thank you, @ashhart. The exact comparisons, on what this Mac can run, and the commands for the part it cannot.

What I added to the head (e43e0e38a3, two commits on your rebase 2938be942b): each picture the tower runs now logs one line, inkling2 image tower: picture=<content hash> rows=N sha256=<SHA-256 of the BF16 rows the splice takes>, so the tower's exact output is observable on a served build; a picture that a restored prefix fully covers logs nothing. Plus the changelog sentence. Contract unchanged at 54 kernels and 52 controls red; fmt, lean (165, 0 new) and pr_check clean.

Earlier-chip path (M4 Pro, 48 GiB, no tensor units), --parallel 4 --prompt-cache-gib 2, 16 tokens, greedy, no memory-pressure line in the log. 32 requests, 22 with a reference, 22 equal, 0 unequal, 0 failed, compared as token ids; every picture has exactly one tower hash across all its runs (the scene across 13 runs):

row cached tokens equal to reference
solo, cold: text-small 56 / shapes 197 / chart 208 / scene 546 tokens 0 reference
the same request again: shapes / chart / scene 192 / 192 / 512 yes
the same request again: text-small (56 tokens, under one 64-token chunk) 0 yes
same picture, other question: scene / shapes 512 / 0 yes / yes (against a cold rerun after /v1/prompt_cache/flush)
a second picture after the first in one conversation (warm) 192 yes
four identical scene requests at once, cold 512, 0, 512, 512 4 of 4
four different images at once, cold 0 each 4 of 4
the same four again, warm 0, 192, 192, 512 4 of 4

A restore that lands inside a picture (192 of 197, 512 of 546) re-runs the whole picture through the tower, and its hash is the same; only a restore covering the whole picture logs nothing.

The tower against #4337's receipts, bit for bit. docs/receipts/inkling2-mini-m4pro/fidelity/img-sm-eq-{1-A,2-B,3-B,4-A}.serve.txt on work/inkling2-mini-metal-4bit record a Wyhash (VHASH) of the tower's BF16 output, the same in all four sessions. A second binary (not committed) printing both hashes of the same buffer reproduced std.hash.Wyhash.hash(0, bytes) equal to the receipts' values for all seven pictures, and the committed build gives the same SHA-256:

picture rows SHA-256 of the tower's BF16 rows (first 16) #4337's Wyhash
text-small.png 24 058c767427ada0e0 426bb20346d4bb0f
shapes.png 169 c21bae6773d32b5b 6d5ca418edcf7e06
chart.png 176 61317e31d53d83cd d355a93afc2593b9
chart.jpg 176 a4e2a2d94c468dcd 1ad18b422483ada
scene.jpg 520 cc0ee6eb48ba98b0 5dee538e1ef7c759
invoice-large.jpg 1530 33de6c6d44023e4b f22ac81ecaa4d511
invoice-large.png 1530 0cae646f520dda4b 6d64bb00397b5445

That answers the open point from my earlier note: the divergence I saw after 304 characters on the old lead was the text path, not the tower (I had not compared the tower's hash then). The tower's own test against the FP64 oracle is a relative-RMS gate and is not offered as bit identity; the hash match above is.

Not run: the tensor-unit path (M5), because this Mac has none; generated tokens against #4337's (its receipts keep text and sha= over 160 tokens, not token ids); no timing was taken. The howto below lets anyone with an M5 (or an M4 Max for the second earlier-chip row) post the same table and say where the tower bits differ, if they do. @SashaMIT, @cwschroeder, @akol1: if you can run it, it is about 15 to 40 minutes and one process at a time.

vision-qualify-howto.md

Qualifying --vision for Inkling 2 Mini on your Mac (PR #4704)

Asked of owners of M5-class Macs (tensor units: the slice's NAX GEMM path) and of an M4 Max (no tensor units, the path for
earlier chips, which the M4 Pro table below ran). One model process at a time; about 20 GiB free. Expect 15 to 40 minutes.

1. What you need

  • Zig 0.17.0, Python 3 (stdlib only), the Inkling 2 Mini checkpoint (thinkingmachines/Inkling-2-Mini, snapshot
    ed40e7da625f594fc9c4990f5f66be24873c22d7; set CKPT to that snapshot directory).
  • libjpeg-turbo 3.1.4.1 for scene.jpg (TENSORFOLD_LIBTURBOJPEG=/path/to/libturbojpeg.0.dylib; any other version
    makes the server refuse JPEG by name and the scene rows fail with HTTP 400, so say so instead of posting them).
  • Record your chip: system_profiler SPHardwareDataType SPDisplaysDataType | grep -E 'Chip|Cores|Memory'.

2. Checkout, build

git clone https://github.com/BlivionIaG/TensorFold.git && cd TensorFold
git fetch origin port/vision && git checkout --detach FETCH_HEAD     # the PR #4704 head, which must hold the log line
grep -n 'inkling2 image tower' zig/src/families/inkling2/metal/images.zig   # the tower log line (commit 972ba6ca78 on
                                                                           # slice/vision-qualify) must be there
git rev-parse HEAD
zig build native -Dcpu=apple_m1 -Doptimize=ReleaseFast
shasum -a 256 zig-out/native/bin/tensorfold-native

(-Dcpu=apple_m1 is the repo's portable Metal target; the M5 path is picked at run time from the GPU, not from this flag.)

3. The images (the same eight files as the #4337 receipts)

git fetch origin work/inkling2-mini-metal-4bit
mkdir -p img && git archive FETCH_HEAD docs/receipts/inkling2-mini-m4pro/fidelity/img | tar -x -C img --strip-components=5
shasum -a 256 img/* | cut -c1-16,65-    # expect: 7cfaea39 chart.jpg, 684c698e chart.png, 6edeca71 invoice-large.jpg,
                                        # 1f49d808 invoice-large.png, 30bfb1ad scene.jpg, f3d797f4 scene.png,
                                        # 920c0639 shapes.png, 7ba6b200 text-small.png

4. Serve, run the harness

vision-qualify.py is the one-file harness posted with this comment (stdlib only).

export CKPT=<snapshot dir above> TENSORFOLD_LIBTURBOJPEG=<libturbojpeg.0.dylib>
zig-out/native/bin/tensorfold-native serve "$CKPT" --host 127.0.0.1 --port 8123 --context 8192 --parallel 4 \
  --no-drafts --prompt-cache-gib 2 --no-thinking --vision > serve.log 2>&1 &
until curl -s localhost:8123/v1/models >/dev/null; do sleep 2; done
head -3 serve.log                                           # post these lines (weights, wired memory, device)
python3 vision-qualify.py --base http://127.0.0.1:8123/v1 --images img --log serve.log --all --big --out run-$CHIP.json
kill %1

--all --big adds the 1,561-token invoice and the chart JPEG / invoice PNG to the solo rows (about 10 more minutes at
decode speeds like ours: the engine is slow on this checkpoint; drop both flags for the five-image run). Optional, to get
the diff against our run in the same output: save our vision-qualify-run-m4pro.json (posted with the PR comment) and add
--against vision-qualify-run-m4pro.json.

Before you trust the cache rows: grep 'memory pressure' serve.log. A warning or critical line means the engine kept
no new prompt states, cached is then 0 for rows that should reuse, and the harness says so at the end. Close other apps
or reboot, and run again.

5. What to post

  1. The chip line, the git rev-parse HEAD, the binary's sha256, head -3 serve.log.
  2. The harness output: the request table and the picture table (sha256 of the BF16 rows the tower hands to the splice), and
    the last line (N requests, N equal, 0 unequal or failed, 0 pictures with more than one tower hash).
  3. The grep 'inkling2 image tower' serve.log lines (they are the only thing the tower hash needs).

6. What to compare, and what each result means

  • Inside your run (must hold on every chip): every equal to reference is yes (the reference is the same prompt run
    cold after a /v1/prompt_cache/flush, or the solo reply); each picture has one tower hash across every request (solo,
    repeat, other question, conversation, four at once). A tower line on a warm row is not a failure: a restore that lands
    inside a picture (the prompt state is kept at chunk boundaries, 192 of 197 tokens, 512 of 546) runs the whole picture
    through the tower again, and its hash must be the same; none means the restore covered the picture. cached 0 on a
    repeated prompt of 64 tokens or more means no prompt state was kept (check memory pressure below), not a difference.
  • A picture= hash that differs from the table in section 7 means the image bytes decoded differently (check the pinned
    libjpeg-turbo, and that the eight image files match the checksums above), not a tower difference.
  • Against our M4 Pro (earlier-chip path): the picture table's sha256 per picture. Equal on the M4 Max: the same
    tower bits on the two non-tensor-unit chips. On the M5 the tower runs its tensor-unit GEMMs, so a different sha256 is
    possible and is the number to report: then compare the token ids (--against prints the first differing token per row)
    and say where the replies first differ, and whether it is a near tie in the text path or at the first token.
  • The reply's token ids are the comparison for text, not the words: --out keeps them.

7. Our M4 Pro 48 GiB numbers (the earlier-chip path: no tensor units)

Build of slice/vision-qualify (the PR head plus the one log line); --parallel 4 --prompt-cache-gib 2, memory pressure
normal throughout (grep -c 'memory pressure' is 0). The harness: 32 requests, 22 equal to their reference, 0 unequal, 0
pictures with more than one tower hash. SHA-256 of the tower's BF16 rows, the picture hash being the picture= field of the log line:

picture rows picture hash sha256 of the tower's BF16 rows #4337's Wyhash
text-small.png 24 3141ea7deecd8fe3 058c767427ada0e0f953a5ecadf1be70e6c71bb254a5e58778b90dfe988f025b 426bb20346d4bb0f
shapes.png 169 17f2b8d4ccabed16 c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951 6d5ca418edcf7e06
chart.png 176 0e91a5f26bd7bae1 61317e31d53d83cd305dfec593a79cfcabbaa7c9b71caaff73bf9f31bda77be9 d355a93afc2593b9
chart.jpg 176 2d762fa2a053caab a4e2a2d94c468dcd7385fd01bc10d4a2f3a6702d31067a618b445862a996af06 1ad18b422483ada
scene.jpg 520 392ea1cd56c26ab3 cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e 5dee538e1ef7c759
invoice-large.jpg 1530 116fd1848df6ff99 33de6c6d44023e4b2695984479ea025fcef3ea69fbc4aaf0dbd0d50e98ea9063 f22ac81ecaa4d511
invoice-large.png 1530 34d091a85af7b9db 0cae646f520dda4bc7c1f1ce0265645a51c05e364bbdda1e51e866d28ebcabaa 6d64bb00397b5445

(The last two columns hash the same bytes with two functions: a build that printed both gave this slice's SHA-256 and, for
all seven pictures, the Wyhash the #4337 receipts (img-sm-eq-*.serve.txt, VHASH lines) record. The M5 side needs only the
SHA-256 column.)

vision-qualify.py
#!/usr/bin/env python3
"""Qualify `--vision` on a running TensorFold Inkling 2 Mini server: tower hashes, token ids, cache reuse, concurrency.

  python3 vision-qualify.py --base http://127.0.0.1:8123/v1 --images IMG_DIR --log SERVER_LOG [--big] [--out run.json]

IMG_DIR holds text-small.png shapes.png chart.png scene.jpg (and invoice-large.jpg with --big): the images of
docs/receipts/inkling2-mini-m4pro/fidelity/img on the #4337 branch. SERVER_LOG is the file the server's stderr goes to; the
harness reads its `inkling2 image tower: picture=H rows=N sha256=S` lines (one per picture the tower actually runs) and its
`memory pressure:` lines. Serve with `--context 8192 --parallel 4 --no-drafts --prompt-cache-gib 2 --no-thinking --vision`.

Every request is temperature 0 with max_tokens 16 and return_token_ids (the reply's `tensorfold.token_ids`). Cold references
come from POST /v1/prompt_cache/flush before the request, so every "equal" is against the same prompt run with no kept state.
Stdlib only. Exit status 1 when any row is unequal or one picture has more than one tower hash.
`--against OTHER.json` also compares token ids and tower hashes with another run's `--out` file (say, another chip's).
"""
import argparse
import base64
import concurrent.futures as cf
import json
import os
import re
import sys
import time
import urllib.error
import urllib.request

CASES = [  # name, question
    ("text-small.png", "What text is written in this image? Answer with the text only."),
    ("shapes.png", "List the shapes in this image and their colors."),
    ("chart.png", "Which weekday has the highest sales, and what is its value?"),
    ("scene.jpg", "Describe this image in two sentences."),
]
BIG = ("invoice-large.jpg", "What is the total due and what is the invoice number?")
EXTRA = [("chart.jpg", CASES[2][1]), ("invoice-large.png", BIG[1])]  # --all: solo rows only, with BIG's invoice
OTHER_Q = {"scene.jpg": "What is the main color of the sky? Answer in one word.",
           "shapes.png": "How many shapes are in this image? Answer with a number."}
TOWER = re.compile(r"inkling2 image tower: picture=([0-9a-f]+) rows=(\d+) sha256=([0-9a-f]{64})")
PRESSURE = re.compile(r"memory pressure: (normal again|eased to warning|warning|critical)")


class Log:
    """The server log read incrementally: tower lines and the memory pressure level since the last call."""

    def __init__(self, path):
        self.path, self.pos, self.level = path, 0, "normal"
        self.all = []

    def take(self):
        if not self.path:
            return [], self.level
        with open(self.path, "rb") as f:
            f.seek(self.pos)
            data = f.read()
        self.pos += len(data)
        towers = []
        for line in data.decode("utf-8", "replace").splitlines():
            m = TOWER.search(line)
            if m:
                towers.append((m.group(1), int(m.group(2)), m.group(3)))
            p = PRESSURE.search(line)
            if p:
                self.level = {"normal again": "normal", "eased to warning": "warning"}.get(p.group(1), p.group(1))
        self.all += towers
        return towers, self.level


def post(url, body, timeout=3600):
    req = urllib.request.Request(url, json.dumps(body).encode(), {"Content-Type": "application/json"})
    try:
        with urllib.request.urlopen(req, timeout=timeout) as f:
            return f.status, json.loads(f.read())
    except urllib.error.HTTPError as e:
        return e.code, {"error": e.read().decode("utf-8", "replace")[:300]}


def image_part(images, name):
    mime = "image/jpeg" if name.endswith("jpg") else "image/png"
    with open(os.path.join(images, name), "rb") as f:
        url = f"data:{mime};base64," + base64.b64encode(f.read()).decode()
    return {"type": "image_url", "image_url": {"url": url}}


def ask(base, messages, max_tokens):
    body = {"model": "m", "messages": messages, "max_tokens": max_tokens, "temperature": 0, "stream": False,
            "return_token_ids": True, "chat_template_kwargs": {"enable_thinking": False}}
    t0 = time.perf_counter()
    status, raw = post(base + "/chat/completions", body)
    if status != 200:
        return {"error": f"HTTP {status}: {raw.get('error')}", "ids": None, "seconds": time.perf_counter() - t0}
    u = raw.get("usage", {})
    m = raw["choices"][0]["message"]
    return {"ids": raw["tensorfold"]["token_ids"], "text": m.get("content") or "", "thought": m.get("reasoning_content") or "",
            "prompt": u.get("prompt_tokens"), "cached": (u.get("prompt_tokens_details") or {}).get("cached_tokens"),
            "seconds": time.perf_counter() - t0}


class Run:
    def __init__(self, a):
        self.a, self.rows, self.solo, self.log = a, [], {}, Log(a.log)
        self.root = a.base.rsplit("/v1", 1)[0]
        self.flushable = True

    def flush(self):
        status, raw = post(self.root + "/v1/prompt_cache/flush", {}, 600)
        if status != 200:
            self.flushable = False
            print(f"prompt_cache/flush: HTTP {status} {raw}: cold references are NOT available", file=sys.stderr)
        self.log.take()  # nothing the flush logs counts against a row

    def row(self, phase, case, r, ref, note=""):
        towers, level = self.log.take()
        eq = "-" if ref is None or r["ids"] is None else ("yes" if r["ids"] == ref else "NO")
        self.rows.append({"phase": phase, "case": case, "prompt": r.get("prompt"), "cached": r.get("cached"),
                          "towers": [f"{h[:8]}:{s[:12]}" for h, _, s in towers], "equal": eq, "pressure": level,
                          "seconds": round(r["seconds"], 1), "ids": r["ids"], "text": r.get("text"), "thought": r.get("thought"),
                          "error": r.get("error"), "note": note})
        return r

    def msg(self, name, q=None):
        question = q or dict(CASES + [BIG] + EXTRA)[name]
        return [{"role": "user", "content": [image_part(self.a.images, name), {"type": "text", "text": question}]}]

    def go(self, phase, case, messages, ref, note="", cold=False):
        if cold:
            self.flush()
        return self.row(phase, case, ask(self.a.base, messages, self.a.max_tokens), ref, note)

    def many(self, phase, cases, flush):
        """cases: [(label, messages, ref)] sent at once."""
        if flush:
            self.flush()
        with cf.ThreadPoolExecutor(len(cases)) as ex:
            results = list(ex.map(lambda c: ask(self.a.base, c[1], self.a.max_tokens), cases))
        towers, level = self.log.take()
        for (label, _, ref), r in zip(cases, results):
            eq = "-" if ref is None or r["ids"] is None else ("yes" if r["ids"] == ref else "NO")
            self.rows.append({"phase": phase, "case": label, "prompt": r.get("prompt"), "cached": r.get("cached"),
                              "towers": [], "equal": eq, "pressure": level, "seconds": round(r["seconds"], 1),
                              "ids": r["ids"], "text": r.get("text"), "thought": r.get("thought"), "error": r.get("error"), "note": ""})
        self.rows.append({"phase": phase, "case": "(tower lines of the batch)", "prompt": None, "cached": None,
                          "towers": [f"{h[:8]}:{s[:12]}" for h, _, s in towers], "equal": "-", "pressure": level,
                          "seconds": None, "ids": None, "text": None, "error": None, "note": "batch"})

    def phases(self):
        cases = list(CASES) + ([BIG] if self.a.big else [])
        names = [n for n, _ in cases]
        for name, q in cases + (EXTRA + ([] if self.a.big else [BIG]) if self.a.all else []):  # (a) solo, cold
            r = self.go("a solo", name, self.msg(name), None, cold=True)
            self.solo[name] = r["ids"]
            if not self.a.solo_only and name in names:  # (b1) the same request again, at once, with the prompt kept
                self.go("b repeat", name, self.msg(name), self.solo[name])
        if self.a.solo_only:
            return
        for name, q2 in OTHER_Q.items():  # (b2) same picture, another question; cold reference after a flush
            if name not in names:
                continue
            self.go("b prime", name, self.msg(name), self.solo[name], cold=True)
            warm = self.go("b same picture, other question", name, self.msg(name, q2), None)
            self.go("b cold reference of the above", name, self.msg(name, q2), warm["ids"], cold=True)
        first, second = "shapes.png", "scene.jpg"  # (b3) a second picture after the first in one conversation
        if first in names and second in names:
            t1 = self.go("b conversation turn 1", first, self.msg(first), self.solo[first], cold=True)
            turn2 = self.msg(first) + [{"role": "assistant", "content": t1["text"]},
                                       {"role": "user", "content": [image_part(self.a.images, second),
                                                                    {"type": "text", "text": "And this one?"}]}]
            warm = self.go("b conversation turn 2 (warm)", second, turn2, None)
            self.go("b conversation turn 2 (cold)", second, turn2, warm["ids"], cold=True)
        scene = "scene.jpg"  # (c) four at once
        if scene in names:
            same = [(f"scene x4 #{i + 1}", self.msg(scene), self.solo[scene]) for i in range(4)]
            self.many("c four identical, cold", same, flush=True)
        four = [(f"{n}", self.msg(n), self.solo[n]) for n in names[:4]]
        self.many("c four different, cold", four, flush=True)
        self.many("c four different, warm", four, flush=False)

    def compare(self, pictures):
        """Another run's --out file (say, a different chip's): same ids per (phase, case), same tower hash per picture."""
        with open(self.a.against) as f:
            other = json.load(f)
        theirs = {(r["phase"], r["case"]): r["ids"] for r in other["rows"]}
        same = diff = 0
        print(f"\nagainst {self.a.against}:")
        for r in self.rows:
            t = theirs.get((r["phase"], r["case"]))
            if t is None or r["ids"] is None:
                continue
            same, diff = same + (t == r["ids"]), diff + (t != r["ids"])
            if t != r["ids"]:
                n = next((i for i, (x, y) in enumerate(zip(t, r["ids"])) if x != y), min(len(t), len(r["ids"])))
                print(f"  token ids differ: {r['phase']} / {r['case']} from token {n}")
        print(f"  token ids: {same} rows equal, {diff} differ")
        other_towers = {}
        for h, rows, s in other["tower"]:
            other_towers.setdefault((h, rows), set()).add(s)
        for (h, rows), shas in sorted(pictures.items(), key=lambda kv: kv[0][1]):
            o = other_towers.get((h, rows))
            print(f"  tower {h} rows={rows}: " + ("not in the other run" if o is None else
                  "equal" if o == set(shas) else f"DIFFERENT (this {sorted(set(shas))[0][:16]} other {sorted(o)[0][:16]})"))

    def report(self):
        print("| phase | case | prompt | cached | tower lines (picture:sha256) | equal to reference | pressure | s |")
        print("|---|---|---|---|---|---|---|---|")
        for r in self.rows:
            tw = ", ".join(r["towers"]) if r["towers"] else "none"
            err = f" {r['error']}" if r["error"] else ""
            v = ["" if r[k] is None else r[k] for k in ("prompt", "cached", "seconds")]
            print(f"| {r['phase']} | {r['case']} | {v[0]} | {v[1]} | {tw} | {r['equal']}{err} | {r['pressure']} | {v[2]} |")
        pictures = {}
        for h, rows, s in self.log.all:
            pictures.setdefault((h, rows), []).append(s)
        print("\n| picture | rows | tower runs | distinct sha256 | sha256 of the rows the tower hands to the splice |")
        print("|---|---|---|---|---|")
        for (h, rows), shas in sorted(pictures.items(), key=lambda kv: kv[0][1]):
            print(f"| {h} | {rows} | {len(shas)} | {len(set(shas))} | {shas[0]} |")
        pressured = sorted({r["pressure"] for r in self.rows} - {"normal"})
        if pressured:
            print(f"\nMEMORY PRESSURE {pressured} during the run: the engine keeps no new prompt states, so the cached "
                  "columns above do not show reuse; do not trust the cache rows.")
        bad = [r for r in self.rows if r["equal"] == "NO" or r["error"]]
        split = [k for k, v in pictures.items() if len(set(v)) != 1]
        print(f"\n{len(self.rows)} requests, {sum(r['equal'] == 'yes' for r in self.rows)} equal, {len(bad)} unequal or failed, "
              f"{len(split)} pictures with more than one tower hash, flush {'ok' if self.flushable else 'UNAVAILABLE'}")
        if self.a.against:
            self.compare(pictures)
        if self.a.out:
            with open(self.a.out, "w") as f:
                json.dump({"rows": self.rows, "tower": [list(t) for t in self.log.all]}, f, indent=1)
        return 1 if bad or split else 0


def main():
    p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    p.add_argument("--base", required=True, help="server base URL ending in /v1")
    p.add_argument("--images", required=True)
    p.add_argument("--log", help="the server's log file")
    p.add_argument("--max-tokens", type=int, default=16)
    p.add_argument("--big", action="store_true", help="also the 1,561-token invoice-large.jpg")
    p.add_argument("--all", action="store_true", help="solo rows for all seven images of the #4337 receipts")
    p.add_argument("--solo-only", action="store_true", help="only phase a (the tower hashes of the pictures)")
    p.add_argument("--against", help="another run's --out file: compare token ids and tower hashes with it")
    p.add_argument("--out", help="write every row with its token ids as JSON")
    a = p.parse_args()
    run = Run(a)
    run.log.take()
    run.phases()
    sys.exit(run.report())


if __name__ == "__main__":
    main()

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks @BlivionIaG. The new log hashes the synchronized BF16 rows used by the splice, and the reported 22 equal cache/concurrency comparisons are useful evidence for the earlier-chip path. The image startup, chunk bounds and total budget handling remain intact.

This is ready for the remaining comparisons, with landing still held for the tensor-unit path and exact generated-token equality with the pinned reference. The dual-hash tower comparison helps, but the uncommitted diagnostic and truncated hashes do not close those checks. Please retain full tower hashes and token IDs on the final tree, including cache reuse and concurrency; no near-tie tolerance is accepted. The new hashing/logging cost also remains unmeasured.

  • Synthena

@BlivionIaG

Copy link
Copy Markdown
Contributor Author

Thank you, @ashhart. Taking your points in order.

Full hashes and token ids on the final tree. The run I posted was on the code of the current head: 972ba6ca78 (the log line) is e43e0e38a3 minus its changelog sentence, no other change. The truncated hashes in my table were only for reading; the full SHA-256 of each picture's tower rows are in the howto table in my earlier comment (64 hex digits each), and the run's own record, with the full tower hashes and every request's token ids, is below (vision-qualify.py --out; rows = the 32 requests, tower = every tower log line of the run). I will rerun it on whatever the final head is and post the file again; nothing about it depends on a diagnostic build. You are right that the Wyhash receipts of #4337 came from an uncommitted diagnostic: they show that this tower matches the old branch's recorded values, and they are not offered as the closing check.

Cost of the hashing line (a microbenchmark of the same std.crypto.hash.sha2.Sha256 on buffers of the tower's sizes, zig run -OReleaseFast -mcpu=apple_m1, best of 20, M4 Pro; not an in-engine timing): 2,396,160 bytes (the scene's 520 rows) 0.70 ms; 7,050,240 bytes (the invoice's 1,530 rows) 2.28 ms. The same Mac's tower takes about 1.6 s and 12.7 s for those two pictures on this head, so the line costs about 0.04 % and 0.02 % of the tower. It runs once per picture the tower computes, not per token.

Still open, and not something this Mac can close: the tensor-unit path, and generated-token equality with the pinned reference on both paths. The howto in my earlier comment is for the first; for the second I need to know which reference you mean for images, because the pinned Transformers run (6173a2f6, BF16 eager) is how the tower was first checked (83 of 83, in #4337), and I do not think a BF16 run of the whole model fits this 48 GiB Mac [INFERENCE, not tried]. If you can name the run you would accept, or an owner of an M5 who can run both, I will take it from there. No near-tie tolerance is being asked for or offered: every row of the table is token-id equality.

run record (vision-qualify-run-m4pro.json, 17 KB)
{
 "rows": [
  {
   "phase": "a solo",
   "case": "text-small.png",
   "prompt": 56,
   "cached": 0,
   "towers": [
    "3141ea7d:058c767427ad"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": 25.8,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149876,
    150311,
    149881,
    149876,
    150641,
    13,
    149904,
    149951,
    150294,
    196980,
    50139
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b repeat",
   "case": "text-small.png",
   "prompt": 56,
   "cached": 0,
   "towers": [
    "3141ea7d:058c767427ad"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 25.7,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149876,
    150311,
    149881,
    149876,
    150641,
    13,
    149904,
    149951,
    150294,
    196980,
    50139
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "a solo",
   "case": "shapes.png",
   "prompt": 197,
   "cached": 0,
   "towers": [
    "17f2b8d4:c21bae6773d3"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": 37.4,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    150299,
    165702,
    149880,
    160200,
    149881,
    149876,
    150641,
    13,
    149904
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b repeat",
   "case": "shapes.png",
   "prompt": 197,
   "cached": 192,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 23.1,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    150299,
    165702,
    149880,
    160200,
    149881,
    149876,
    150641,
    13,
    149904
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "a solo",
   "case": "chart.png",
   "prompt": 208,
   "cached": 0,
   "towers": [
    "0e91a5f2:61317e31d53d"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": 37.6,
   "ids": [
    200001,
    200008,
    371,
    150409,
    149884,
    161646,
    150081,
    149878,
    150809,
    158785,
    13,
    151217,
    149991,
    150546,
    149876,
    150473
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b repeat",
   "case": "chart.png",
   "prompt": 208,
   "cached": 192,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 23.4,
   "ids": [
    200001,
    200008,
    371,
    150409,
    149884,
    161646,
    150081,
    149878,
    150809,
    158785,
    13,
    151217,
    149991,
    150546,
    149876,
    150473
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "a solo",
   "case": "scene.jpg",
   "prompt": 546,
   "cached": 0,
   "towers": [
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": 63.6,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b repeat",
   "case": "scene.jpg",
   "prompt": 546,
   "cached": 512,
   "towers": [
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 26.2,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b prime",
   "case": "scene.jpg",
   "prompt": 546,
   "cached": 0,
   "towers": [
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 63.4,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b same picture, other question",
   "case": "scene.jpg",
   "prompt": 552,
   "cached": 512,
   "towers": [
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": 26.6,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149876,
    150520,
    150519,
    149879,
    149876,
    158808,
    149881,
    149876,
    150641,
    13,
    220
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b cold reference of the above",
   "case": "scene.jpg",
   "prompt": 552,
   "cached": 0,
   "towers": [
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 65.1,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149876,
    150520,
    150519,
    149879,
    149876,
    158808,
    149881,
    149876,
    150641,
    13,
    220
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b prime",
   "case": "shapes.png",
   "prompt": 197,
   "cached": 0,
   "towers": [
    "17f2b8d4:c21bae6773d3"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 38.2,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    150299,
    165702,
    149880,
    160200,
    149881,
    149876,
    150641,
    13,
    149904
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b same picture, other question",
   "case": "shapes.png",
   "prompt": 200,
   "cached": 0,
   "towers": [
    "17f2b8d4:c21bae6773d3"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": 38.0,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    151457,
    165702,
    149881,
    149876,
    150641,
    13,
    149904,
    149951,
    150294
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b cold reference of the above",
   "case": "shapes.png",
   "prompt": 200,
   "cached": 0,
   "towers": [
    "17f2b8d4:c21bae6773d3"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 37.9,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    151457,
    165702,
    149881,
    149876,
    150641,
    13,
    149904,
    149951,
    150294
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b conversation turn 1",
   "case": "shapes.png",
   "prompt": 197,
   "cached": 0,
   "towers": [
    "17f2b8d4:c21bae6773d3"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 37.8,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    150299,
    165702,
    149880,
    160200,
    149881,
    149876,
    150641,
    13,
    149904
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b conversation turn 2 (warm)",
   "case": "scene.jpg",
   "prompt": 731,
   "cached": 192,
   "towers": [
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": 64.2,
   "ids": [
    200001,
    200008,
    371,
    150409,
    150008,
    151089,
    150103,
    152272,
    149880,
    171960,
    25,
    196980,
    1738,
    149876,
    165702,
    149881
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "b conversation turn 2 (cold)",
   "case": "scene.jpg",
   "prompt": 731,
   "cached": 0,
   "towers": [
    "17f2b8d4:c21bae6773d3",
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 78.6,
   "ids": [
    200001,
    200008,
    371,
    150409,
    150008,
    151089,
    150103,
    152272,
    149880,
    171960,
    25,
    196980,
    1738,
    149876,
    165702,
    149881
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four identical, cold",
   "case": "scene x4 #1",
   "prompt": 546,
   "cached": 512,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 80.0,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four identical, cold",
   "case": "scene x4 #2",
   "prompt": 546,
   "cached": 0,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 80.0,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four identical, cold",
   "case": "scene x4 #3",
   "prompt": 546,
   "cached": 512,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 80.0,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four identical, cold",
   "case": "scene x4 #4",
   "prompt": 546,
   "cached": 512,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 80.0,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four identical, cold",
   "case": "(tower lines of the batch)",
   "prompt": null,
   "cached": null,
   "towers": [
    "392ea1cd:cc0ee6eb48ba",
    "392ea1cd:cc0ee6eb48ba",
    "392ea1cd:cc0ee6eb48ba",
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": null,
   "ids": null,
   "text": null,
   "error": null,
   "note": "batch"
  },
  {
   "phase": "c four different, cold",
   "case": "text-small.png",
   "prompt": 56,
   "cached": 0,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 100.7,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149876,
    150311,
    149881,
    149876,
    150641,
    13,
    149904,
    149951,
    150294,
    196980,
    50139
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, cold",
   "case": "shapes.png",
   "prompt": 197,
   "cached": 0,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 100.7,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    150299,
    165702,
    149880,
    160200,
    149881,
    149876,
    150641,
    13,
    149904
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, cold",
   "case": "chart.png",
   "prompt": 208,
   "cached": 0,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 100.7,
   "ids": [
    200001,
    200008,
    371,
    150409,
    149884,
    161646,
    150081,
    149878,
    150809,
    158785,
    13,
    151217,
    149991,
    150546,
    149876,
    150473
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, cold",
   "case": "scene.jpg",
   "prompt": 546,
   "cached": 0,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 100.7,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, cold",
   "case": "(tower lines of the batch)",
   "prompt": null,
   "cached": null,
   "towers": [
    "3141ea7d:058c767427ad",
    "17f2b8d4:c21bae6773d3",
    "0e91a5f2:61317e31d53d",
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": null,
   "ids": null,
   "text": null,
   "error": null,
   "note": "batch"
  },
  {
   "phase": "c four different, warm",
   "case": "text-small.png",
   "prompt": 56,
   "cached": 0,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 34.8,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149876,
    150311,
    149881,
    149876,
    150641,
    13,
    149904,
    149951,
    150294,
    196980,
    50139
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, warm",
   "case": "shapes.png",
   "prompt": 197,
   "cached": 192,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 34.8,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149991,
    149882,
    150299,
    165702,
    149880,
    160200,
    149881,
    149876,
    150641,
    13,
    149904
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, warm",
   "case": "chart.png",
   "prompt": 208,
   "cached": 192,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 34.8,
   "ids": [
    200001,
    200008,
    371,
    150409,
    149884,
    161646,
    150081,
    149878,
    150809,
    158785,
    13,
    151217,
    149991,
    150546,
    149876,
    150473
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, warm",
   "case": "scene.jpg",
   "prompt": 546,
   "cached": 512,
   "towers": [],
   "equal": "yes",
   "pressure": "normal",
   "seconds": 34.8,
   "ids": [
    200001,
    200008,
    371,
    150409,
    159306,
    149878,
    150103,
    12,
    3862,
    152041,
    149879,
    149876,
    150641,
    13,
    151217,
    149991
   ],
   "text": "",
   "error": null,
   "note": ""
  },
  {
   "phase": "c four different, warm",
   "case": "(tower lines of the batch)",
   "prompt": null,
   "cached": null,
   "towers": [
    "3141ea7d:058c767427ad",
    "392ea1cd:cc0ee6eb48ba"
   ],
   "equal": "-",
   "pressure": "normal",
   "seconds": null,
   "ids": null,
   "text": null,
   "error": null,
   "note": "batch"
  }
 ],
 "tower": [
  [
   "3141ea7deecd8fe3",
   24,
   "058c767427ada0e0f953a5ecadf1be70e6c71bb254a5e58778b90dfe988f025b"
  ],
  [
   "3141ea7deecd8fe3",
   24,
   "058c767427ada0e0f953a5ecadf1be70e6c71bb254a5e58778b90dfe988f025b"
  ],
  [
   "17f2b8d4ccabed16",
   169,
   "c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951"
  ],
  [
   "0e91a5f26bd7bae1",
   176,
   "61317e31d53d83cd305dfec593a79cfcabbaa7c9b71caaff73bf9f31bda77be9"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "17f2b8d4ccabed16",
   169,
   "c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951"
  ],
  [
   "17f2b8d4ccabed16",
   169,
   "c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951"
  ],
  [
   "17f2b8d4ccabed16",
   169,
   "c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951"
  ],
  [
   "17f2b8d4ccabed16",
   169,
   "c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "17f2b8d4ccabed16",
   169,
   "c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "3141ea7deecd8fe3",
   24,
   "058c767427ada0e0f953a5ecadf1be70e6c71bb254a5e58778b90dfe988f025b"
  ],
  [
   "17f2b8d4ccabed16",
   169,
   "c21bae6773d32b5b04535f1d1bf745c3531b5ba8ef778b9db65a10955c3a9951"
  ],
  [
   "0e91a5f26bd7bae1",
   176,
   "61317e31d53d83cd305dfec593a79cfcabbaa7c9b71caaff73bf9f31bda77be9"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ],
  [
   "3141ea7deecd8fe3",
   24,
   "058c767427ada0e0f953a5ecadf1be70e6c71bb254a5e58778b90dfe988f025b"
  ],
  [
   "392ea1cd56c26ab3",
   520,
   "cc0ee6eb48ba98b070d2ac7044b37296d9b45e98daaa41af8d37794c3a84708e"
  ]
 ]
}

@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you, @BlivionIaG. We ran this on an M5 Ultra with Inkling 2 Mini, main against your three commits on today's main.

  • Text replies: identical token ids on main, on this branch, and on this branch with --vision (math, code and prose prompts).
  • Images (your RGB and RGBA fixtures plus two synthetic PNGs): token ids identical across repeat runs and against the build before the logging commit; the logged tower row hashes and all 24 tower stages' hashes (two test images) are identical run to run.
  • Prompt cache: a second turn restored from the cache equals the same turn fresh, and asking about the picture again equals the serial reply.
  • Concurrency: two image prompts at once equal their serial replies.
  • Memory: unchanged without --vision; the tower adds about 610 MiB with it. The logging line costs nothing measurable (time to first token 2.3595 s before, 2.3570 s after).
  • Not run here: JPEG and WebP inputs, since the test machine lacks those libraries (the server refuses them by name, as intended).

Main doesn't serve Inkling images, so there's no older reference to compare picture replies against; the checks above are same-engine exactness, which is our bar for a new input path. With the text path unchanged and images opt-in, this is now in our landing queue.

  • Synthena

ashhart pushed a commit to BlivionIaG/TensorFold that referenced this pull request Nov 24, 2026
- The ashhart#4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
ashhart pushed a commit to BlivionIaG/TensorFold that referenced this pull request Nov 24, 2026
- The ashhart#4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
BlivionIaG and others added 4 commits November 24, 2026 23:35
…ch decode and prefill row splice

- Add the 23-layer vision tower (vision.metal, vision_gemm.metal) as the `vision` source of inkling2_metal, with host code in metal/vision*.zig.
- Decode PNG/JPEG/WebP through the family's image decoder and patchify in the processor's merge-block order with the HF two-step normalisation.
- Splice the tower's BF16 rows over the image placeholders in forward prefill, across chunks and cache restores (metal/images.zig); native opener loads the tower under --vision.
- Let inkling2_loop past the Metal dispatcher's --vision gate (native/metal.zig) so the opener is reached, and name Inkling 2 Mini in the refusal text and docs/vision.md.
- Add contract records, probes and host-checked planted controls for the tower kernels; test-inkling2-media-metal runs the device and checkpoint checks.
- Build the Mini contract suites in place: their probes point into the suites, and the returned copy left them dangling once a seventh suite was added.
- Add the vision CHANGELOG bullet under Unreleased.

Co-authored-by: BlivionIaG <15323295+BlivionIaG@users.noreply.github.com>
…ts BF16 rows

- One info line per image the tower computes (the picture's content hash, rows, SHA-256 of the rows the splice takes); a picture a restored prefix covers logs nothing.
- Host test for the digest's hex.
- The ashhart#4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
@ashhart
ashhart merged commit 6862833 into ashhart:main Nov 24, 2026
1 of 11 checks passed
ashhart pushed a commit that referenced this pull request Nov 24, 2026
- The #4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @BlivionIaG. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

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.

2 participants