Skip to content

native: Qwen3.5-2B on Metal attests the execution witness's path, every weight byte with the kernel sources this OS compiles - #4908

Open
kotevcode wants to merge 2 commits into
ashhart:mainfrom
kotevcode:execution-witness-metal
Open

kotevcode wants to merge 2 commits into
ashhart:mainfrom
kotevcode:execution-witness-metal

Conversation

@kotevcode

@kotevcode kotevcode commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 reading unsupported_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.

Checks on this head

  • Head commit: 5bcc339
  • Lean checker and python3 tools/pr_check.py --base upstream/main --pr 4908: lean 165 and 165 on the base and this head, 0 new; 0 errors.
  • Tests run, with the command and pass, fail and skip counts (macOS 26.6 build 25G72, Apple M5 Max, Xcode 27.2, Metal toolchain 27B47):
    • zig build test-execution-witness-metal-host: 6 passed, 0 failed, 0 skipped.
      • The path's conditions.
      • Every library's functions add up to q.kernels.total, and the kernel digest is stable.
      • Any one of these changes the digest: a shard byte rewritten at the same size and header, the kernel digest, the GPU, tensor units, the compile options, the lane rows, KV pages, or a resolved profile value.
      • A moved shard reads files_changed; a reload hashes again to the same digest.
      • Unstampable files read hash_failed and the load goes on.
    • zig build test-execution-witness-cuda-host: 22 passed. test-execution-witness-host: 54. test-disk-identity-host: 39. test-metal-residency-host: 11. compile-disk-identity-metal-host builds. compile-metal-residency-host fails on main too since ec277c1: inkling2.zig imports engine_api, which the stand-in's core module lacks.
    • zig build test -Dcpu=apple_m1: 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's std.mem.zeroes on a Decoder with a non-nullable pointer (76200b6); qwen27/mtp_pick.zig's bf16_topk import; info's Qwen3.8-27B pricing test, which expects "not priced" where this Mac fits it; and the start CLI's managed-log tests (one KR67 test here, three of them on main). This PR touches none of them.
  • CI: passes on this head (Zig format, No GPU; 10 pass, 2 skipped).
  • Not run, and why: other Macs and macOS builds (one M5 Max here); the 0.8B and 9B, which q.config refuses on this path.

Receipt

  • Main against branch: below, on one Mac, main ea57d96 against this head. Raw results, the driver and the analysis: https://gist.github.com/kotevcode/54b2d0bd8f14f51e0d47891c924a1b3b
  • Boxes it reaches: Apple silicon Macs serving native Qwen3.5-2B with --execution-witness.
  • New switch? No. It uses the existing --execution-witness flag and execution_witness request field; there's no new profile row.
  • Environment: base ea57d96; branch 5bcc339; Zig 0.17.0; Xcode 27.2 (27B52), Metal toolchain 27B47; macOS 26.6 (25G72); Apple M5 Max, 128 GB; zig build native -Doptimize=ReleaseFast -Dcpu=apple_m1 for both; mlx-community/Qwen3.5-2B-MLX-4bit@93760be4f1f69842a46bc13dbdc0f19e291392a3, serve --context 8192 --no-thinking --api-key, a fresh process per start.
  • Paths and platforms the change reaches: native Qwen3.5-2B on Metal, which I ran. Not run: other Apple chips, other macOS builds.
  • Arms: A main; B branch; C branch with --execution-witness and "execution_witness": true on every request, measured after known; 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.
2B on Metal A B C D
Start to /health 200, s (n=4) 0.464 0.536 0.555 0.496
Start to known, s (n=4) 1.84–2.08 1.81–2.11
Cold first token, 7,680 tokens, ttft_s (n=4) 2.622 2.559 2.612 2.602
Decode, 1 stream, chat, tok/s (bench_openai, n=4) 146.6 140.3 142.2 144.9
Decode, 1 stream, code, tok/s (bench_openai, n=4) 335.0 293.0 390.5 381.7
Decode, 8 streams aggregate, code / chat, tok/s 785.1 / 529.3 756.8 / 510.2 796.0 / 533.7 770.1 / 536.8
Decode, 8 streams per stream, code / chat, tok/s 99.9 / 67.1 96.0 / 64.8 100.8 / 67.7 98.1 / 68.1

B reads lowest in most rows, though C and D run B's binary with more work. Chat's 1-stream runs: A 146.4–153.2, B 134.2–141.5, C 138.2–144.5, D 136.1–147.6. The code prompt drafts and spreads widely in every arm: A 277.7–380.4, B 291.5–328.1, C 362.5–408.0, D 361.5–402.6. To check flag off against main directly, 8 more alternating rounds of A and B (bench_openai, greedy) gave chat 148.6 and 148.5 tok/s and code 332.7 and 363.5 (medians), with the same tokens; the lower of each round's pair is A in four rounds and B in four for chat.

  • Exactness: 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 one token_sha across A, B, C and D: code bc1513a7f13c, chat f5c2a018d77d, the cold 7,680-token prompt 4fe11ea07e60…. At 1 and 8 streams, a 128-token greedy reply was ca9f285b473f… on A, B and C.
  • Witness, on C and D:
    • Every check read known on the path; 350 objects through C's proxy, all known, each token_sha256 equal to tensorfold.token_sha256.
    • pending at ready.
    • A restart gives the same content and components with a new instance.
    • Touching model.safetensors while the hash runs: the snapshot and replies read files_changed.
    • --idle-unload 5: parked; the next request reloads at epoch 2 and reads pending, then known with the same content.
    • --recall: feature_excluded, feature --recall.
  • Fresh and resumed, on the branch with the flag and --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 same prompt_sha256, request_sha256 and token_sha256 as the same turn on a fresh server, and the same binding when repeated. The bindings differ only through the witness (a new instance).
  • Prompt speed before and after: tools/bench_cache.py --require-cold --expected-prompt-tokens 7680, above; every run cold (0 cached) and qualified.
  • Licence of any new weights or drafter: n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. The bits don't change.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted.

…ove to weights_witness.zig, and CUDA keeps its kernels, GPU and components
…ry weight byte with the kernel sources this OS compiles
@AIFlowML

Copy link
Copy Markdown
Contributor

I checked the stack at 5bcc339106ef86c353d380cf3e0ef0954ffeb857, including #4907, against main 4c79cfe346d3c239ff7dfd7aa694df799755bafa. The trial merge was clean. On macOS ARM64, zig build test-execution-witness-metal-host test-execution-witness-cuda-host test-execution-witness-host test-disk-identity-host -Dfixed-cpu --summary all passed all 123 tests.

I also applied Ash's overlapping build-fixture PR #4987 (7a156856dce85bc201577167b95e4e257713908b) after this stack. That merge was clean and zig build test-execution-witness-metal-host compile-metal-residency-host test-metal-residency-owners-host -Dfixed-cpu --summary all passed all 21 steps, including the residency compile and 87 tests. This verifies that landing order for the shared host build wiring. I did not rerun model serving or the live Metal witness receipt.

Igor Lessio - AIFLOW LABS

This branch has not been deployed

No deployments
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