Repository navigation
native: Qwen3.5-2B on Metal attests the execution witness's path, every weight byte with the kernel sources this OS compiles - #4908
Conversation
|
I checked the stack at I also applied Ash's overlapping build-fixture PR #4987 ( Igor Lessio - AIFLOW LABS |
|
Thank you, @kotevcode. The Metal path keeps hashing behind the flag and binds the libraries the loader actually compiles, including the page-header concatenation. The public receipt still contains the fixed path and opaque digests rather than private input values. This is ready for controlled comparisons. Final-tree token parity, off-path startup cost, and live receipt/reload checks remain before landing; the supplied host results are recorded.
|
5bcc339 to
7d8bf41
Compare
|
Thank you, @kotevcode. The Metal-witness patch is unchanged from the reviewed version; the shared extraction is now on main, and this head merges cleanly. The flag gate, source bindings and ownership remain intact. Still ready for controlled comparisons. Final-tree token parity, flag-off startup cost and live receipt/reload checks remain before landing.
|
|
Thanks @ashhart. I rebased this onto main after #4907 landed: it's one commit now, 7d8bf41 on 8e0548f, with the same diff. I ran the three remaining checks on that tree, main 8e0548f against 7d8bf41, on an M5 Max with macOS 26.6 (25G72). The description and the gist have the full numbers.
Raw results and scripts: https://gist.github.com/kotevcode/54b2d0bd8f14f51e0d47891c924a1b3b |
|
@kotevcode, we ran the remaining checks on your head
It's in a landing train now.
|
…ry weight byte with the kernel sources this OS compiles
7d8bf41 to
af97136
Compare
|
Thank you @kotevcode. 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
With
--execution-witness, native Qwen3.5-2B on a Mac attests its path,qwen3_5-2b/metal/tp1/mlx-q4g64/text, instead of readingunsupported_path. The engine stamps the checkpoint's files before the load and reads every shard byte once the server is ready, as on CUDA. In place of kernel images and the GPU's facts, it binds the Metal sources the load compiles, this OS's compile options, the OS build and chip, tensor units, the resolved profile and the served shape. Without the flag nothing changes: the witness is never opened.metal_witness.zig(105 lines) is aMetalbackend forweights_witness.Witness(native: the execution witness's stamps, weight read and hash thread move to weights_witness.zig, and CUDA keeps its kernels, GPU and components #4907).keephashes these, in order:kernels(): one SHA-256 over every libraryq.kernels.loadcompiles, with its source, its functions in pipeline order, and a projection's tile (columns, threads).q.kernels.options(): math mode, math functions and language version.disk_identity.machine: the OS build and the chip, read as Metal's kept states key them (no second reader).disk_identity.profilefor the family and backend.tail: the window, the streams, the prompt step (TF_QWEN35_CHUNK's value), the lane rows the load's exactness check left, and whether the caches are paged.families/qwen3_5/kernels.zignames its libraries once, inlibraries: eachsources.allentry, then layout, then paged.loadloops over that list, andoptions()is theCompileOptions.mlx()every library takes, so the witness hashes exactly what the load compiles. A test checks that the libraries' functions add up toq.kernels.total, so a pipeline outsidelibrariescan't load unhashed.native/qwen35.zigopens the witness beforeModel.loadwhenmetal_witness.wanted(o). After the load it binds the device and shape, passes the source to the lane host, and adopts the witness once the host starts; a refusal or failure releases it.wantedis the shared condition from native: the execution witness's stamps, weight read and hash thread move to weights_witness.zig, and CUDA keeps its kernels, GPU and components #4907: the flag, one rank, text, and no drafter,--slide,--record,--learn,--recallor MTP drafts.docs/api.mdnames the Metal path and itscomponents.enginelist next to the CUDA one.test-execution-witness-metal-hostis a new host step, also run byzig build test. The build stand-ins forresidency_host,drama3_metal,slide_hostandqwen35_cache_hostexportdigest_cacheandcheckpoint_identity, whichweights_witnessimports.Issue: Refs Execution witness: Qwen3.5-2B on Metal #4630 (part 2 of 2: the Metal path; part 1 is native: the execution witness's stamps, weight read and hash thread move to weights_witness.zig, and CUDA keeps its kernels, GPU and components #4907, merged).
Based on: main at 8e0548f, which has native: the execution witness's stamps, weight read and hash thread move to weights_witness.zig, and CUDA keeps its kernels, GPU and components #4907; this PR adds 7d8bf41.
atc overlap --json: run on this head against main;complete: false(otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit). MoE route tap: optional TF_ROUTE_TAP trace of global top-k #1886 shares one file and is clean.Checks on this head
python3 tools/pr_check.py --base upstream/main --pr 4908: lean 164 and 164 on the base and this head, 0 new; 0 errors.zig build test-execution-witness-metal-host: 6 passed, 0 failed, 0 skipped.q.kernels.total, and the kernel digest is stable.files_changed; a reload hashes again to the same digest.hash_failedand the load goes on.zig build test-execution-witness-cuda-host: 22 passed.test-execution-witness-host: 55.test-disk-identity-host: 40.test-metal-residency-host: 11.test-metal-residency-owners-host: 84.compile-metal-residency-hostandcompile-disk-identity-metal-hostbuild.zig build test -Dcpu=apple_m1, on the previous head 5bcc339 (main ea57d96 with native: the execution witness's stamps, weight read and hash thread move to weights_witness.zig, and CUDA keeps its kernels, GPU and components #4907's commit; this head has the same diff on current main): 1029 of 1033 steps; 16742 passed, 2 failed, 128 skipped in the steps that ran (steps cached from an earlier run aren't counted). The same 4 steps fail on main at ea57d96:uocr/serve.zig:288'sstd.mem.zeroeson aDecoderwith a non-nullable pointer (76200b6);qwen27/mtp_pick.zig'sbf16_topkimport;info's Qwen3.8-27B pricing test, which expects "not priced" where this Mac fits it; and thestartCLI's managed-log tests (one KR67 test here, three of them on main). This PR touches none of them.q.configrefuses on this path.Receipt
--execution-witness.--execution-witnessflag andexecution_witnessrequest field; there's no new profile row.zig build native -Doptimize=ReleaseFast -Dcpu=apple_m1for both;mlx-community/Qwen3.5-2B-MLX-4bit@93760be4f1f69842a46bc13dbdc0f19e291392a3,serve --context 8192 --no-thinking --api-key, a fresh process per start.--execution-witnessand"execution_witness": trueon every request, measured afterknown; D branch with the flag and no field. Order rotated ABCD, BCDA, CDAB, DABC. C's field goes through a small proxy that adds it and records each object, since the repo's tools have no extra-body option; D measures the same server without the proxy. Each cell is the median of its runs./health200, s (n=4)known, s (n=4)ttft_s(n=4)bench_openai, n=4)bench_openai, n=4)Another process used about two cores of this Mac during the run, so the four-arm medians spread wider than in earlier runs: chat's 1-stream runs read A 125.1–137.7, B 87.4–141.0, C 117.9–141.2, D 130.2–141.2, and the drafted code prompt A 261.1–330.1, B 104.7–341.7, C 259.6–364.4, D 280.1–339.8. The alternating runs compare A and B under the same load:
bench_openai, greedy): chat 135.3 and 136.5 tok/s, code 320.8 and 294.5 (medians), with the same tokens. Chat's lower of each pair is A in six rounds and B in two; code's is A in four and B in four.startup.py): spawn to/health200 is 0.538 s on A and 0.539 s on B (ranges 0.524–0.560 and 0.524–0.583), and spawn to the first streamed token 0.548 s and 0.549 s. The four-arm table's B reads later at/healthin every run so far, and D, the same binary with more work, doesn't; head to head the gap is 0.6 ms.bench_concurrent.py --levels 1,8 --tokens 256 --alone --serial, sampled at 1.0 with seeds and greedy, code and chat. All 4 arms passed: 108/108 alone and 36/36 serial equal each, 0 unequal, 0 failed, and every 8-stream cell overlapped. Chat's serial cells accepted no draft, so the drafted-against-plain check is code's. Each prompt gave onetoken_shaacross A, B, C and D: codebc1513a7f13c, chatf5c2a018d77d, the cold 7,680-token prompt4fe11ea07e60…. At 1 and 8 streams, a 128-token greedy reply wasca9f285b473f…on A, B and C.knownon the path; 348 objects through C's proxy, allknown, eachtoken_sha256equal totensorfold.token_sha256.pendingat ready.contentandcomponentswith a new instance.model.safetensorswhile the hash runs: the snapshot and replies readfiles_changed.--idle-unload 5:parked; the next request reloads at epoch 2 and readspending, thenknownwith the same content.--recall:feature_excluded, feature--recall.--prompt-cache-gib 4(this model keeps prompt states only with it): a second turn resumed from 7,552 of 7,738 tokens gives the sameprompt_sha256,request_sha256andtoken_sha256as the same turn on a fresh server, and the same binding when repeated. The bindings differ only through the witness (a new instance).tools/bench_cache.py --require-cold --expected-prompt-tokens 7680, above; every run cold (0 cached) and qualified.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.