Repository navigation
gpu: raise the Vulkan Qwen3.5 context ceiling to 8192 keys - #3417
joshuaswarren wants to merge 1 commit into
Conversation
|
[Joshua's agent] ATC check on this PR: |
|
[Joshua's agent] First GPU result for this PR: the attention contract passes on a 13-inch M1 MacBook Pro (Apple M1, Honeykrisp, Linux 7.3.0-2 lab kernel, gpu-timeouts=0 before and after). The long-stream cases ran on the device against the f64 reference:
Every case also checked that repeats are byte-identical, that planted wrong outputs are refused, and that inputs are unchanged. The 64 rows of the last case each decode alone bit-identical to the batched result. Still queued on this Mac and on a 14-inch M2 Max: the same contract on the M2 Max, the #3401 against #3417 speed pairs at document-256, document-1024 and the 7105-token prompt, and a model run at |
|
[Joshua's agent] Results for head bed6b62 (code commit d6917e7). Attention contract on a 14-inch M2 Max ("Apple M2 Max (G14C B1)"): passed 18 of 18, including decode at 7169 and 8192 keys and 64 rows up to 8192. The 13-inch M1 also passed 18 of 18 (earlier comment). Contexts at or below 7168 keys must not get slower, so I ran #3401 (old) against #3417 (new) on the 13-inch M1, 5 alternating pairs each, same prompts and the same checks as the earlier A/B rows:
The token ids and the logits hash are the same on both sides in all 10 pairs, and no GPU timeouts were recorded. This is the expected result: below 7168 keys the shared-memory SPIR-V is byte-identical, so the PR changes nothing there. Still running: the 7105-token prompt on the 13-inch M1, and the A/B and the |
|
[Joshua's agent] Merged main (05c5d3c) into the chain to clear the CHANGELOG conflict. The only conflict was the Unreleased list in CHANGELOG.md: this chain's entry kept, main's new entries kept below it, no code touched. No force-push; each branch got one merge commit on top of its old head. New heads: #2016 33d268f, #2017 30e069b, #2038 54f9b40, #3401 096df4e, #3417 a52027e. |
|
[Joshua's agent] 13-inch M1 A/B, Qwen3.5-2B Vulkan, pinned CPUs, kernel 7.3.0-2-20261110.1-lab. Old arm is #1544 (the base of this chain), new arm is the #3417 head built from this PR's tree. Run2 ms (second forward of the same process), median over pairs, gain = (old - new) / old.
New-arm run2 range: unicode-24 1991 to 2119 ms, document-256 3645 to 3680 ms, document-1024 9917 to 9922 ms. The document-1024 row is incomplete: the lab scheduler stopped the job at its time cap before the last old-arm runs (each old run takes about 123 s), so I report the runs that finished and compute the median from the raw per-run lines in the receipt. No summary VERDICT line was written. The two shorter cases have all 5 pairs. This is a chain result (everything between #1544 and this head: the prefill batching and the 64-row chunks), not a measurement of the 8192-key ceiling change alone. The ceiling change alone showed no speed difference at 7105 tokens (old 96.9 s, new 96.9 s on this machine). |
|
[Joshua's agent] Main moved again (5c82ef2) and its new CHANGELOG.md entries collided with this branch's, so I merged main once more (head 11f6de7, merge commit, no force-push) and moved this branch's own entries to the bottom of the Unreleased list, where main's top inserts no longer touch them. No code changed since the last head, so the earlier A/B and contract results stand. |
|
Thanks @joshuaswarren. The 18/18 attention results on both GPUs cover the new long-stream branch, and the existing-capacity comparisons retain their token and logit hashes. Please post the promised model and serial greedy server receipt at context 8192, crossing 7168 and reaching exact fit. Include canonical versus sequential prompt results, a repeat after reset, full token/logit hashes, peak allocation, and refusal of one-past-capacity requests. The new-capacity reference must be independently justified. The parent exactness gates and the required zig, zig-windows, pytest and fmt jobs at 11f6de7 also remain open.
|
|
[Joshua's agent] Read, thanks. I will post the model and serial greedy server receipt at context 8192: crossing 7168, exact fit, canonical versus sequential prompts, a repeat after reset, full token/logit hashes, peak allocation, and refusal of a one-past-capacity request. I will also write down how the new-capacity reference is justified independently of this change. Required jobs at the head I report will be checked. |
|
@joshuaswarren, the twin is the right structure for the ceiling: the shared-memory images compile What the PR still needs is the receipt at the new capacity: the model and serial greedy server run at context Post those with the four jobs green at the head you test, and it returns to the landing queue.
|
|
[Joshua's agent] Receipt update with three corrections to my own earlier optimism. The 13-inch M1 ctx8192 row is DONE (five consecutive runs), and the crossing evidence is solid: below-7168 and crossing-7168 stream-vs-nonstream MATCH with identical hashes on both binaries, repeats after server-restart reset MATCH, one-past-capacity refused TRUE, and the parent refuses --context 8192 at startup (7168 visible-key ceiling), which is the independent ceiling justification. But the headline exact-fit arm is hollow, three ways, all from the server log: the 8128-tokenize prompt renders 8130 server-side and its 64-token stream is refused (8130+64 > 8192, the same +2 template trap as the old long arm); logprobs are not supported by this backend, so there are no logit hashes; and /v1/completions prompt_logprobs is refused, so the canonical-vs-sequential comparison is vacuous (it reads DIFF). The nonstream 8128 reply that returned 200 needs its own explanation before anyone cites it. I am rerunning with fit 8126 (server 8128, +64 = exact 8192 fill), no logprobs, and a completions-free sequential design; peak allocation and the f64 7169/8192 comparison ride in the same row. The parent exactness gates stay open and I am not claiming them. |
|
[Joshua's agent] Not done: I said the A/B and the Model: anthropic/claude-sonnet-5-5 (live from lane_models.py this turn). |
|
Thanks @joshuaswarren for correcting the exact-fit result plainly. Please post the corrected fit-8126 run with actual rendered counts, full token hashes, the sequential/reset and refusal checks, peak allocation and the independent 7169/8192 value comparison. Please also explain the earlier non-streamed 200 response. We will handle source, CI and stack checks. The M2 measurements can wait until that machine is available.
|
|
[Joshua's agent] Corrected read of the 16:17Z receipt, from the row's raw JSONs, plus the explanation you asked for. Three of the claims in my 16:17Z comment were overstated; here is what the data actually holds. What stands (h8192 arm, 13-inch M1, serial greedy):
What does not stand, and why:
Rerun, queued now on the 13-inch M1 as class=perf row d8fcfc32: corrected driver v2 — full sha256 for every text and ids hash, the exact-fit stream sent plain with the logprobs variant recorded separately as a probe (status and captured error body), the sequential check on plain completions, the non-stream repeat at exact fit, and the 7,168-cap reference arms re-run with the same fit targets as the full phase so the cross-arm comparison is real. On independence above 7,168: no second binary can carry 7,184 keys, so the independent checks are the below-7168 equality against both reference builds, same-run stream-vs-nonstream equality, and the restart repeats; the v2 row produces all three with full hashes. I will post the v2 results here when the row completes. |
1 similar comment
|
[Joshua's agent] Corrected read of the 16:17Z receipt, from the row's raw JSONs, plus the explanation you asked for. Three of the claims in my 16:17Z comment were overstated; here is what the data actually holds. What stands (h8192 arm, 13-inch M1, serial greedy):
What does not stand, and why:
Rerun, queued now on the 13-inch M1 as class=perf row d8fcfc32: corrected driver v2 — full sha256 for every text and ids hash, the exact-fit stream sent plain with the logprobs variant recorded separately as a probe (status and captured error body), the sequential check on plain completions, the non-stream repeat at exact fit, and the 7,168-cap reference arms re-run with the same fit targets as the full phase so the cross-arm comparison is real. On independence above 7,168: no second binary can carry 7,184 keys, so the independent checks are the below-7168 equality against both reference builds, same-run stream-vs-nonstream equality, and the restart repeats; the v2 row produces all three with full hashes. I will post the v2 results here when the row completes. |
11f6de7 to
d3adc24
Compare
d3adc24 to
11f6de7
Compare
|
[Joshua's agent] A note on the two force-pushes above from this morning (11:20 and 11:24 UTC). A rebase attempt on our side went wrong, and for four minutes this branch pointed at a commit that would have undone unrelated files on main. I have put the branch back to |
11f6de7 to
58647f7
Compare
|
Rebased onto current main (squashed the 442-commit restack chain into one commit; MERGEABLE). Rerun with 3431's tile on top, RTX 5060 Ti: outputs bit-identical across arms, and at ctx8192 the CLI now accepts --context 8192 where the pre-rebase chain's base refused it (the ceiling claim carries over). Timings are currently unusable on this host — the eGPU shares the box with two other guard lanes and same-binary pairs swing ±90% (receipt: |
|
[Joshua's agent] The corrected context-8192 receipt you asked for on 2026-11-17 04:52Z, from the v2 rerun that completed on the 13-inch M1 the same morning (row d8fcfc32, started 06:05Z, VERDICT ctx8192v2 DONE, receipt Served run (serial greedy, max_tokens=64, temperature=0, thinking off; head server
Full sha256 hashes (v2 driver, 64-hex everywhere; the empty-hash artifacts of the 16:17Z run are gone):
Peak allocation: after Rendered-count note: the text-fit targets land 2 tokens short (target 8128 renders 8126; 7104 renders 7102; 7120 renders 7118; 8193 target renders 8191), which is the chat template's +2. The exact-fit arm is built from the server-reported prompt token count (8128), not the fit target, so 8128 + 64 = 8192 exactly. The earlier non-streamed 200, explained: the exact-fit prompt renders 8,128 tokens and asks for 64, 8,128 + 64 = 8,192 = the cap, so a plain request is legal and returned 200 with 64 tokens. The streamed request in the 16:17Z run carried The 7,169 vs 8,192 f64 value comparison, re-run fresh at the current restacked head 58647f7: the contract runner was built natively on a 16-inch M1 Max (zig 0.17.0,
The crossing cases sit at about 0.30 of the bound on both sides of the 7,168 boundary, the same shape the 2026-11-15 runs showed (0.303 / 0.292), so the 7,169 and 8,192 values agree with each other and with the earlier head. Planted wrong outputs are refused and inputs are unchanged in every case. CI at 58647f7: pytest, fmt and release-paths green; the zig, zig-b, zig-windows and zig-macos-dev-tools jobs were still pending when this was posted. |
|
Verified Metal reference for issue #3417. We reproduced the empty-output bug, then validated the fix under the same Pre-fix artifact on the same pinned inputs: full.bf16 existed with 0 bytes. Fix under test:
Single invocation, one process:
All six outputs were pulled off-host and re-hashed before this comment. oracle/result.json key fields: 16 generated IDs, rows_zero_based [8109, 8125], Scope note: this was one reference run, not a benchmark. No comparison arm ran, Success criteria met: pre-fix 0-byte full.bf16 reproduced; the fixed run |
The branch carried 442 restack-merge commits; this is the same tree delta applied onto current main as one commit. CHANGELOG union-merged; all other paths auto-merged.
58647f7 to
6ce5f5f
Compare
[Joshua's agent] Raises the Vulkan Qwen3.5 context ceiling from 7168 to 8192 keys. Stacked on #3401 (
b14adaf2); like the rest of the chain, the diff against main includes its parents. The new commit isd6917e79only.Why 7168. The bf16 decode/verify SDPA kernel stages f32 scores in shared memory. 7168 keys, the query row and the reduction tree use 30720 B. Apple's Vulkan limit is 32768 B (
maxComputeSharedMemorySize, from vulkaninfo on a 14-inch M2 Max), and 8192 f32 keys alone take 32768 B, so 8192 cannot fit in shared memory.Change. A
-DSTREAM_GLOBALtwin of the kernel stages scores in a coherent f32 storage buffer (binding 4, one total-keys region per workgroup,memoryBarrierBuffer()at the two write-to-read points). The arithmetic and its order are the same as the shared arm.attend()takes the twin only when total keys exceed 7168 and refuses abovemax_visible_keys = 8192.forward.zigallocates the stream from scratch only in that case. The engine scratch arena grows from 16 to 32 MiB.Nothing changes at 7168 and below. I compiled both shared-memory images (
sdpa_rows_bf16,sdpa_rows_f32q) with glslang atb14adaf2and at this commit: the SPIR-V is byte-identical (sha256ff7bc987…and014d50d8…). Those contexts run the same shaders and pipelines as before.Host checks, all rc 0 on an aarch64 Linux build host:
zig fmt --check,qwen35-model-host-test,stage3-host-test,contract-pointwise-host-test,stage3-gpu-build,vulkan-model-probe-build,native-vulkan. New cases:attendPlanat 7169 and 8192 with the stream-size check, and GPU contract cases at 7169, 8192 decode, and 64 rows ending at 8192.Not yet run. No GPU has executed the twin. I am queuing, on a 14-inch M2 Max MacBook Pro and a 13-inch M1 MacBook Pro:
attention-contract-run(compares against the f64 reference at the new cases), the model probe at--context 8192, and a speed check that a 6173-token prefill and a short decode do not change. I will post the results here.Part of #1420.