Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions docs/receipts/qwen35-ane-share-m1-ultra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Metal qwen3_5 ANE prompt-column share (TF_ANE_COLUMNS)

Receipts for the opt-in Neural Engine share of the qwen3_5 prompt MLP. With `TF_ANE_COLUMNS=C` set before
`tensorfold-native serve`, the first C columns of every `gate`/`up` projection in a prompt pass wider than
`batch_rows` (32) run on the ANE through a reusable `ane_share` program; the GPU computes the remaining columns
and the SiLU·up merge for the full width, and keeps the down projection. Passes a merged decode round can reach
(<= 32 rows) never touch the share, so decode and the lane verify windows are the stock GPU path bit-for-bit.
With the variable unset the binary takes the stock path.

Measured on 2026-12-04 on an Apple M1 Ultra, against `main` at merge-base `bf1a2eb22`.

## Builds and hardware

- Head: `4fef6fb89` (`w7r/qwen35-ane-rows-v2`). Base: `main` merge-base `bf1a2eb22`.
- Zig 0.17.0. Binaries: `zig build native` in each tree.
- `tensorfold-native` SHA-256, base: `735eca22f65aecbde702eefa9c4265dd7d02c15911023377bab764248de62886`;
head: `d3a9407a12fcc8b34dfc46a285bc3f3766ad6df892a4e8ef3999735301c6f683`.
- Chip: Apple M1 Ultra (apple-m1-ultra), macOS, arm64. One host, quiet box during the runs.
- Checkpoint: `mlx-community/Qwen3.5-2B-MLX-4bit@93760be4f1f69842a46bc13dbdc0f19e291392a3`, local copy
`~/models/qwen35-2b-4bit`.
- Served model name `qwen35-2b-4bit`. Servers: `tensorfold-native serve <ckpt> --host 127.0.0.1 --port <port>
--prompt-cache-gib 0`; the head arm sets `TF_ANE_COLUMNS=2048` in its environment.

## What the share changes, in bits

The ANE evaluates the shared gate/up columns in fp16 where the GPU path uses bf16. The prompt pass's logits can
differ from the GPU-only path by the fp16-vs-bf16 rounding, and greedy decode then amplifies it: on the
`tf-receipt-v1` pack two of four greedy prompts (`code_greedy`, `reasoning_greedy`) emit different tokens on head
than on base; the other two are identical. The token stream stays internally consistent on the head build —
every reply still equals its `"draft": false` run and its solo run on the same server — but it is not
bit-identical against the GPU path, so no `perf_receipt.py` receipt can verify. `decode-abba-51fa1a34.json`
keeps the raw mirrored ABBA pass as evidence instead of as a verified receipt.

## Exactness: consistent on the head build

`tools/bench_concurrent.py --alone --serial` on head (`TF_ANE_COLUMNS=2048`): `alone.equal` 12/12 on all four
prompt rows (concurrent replies equal their solo runs), `serial.equal` clean with drafts accepted (196 and 135
accepted drafts on the code rows). The same run on base is 12/12 equal as well. The row floor confines the
share to prompt bulk, so co-batched decode rows never change a stream's tokens.

## Speed

Decode tok/s, mirrored ABBA (`base,head,head,base`), pack `tf-receipt-v1`, `decode-abba-51fa1a34.json`:

| mean base | mean head | delta | base-vs-base noise |
|---|---|---|---|
| 117.602 tok/s | 117.587 tok/s | -0.01% | 2.29% |

`tools/bench_openai.py` (256-token replies): base 118.0–119.2, head 119.0–120.7 tok/s — parity.

Cold first-request `ttft_s`, `tools/bench_cache.py --require-cold` (2571-token fixture), both `qualified: true`:

| arm | runs, s | median, s |
|---|---|---|
| base | 1.506, 1.454, 1.460, 3.005, 1.587 | 1.506 |
| head | 1.542, 1.404, 1.411, 1.535, 2.945 | 1.535 |

Long-prompt TTFT, mirrored ABBA on a 9013-token prompt (runs/abba logs under `runs/`):

| arm | runs, s |
|---|---|
| base | 6.349, 6.320 |
| head C=2048 | 6.288, 6.200 |

