Repository navigation
lanes: a stream whose next rows find no memory ends with length; the round's other streams run on - #3378
Draft
CodingEmil wants to merge 3 commits into
Draft
lanes: a stream whose next rows find no memory ends with length; the round's other streams run on#3378CodingEmil wants to merge 3 commits into
CodingEmil wants to merge 3 commits into
Conversation
CodingEmil
force-pushed
the
lanes-outgrown-length
branch
from
November 15, 2026 16:22
542961f to
e05a772
Compare
7 of 8 tasks
…nit Macs take TF_QWEN27_METAL_KV_PAGES A 512-key prompt chunk spans exactly two KV pages, so the paged prompt kernels take both page bases before their 32-key steps instead of reading the page table at every step. The M5 refusal of the flag goes, now that the paged kernels have run on an M5 Ultra (part of ashhart#1293).
…gives them back when it leaves With TF_QWEN27_METAL_KV_PAGES=1 a slot no longer holds a promise of its whole window from startup. A stream opening a slot is promised its prompt and one widest pass; a pass past that promises the rest before it takes a page, and a promise the pool cannot meet fails with LaneMemory before any page is taken or table entry written. Leaving, failing or being put back, a reset and a move to slot 0 give the pages and the promise back; a standing slot 0 keeps the pages of its committed rows. The page lifecycle is in families/qwen27/slot_pages.zig, its host tests in slot_pages_test.zig (part of ashhart#1293).
…round's other streams run on A backend may answer Backend.grow before a verify: false means the stream's caches find no memory for the window's rows. That stream finishes with `length` and a message before the forward, and a shared round verifies the others' windows; without the hook a round runs as before. Qwen3.8-27B on Metal with TF_QWEN27_METAL_KV_PAGES=1 answers it: its slot covers the window's rows through slot_pages before the round, and a slot the pool cannot cover ends its stream instead of failing the round's. Host tests in lanes/outgrown_test.zig and native/qwen27_outgrown_test.zig (test-qwen27-outgrown-host), part of ashhart#1293.
CodingEmil
force-pushed
the
lanes-outgrown-length
branch
from
November 15, 2026 23:02
e05a772 to
930d220
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Before, a backend could only report missing memory for a stream's next rows by failing its verify. Then
core.step()failed andlane_host_end.failRoundfailed every stream in the round. With this change, a backend may answer an optionalBackend.growbefore the verify. A stream whose window finds no memory finishes withlengthand a message before the forward, and the round verifies the other streams' windows. Qwen3.8-27B on Metal withTF_QWEN27_METAL_KV_PAGES=1answers it: before the round, its slot covers the window's rows throughslot_pages, and a slot the pool cannot cover ends its stream. A backend without the hook runs exactly as before.7238ed8e9) and qwen27 metal pages: a stream promises its pages as its rows come and gives them back when it leaves #3377 (864e6f1d5), which makes a slot's pages grow as rows come. This pull request adds one commit,542961fdb.atc overlap --json(2026-11-14 17:55 UTC,ATC_READ_ONLY=1, on542961fdb): incomplete (otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit). Fiveconflicts(dsv41 metal: the vision tower's kernels under the kernel contract #1721, dsv41 metal: image prompts #1722, glm cuda: TF_GLM_GRAPHS=1 replays verify windows as CUDA graphs (#1490) #2279, hip flashnext: a shared round's streams draft in one head pass a step #2696, XPU: Qwen3.8-27B attention merge with 16 subgroups per head, bit-identical #2799), each on one shared file. They are the same five qwen27 metal: M5 takes TF_QWEN27_METAL_KV_PAGES; a paged prompt chunk finds its two pages once #3180 lists, where each wasCHANGELOG.md's Unreleased list; I have not rechecked them withgit merge-treeon this head.Checks on this head
542961fdbon864e6f1d5.python3 tools/zig/lean_check.py, on the base and on this head: 341 on the base, 341 on the head, 0 new (tools/zig/lean_new.py). The 341 are inherited.zig/src/core/lanes/engine.zigstays at 600 lines: the new logic is inzig/src/core/lanes/outgrown.zig, and the engine's two verify calls go through it.qwen27_slots.grow(qwen27_slots.zig558 lines,qwen27_lanes.zig562).zig build testbuilds fromzig/src/core/lanes/lanes.zig), run on their own: base 367 passed, 1 skipped; head 370 passed, 1 skipped (the 3 new tests inoutgrown_test.zig).zig build test-qwen27-outgrown-host(new): 2/2 passed. Its test runs the lane engine with the core's fake backend, whosegrowcovers each slot throughslot_pagesover a host pool of three pages, asqwen27_slots.growdoes.lengthand its message.zig build test-qwen27 test-qwen27-reply-cache-host test-qwen27-startup-host test-lane-api-host test-lane-strand-host test-lane-halt-host test-lane-lone-host test-lane-interrupted-host test-kv-pool test-prefill-service-host test-flashnext-batch-host: 84/84 steps, 1109 passed, 2 skipped.zig build native tf-qwen27-attention-pages tf-qwen27-pages-resume -Dcpu=apple_m1: builds.zig build test test-golden -Dcpu=apple_m1 --summary all, with the GPU free: 870/870 steps succeeded, 13443 passed, 115 skipped, 0 failed. Six test steps came from the build cache (the lanes module's among them, counted in the line above), and the summary does not count their tests.tf-qwen27-attention-pages(plain and--shared-prefix) andtf-qwen27-pages-resumeon this head, on the device: PASS.zig fmt --check build.zig zigandgit diff --check: clean.python3 tools/pr_check.py: 0 errors, 1 warning (it asks for--pr NUMBERto check the Unreleased line).engine.zigand this head's hook and tests, all four new tests fail:max_newinstead of ending after 5 tokens;expected 3, found 24;asked > 0: the base never asks the hook;qwen27 outgrown:, at the cut stream's message: "a" runs to itsmax_new.zig build dev-tools: the change adds an optional vtable field with a default;test-host: no Linux machine with Zig here; CI will run it. The new host step is listed inzig/build/host_ci.zigbeside the other qwen27 host steps.Receipt
Main against branch: no timing cells planned.
qwen27_slots.growcovers the window's rows one call earlier than the verify would (the verify's owncoverthen finds them held). Every other backend runs as before:verifyas before;If you want the paged default measured, I can add a
bench_concurrent --levels 1,2 --alone --serialcell and a decode A-B-B-A against the demand-pages head on an M5 Ultra.When a stream ends this way on qwen27 with only this stack: never on its own. Each slot holds at most its window, and the pool has every slot's window (see qwen27 metal pages: a stream promises its pages as its rows come and gives them back when it leaves #3377). The
falseanswer is reached once something else holds pages of the same pool, as kept states will in Metal: KV pages from the core pool #1293 step 4. This pull request makes that case end one stream instead of the round.Boxes it reaches: every engine on the lane core, through
zig/src/core/lanes/engine.zig. Only a backend that setsgrowchanges behaviour; on main with this stack, that is Qwen3.8-27B on Metal withTF_QWEN27_METAL_KV_PAGES=1.New switch? Default, accepted values, profile row: none.
Backend.growis an optional vtable hook, null by default.Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision:
542961fdbon864e6f1d5, Zig 0.17.0, Apple M5 Ultra, 96 GB, macOS 27.2. Host tests, the full test run and the page tools; no served checkpoint.Paths and platforms the change reaches, which I ran and which I could not:
grow:familyRound: drafts withfamily_mtp, non-pipelined engines, logprobs, grammars);familyRound;roundStreams).queue);LaneMemorypromise still requeues the request);recorder.ziganddrafted.zigwrappers, whose own vtables do not passgrowon.Exactness, from
tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: not run on a device. In the host tests, the stream that keeps running gives the same tokens as alone, both in the core test and in the qwen27 one over a host pool. A backend whose hook always holds gives the same tokens, steps and shared rounds as a backend without it.Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): not asking for a run; see above.
Decode speed before and after, from
tools/bench_openai.py: not measured; the qwen27 cost is the window's page check one call earlier.Prompt speed before and after: n/a, the change does not reach prompt passes.
Licence of any new weights or drafter, or "n/a": n/a, none.
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 (fake backend and host pool, no device).
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: not measured on a device. Without a slot out of pages, every path runs as before.No precision traded for speed. No arithmetic changes.
Decode and prompt processing are no slower than main at one stream and the widest admitted: not measured.