Repository navigation
Inkling 2 Mini on Metal: images under --vision (the tower, the processor and its contract) - #4704
Conversation
3e0e9bc to
f790014
Compare
ab82e7b to
cc9471a
Compare
|
Served images on the restacked head (
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. |
cc9471a to
9c4e3ef
Compare
|
CI on
I keep this draft until lead's own |
aefb063 to
c41911e
Compare
|
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
|
9c4e3ef to
c3e938a
Compare
|
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.
|
- The ashhart#4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
|
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 ( Earlier-chip path (M4 Pro, 48 GiB, no tensor units),
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.
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 vision-qualify-howto.mdQualifying
|
| 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()|
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.
|
|
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: Cost of the hashing line (a microbenchmark of the same 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 ( 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"
]
]
} |
|
Thank you, @BlivionIaG. We ran this on an M5 Ultra with Inkling 2 Mini, main against your three commits on today's main.
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.
|
- The ashhart#4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
- The ashhart#4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
…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.
- The #4704 bullet says each picture the tower runs logs its content hash, rows and the SHA-256 of its BF16 rows.
|
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. |
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--visionby name. This ports the Metal vision work of #4337 (by @BlivionIaG) ontomain, where #4387 landed. It is slice M7 of #4274 (claim: #4274 (comment)).mainat834237bca8. This pull request's own commit isc3e938acff. It does not depend on the open DSpark, prompt-kernel or decode pull requests.gh pr list --search 'inkling in:title,body').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) andvision_gemm.metal(Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337'sgemm.metalwithout its fourbf16_nnkernels, which only the superseded draft used), joined asinkling2_metal.visionthroughvision_sources.zigwith../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 existingimage.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.imagescopies the tower's BF16 rows over the image placeholders after the embedding norm, validated (one segment, no id override, bounds, placeholder ids).images.zighands each prefill chunk the part of each picture inside it and skips pictures wholly inside a restored cache prefix.native/inkling2.zig:--visionloads the tower (its bytes join the resident budget before the cache budget), and the opener refuses only guidance. The tower readsmodel.visual.*itself, sinceModel.loadreadsmodel.llm.*only.vision.eps(layer_norm_eps) in the config.native/metal.zigrefused--visionforinkling2_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.mdlists it); andtf-kernel-contract --only inkling2segfaulted once the vision suite was added, because the probes point into the suite struct and it was returned by value, soSuites.init(s: *Suites, ...)now builds the set in place (metal_main.zigupdated).Checks on this head
c3e938acff, one commit onmainat834237bca8.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.-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(mainalone: 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).serve --vision --context 8192 --parallel 1 --no-drafts --prompt-cache-gib 0 --no-thinking, greedy, onthinkingmachines/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;mainreturns 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) aremain's current prompt and expert speed, not this slice's.test-inkling2-metal-hostand the wholezig build test test-goldenon 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
mainrefuses 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 equalmain's (0b037128ee78,b37d8a0e39c4,146f8038bfc7,870a47079391, the last with 384 cached tokens).inkling2_loopon Metal with--vision.--vision,--vision-max-imagesand--vision-image-tokensalready exist; without--visionimages are still refused by name.thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7.6173a2f6BF16 eager, 83 of 83, and the public fixture, 20 completion ids of 20.Checklist