Repository navigation
Metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) - #4435
Conversation
|
#4433 opened four minutes before this one with the same clamp. I searched for an existing report before starting and it was not up yet, so this is a duplicate by accident, not a competing fix. What this one adds over #4433:
I am glad to close this in favour of #4433 and offer the test there, or to keep this one. Whichever you prefer. |
|
I independently reproduced the oversized read on an M5 Max (macOS 27.2, Zig 0.17.0). I extracted
A trial merge into Rebase recheck. The new head Igor Lessio - AIFLOW LABS |
dad62b9 to
f953d4f
Compare
|
Thanks @sethforprivacy. This is the loader fix Inkling 2 Mini's released single-file checkpoint (19.5 GB) needs on every Mac, and @AIFlowML's independent repro matches it. The red checks are from a 21 Nov run while main itself was red (the pytest PyYAML outage, fixed by #4469). We've put it in our landing queue, which re-runs CI on today's main.
|
f953d4f to
e2c46b4
Compare
|
Thank you @sethforprivacy. 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. |
…l. PR #4) (#10) * glm cuda: paired experts pass each rank's own FFN partial under split Under TF_GLM_PREFILL_REDUCE=split (the default), #4510 made the partials exchange send peers' partials only, and glueRows takes the rank's own partial as its own argument. The paired path (#4493, TF_GLM_PAIR_EXPERTS=1) passed 0 there since its rebase onto #4510, so hc_post read an unwritten slot for the rank's own rows. It now passes r.b.part at the rank's first row, as the unpaired path does. The default path (switch off) is unchanged. * changelog: #4619 under Unreleased * perf(hip): DFlash2 holds run only the rows their drafts need A frame now runs min(block, deepest depth + 1) rows a stream, so a hold costs what the lane core's step_ms x drafts price assumes, and step_ms is measured as the marginal cost of a draft past a one-draft hold. The core's existing depth rule then drafts shallower in shared rounds. Tests pin that truncated frames keep acceptance within 0.05 of the full block at depths 1 and 3, that a frame refuses blocks outside 2 to the config's before it takes any scratch, and that the measured draft step falls back to the full block's cost a draft when noise makes it non-finite or below a 0.01 ms floor. (cherry picked from commit 93651916ad44de153464366f2e758e135924ae28) * docs(hip): the 27B recipe's DFlash2 figures on current main The recipe's plain and drafted decode figures on gfx1151 came from the proposal branch's base. They are now the medians of this branch's served runs on main f0a54bdf5 (bench_concurrent, 256 tokens, 3 reps, two fresh servers an arm), with two streams added; four chat streams decode below plain, and the recipe says so. (cherry picked from commit 081a3751ea9218dfa523c38fdcd40b33dc38c5cb) * hip: avoid shadowing the engine import in the facts test (cherry picked from commit 2a62668b076f3dfa1e03f7cb95d1d996b550dab7) * changelog: #3918 under Unreleased * metal loader: a checkpoint span of 16 GiB or more loads (each pread capped at 1 GiB) * changelog: #4435 under Unreleased * changelog: #4435 under Unreleased * pull: a full address table replaces its oldest entry instead of failing the pull #4140 remembers each resolved address with its name's deadline in a fixed 64-entry table and returned TooManyHosts once it was full, which aborted the pull. A long multi-shard pull across rotating CDN addresses can reach that. Now the oldest entry is replaced; an address without an entry already takes a fresh connect deadline (addressDeadline returns null), so only that deadline carry-over is lost for an old address. Found in our release review. * pull: rememberAddress's doc comment on one line (lean) * changelog: #4621 under Unreleased * grammar: isolate fixed JSON budgets and report bounded exploration failures * build: declare grammar-real-tokenizer before grammar.zig's early returns Declared after the no-xgrammar return, it was missing from zig build --help on an ordinary build, and build_options_test.py requires every declared option on every target. * server test: the over-work refusal now reads "exceeded its work limit" grammar_budget.require replaced server.zig's over-work message; the required-tool grammar test still looked for the old wording and failed on Linux and Windows. * changelog: #4615 under Unreleased * pull: a socks or https:// proxy in the environment is skipped with a warning, not a refusal #4140 taught pull http:// proxies, but fromEnv refused the whole pull when HTTPS_PROXY or ALL_PROXY named a socks or https:// proxy, even with NO_PROXY covering the host. 1.3.3 ignored every proxy, so those shells could pull before and could not now. Such a proxy is now skipped by name (never its value) and pull connects directly, as before; http:// proxies and malformed-URL refusals are unchanged. * changelog: pull: a socks or https:// proxy in the environment is skipped with a warning, not a refusal * changelog: #4642's line from lines/4642.txt in place of its own * Release 1.3.4: the version, install examples and changelog * qwen35 cuda: opt-in one batched DFlash2 absorb across a round's streams TF_Q35_DFLASH_ABSORB_BATCH=1 (default off) absorbs a shared round's live kept rows, two or more streams, in one pass: each stream's gather into its own rows, one fc, norm and k/v projection over all of them (one weight read), then each stream's rope at its own positions and its own ring write. Prompt absorbs, a repeated stream or host features keep the per-stream call. No kernel on the path reduces across rows, and verify keeps decode's bits a row; the contract command absorb-batch compares fc, k and v rows batched and alone byte for byte at 1, 4, 8 and 16 streams, with NaN/Inf and a planted control. * changelog: qwen3.5 cuda dflash2: opt-in batched drafter absorb across a round's streams * changelog: #4648's line from lines/4648.txt in place of its own * sessions: the tier runner's waits on their own conditions, untimed The runner shared one condition between submit's signal to the tier thread and wait()'s 5 ms timed waits. When a timed waiter timed out while the thread's broadcast was pending, Condition.deregister kept that signal for the thread without waking it, and the next submit's signal() saw waiters equal to signals and did nothing: the thread slept with a job queued and wait() polled forever. The sessions_writes DeepSeek host test hung this way on CI; serving with the tier thread on could too. The thread now waits alone on `work` (submit signals it, deinit broadcasts), and wait() waits untimed on `finished`, which the thread broadcasts under the mutex after storing each job's state. The write bench's stand-in thread follows. The test's assertions are unchanged. * changelog: sessions: the tier thread's job runner can't lose a wakeup (the DeepSeek sessions test's 20-minute hang) * changelog: sessions: the tier thread's job runner can't lose a wakeup (the DeepSeek sessions test's 20-minute hang) * server tests: a walk-away waits for the engine to hold all n choices The n-choices admission test closed its client once admission counted four places, then expected the engine to have been cancelled. Admission widens before any choice submits, and a choice that sees its client gone while it prepares returns without reaching the engine (chat.zig's gone checks before submit): nothing runs, so nothing is cancelled, and its places are freed. On a loaded host the close could land there, and the cancel count stayed 0. The server's order is right: a submitted choice is cancelled and drained before its choice returns, and the route frees the places after every choice joined. The test now waits, bounded, for the engine to have all four submits before the client walks away, as the single-request test waits for the engine to hold its request; every assertion stays. A filtered step, test-admission-http-host, runs the admission HTTP tests alone. * changelog: tests: the admission stress test waits for its choices to submit before a client walks away * changelog: #4654's line from lines/4654.txt in place of its own * desktop: fix main's two failing app tests (model-revisions, room-worker-effort) * changelog: #4606 under Unreleased * changelog: #4606 under Unreleased * metal row projection: narrow kernel below a per-generation cutover On chips with tensor units, every window of 4 or more rows took the 8-row kernel, which is slower at 4 rows (#3396). Windows now take the wide kernel from a cutover in a table keyed by GPU generation. The table starts at 8 rows for generation 17 and needs confirming on an M5 with tf-row-cutover, which times both kernels at 1 to 32 rows and checks their bytes are equal. Chips before generation 17 keep the narrow kernels. Both kernels compute each row with the same operations in the same order, so output does not change. The two dispatch tests now skip on inert pipeline stand-ins, which have no id. * qwen27 quant host stub: generation() returns u32 like the Metal device row_projection.wideFrom takes the device's u32 generation; the stub returned usize, so test-qwen27-quant-host and the host test build stopped compiling on Linux. * changelog: #4617 under Unreleased * changelog: #4606 under Unreleased * changelog: #4617 under Unreleased * qwen27 metal: opt-in adaptive DFlash2 block for a lone stream TF_Q27_DFLASH_ADAPTIVE_BLOCK=1 (default off) lets a lone stream's drafter block take 8 or 16 rows. It starts at 16, narrows to 8 after 8 consecutive rounds landing at most 4 tree drafts, and returns to 16 after a round landing 6 or more. Shared rounds keep 16. Only the drafter's proposal changes. The target still verifies every row and draws each token as before, so target tokens are unchanged. With the switch off, nothing writes the block. * changelog: #4628 under Unreleased * changelog: each line once under Unreleased * tests: pin the DeepSeek shard's serve-time environment and quiet the drift check's fake golden diff The namespace-pin output seen in DV44 ("expected 8b5aad89..., found 460ace0b...") is the deliberate drift rejection, printed on every run; the build runner also dumps a run step's stderr behind "failed command" even when every test passes, so the decoy read as a real pin failure. - checkNamespacePin keeps its golden diagnostics for real drift, but the negative case now compares the undone hash quietly. - The fixture's render test saves and clears TF_DSV41_SCHEMA_PROMPT, TENSORFOLD_TOOL_GRAMMAR and TF_DSV41_TOOL_GRAMMAR, restoring them on exit; two deepseek_chat goldens that demonstrably flip under an ambient TF_DSV41_SCHEMA_PROMPT=0 pin it the same way. * changelog: tests: DeepSeek-V4.1 chat and fixture tests pin the settings they assume * lanes: restore lone-copy pricing only without a model drafter Keep current main head depth functions and every non-opted path. Only HIP Qwen copies-only facts opt into prefix prices and retained calibration. Restore price, backoff, sampling and scope regressions. Co-authored-by: Abraham <119352736+AbrahamCete@users.noreply.github.com> * changelog: lanes: lone-copy pricing only for families that opt in and serve without a model drafter * changelog: #4661's line from lines/4661.txt in place of its own * lanes: refuse empty copy chances by name * lanes: keep unpriced copy width for zero or non-finite costs * lanes: skip copy pricing when copies are disabled * changelog: lanes: three guards on lone-stream copy pricing * changelog: 1.3.4's section as released (the lone-copy pricing line in, #4648's duplicate out, no 'taken out again' line) * qwen27 metal: opt-in batched DFlash2 absorb across streams A shared round absorbed each stream's new taps in its own pass, so N streams read the absorb weights N times. TF_Q27_DFLASH_ABSORB_BATCH=1 (default off) stacks up to 128 rows from 2 or more streams into one pass. Each row keeps its own position and each stream's keys and values go to its own caches. A larger round, a lone stream and other families sharing this drafter keep the per-stream absorb. Host cells compare the caches byte for byte at 1, 2 and 4 streams with uneven rows and planted NaN and Inf. * glm metal dflash: pass no stacked absorb to the shared absorbBlocks * changelog: #4629 under Unreleased * Agent docs: say what ATC installs and what a public check-in sends AGENTS.md now asks agents to get the human's yes before installing ATC or publishing, defaults agents to --local, and pins the ATC install to a tag. CONTRIBUTING.md lists what a public check-in sends to tensorfold.dev and explains that the comment ID ties an anonymous session to its GitHub account. * Agent docs: list the display field and pin the exchange install A public check-in also sends whether the session shows the GitHub name. docs/atc/exchange.md now pins the ATC install like CONTRIBUTING.md. * ATC skill: keep the local reporting example local In a repository with .github/atc-presence.json, a bare atc start publishes, so the example for reporting on this machine now passes --local. * ATC skill: default to --local like AGENTS.md * ATC skill: working on an issue does not authorize public check-ins A request to work on an issue still covers the claim and renewal, but a public check-in needs the human's own agreement, as AGENTS.md says. * changelog: Agent docs: say what ATC installs and what a public check-in sends (#4235) * flash next metal: opt-in MB=2 grouped gate/up decodes an expert's weights once for two rows (#1486) TF_FN_GX_GATEUP_MB2=1 (default off) launches gx_gateup_mb2 in place of gx_gateup. List slots pair (even, next) when both hold one expert. Every other slot, a lone trailing one included, runs the MB=1 row code. Each row keeps its sums, products, FMAs and order. With the flag off, the compiled shader text is unchanged. * changelog: flash next metal: opt-in MB=2 grouped gate/up * pull: reset refused settings and name every proxy parse failure * changelog: pull: name the variable at fault on every configure * lanes: price opted-in drafted lone copies as in 1.3.3 * changelog: lanes: price drafted lone streams as in 1.3.3 for families that opt in * changelog: lanes: price drafted lone streams as in 1.3.3 for families that opt in * lane host: score askers wait on their own condition, apart from the lane thread's timed waits A score or decide asker waited untimed on the host's wake condition, which the lane thread also waits on, timed, when idle. std.Io.Condition hands a broadcast's signals to the waiters registered at that moment, and each takes one only once its futex wait returns. When the lane thread answered an ask and went back to its idle wait before the woken asker had taken its signal, the lane thread's new timed wait found that signal when it expired and took it; the asker then found none and slept on with its answer ready, until some other work broadcast wake again. Askers now wait untimed on the score queue's own condition, broadcast when answers are set or the host closes; the lane thread keeps wake. test-lane-condition-stress-host makes that schedule certain rather than hoping load hits it: it runs the real host, lane thread and Engine.score on std.testing.io with its futex waits observed, holding the asker once woken until the lane thread has begun two timed waits on wake. With the asker on wake the answer never arrives (the test reports it after three seconds and the host's close frees the asker); on its own condition it returns at once. * background responses: shutdown waits on its own condition, apart from cancel's timed waits A cancel waits for its response's end with a deadline on the manager's ended condition; the server's shutdown waited untimed on the same condition for every job to leave. std.Io.Condition lets a timed waiter that waits again take a signal a broadcast left for another waiter. Today no wake shutdown needs can be taken that way: a cancel waits again only while its own job is still listed, so the last job's end, the one wake shutdown waits for, is never followed by a cancel's wait. Shutdown now waits untimed on drained, broadcast with ended when a job leaves, so that a later timed waiter on ended cannot take it either. No behaviour changes today; the test the first version carried, a copy of the manager's wait shape, is dropped (it never ran the manager's code). * lane host tests: the halt tests' waits on wake are timed, as the lane thread's are Two tests waited untimed on the host's wake for the halt reason while the lane thread, which also waits on wake with timeouts when idle, was running: the shape the score askers had. The lane thread is held inside the backend there today, so nothing strands, but a timed wait that re-checks the reason cannot strand however the lane thread waits. * changelog: lane host, background responses: waits that cannot miss a wakeup * nemotron cuda: fill a new prompt a chunk a call between other streams' rounds serialChunks becomes a Pass whose next() runs one chunk: the whole pass loops it, and the new prefill_step calls it once a round, so both share one implementation. prefillFrom splits into begin, the segmented choice, the pass and firstToken for the same reuse. The lanes' prompt setup moves verbatim into cuda_lanes_fill.zig (whole and step; cuda_lanes.zig was at 598 lines). A step binds the stream's sequence, which restores its position, sampling, decision row and MTP head, sets the tap and prompt-row hooks for its one chunk, and on the last chunk takes the first token and the head's last row as the whole pass does. Image prompts (the tower keeps one row buffer an engine) and staggered-segment passes fill whole in their first step. A cancel between chunks keeps the interrupted prefix and drops the pass; release drops it too. test-nemotron-cuda-steps-host: an image prompt fills whole, each image through the tower once; a pass that cannot begin holds nothing; a cancel between chunks drops the pass. * nemotron cuda reports_fill: each chunk's rows reach the host and Drafted (REV59 1) The stepped pass stores fill_at after every chunk, but the backend did not declare reports_fill, so the lane host treated its progress as unreported (status, load ledger, remaining work, the prefill budget, srpt samples) and Drafted, which steps a target only when it reports its fill, would have run the whole pass under --drafter. The backend now declares it. * nemotron cuda cancel_prefill: a lane-host cancel between chunks keeps the prefix (REV59 2) The lane host takes a cancel between two prompt calls itself: it calls the backend's cancel_prefill, if any, then releases the stream, and never steps the pass again. Nemotron CUDA kept an interrupted prefix only when a cancel landed inside a chunk, so a cancel between chunks (the common case under the host) lost it. cancel_prefill now binds the stream's sequence, where the prompt cache's save reads the state, and keeps the prefix where its last chunk ended; with no pass between chunks it keeps nothing. * nemotron cuda fill_at: what was restored at open, the whole prompt at the end (REV59 3) A stream offered a kept state starts with fill_at at the kept row. When the restore failed, was refused or was skipped (prompt logprobs), open left it there, and only a stepped pass's unfinished chunks wrote it again, so the first chunk, a failure in it, a one-chunk pass or a whole pass reported rows never filled. open now sets it to the row its pass starts at, and the pass's end to the prompt's length. * nemotron cuda steps: a stream cancelled while it waited opens nothing (REV59 4) The first cancel check was the pass's own, before its first chunk: by then a cancelled stream had taken a sequence, restored any kept prefix and, for an image prompt, run every image through the vision tower. The whole pass and the first step now refuse a cancelled stream before opening it. * nemotron cuda: the backend's end frees the passes held between chunks (REV59 5) Cuda gained a map of stepped passes standing between their chunks but its deinit never freed it, so an engine torn down after any stepped prompt leaked it. deinit now frees it. The host test's rig runs on a driver whose stream waits and host frees only count, so the real deinit runs. * nemotron cuda steps: a step that fails other than by a cancel releases its stream (REV59 6) Once a step opened a stream's lane (the own sequence, a paged lease or a new sequence), a failure in its pass left the lane in place: the lane host releases a failed stream itself, but Engine.fillStream releases only on a cancel, so its direct callers leaked the sequence. prefill_step now releases the stream, after its queued GPU work, on any error but a cancel (the cancel stays the host's, which keeps the interrupted prefix first); release is idempotent, so the host's own release finds nothing. * nemotron cuda steps: an unfinished chunk waits for its GPU work when the host bills it (REV59 7) The lane host sets settle_step on a stream whose prompt calls it times against decode's share (--decode-share, or past 32k rows by default), so a call's time must include its GPU work. A Nemotron chunk's kernels stay queued on the engine's stream when the call returns, so the call billed its launch time and the next decode round paid for the chunk. With settle_step, an unfinished chunk now waits for its stream before returning, as GLM's CUDA lanes do; without it nothing changes. * changelog: nemotron cuda: chunked prefill between other streams' rounds * gemma4 cuda: opt-in greedy argmax in the target graph, no unread tok download TF_GEMMA4_ARGMAX_GRAPH=1 (default off): a verify round whose windows are all greedy and unmasked captures tf_round_bf16_argmax over the round's rows in the target forward's graph (a second graph set by row count; eager forwards launch it right after), instead of one launch a window after the graph. Each row has its own block, so every pick is the one the per-window launch made. Entries that are all picks no longer download tok, which no greedy entry reads, and each forward's ids, positions and slots are staged in pinned memory, reused only after an event shows the last copy done. * changelog: #4616 under Unreleased * cuda: size idle Qwen page pools after warm-up when requested * env defaults: pin TF_CUDA_POOL_AFTER_WARMUP's 0 and 1 forms * cuda startup test: pass the empty pool sizing text * changelog: #4591 under Unreleased * qwen3_8 cuda: opt-in PDL on ModelOpt qmmf lanes (REV26 1A) * qwen3_8 cuda: dependent launches on the qwen35 glue kernels (REV26 1B) * changelog: qwen3_8 cuda: opt-in PDL on ModelOpt qmmf lanes and qwen35 glue * tests: re-pin the files #4706 changes * metal row projection: the narrow/wide cutover keyed per chip, not per generation (#3396) The row kernels' cutover from narrow to wide windows was keyed by the GPU generation alone, so an M5 Max took the wide kernels from 8 rows as an M5 Ultra does. On an M5 Max the wide kernel never wins from 1 to 32 rows at 3 to 8 bits, and at 2 bits only at 32 (the reporter's tf-row-cutover run: at 4 bits and 8 rows 45.4 us narrow against 88.7 us wide), so its 8-row windows ran at about twice the time. What separates the two is the GPU's size, which Metal does not report as a core count; it does report the device's name, whose last word gives the tier. The cutover is now keyed on the generation plus that tier, with a cutover for each code width: a row without a tier holds for its generation and later (generation 17: 8 at every width, the M5 Ultra and every other M5 as before), a row with a tier for that tier of its own generation only (generation 17, Max: 32 at 2 bits, never at 3 to 8). Chips not in the table, and later generations, keep their generation's cutover. tf-row-cutover prints the key it uses and the table's cutover at each width. The narrow and wide kernels give the same bytes (tf-row-cutover and the Metal wide-row contract check it), so no token changes. The table and key live in row_cutover.zig without Metal: test-row-cutover-host checks the Max row, unlisted tiers and generations, names the key reads and the tool's key line; the dispatch tests run per code width. * metal row projection: the recording Metal stubs give a device name (REV75 1) Pipelines.load now reads the device's name for the cutover's chip key, but the host builds' recording Metal stubs had no name: test-qwen27-quant-host (and with it zig build test) failed to compile where its quantized matrices load the row pipelines. The qwen27, LFM2, Gemma 4 head and Flash Next stubs now give an empty name, which keys no listed chip, so their row pipelines keep their generation's cutover, as before the per-chip key. * metal row cutover: the chip key reads only names it knows (REV75 2) chipOf took a name's last word as its tier and any other "Apple M..." name as base: "Apple M5 Extreme", "Apple M5 Max (40-core)" or "Apple Mx" read as base, and "Apple A19 Pro", "AMD Radeon Pro" or "Foo Max" as a tier. Today neither changes a cutover (base has no row; no such device is generation 17), but a base row would have taken them silently. It now reads "Apple M<digits>" as base and "Apple M<digits> Pro|Max|Ultra" as that tier, words split on spaces (a trailing space is no word), and gives any other name no tier, so it keys its generation's cutover as an unlisted chip does. * metal row cutover: a per-width table is tested per width (REV75 3) The dispatch tests set every width's cutover to one value, so a lookup reading the wrong width's slot would have passed them. The lookup is now row_cutover.takes, on the host: with the M5 Max's table a 2-bit window of 32 rows takes the wide kernels and one of 31 does not, while every other width stays narrow at 32; the Ultra's table goes wide at 8 rows and not 7 at every width; a width the kernels do not unpack takes none. The Metal dispatch test (macOS) also runs the Max's mixed table through call and callStrided. * metal row cutover: tf-row-cutover prints the device name its key read (REV75 4) tf-row-cutover printed the generation and tier it keyed on, not the name the tier was read from, so a run on a chip whose name the key does not know (a new tier word, a virtual machine's device) showed "tier unknown" with nothing to say why. Its key line now begins with the device's name as Metal gives it. * Fix integer pipeline IDs in row dispatch tests * changelog: metal: row projection cutover per chip (M5 Max narrow up to 32 rows; Ultra unchanged) * changelog: metal: row projection cutover per chip (M5 Max narrow up to 32 rows; Ultra unchanged) * Llama: a failed open gives the prompt cache its room back (D1073) The pass charged the stream's cache to the budget, fitted the prompt cache's room to what was left, and only then made the cache and recorded it. If making or recording it (or anything after, up to the end of the pass) failed, the errdefer gave the bytes back but left the room fitted short, and with no cache recorded the release after it did nothing: the store stayed smaller by the stream's bytes until another stream opened or ended. The errdefer now gives the bytes back and fits the room to them, as releaseFn does. Nothing changes when nothing fails. test-metal-open-room-host checks the family's open path in its source (the Metal backend builds on macOS only): the charge's undo refits the room and stands before the cache is made. On main it fails. * Ripple: a failed open gives the prompt cache its room back (D1073) The pass charged the stream's cache to the budget, fitted the prompt cache's room to what was left, and only then made the cache and recorded it. If making or recording it (or anything after, up to the end of the pass) failed, the errdefer gave the bytes back but left the room fitted short, and with no cache recorded the release after it did nothing: the store stayed smaller by the stream's bytes until another stream opened or ended. The errdefer now gives the bytes back and fits the room to them, as releaseFn does. Nothing changes when nothing fails. test-metal-open-room-host checks the family's open path in its source (the Metal backend builds on macOS only): the charge's undo refits the room and stands before the cache is made. On main it fails. * Spark2.5: a failed open gives the prompt cache its room back (D1073) The pass charged the stream's cache to the budget, fitted the prompt cache's room to what was left, and only then made the cache and recorded it. If making or recording it (or anything after, up to the end of the pass) failed, the errdefer gave the bytes back but left the room fitted short, and with no cache recorded the release after it did nothing: the store stayed smaller by the stream's bytes until another stream opened or ended. The errdefer now gives the bytes back and fits the room to them, as releaseFn does. Nothing changes when nothing fails. test-metal-open-room-host checks the family's open path in its source (the Metal backend builds on macOS only): the charge's undo refits the room and stands before the cache is made. On main it fails. * Flint: a failed open gives the prompt cache its room back (D1073) The pass charged the stream's cache to the budget, fitted the prompt cache's room to what was left, and only then made the cache and recorded it. If making or recording it (or anything after, up to the end of the pass) failed, the errdefer gave the bytes back but left the room fitted short, and with no cache recorded the release after it did nothing: the store stayed smaller by the stream's bytes until another stream opened or ended. The errdefer now gives the bytes back and fits the room to them, as releaseFn does. Nothing changes when nothing fails. test-metal-open-room-host checks the family's open path in its source (the Metal backend builds on macOS only): the charge's undo refits the room and stands before the cache is made. On main it fails. * Step-5: a failed open gives the prompt cache its room back (D1073) The pass charged the stream's cache to the budget, fitted the prompt cache's room to what was left, and only then made the cache and recorded it. If making or recording it (or anything after, up to the end of the pass) failed, the errdefer gave the bytes back but left the room fitted short, and with no cache recorded the release after it did nothing: the store stayed smaller by the stream's bytes until another stream opened or ended. The errdefer now gives the bytes back and fits the room to them, as releaseFn does. Nothing changes when nothing fails. test-metal-open-room-host checks the family's open path in its source (the Metal backend builds on macOS only): the charge's undo refits the room and stands before the cache is made. On main it fails. * MiniMax-M3: a failed open gives the prompt cache its room back (D1073) The pass charged the stream's cache to the budget, fitted the prompt cache's room to what was left, and only then made the cache and recorded it. If making or recording it (or anything after, up to the end of the pass) failed, the errdefer gave the bytes back but left the room fitted short, and with no cache recorded the release after it did nothing: the store stayed smaller by the stream's bytes until another stream opened or ended. The errdefer now gives the bytes back and fits the room to them, as releaseFn does. Nothing changes when nothing fails. test-metal-open-room-host checks the family's open path in its source (the Metal backend builds on macOS only): the charge's undo refits the room and stands before the cache is made. On main it fails. * changelog: metal: a failed stream open gives the prompt cache its room back (six families) * Expect the specific zero-head vision config error * Check prompt file identity and canonical prefix reuse * Decode Hy4 checkpoint numbers without quad floats * changelog: macos: native server memcpy from libSystem (Hy4-flash config without typed std.json); two macOS-only test fixes * nemotron cuda: opt-in shared rounds of 16 streams and 32 rows (TF_NEMOTRON_WIDE_ROUNDS) TF_NEMOTRON_WIDE_ROUNDS=1 (default off) lets a shared round hold 16 streams and 32 rows on GB10 for one-rank, non-latent, non-Bolt checkpoints without checkpoint e4m3 rows, so the experts' and projections' weights are read once a round at 16 streams instead of twice. A lone stream's window, graphs and measured costs are unchanged; widths 17-32 are priced as the 16-row cost scaled linearly, a 32-row round as two 16-row rounds. Each row keeps its bits from two 16-row rounds: affine-4 rows past 16 take verify, whose 32-row tile runs decode's group chain and slice order on a second m16 tile; the NVFP4 lane's 32-row tile is the same body; router logits at 17-32 rows take tf_nemo_router, the chain tf_nemo_router_rows runs; the routed and shared experts stay in 16-row items (tf_plan_routed's staging widened to 32 rows, the shared plan four items past 16 rows); the gather, last-row and scatter copies take 16 parts. The contract command wide-rounds compares Lightning's dense shapes at 17, 25 and 32 rows against 16-row calls, byte for byte, in affine-4 and NVFP4, with NaN/Inf and a planted control. * nemotron cuda wide rounds: the shared window takes the round's rows (fixes WindowTooWide) With TF_NEMOTRON_WIDE_ROUNDS on, the served GB10 run failed most rounds of 4, 8 and 16 streams with WindowTooWide: the shared window's forward (cuda_forward.zig windowRows) refused any round past glue's rmax, the per-sequence Mamba stride, which stays at a stream's own 16 rows. It now checks the round's rows against sharedRows (cuda_wide.windowFits), 32 with the switch and 16 without; each stream's Mamba rows still stride at rmax, and the scan refuses a segment past it as before. Every other call a 32-row Lightning round makes takes its rows: affine-4 dense rows past 16 go to verify (up to 128 on GB10), the routed plan stages 32 (plan_rows), the shared expert's plan holds them in 16-row items, the router's logits run 16-row tiles, and the part tables take 16 streams. AffineNKernels.decode (qlinear.zig) keeps its 16-row cap: no Nemotron call reaches it, and the CUDA loader reads Lightning's MLX matrices at 4-bit in groups of 64 only. test-nemotron-wide-walk-host parses Lightning's config (its quantization block) and walks a 32-row round through every row limit, and checks that with the switch off each stays at 16 rows and 8 streams. * nemotron cuda wide rounds: each part of a round's attention starts at its own rows (REV60 1) The forward and the MTP head handed a shared round's attention to attentionSegs in parts of 8 streams, its launch table's width. The batched kernels index launch rows from 0 and find each row's stream by its start row, but a part past the first carried the round's global start rows and the round's base pointers: in any round of 10 to 16 streams the second part's launch wrote streams 0..7's query rows into its first stream's cache, at positions before its own, wrote its outputs over streams 0..7's, and never computed its own (9 streams escaped: a part of one stream takes the per-stream kernels, which offset their pointers). attentionSegs now takes every stream and launches parts of up to 8 itself, each part's table rebased to the part's first row and every row pointer (queries, partial outputs, maxima, sums, output, group sums) moved there, as the per-stream path already moves them; rows that do not follow each other take the per-stream path. Both callers pass the whole round. The test runs the real attentionSegs on a driver that executes the three kernels' row mapping (seg_of, position plus row, row outputs) over a model memory: rounds of 9 to 16 streams, whole and in the old callers' parts of 8, give every stream the outputs and new keys and values of the same streams run as two 8-stream rounds, and leave every earlier key in place. On the previous attentionSegs the parts of 8 overwrite earlier keys. * nemotron cuda wide rounds: not with Sliding Weights (REV60 2) Sliding Weights route a pass's lessons by stream: the forward hands the lesson route each stream's rows, and the route, like the gate kernels' copy of it (train.cu), holds lesson_route.max_segments (8). In a wide round the forward routed its first 8 streams only, so streams 9 to 16 ran without their learned adapters. Lessons attach only through Sliding Weights, which the engine knows at init, so the switch now leaves rounds at 8 streams when it is asked for, as it does off GB10. * nemotron cuda wide rounds: a stream's own rows stay within its window (REV60 3) The shared window's forward now takes up to sharedRows (32) rows, but each stream's rows still stride at windowRows (16) in its own buffers: its ids and hidden rows, and its Mamba conv and scan rows (rmax). verifyShared checked only the round's total, Head.chains only the total of the kept rows, and the batched Mamba launch none, so a direct caller handing one stream more than 16 rows would write past its buffers (the lane engine caps a stream at 16, so served traffic never did). Each now refuses a stream past its window: verifyShared with BadWindow, chains with BadDraftRequest, mambaSegs with ScanShape (as the scan alone did). * nemotron cuda wide rounds: the lanes learn what a row past 16 costs (REV60 4) With the switch, shared rounds of 2 to 8 streams may run 17 to 32 rows, but their costs are the measured 16-row window's extended linearly, while row 17 moves the dense calls to the 32-row verify, splits the shared expert in four items and the router into two tiles. A round the table underprices had its excess read as fixed overhead, which makes the next draft look cheaper and the next round wider. With the switch the lanes now learn what a row costs (learn_row_costs, as GLM's lanes do on a machine their table was not measured on): the excess goes to the row cost, and no overhead is learned from a wide round until it has one. Switch off: unchanged. The size of the cliff is the device check's to show. * nemotron cuda: the shared-widths check sends the rounds the switch allows (REV60 5) tf-cuda's shared widths check took up to the engine's 16 streams but kept each round's room at windowRows (16): with the switch on it never sent a 17-32-row round, which is why it could not catch the WindowTooWide refusal, and with the switch off it accepted 9-16 streams only for verifyShared to refuse them. Its room is now sharedRows (32 with the switch), each stream's rows stay within its own window (verifyShared refuses more), and its stream bound is the switch's (8 off, 16 on). With the switch off its splits are exactly as before. The split is cuda_wide.checkRows, tested on the host: rounds of 2-16 streams reach past 16 rows with the switch, never a stream past 16, and match the old splits without it. * tests: wide rounds' device contract takes ModelOpt's FP8 and bf16 dense rows too (REV60 6) The switch admits ModelOpt checkpoints at full precision, whose dense projections can be FP8 or bf16 as well as NVFP4, but the GB10 contract (tf-cuda-test wide-rounds) compared only affine-4 and NVFP4 at 17, 25 and 32 rows against 16 plus the rest. It now runs every Lightning dense shape in all four formats, FP8 and bf16 built as the ModelOpt loader views them, with the same NaN/Inf rows and planted control. The host side of the finding is the attention walk over the real attentionSegs (REV60 1) and the per-stream bounds (REV60 3); the router and experts keep 16-row items or tiles in code (REV60's table) and are the served run's to show. * nemotron cuda wide rounds: the switch set where it cannot apply says why (REV60 7) TF_NEMOTRON_WIDE_ROUNDS=1 off GB10, on a latent, Bolt, e4m3-row or bf16-expert checkpoint, across ranks or with Sliding Weights left rounds at 8 streams with no word. The engine now logs which of those keeps them there. tf-cuda opened the engine without the startup check of Nemotron's variables that the server's open makes, so a malformed value read as off there; it now makes the same check first. The rest of the finding stands as written: with the switch off the 16-stream tables are sized at build time (a few MiB of device and mapped memory) and qlinear's 17-32-row affine-4 verify is reachable only by a caller passing more than 16 rows, which no Nemotron path does with the switch off. * tests: re-pin nemotron_ops.cu and qlinear.zig, which this change touches The wide rounds change edits both pinned files (nemotron_ops.cu's routed plan and part tables, qlinear.zig's 17-32-row affine-4 verify); their pins now hold the final tree's hashes. The REV60 fixes after it touch no pinned file. * nemotron cuda wide rounds: saved lessons put rounds back at 8 streams (REV74 1) REV60 2 refused the switch under --slide, on the premise that lessons attach only through Sliding Weights. They also attach without it: the native open loads a checkpoint's saved living lessons whenever they are there, after Engine.init has decided the switch. A taught checkpoint served without --slide and with TF_NEMOTRON_WIDE_ROUNDS=1 then ran rounds of up to 16 streams, and the lesson route (8 streams, as train.cu's copy) dropped the saved lessons for streams 9 to 16. loadLiving now turns the switch off, and logs why, before it attaches them (cuda_wide.withLessons). That is safe after init: every buffer was sized for 16 streams and 32 rows, and 8 streams use less of each; the lanes' facts are read after the load. As a guard for any later path, the shared window now refuses a round of more than 8 streams while any layer carries a lesson (LessonsPastRoute) instead of serving it without them. * nemotron cuda wide rounds: the attention walk models every plane, paged caches and 32 rows (REV74 2) The walk over the real attentionSegs modelled the query, partial-output and output rows only and checked earlier keys alone. Its kernel model now also writes and reads the maxima and sums planes and the merge's group sums (xs, which the attention's out projection reads next), checks every stream's earlier values as well as keys, and runs five layouts at 9 to 16 streams: 1-2 rows a stream, 2 each (32 rows at 16 streams), both with paged caches (key_at through each stream's page table and the page stride), and streams whose rows are apart (the one-stream-at-a-time path). A planted control moves one stream's query and the comparison flags that stream alone. Mutating rowsAt shows what it catches: a wrong group-sum offset fails it. A wrong maxima or sums offset does not, and cannot change a round: those planes are scratch the merge reads back from the same pointer within the part. * nemotron cuda wide rounds: direct calls follow the switch's stream count; conv checks its rows (REV74 4) Head.chains and the lanes' shared verify checked their streams against the build's 16, so with the switch off a direct caller could hand them 9 to 16 streams (the lane engine never does: its facts say 8, and Engine.verifyShared checked the switch's count). Both now check cuda_wide.streams. Glue.conv, alone among the Mamba launches, took a stream's rows past rmax unchecked; it now refuses them as the scan does (its one caller already checked). tf-cuda's usage line gives shared-widths' 16 with the switch, and the environment doc lists every case the switch is refused in. * nemotron: a draft call batches the switch's streams, 8 with it off Cuda.draftFn batched up to its parts array (16) while Head.chains takes cuda_wide.streams (8 with TF_NEMOTRON_WIDE_ROUNDS off), so a direct caller with 9-16 drafting streams failed after moving the head instead of drafting the ninth on alone as main does. The decision is now cuda_wide.batches. * nemotron: with wide rounds off, sizes, plans and kernel paths are main's REV83 2: TF_NEMOTRON_WIDE_ROUNDS off now changes nothing. - Head buffers and pinned words, the lanes' mapped logprob rows and grammar bits, and the engine's pinned draw words are sized by cuda_wide.streams (main's 8 streams off), not the 16-stream maximum. - The shared expert's fixed plans keep main's 16-row, 8-word layout off; the 32-row, 14-word layout is used only when the switch took at load. - The 17-32-row affine-4 route to verify moves from shared qlinear.decode (main's again) to Nemotron's dense call, behind the switch; the routed plan admits 32 rows only with it. - tf-cuda checks only the switch's own value, as main checked none. * tests: re-pin qlinear.zig, which is main's again * changelog: nemotron cuda: opt-in wide decode rounds (up to 16 streams; off changes nothing) * qwen: one EOS rule for the family readers; qwen27 reads generation_config.json (#3701) * changelog: #4678 under Unreleased * Bound request web DNS work by the existing resolver deadline and worker cap * changelog: #4551 under Unreleased * server: per-family tool-call render and parse conformance test A table-driven host test covering every chat template family shipped in the repository: GLM-5.3, Qwen3.8, Dory, LFM2, ChatML control tokens, DeepSeek control tokens, GLM control tokens, MiniMax-M3 and Gemma. Each family renders a tools definition plus a user turn through its own fixture template and the rendered assistant call and tool result keep the family's markup; its model output parses back through tool_parse.parse (with the LFM2/MiniMax DSML rewrites where native markup needs them) with the same name and arguments; two calls keep their order; a truncated call stays text or is rejected, never parsed as a different call. Render path: messages.normalizeWith + toolArguments + srv.text.render; parse path: tool_parse.parse. * changelog: #4555 under Unreleased * lane host: a stepped pass gives its restored entry back after its first call Under prefill_step the host admits several streams into filling at once, and each one's prompt-cache lookup stayed borrowed until a keep mark or the pass's end. A borrowed entry is never evicted, so a later stream's room could not be made from it and its cache was allocated beside every other filling stream's kept state, past the budget. A backend restores the kept state in its pass's first call (open), as the whole pass does before its first chunk. The host now reports the lookup after that first call once the restore is settled (restored, refused, or none offered), as the whole pass's prefill does when it returns; a backend that has not restored by then keeps its lookup as before. * lane host: no stream admitted beside a fill that has not begun with its kept state borrowed The earlier fix gives a stepped pass's restored entry back after its first call. But the host admitted every queued request a lane was free for in one go, and each admission's prompt-cache lookup borrows its entry: when the first of them made its first call (where a backend opens its cache and makes room by evicting), every other admitted stream that had not begun still pinned its entry, so the room was made around them and the store and caches could pass the budget by up to the lanes less one kept states, longer when a fill's first call was put off (decode-share debt). Admission now holds while a filling stream that has not begun holds a borrowed entry; it goes on once that stream's first call has reported it, the next loop round. Requests that found nothing kept, and backends without stepped fills, admit as before. The test queues two requests whose prompts each have a kept state before a two-lane host starts: during each one's first call the other's entry has no borrowers. Without the hold the second is admitted beside the first and its entry is pinned (expected 0, found 1). * lane host: a filling job lends its kept state back until its first call The earlier hold kept a second stream from being admitted beside a fill that had not begun with a borrowed entry. It missed a cache miss queued ahead of a hit: the miss was admitted with nothing borrowed, the hit after it in the same loop with its entry borrowed, and when the shorter miss filled first, its first call made room around the pinned entry (in admit.many as well). And the hold made every queued prompt, a short foreground one too, wait behind an unstarted fill, for as long as decode-share debt or fcfs put that fill's first call off. A job no longer holds its borrow while it waits to fill. Entering the fill queue it gives the entry back to the store, keeping its serial (entries now carry one, so an address reused after an eviction is never mistaken for it); its first call borrows it again by that serial, just before the backend restores it, and the report after that call gives it back. The lookup itself stays at admission, so marks, kept rows and the fill order are as before, and a lent entry stays in the reservation snapshot's protection like a queued job's. If the entry was evicted or expired while the job waited, the job drops its kept state and fills from the start (exact). No unstarted job holds a borrow, so the admission hold is gone and admission is main's again. Tests: with two kept prompts both resume and neither is pinned beside the other's first call; with a miss queued ahead of a longer hit, the hit's entry has no borrowers while the miss opens (before this change: 1); a prompt queued behind an unstarted hit is admitted with it before either's first call (before this change: held); the store borrows by serial and not an expired entry. * prompt cache: every entry the store holds has its own serial, never 0 An earlier change named entries by a serial so a lent state is borrowed again by identity, but only the keep and the imprint recall numbered theirs: a state read back from disk (rows_read, --learn-conversations) kept serial 0, so two of them shared it, and a lent one's reborrow could take the other, restoring from a freed state or reporting into an innocent entry. The serial is now given where every entry is published, prompt_cache_index.add, so no path can skip it, and starts at 1; reborrow refuses 0, and a job whose entry has none keeps its borrow instead of lending it. Test: two states read back from disk carry distinct non-zero serials, a reborrow takes exactly the one lent, and once that one is evicted it finds nothing rather than the other (before this change: both 0, the reborrow takes the first). * lane host: a lent job's own kept state stays protected A lent job stays in the reservation snapshot's protection, but the snapshot protected each job's deepest matching state: once another pass kept a longer prefix of the same prompt, the longer one was protected and the lent state, now superseded (the first victim), was not, so a lookup or keep could evict it and the job filled cold beside a state that would have served it. A lent job's protection is now the exact state its serial names. Test: with a state kept at 8 lent and a longer one kept at 12 after, the snapshot protects the one at 8 (before this change: the one at 12). * lane host: a lent state gone at the first call is looked up again, as at admission When a lent state was evicted before its job's first call, the job went on cold with what its admission had planned for resuming: the load ledger's hint kept the lent state's row (so the cold pass's chunks were never counted, and a cancel mid-pass lost them), the keep marks skipped every row up to that state (so the cold pass kept nothing there for the next turn), and the cache promise had been credited the room the lent state would give back. The job is now looked up again at that point, through the same lookup its admission made (factored as lane_stream.kept): its marks and promise are planned afresh, it borrows any state kept since, and its fill and the ledger's hint follow what it resumes. Test: a state lent and evicted before the first call: the pass fills from 0, the ledger is sure of a 0 hint, the marks include the cold pass's keep at 16, the promise holds a slot for it, and the request keeps it again at its end (before this change: hint 16, no marks, no promise). * lane host: a first call's rows are counted from what it resumes after its reborrow The first call's reborrow ran inside fillAt, after step had read the rows the job had left (from the lent state's row) and after longStep and srptStep had chosen its share from them. A lent state evicted meanwhile made the cold first chunk show no progress (step returned the no-progress maximum, spending the prefill budget at once) and could share a long prompt as if short. step and longStep now borrow it again before they read anything (the reborrow does nothing a second time), so every reading is the job's own after it. Test: the evicted case's first step counts exactly the rows the chunk filled (before this change: the no-progress maximum). * changelog: #4751 under Unreleased * Add checked BF16 Vulkan tensor operations and operator gate * Add checked BF16 Vulkan norm and MLP operator gate * Add native Vulkan attention, recurrent and greedy operator gates * Report the first residual-add class mismatch without changing acceptance * Make attention and recurrent probes reject unwritten outputs and match Ash head norm * Add the native Vulkan dense Qwen3.5-2B greedy engine and oracle probe * Qualify residual denormals by device float controls and request supported preservation * Fix Vulkan attention gate widening and diagnose GDN reference failures * Separate Vulkan prefill snapshot dummy from read-only slot * Match Vulkan decode raw-gate flag to the shader mask * fix(vulkan): admit parsed checkpoint geometry and validate full load * feat(vulkan): chunk Qwen3.5 prefill within the context ceiling * fix(vulkan): use one GDN path for prefill and decode * build(vulkan): give the contract runner every operator's SPIR-V and a -Dcontract-root option The contract runner built only the Q4 projection's shaders. Each later operator registers in the same runner, so it now imports the stage 1 to 5 shader modules (norm, rope, attention, GDN, greedy and the data-movement kernels) that the operator probes already build, and the stage modules are hoisted out of their probe blocks so both can share them. -Dcontract-root points the runner at another root file, so one operator group can be built and run on its own. * contract(vulkan): the gdn group's GatedDeltaNet shaders under the kernel contract The stage 4 GatedDeltaNet images (conv_dw1d, gdn_conv_decode, gdn_split, gated_delta_prefill_ash and gated_delta_decode in its ASH_QWEN35 raw-gates mode) register as eight kernels through the production Gdn wrapper, so the wrapper's binding tables — the read-only g slot and the single-chunk snapshot dummy among them — are the ones under test. f32 state flows in and out of place, the interior chunk snapshot is bound exactly when chunks exceed one, and the decode loop chains the carried state. References are the stage 4 fixture's f64 walkers made parametric in tokens; every depth a spec states is a function of the token count (one ~130-deep state update per token, the fixture's stated derivation). The f32 state parts prove fp32 sums with an engineered stress fill whose kv partials overflow fp16; the bf16 parts declare bf16=0 with the reason the output's own rounding hides the sum error, as HIP's mamba and CUDA's gdn_prep do. The host suite cross-checks the walker against the fixture's bit for bit and proves the generated fills against the references without a GPU. contract_gdn_main.zig runs the group alone via -Dcontract-root and prints the same LIMITS lines, records audit and runAll tally as contract_main, plus live local-size and shared-memory evidence for all seven pipelines. Proven: zig build vulkan-host-test (20 gdn contract tests, walker parity with fx.RecurWalk/fx.Decode, stress fp16 margins >= 100x); both contract runners build; the runner refuses the software Vulkan device fail-closed. GPU gates 1-4 pending on the M1/M2 devices (none reachable from this host: llvmpipe only). * contract(vulkan): fix the gdn group's fixture against the first device run Three fixture bugs the M1 Max's first run surfaced, none of them shader bugs: the split parts uploaded one combined output buffer where the wrapper binds soa, g and beta separately (OutOfRange on every gate); the decode conv's unchanged-check listed the host chain scratch as an input while indexing one device buffer fewer, so input_now's tail was never filled (a false 'a run changed its inputs'); and the prefill recurrence's random fill used the stage 4 fixture's ranges, which only ever ran at 8 tokens - at 130 the walk outgrew f32. The random fill now decays (g, beta and the whole soa at 2^-3 scale or less), so any token count stays bounded. Also the sums replay the gates ran: every dot re-summed in the requested accumulator and order, the conv chains replayed from the uploaded initial state, exactly as computeWant walks them. Proven: vulkan-host-test green; runAll on Apple M1 Max (G13C C0) Honeykrisp - prefill conv, decode conv and decode state pass gates 1-4 fully; prefill y, hf+snap and split classes settle with the fill fix pending the next device run. * contract(vulkan): keep the gdn split's served a_log normal and state the soa sums proof The M1 Max run showed the split g shapes gate failing where a random a_log above ~2.4 drove g into f32 subnormals the device flushes - the exact case the stage 4 fixture's census deferred to Main. The served random fill now draws a_log in [-6, 0] (g >= e^-4.5, normal), with the census case named in the fill; the subnormal-flush decision stays with Main. The split soa sums gate moves to f16=0 with the measured reason: the fixture budget's magnitude term at the output's scale is wider than any fp16 miss the stress can engineer, and gate 3's shapes already bound the norm's sum to f32 quality (a bf16-summed ss misses ~2^-8 relative against an observed worst of 0.037 of bound). Proven: vulkan-host-test green. * contract(vulkan): the datamove group's seven exact kernels through gates 1-4 cast_f32_bf16, cast_bf16_f32, copy_u32, copy_u16, gather_u32, gather_u16 and dequant_bf16 register with the kernel contract, bit for bit (a NaN keeps its class; a non-finite dequant scale or bias is checked by class; every gather run includes an out-of-range id whose stated rule is the documented zero row). tf-stage1-datamove runs the group on a real GPU (zig build stage1-datamove) and refuses CPU devices; the stage 1 imports hoist so the probe and this runner share them. Ported from w7p/native-vulkan's a3f040c7 onto the engine-pr2 tree: the files needed no source change; the wiring reuses this tree's hoisted stage1_shaders module. Proven: zig build -Dvulkan=true stage1-gpu-build and vulkan-host-test pass on this box (llvmpipe only); tf-stage1-datamove --help exits 0 and the runner fails closed (exit 1) with only the software device present. * contract(vulkan): the attention group over the engine's served shapes rope_bf16 and sdpa_rows_bf16 against stage3_fixture's f64 references generalized past the fixture's 8-key score buffer to the served shapes (decode rows 1, prefill rows <= 32, visible keys 1..7168 on the 16-key tile, 256-lane scan and 1024-thread stride edges and the kStreamKeys bound). The sdpa bound is derived from the shader text -- denominator depth ceil(n/256)+8, the 256-lane strided chains plus the 8-level tree, NOT the plain n-term sum -- and pinned to the source by a host test. Single-key rows carry the V bits exactly; multi-row prefill rows decode alone bit-identical. Ported from w7p/native-vulkan-model's 60a22e77 onto the engine-pr2 tree: the files needed no source change; the wiring reuses this tree's hoisted stage1/stage3 shader modules. Proven: zig build -Dvulkan=true stage3-gpu-build, stage3-host-test and vulkan-host-test pass on this box; tf-attention-contract --help exits 0 and honestly refuses this box's software llvmpipe (exit 1). Real-GPU run needs the Apple Vulkan rig. * contract(vulkan): the greedy group's composed draw through gates 1-4 The greedy draw — finite_logits, argreduce_chunk and argreduce_combine behind one submission, three launches inside the run hook — registers through gates 1-4, plus the planted control contract_controls_greedy.comp (the mirror of HIP's tf_ctl_fmax_max: a row max that drops a NaN), registered with control = .nonfinite and required to go red. The acceptance is exact: the token equals the host greedyRef (max wins, ties to the lowest index, +0/-0 equal), a planted non-finite row refuses naming its first offender, repeats are byte-identical, inputs and guards untouched. Ported from the greedy agent's files on w7p/native-vulkan-model onto the engine-pr2 tree: the files needed no source change; the wiring compiles the control beside the stage 5 variants and reuses this tree's hoisted stage5_shaders module. Proven: zig build -Dvulkan=true stage5-gpu-build, stage5-host-test and vulkan-host-test pass on this box; tf-vulkan-greedy-contract --help exits 0 and the runner fails closed (exit 1) with only the software llvmpipe present. * contract(vulkan): the pointwise group's six closures over the production shapes contract_pointwise.zig states and checks the six pointwise closures of stages 2-4 on the host: the stage 2 trio reuses stage2_fixture, the f32-preserving residual add claims the exact f32 sum bit for bit (a flush-to-zero device fails HONESTLY), the attention output gate uses boundExact with ops 4 mids 1 and demands signed-exact zeros, and the gated RMSNorm uses the rows family bound plus ops 10 mids 12 with nan/inf/±0/zero-row/nan-row controls class-checked. Every checker also refuses a corrupted output, a sign-flipped zero and a planted nonfinite. contract_pointwise_main.zig drives all six on a real GPU through the wrappers' exact dispatch shapes (NormMlp for stage 2; the preserve add, gate and gated norm at attention.gatePlan's and gdn.gatedNormPlan's geometry), three byte-identical repeats per case. Ported from w7p/native-vulkan-stage2 (c0ee7bfa + eb724158) onto the engine-pr2 tree. One source adaptation: this tree's NormMlp.Shaders gained the add_preserve_bf16 field, so the runner now serves it (the image this tree's stage 2 closure already compiles); the shader sources themselves landed with this tree's stage 3/4 closures. Proven: zig build -Dvulkan=true contract-pointwise-build, vulkan-host-test pass on this box, and zig-out/stage{2,3,4} carries the six images; tf-contract-pointwise --help exits 0 and the runner fails closed (exit 1) with only the software llvmpipe present. * build(vulkan): run the datamove host tests on the build host, not the cross target The datamove test module was built for -Dtarget, so a cross build (aarch64 on the x86 build host) failed with 'unable to spawn foreign binary' in vulkan-host-test. It now gets its own host-target module like every other host suite. Proved by: vulkan-host-test and all stage and runner build steps pass with -Dtarget=aarch64-linux-gnu (224/224 steps). * contract(vulkan): refuse odd 16-bit edge shapes in the datamove casts and u16 copy On a real device (Apple M2 Max, Honeykrisp) the shapes gate failed three kernels with the Zig error Misaligned: the gate's edge shapes include odd element counts, and a 16-bit range of an odd count is not bindable (dispatch.bind needs whole 32-bit words; View.init refuses the same ragged tail), so the fixture's view call raised an error that the gate scored as FAIL. The kernel refuses that edge, so prepare now returns false for it (an edge refused by the kernel, as the gates count them); served shapes (146x1, 3x700, 300x1, 2x520) are all even. Proved by: vulkan-host-test and stage1-gpu-build pass for aarch64 (81/81 steps, 210/212 tests, 2 skipped). Not proved: no device rerun yet. * contract(vulkan): the gdn prefill's uploads must not slice out past what prepare sized The M2 Max's run of the gdn group died in gate 1 of the prefill_y kernel: "index out of bounds: index 524288, len 10248" at contract_gdn.zig's uploadBuffers, called from the nonfinite gate's prepare. 524288 is 2 * state_elems and 10248 is 5 * linear_dim + the guard words, so the sliced region belonged to a different kernel: the prefill arm uploaded the same buffers for prefill_y and prefill_state, and the state's region (prefill_y's out holds y only) was sliced out of a much shorter out. The upload path now lives in one place, uploadWords, which hands each device buffer the words it takes: a checked output its own region of out, an output no fetch reads fresh poison scratch, and every region bounded by what prepare sized, so a mismatch is an error the gate reports instead of a panic that kills the runner. The prefill_y and decode_state outputs that no fetch downloads take scratch, the checked ones keep out's region, and every other arm keeps the bytes it had. Proof: a new host test drives the gates' own shape sequence (gate 1 and 2's small() shape, gate 3's served and edge shapes, gate 4's stress shape) through prepare and the upload path with no device, and holds every upload inside the region prepare sized and the buffer count at what run() binds. It fails on the old sourcing with the same out-of-range region the device hit (outWords: OutputRegionOutOfRange) and passes on the fix; the whole host suite is 21/21 and the arm64 runner builds clean (100/100 steps). The split g gate's class finding (1 of 128 outputs: nan where float64 gives finite) is untouched: it is a device finding for the maintainer to decide on, not a fixture bug. * contract(vulkan): upload the greedy shell's guard pattern instead of assuming it Why: the repeat gate failed on the PR-B device run with 'a run wrote outside its outputs' (gates.zig intact check). The rig's input() uploaded only the data window at offset guard, so the shell's guard bytes never held the 0xa5 pattern intact() demands — fresh device memory reads as zeros, and the gate was false on every run of every shape. The draw itself never writes the shell (its outputs are the internal partials and results buffers, the same shape HIP's argmax contract declares via rig.scratch/rig.output), so the guard finding was a runner bug, not an overrun. What: Rig.input builds the full shell through a new shellFor (pattern, data, pattern) and uploads it at offset 0, the way the datamove rig's slot() already did. New host test pins the layout: guards patterned on both sides, data between, exact length — the invariant the old code never stated anywhere. Proof: zig build vulkan-host-test stage5-gpu-bui…
What this changes
Before: the Metal loader stops with
ShortReadon a checkpoint span of 16 GiB or more, because it reads the span in eight preads and macOS refuses a pread of more than INT_MAX bytes. After: each pread asks for at most 1 GiB, so the span loads; the bytes read are the same.Inkling 2 Mini is the first checkpoint to reach this:
thinkingmachines/Inkling-2-Miniis one 19.5 GB safetensors file, andaddFileSelectedreads itsmodel.llm.span (about 17.6 GiB) as eight parts of 2.2 GiB.atc overlap --json: not run, ATC is not installed on the machine that pushes. Checked by hand withgit merge-treeagainst Inkling 2 Mini on CUDA and Metal #4387 and Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337, the two open pull requests I know to touch this file's callers: both merge cleanly with this branch.Checks on this head
dad62b9cf9, on main69e4d0f04f. The code and the test aree08a88fd68, which the checks below ran on;dad62b9cf9adds only the Unreleased line.python3 tools/zig/lean_check.py, on the base and on this head: 165 and 165, 0 new (lean_new.py).tools/pr_check.py --base origin/main --pr 4435ondad62b9cf9: 0 errors, 0 warnings.zig build test test-golden -Dcpu=apple_m1on this head: 961 of 965 steps succeed and 3 fail, the same 3 as on main (Zig's cache replays unchanged test binaries, so this run's counts cover only the rebuilt ones: 2,157 of 2,205 tests passed, 46 skipped, 2 failed). The new test,core.checkpoint_metal.test.a span longer than one pread may ask for is read whole, passes.max_preadset tomaxInt(usize)): the new test fails,readAllreturningShortReadon a 2 GiB + 4 KiB span.families.deepseek_v41.metal.vision.test.the release's vision_config parses to the defaultsin two test binaries (expectederror.UnsupportedVision, founderror.ZeroHeads), and the link checktensorfold-native links its own memcpy.zig build test test-golden -Dcpu=apple_m1on69e4d0f04fitself gives the same ones: 961 of 965 steps, 16,969 of 17,118 tests passed, 147 skipped, 2 failed, andtest-golden324/337 and 69/69 equal with 0 unexpected on both.zig fmt --check build.zig zigandgit diff --check: clean.Receipt
core/checkpoint_metal.zig(addFile,addFileSelected,addFileSplit,Checkpoint.read,Stage.read).dad62b9cf9, Zig 0.17.0, Xcode's Metal toolchain, Mac Studio M5 Ultra (256 GB), macOS 27.0,thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a, the loader reads the same bytes. On Inkling 2 Mini on CUDA and Metal #4387's branch with this change applied, the Mini checkpoint loads (18.2 GiB resident) where it stopped withthe native Inkling 2 Mini engine cannot load this checkpoint (ShortRead).tools/bench_openai.py: n/a, not reached.The new test maps 2 GiB + 4 KiB of anonymous memory and reads a sparse file of that size into it, so it touches about 2 GiB while it runs and nothing on disk. It skips if the file or the mapping cannot be made.
Checklist