Repository navigation
CPU: Qwen3.5-2B served on the host's cores (zig build native-cpu), every operation in the kernel contract, judged against a float64 reference - #2551
Conversation
249df78 to
982e923
Compare
|
@Whq02 thanks, this follows what #2448 agreed closely, and moving the three settings onto the parser was the right call. On scope: we'd like to take this as a separate, opt-in
|
|
Thanks @Whq02. We've done five of the six asks on your branch, rebased onto today's main, as five commits on top of yours with you as co-author. Your commits are unchanged apart from the rebase, which conflicted in
Checks on the branch head, on an arm64 Mac:
One thing is still yours: (3) the float64 reference. We couldn't find
|
|
(3) is on the branch as one commit on 982e923, e28ebec: Whose it is: it was written for this PR after joshuaswarren's oracle from #1544 (the gist behind "both scripts" in its first comment, which states no licence). It follows that script's operations and their order so that the two agree to the bit: the same On that tip: Your five commits are not on |
|
@Whq02, a correction to our earlier note: it described a rebase and five commits of ours as already on your branch, but that push never happened, sorry. Since then you've added (3) yourself on
|
|
Yours, please: push (1), (2) and (4) on top, rebased as you need; the co-author credit is fine. If that push does not also carry (5) and (6) from your first note (the "through fp32" wording in |
…he CPU engine's build hook, and main's two environment rows beside the CPU engine's
|
@Whq02, pushed: your branch now ends at
You're co-author on each of our five commits. Checks on the new head, on an arm64 Mac: Left for you, as you said: the description's head line and its "rounded once" wording.
|
|
Thanks. Read on The description is updated: the head line reads Nothing more from this side unless CI on this head shows something: the pinned digest's first run on Linux and Windows is the one to watch, and if it differs across hosts I'd rather read the three digests than loosen the test. |
|
Thanks @Whq02. CI on Two things before it lands, both on our side:
If that run is level, we'll land it with your credit. On where the float64 reference comes from: writing it fresh for this PR, following the #1544 oracle's operations in the same order, and crediting it in the commit and description is fine by us. @joshuaswarren, your oracle is credited here; say if you'd like anything changed.
|
|
On exact head I sent the same 26-token and 180-token greedy prompts with The trial merge into main Igor Lessio - AIFLOW LABS |
968d0de to
dde63ec
Compare
|
I rechecked #4296's build-step overlap at zig build native-cpu test-cpu test-chunked-write -Dcpu=apple_m1 -j4 --summary all
zig build cpu-contract -Dcpu=apple_m1 -j4 --summary allOn M5 Max with Zig 0.17.0, the CPU server built and all 48 host tests passed. The CPU contract passed all 15 kernels and caught all 36 planted controls. This is the current-head CPU build and contract check. The full-checkpoint serving receipt is separate. Igor Lessio - AIFLOW LABS |
…u, the portable shape: the registered projection and norm, fp32 sums in the attention and the delta rule, every other row in float64 rounded once to bf16, the same bytes on x86_64 and arm64 at every thread count; tf-qwen35-cpu-forward and tools/zig/cpu_fidelity.py judge its teacher-forced logits against a float64 reference, every top-token difference with both margins
…act beside the projection and the norm (the embedding, residual add, MLP activation, attention gate and rotary; the head norms; the attention with its bound carried through the softmax; the delta rule's inputs, decay and recurrence with its bound carried through the state), 15 kernels through gates 1 to 4 with 36 planted controls, no device
…rule asks (the fidelity tool's usage in its parsers' help)
…tep, a 16-row verify window, the 32-row verify batch, a 128-row prompt chunk; the per-segment delta rule at the first three), the attention's prompt-chunk rows in place of a batch it never runs, and the engine's remaining line comments as doc lines or gone
…ep's, a window's and a chunk's
… on 1 to 8 threads and asks for the same committed states and logits byte for byte
…g (TF_QWEN35_CPU_THREADS a whole count from 1, TF_QWEN35_CPU_WINDOWS and TF_QWEN35_CPU_TRACE 0 or 1), registered in the table, the test and docs/environment.md, so a malformed value is refused at startup with its accepted form
…ne's fidelity is judged against, in the tree: the whole Qwen3.5-2B forward in float64 over the exactly dequantized 4-bit weights (numpy only, one thread), --run-input writing OUT/CASE/logits_f64.npy one row a teacher token for cpu_fidelity.py compare; the same math as the oracle ashhart#1544's packet froze (joshuaswarren's gist, its placeholder pins, legacy runner and diagnostics left out), bit-identical to it on a 15-row and a 301-row case (the latter 302 tokens) here; the recipe names the three steps of the comparison
…ere the CPU engine is built TF_QWEN35_CPU_THREADS takes 1 to 255, the trace switch is read once at open, PROCESSOR_IDENTIFIER goes through sys.getenv, and TF_QWEN35_CPU_WINDOWS has a profile row for the CPU backend. Co-authored-by: Whq02 <178854749+Whq02@users.noreply.github.com>
Co-authored-by: Whq02 <178854749+Whq02@users.noreply.github.com>
Co-authored-by: Whq02 <178854749+Whq02@users.noreply.github.com>
The recipe and the CHANGELOG line say the float64 rows round through fp32 and that equal bytes across hosts are checked by that digest, not built in. Co-authored-by: Whq02 <178854749+Whq02@users.noreply.github.com>
… macOS Co-authored-by: Whq02 <178854749+Whq02@users.noreply.github.com>
…le, after main's 5725d22 ashhart#2551 makes prefill.run take the backend's saved-state module (Metal's snapshot.zig, the CPU's cpu_state.zig). Main's 5725d22 split run into open and step for Metal's stepped prompts, so open now takes the module too, and main's own callers pass snapshot.zig: Metal's prefillStepFn, the stepped-prefill tests and the cache test's second run (5b92873). The CPU backend's call is ashhart#2551's own.
dde63ec to
538397e
Compare
|
Thanks @Whq02. We've read the current head, and there's nothing left for you on the code. Every point from our last reviews is in place:
The CHANGELOG entry has been taken out of the PR; we'll add the line when we land it, so there's nothing to do there either. What remains is on our side: the short Metal check we mentioned.
If that's level, we'll land it with your credit. Thanks also to everyone who ran independent checks on the CPU build.
|
|
One correction to the note above: the Qwen3.5-2B and 9B checkpoints aren't on our test Macs yet, so that Metal comparison has to wait until we have them there. We'll post the result here when it's run. If you or anyone following can run it sooner on an Apple-silicon Mac, a token-for-token comparison against main with a resumed turn would settle it.
|
|
Ran it here, on an Apple M5 Pro (48 GiB, macOS 27.0 build 26A425) with Zig 0.17.0. Qwen3.5-2B and the 9B return the same reply tokens and usage with and without this change on every turn, the resumed ones included, and prompt time is level within the run-to-run spread. Binaries, each from
One limit of these builds: this Mac has the Command Line Tools and no Xcode Metal toolchain, so Checkpoints: Serve, a new server for every run and one engine at a time: tensorfold-native serve MODEL --name qwen35 --host 127.0.0.1 --port 18651 --parallel 1 --context 8192 \
--prompt-cache-gib 1 --no-thinking --no-update-checkRequests: chat, Result. The reply's token ids and the usage counts are identical in every run of all four binaries. The times are each reply's
Beside the runs:
What this claims: on this one M5 Pro, a three-turn greedy chat of 64-token replies at one stream returns the same tokens and usage before and after the change, resumed or cold, at level prompt time; it does not claim a sweep, sampled or concurrent replies, a drafter, M1 to M4, an idle machine, or a binary built with the offline Metal compiler. The client:
|
|
Thanks @Whq02. The pinned Metal runs answer the remaining 2B resume check, and the changed shared files match the integration you measured. Your explanation of the 9B control, and of the Metal build that could not finish, is useful. Under the current exactness rule, the CPU fidelity result still needs a strict comparison: ten top-token IDs that differ cannot count as matches just because their margins are small. Please keep the accuracy report separate, make the exact comparison reject every unequal ID, and include the result against the checkpoint’s identified serial reference. We will handle the environment-flags integration and test-file split on main.
|
What this changes
Before: the tree registers a CPU affine projection and RMS norm in the kernel contract (#2478) and no engine calls them;
Qwen3.5-2B serves on Metal, CUDA and HIP. After:
zig build native-cpubuildstensorfold-nativewith a CPU engine(
zig-out/native-cpu/bin,"backends": ["cpu"]) that servesmlx-community/Qwen3.5-2B-MLX-4biton the host's cores,x86_64 or arm64, with no GPU and no kernel library, through the same lane core, prompt cache and sampler the GPU
engines use (
zig/src/native/cpu.zig,qwen35_cpu.zig,cpu_admit.zig; the family underzig/src/families/qwen3_5/cpu_*.zig). It builds for any OS; it ran here on an arm64 Mac and, for its bytes, on x86_64Linux under emulation (Windows is the third pull request). Default builds are unchanged: the step is opt-in, and the
edits to existing files are the build hook (one line),
prefill.zigtaking the backend's saved-state module as aparameter (the Metal backend and its cache test pass their own, so the Metal engine's prompt reuse runs unchanged over
the CPU's),
--backendacceptingcpuwhere the binary serves it (cli.zig, as the HIP build'srocm), thecontract's listing and the two docs; nothing on the Metal, CUDA, HIP, XPU or Vulkan paths changes behaviour.
The arithmetic is the portable shape the issue agreed to judge against a float64 reference, not against Metal's bits:
the registered projection and RMS norm as #2478 left them (the residual add is its own row before the norm); fp32 sums
with fixed orders in the attention (chunks of 128 keys, four interleaved splits, merged by the running max) and in the
delta rule's recurrence (one fp32 state a head, 32 lanes of four fused terms then a tree); and every other row (the
embedding, residual add, MLP activation, attention gate, rotary, the q/k head norm, the delta rule's inputs, decay and
gated output norm) computed in float64 and rounded to bf16 through fp32. No measured table, no denormal flush (the float64
reference flushes none), no Metal probe. The same bytes come back at 1 to 8 threads (the engine's exactness test runs a prompt and a decode step on each
count; the fidelity tool at 1, 2, 4 and 8), at 1, 16 and 32 rows a pass (a decode step, a verify window, a prompt
batch); on x86_64 (
-mcpu=x86_64_v3andbaseline, under emulation) the list case's 155 rows were the same bytes ason arm64 — the float64 functions come from each host's libm, so that equality is observed, not by construction. Every operation the forward runs is registered in the contract beside the projection and norm: 15 kernels
through gates 1 to 4 with 36 planted controls (
zig build cpu-contract;test-kernel-contractruns them as a test),host-only, no gate 5.
Fidelity, frozen before the run:
tools/zig/cpu_fidelity.py freezewrote the prompt set and its sha256 first; theVulkan precedent's float64 oracle (
qwen35_cpu_long_ref.py --run-input, #1544's comment, full float64 over the exactlydequantized weights) computed the reference logits (
tools/zig/qwen35_cpu_long_ref.pyon this branch is that forward,written for this PR after joshuaswarren's script and bit-identical to it on a 15-row and a 301-row case and on the three
cases' reference digests, so the comparison can be rerun); then
tf-qwen35-cpu-forward(zig build qwen35-cpu-forward)computed the engine's teacher-forced bf16 logits on the same histories and
cpu_fidelity.py comparelisted everytop-token difference with both sides' top two and margins. 591 rows over five cases (three raw continuations and two
recorded greedy chat replies, one behind a 2138-token prompt): 581 top tokens agree, 10 differ, every one the same two
contenders on both sides with both margins within one bf16 spacing of the top score (the tree's one-step tie policy,
tools/zig/qwen27_margins.py), 0 differences beyond it; the list with margins is below. The drafted, concurrent andresumed checks run against its serve as against any other (
zig/tests/qwen35/serve_check.py: 15 of 15 ok, with asecond serve at
--prompt-cache-gib 0for the fresh side; and a resumed turn that restored 3,328 cached tokens gave thefresh serve's 29 token ids). This is the second of the three pull requests agreed on #2448; Windows remains.
maintainers for the review's asks (the settings in their own scope with
TF_QWEN35_CPU_THREADS1 to 255, the--backend cpumessage on a GPU build, "through fp32", a pinned digest of a synthetic forward, CI on three systems).atc overlap --json: run 2026-11-08T00:21Z on 0a0d602eb (this head less its last two commits, two doc lines and atest; the same 31 files) against
origin/mainat 3ace0f6 (ATC 0.9.0;complete: false,pullFilesLimit):changedFiles31, 69 open pull requests share a file, 10clean, 59unknown, 0conflicts.git merge-treeof those 69 heads against this head and against main alone: 61 the same both ways (10clean, 51 conflict with main alone already), and eight conflicts this branch causes:
cli.zigagainst theseven Vulkan pull requests (Native Vulkan backend for Qwen3.5-2B (opt-in): engine and kernel-contract registration (stacked on #1526) #1544, Implement GLP control vectors with a fused Metal kernel for Qwen3.8-27B #1835, Vulkan: qmm_q4_vec4 reads the 4-bit projection 16 bytes at a time, 34.8% to 43.0% less run time on an M1 with the same logits (stacked on #1544) #1990, Vulkan: qmm_q4_tile reads the 4-bit projection from 32-column tiles, 29% to 67% less run time on an M1 with the same logits (stacked on #1990) #2015, Vulkan: one submission per batch of dispatches, 30% to 56% less run time on an M1 with the same logits (stacked on #2015) #2016, Vulkan: qmm_q4_tile_rows computes four rows and two columns of a prompt chunk per thread, 3.6% to 33% less run time on an M1 with the same logits (stacked on #2016) #2017, Vulkan: a dispatch records a barrier only when it conflicts with an earlier one, 2% to 20% less run time on an M1 and an M1 Max with the same logits (stacked on #2017) #2038), which add
vulkanto the two--backendlines this one addscputo (resolved by keeping both values), andbuild.zigagainst Tests: pins for the documented limits, defaults and flag dependencies, a replay of the prompt cache's eviction, and a timing of its index #2305, which addsits build step on the line after
mcdma_pair.add, where the CPU hook sits (one line each side; Tests: pins for the documented limits, defaults and flag dependencies, a replay of the prompt cache's eviction, and a timing of its index #2305 conflicts withmain already in
CHANGELOG.md). Nothing shares the 20 new files.Checks on this head
reference script's on e28ebec). Since then the engine's arithmetic has not moved:
cpu_ops.zigchanged in commentsand one test's name, and the trace switch is read once at open (
cpu_backend.zig,qwen35_cpu.zig); the rest is thesettings' scope, a CLI message, docs, one test and CI. The maintainers' checks on this head are in their comment of
12 Nov 16:56Z, and this head's CI is the pinned digest's first run on Linux and Windows.
python3 tools/zig/lean_check.py, on the base and on this head:python3 tools/pr_check.py --base origin/mainon this head: merge base 3ace0f6, 31 changed files, lean 116 on the base and 116 on this head, 0 new;0 errors, 1 advisory warning (no
--pruntil this number exists). Every Zig comment is a//!or///line, oneline each; the longest new file is 353 lines.
checkpoint at revision 93760be4f1f69842a46bc13dbdc0f19e291392a3):
zig build cpu-contract --summary all:SUMMARY 15 kernels: 15 pass gates 1-4, 0 fail, 0 known findings; 36 controls: 36 red as planted, 0 missed; 0 limit problems (no launch to check); gates 102406 ms, exit 0 (the gates'time is the float64 references and gate 4's replay, the projection's head shapes the largest part); the 15
kernels' gate lines are below.
zig build test-cpu-contract-host --summary all: 5/5 steps; the contract's 10 tests passed (the gates as a test,the rig's guards, the seven fixtures' gate bindings and served shapes), 0 failed, 0 skipped, and the kernels' 3.
zig build test-cpu --summary all(the engine's own tests, undertest): 5/5 steps; 43/43 tests passed (37 inthe family, 6 in the engine), 0 failed, 0 skipped: the rows, mixers and model against float64, the pool, a
snapshot's round trip, the synthetic-weight exactness checks (16-row windows over two streams, kept prefixes and
chunk cuts of 1, 7 and 128 equal to one-row steps bit for bit; the same prompt and decode step at 1 to 8 threads,
the same committed states and logits), the admission and refusals.
zig build test-cpu-kernels --summary all: 3/3 steps, the pass reused from the byte-identical binary (CPU: Qwen3.5-2B's affine projection and RMS norm on the host's cores, registered in the kernel contract (gates 1 to 4, host-only) #2478'stests, unchanged).
zig build test-kernel-contract --summary all, from an empty local cache:Build Summary: 30/30 steps succeeded; 233/233 tests passed(the existing host contract tests, plustest-cpu-contract-host).zig build test-golden --summary all: 5/5 steps; 322/335 and 55/55 equal to the server goldens, 0 unexpecteddifferences (the 13 are its recorded known differences).
zig build test --summary all, whole, on this Mac (on 0a0d602eb, this head less two doc lines and the thread test, whichtest-cpuran on this head):648/763 steps succeeded (62 failed); 9933/10003 tests passed (70 skipped), no test failed,test-cpu success; the 62failed steps are all
xcrun -sdk macosx metalshader compiles of the Metal kernels (xcrun: error: unable to find utility "metal": this Mac's developer tools carry no Metal compiler), none a test and none a file this changetouches; CI runs
teston ubuntu-latest and windows-latest (no-gpu.yml).zig fmt --check build.zig zigandgit diff --check origin/main..HEAD: clean.fidelity/in the receipt): the prompt set frozen with sha256 at 23:03Z and the two recorded cases at23:07Z, the reference computed next (8 to 112 s a case), the engine's logits after;
cpu_fidelity.py comparepercase: prose 113/118 top tokens agree (5 near-ties), code 128/128, list 87/89 (2), record-chat 126/128 (2),
record-doc 127/128 (1); 0 other differences; the worst logit anywhere is 0.4681 from float64 (record-doc row 115,
vocabulary entry 65757, 9.5 against 9.032: about seven and a half (7.49) bf16 spacings of 0.0625 at that magnitude,
on a token far from the top).
above covers every count from 1 to 8) and at 1, 16 and 32 rows a pass (one sha256,
9ac12bf94df5…); the tool cross-compiled forx86_64-linux-muslat-mcpu=x86_64_v3and
-mcpu=baselineand run in an x86_64 Linux container under emulation on the same Mac gives the same bytes.zig build native-cpu's serve (--parallel 4 --prompt-cache-gib 1 --no-thinking,TF_QWEN35_CPU_WINDOWS=1) with a second instance at--prompt-cache-gib 0:python3 zig/tests/qwen35/serve_check.py URL qwen3.5-2b 64 FRESH_URL: 15 ok, 0 failed (drafted == serial, solo ==together, serial together == serial solo, the same twice, decoders unchanged by a long prompt, the long prompt
among decoders == alone, at greedy and t0.8; resumed == fresh); the resumed check whose first turn passes the
128-token prompt grid (3,413 tokens; the second turn restored 3,328) gave the fresh serve's 29 token ids.
rsqrtplanted as fp321 / sqrt(x)incpu_kernels.zig, the comparison lists rows thepacket's list does not, two of them beyond the tie policy (list row 65, reference margin 0.0772 at a top of 14.78;
record-doc row 37, 0.1406 at 23.19), and every case's bytes change; each of the 36 controls is red in the
SUMMARYrun; the engine's exactness test fails if a window and its one-row replay differ (the synthetic weightsmake a changed reduction visible in the committed state's bytes).
zigjob gains the engine's tests undertest(about 20 s of compile and3 s of run on this Mac) and the contract's 11 more registrations under
test-kernel-contract(the gates run abouttwo minutes here, the projection's head shapes the largest part, as in CPU: Qwen3.5-2B's affine projection and RMS norm on the host's cores, registered in the kernel contract (gates 1 to 4, host-only) #2478).
ubuntu-latestruns themonce this is open; the engine's bytes ran on x86_64 under emulation only); Windows (the third pull request; nothing
here is OS-specific beyond
cpu_admit.zig's memory readings, one a platform behind itsos.tag); the Metalshader compiles inside
zig build test(no Metal compiler on this Mac); Metal, CUDA, HIP, XPU and Vulkan: no GPUkernel or engine changes.
Receipt
the engine's own numbers are below.
native-cpu; measured on one arm64 Mac (15 logical CPUs, 48 GiB) and, for thebytes only, an x86_64 Linux container under emulation on it.
TF_QWEN35_CPU_THREADS=N, worker threads beside the enginethread (default: the logical CPUs less one);
TF_QWEN35_CPU_WINDOWS=1, verify windows of up to 16 rows (copy drafts)after the engine's local exactness check against one-row steps passes at load (default off: one-row rounds). Both
change speed only: the bytes are the same at 1 to 8 threads and at every window width (above);
TF_QWEN35_CPU_TRACE=1,each one-token draw's top two logits and their margin on stderr (default off). No profile row: the CPU
engine registers no profile switch.
7269f56, head 938c103; Zig 0.17.0, no backend toolchain (no device); an arm64 Mac, 15 logical CPUs, 48 GiB, no
GPU used;
mlx-community/Qwen3.5-2B-MLX-4bitat 93760be4f1f69842a46bc13dbdc0f19e291392a3.rows), decode steps and 16-row verify windows, ran on arm64; its bytes on x86_64 under emulation; the Metal, CUDA,
HIP, XPU and Vulkan paths are untouched; Windows not run here.
tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:python3 tools/bench_concurrent.py http://127.0.0.1:18612 qwen3.5-2b --tokens 128 --reps 2 --temperatures 0 --levels 1,4 --alone --serial: every cellfailed 0;aloneequal 2/2 at one stream and 8/8 at four for both prompts(each concurrent reply token-equal to its solo run),
serialequal 1/1 in every cell (the drafted solo run equal to"draft": false); 29.9 and 30.9 tokens/s at one stream, 8.4 and 8.5 a stream (33.0 and 32.8 aggregate) at four, onthe 6-thread serve (
bench/concurrent.json).zig/tests/qwen35/serve_check.pyas above: 15 of 15.can't): n/a, no engine on main; the fidelity rows above are the independent reference.
tools/bench_openai.py: n/a before (no engine on main); after,python3 tools/bench_openai.py http://127.0.0.1:18612 qwen3.5-2b --tokens 128 --reps 2 --temperatures 1.0,0 --label cpuon the 6-thread serve: 31.8 and 32.0 tokens/s at temperature 1.0, 35.0 and33.7 at 0, on the two public prompts; ttft 0.20 to 0.35 s (
bench/decode.json).ttft_sfromtools/bench_cache.py --require-coldon a longprompt, or "n/a" with the reason when the change cannot reach prompt processing: n/a before; after,
python3 tools/bench_cache.py http://127.0.0.1:18613 qwen3.5-2b --tokens 32 --repeats 2 --streams 2 --prompt-file <the 2138-token record-doc prompt> --require-coldon the fresh serve (--prompt-cache-gib 0, 2 threads): the cold first request'sttft_s55.6 s (38 prompt tokens/s at 2 threads),qualified: true, therepeated and concurrent replies token-equal to the first (
bench/cache-fresh.json); the 8-thread forward toolprocesses the same 2,265 rows in 26.8 s, and the 6-thread serve recorded the same prompt and a 128-token reply in
29.7 s.
Kernel contract, only when a GPU kernel is new or changed
These are CPU kernels, registered as the issue agreed (gates 1 to 4, host-only, no gate 5); the section is filled for
them.
Kernels registered with the contract, and the kernel each one replaces: eleven new registrations beside CPU: Qwen3.5-2B's affine projection and RMS norm on the host's cores, registered in the kernel contract (gates 1 to 4, host-only) #2478's
four, none replacing a kernel, each at the engine's rows (a decode step, a 16-row verify window, the 32-row verify
batch over the streams, a 128-row prompt chunk; the per-segment delta rule at a decode step, a window and a chunk):
cpu embedding q4 g64(2048 outputs a token from a packed table),cpu residual add,cpu MLP activation(6144 wide),cpu attention gate,cpu rotary(one head of 256 a row at positions from 4096) — one float64 expression an output,rounded through fp32, no sums;
cpu head norm(the q/k RMS norm over 256, ten head rows a token) andcpu delta output norm(16 heads of 128, times silu(z)) on therowsfamily's RMS reference;cpu attention(one query row'ssoftmax over up to 4096 keys of one kv head, with the chunk edge at 1, 127, 128 and 129 keys; its bound carries the
fp32 dots' error through the softmax to the weights, then the sums);
cpu delta inputs(the four-tap conv, SiLU,the q/k L2 norms, v and beta: 6160 outputs a token),
cpu delta decay(fp32, 16 a token) andcpu delta recurrence(one head's fp32 state over the window's tokens, 128 outputs a token; its bound is carried through thestate token by token).
A planted control for each new kernel, and each one fails as planted: 28, one to four a kernel, each a fault of the
kernel's own structure: every kernel taking a non-finite input as zero (gate 1); the residual add, attention,
recurrence and delta inputs writing an input (gate 2); the embedding reading the next group's scale and bias, the
residual add adding half the residual, the activation taking the next up value, the attention gate reading the query
half, the rotary at the next position, the head norm's weight and the output norm's z shifted by one, the attention
leaving out the row's own key, the recurrence skipping the decay, the conv taps in reverse, a's sign flipped in the
decay (gate 3); the attention summing its weights and values in half precision, the recurrence its dots (gate 4).
All 28 red as planted, with CPU: Qwen3.5-2B's affine projection and RMS norm on the host's cores, registered in the kernel contract (gates 1 to 4, host-only) #2478's eight: 36 of 36.
Each backend's
SUMMARYline and exit status: CPU (arm64, 15 logical CPUs), exit 0:The worst-of-bound figures near 1 are the outputs' own bf16 rounding, which the bound allows exactly. Gate 4's
declared margins: the attention and the recurrence declare
f16 = 0, bf16 = 0with their reasons (the softmaxweights' sums are not integer-exact, and a pairwise fp16 sum of them stays within a few bf16 ulps; the recurrence's
stress state stays dyadic, so fp32 sums are exact in every order), as the RMS norm did in CPU: Qwen3.5-2B's affine projection and RMS norm on the host's cores, registered in the kernel contract (gates 1 to 4, host-only) #2478; the measured margins
are in the lines. The head and output norms sum their squares in float64, inside the fp32 bound by construction.
Chips I could not run: n/a (no GPU); not run on an x86_64 processor itself.
Near-ties with margins
Every top-token difference between the engine's teacher-forced logits and the float64 reference over the 591 rows
(
positionis the absolute row of the history,rowthe teacher row). Each is the same two contenders on both sideswith both margins within one bf16 spacing of the top score (0.0625 in [8, 16), 0.125 in [16, 32)): the tree's one-step
tie policy (
tools/zig/qwen27_margins.py). At 9 of the 10 the engine's two contenders carry the same bf16 logit(margin 0.0000); its greedy draw, like numpy's argmax, takes the lower id at an exact tie. No other difference.
The worst logit anywhere is 0.4681 from float64 (record-doc row 115, vocabulary entry 65757, 9.5 against 9.032, far
from that row's top): the bf16 residual stream and the bf16 output of every operation over 24 layers, not a rounding
fault.
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. (Red: the planted
rsqrtfault above, the 28 new controls, the exactness tests' window-against-one-row and thread-countcomparisons; the engine's
tests need no checkpoint; the fidelity tools take the checkpoint and the oracle as arguments.)
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. If the bits change, the description says which sums change and why. (New engine:
the sums and roundings are stated above; nothing on another backend changes.)
Decode and prompt processing are no slower than main at one stream and the widest admitted; with
--drafter, noslower than without it, greedy and sampled. (No main to compare with: the engine is new and serves no
--drafter;its own speeds are in the receipt.)