The share is at the crossover on M1 Ultra: steady-state ANE eval (~0.7 ms/layer) barely beats the GPU's time on
the shared columns, so it wins only once the prompt is long enough for the pack to amortize; at 2.5k tokens it
loses ~2%. `TF_ANE_COLUMNS=5632` loses (+75% TTFT): the wider share's eval outruns the GPU tail and the serial
handoff dominates. Off by default; the flag only opts in.
159 changes: 159 additions & 0 deletions docs/receipts/qwen35-ane-share-m1-ultra/decode-abba-51fa1a34.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"schema": 1,
"pack_id": "tf-receipt-v1",
"pack_sha256": "ab2a5d0ff262007e3ef4714fa46e62b2b2454b3f97b652ca18da49e4e0583c42",
"generated_at_utc": "2026-12-04T21:04:38Z",
"claim": "TF_ANE_COLUMNS=2048 keeps decode throughput within noise of upstream main on qwen3_5-2b",
"git": {
"base_sha": "bf1a2eb229fca83bda61125122b22c4edd5a5033",
"head_sha": "4fef6fb89a86fa36291faaad19fa1bef3ea84a54"
},
"environment": {
"chip": "apple-m1-ultra",
"os": "darwin",
"arch": "arm64",
"checkpoint_id": "mlx-community/Qwen3.5-2B-MLX-4bit@93760be4f1f69842a46bc13dbdc0f19e291392a3",
"draft": false,
"base_binary_sha256": "735eca22f65aecbde702eefa9c4265dd7d02c15911023377bab764248de62886",
"head_binary_sha256": "d3a9407a12fcc8b34dfc46a285bc3f3766ad6df892a4e8ef3999735301c6f683"
},
"control": {
"prompt_id": "prose_seeded",
"seed_a": 424242,
"seed_b": 989898,
"base_token_sha256": "5d81401260b5227229b601d4c5f0f6902c622865ba1211246ced86ce01465867",
"alt_token_sha256": "bc123399c5ac960dda0b44880f815c9086bf3426d38f2bb4ebc35ba29228b5b8",
"diverged": true
},
"draft_check": null,
"order": [
"base",
"head",
"head",
"base"
],
"rounds": [
{
"index": 0,
"arm": "base",
"agg_tok_s": 118.931
},
{
"index": 1,
"arm": "head",
"agg_tok_s": 118.562
},
{
"index": 2,
"arm": "head",
"agg_tok_s": 116.612
},
{
"index": 3,
"arm": "base",
"agg_tok_s": 116.273
}
],
"summary": {
"mean_base_tok_s": 117.602,
"mean_head_tok_s": 117.587,
"gain_pct": -0.013,
"base_noise_pct": 2.286
},
"prompts": {
"prose_greedy": {
"base": {
"tokens": 128,
"prompt_tokens": 29,
"cached_tokens": 0,
"complete": true,
"token_sha256": "a8d065e8e8d686fe07d596e2df63412079b12d0746f0367978256faece601418",
"output_sha256": "cc5a496badf3aff41d060ae8d67920fc36316538ed62b0fac0b7a73167fa2339",
"tok_s": 117.019,
"ttft_s": 0.0329
},
"head": {
"tokens": 128,
"prompt_tokens": 29,
"cached_tokens": 0,
"complete": true,
"token_sha256": "a8d065e8e8d686fe07d596e2df63412079b12d0746f0367978256faece601418",
"output_sha256": "cc5a496badf3aff41d060ae8d67920fc36316538ed62b0fac0b7a73167fa2339",
"tok_s": 119.917,
"ttft_s": 0.0241
},
"token_equal": true
},
"code_greedy": {
"base": {
"tokens": 128,
"prompt_tokens": 36,
"cached_tokens": 0,
"complete": true,
"token_sha256": "402c654690327cbd7c5e39bc03025b92576c153049f7feea5303926208e7299c",
"output_sha256": "ccbd8a821f78fb384214413f3982988afd70e04b6cc4ce7df0b6701edd0814c4",
"tok_s": 118.186,
"ttft_s": 0.0277
},
"head": {
"tokens": 128,
"prompt_tokens": 36,
"cached_tokens": 0,
"complete": true,
"token_sha256": "ecd1a72c158e72b1dcdcb3f3681752945350597547f6e3befc8a2b40bd77d995",
"output_sha256": "bc1566f14c17d2a992fa79d0c5234e27c1f289e2467b1179cb110478c79921f8",
"tok_s": 117.33,
"ttft_s": 0.0417
},
"token_equal": false
},
"reasoning_greedy": {
"base": {
"tokens": 128,
"prompt_tokens": 47,
"cached_tokens": 0,
"complete": true,
"token_sha256": "fb6def7b7e8ebcde87afd2069c681f008c109e2fafe4ae9c7f72b14f98ff86c3",
"output_sha256": "6ba74eace670da7b977a2f296cab27ff4f6643328dbdcd8cc51f95087e465ec9",
"tok_s": 113.482,
"ttft_s": 0.0323
},
"head": {
"tokens": 128,
"prompt_tokens": 47,
"cached_tokens": 0,
"complete": true,
"token_sha256": "383d17d3aba1bda86ebd3554df1f898cb743be7d250da3ee0e480ad7f46c2a4b",
"output_sha256": "8b50efc88b73edc1f28f40c5a03278b3f04b88813b3e02d192cb73814980bbd9",
"tok_s": 111.804,
"ttft_s": 0.0439
},
"token_equal": false
},
"prose_seeded": {
"base": {
"tokens": 64,
"prompt_tokens": 23,
"cached_tokens": 0,
"complete": true,
"token_sha256": "5d81401260b5227229b601d4c5f0f6902c622865ba1211246ced86ce01465867",
"output_sha256": "40630bab47fc8b05dc62674c9941e44fbeb74c68dbe801a6f93f5b90fbed9a14",
"tok_s": 116.764,
"ttft_s": 0.0224
},
"head": {
"tokens": 64,
"prompt_tokens": 23,
"cached_tokens": 0,
"complete": true,
"token_sha256": "5d81401260b5227229b601d4c5f0f6902c622865ba1211246ced86ce01465867",
"output_sha256": "40630bab47fc8b05dc62674c9941e44fbeb74c68dbe801a6f93f5b90fbed9a14",
"tok_s": 118.881,
"ttft_s": 0.0199
},
"token_equal": true
}
},
"exactness_sha256": "93467c579181722c7612f400f3fe48ef90a11322c0f92bbbfd371874344b8aa3",
"receipt_sha256": "51fa1a34c980ecda3ef4b5e55b80f601dde57f0f10b0ef487c82444f7eb048e8"
}
Loading
Loading