Skip to content

Qwen3.8-27B serves concurrent requests: shared rounds across runner slots, DFlash2 for one stream, and tf-qwen27-bench - #578

Merged
ashhart merged 6 commits into
ashhart:mainfrom
BobClawblaw:qwen27-concurrent
Oct 11, 2026
Merged

ashhart merged 6 commits into
ashhart:mainfrom
BobClawblaw:qwen27-concurrent

Conversation

@BobClawblaw

Copy link
Copy Markdown
Contributor

The two things #520 and #528 asked to carry over to the 27B engine: concurrent streams, and tf-qwen35-bench as tf-qwen27-bench. (The small-projection fusions from #520 are already in the engine: z+b+a, k+v and gate+up are each one projection.)

What changes

  • The 27B moves to the lane host. A request alone runs the DFlash2 serial loop as before, as the lane host's lone driver. When another request arrives, the lone stream is handed to the lane core and every stream decodes in shared rounds, one runner slot each (the runner already batched up to 8 slots), up to --parallel, fewer when their caches do not fit.
  • One stream drafts at a time. The stream in slot 0 drafts DFlash2 trees, alone or in a shared round. In a shared round the core asks for drafts before the keep, so slot 0's kept rows reach the drafter from the verify's taps first. When slot 0's stream finishes, another stream's state moves there (one blit: DeltaNet states, K/V rows, taps ring) and drafts from its next round. Other streams verify copy proposals.
  • Sampled requests draft. Draws take the 2B's top-k preselection (qwen35.backend.draw, the same token as the full row), so a sampled request runs DFlash2 rounds too; the serial host decoded them plain.
  • Prompt reuse per slot. snapshot.zig saves, restores and moves any slot's state, and the drafter's committed taps become a Ring each slot keeps, so a kept state carries what a drafted request needs. The old drafter-based save and restore remain as wrappers.
  • Lane host, opt-in (lane_host.zig): decoded_rows passes each request's decode_spans to the cache and the backend, with the cache on or off, as the serial host's decode_chunk does; with info.warm_turns a prompt-only request prefills and keeps without drawing. Nemotron, GLM and the 2B set neither and are unchanged. A finished reply is kept for the next turn.
  • macOS 27.0.1 (separate commit): 1.0.3's 27B engine does not load on an M5 Ultra with macOS 27.0.1 (Metal 32023.921), LibraryLoad: get_destination_cooperative_tensor rejects an operand type that still carries thread. Two kernels (the prompt attention's products, the lane projection's reg fetch) pass the types through metal::remove_addrspace_t, as nax.h does. Types only.
  • tf-qwen27-streams: N streams alone (in a one-slot runner and in their slot of an N-slot runner), then together in shared rounds of 1-5-row windows with wrong last drafts dropped; every kept row's logits bytes and draw are compared with the stream alone.
  • tf-qwen27-bench: each projection shape at 1/8/16/32 rows on the shipped K split and the others, = where the bytes equal the shipped split's; the projections-only one-row step; shared rounds of 1/2/4/8 streams.

The serial host (qwen27_host.zig) stays in the tree: tf-qwen27-served-check, tf-qwen27-dflash-served-check and tf-qwen27-reuse drive it. They could move to the lane host in a follow-up if you prefer one host.

Checks

M5 Ultra, 256 GB, macOS 27.0.1, Zig 0.17.0, TensorFold/Qwen3.8-27B-MLX-4bit @ 22d8d538, z-lab/Qwen3.8-27B-DFlash2 @ 50307d4c, on f6dbc6f.

Exactness

  • tf-qwen27-streams: 4 streams, 188 rows; 8 streams, 504 rows; all equal.
  • tools/bench_concurrent.py --alone --serial, --parallel 8 --context 8192, 128 tokens, levels 1/2/4/8, greedy and sampled: 252 of 252 checks equal (each concurrent reply equals its run alone, each run alone equals "draft": false). Again after rebasing on f6dbc6f, 64 tokens, levels 1/4/8: 210 of 210.
  • tools/zig/reuse_served.py record (cache on) / replay (--prompt-cache-gib 0) / compare, --context 32768: every reply equal to the cache-off server, drafted equal to "draft": false on 23 of 23. The gate still prints 16 rows as not cached as planned. 14 are drafted turns that resumed further in than its plan, at the kept reply (prompt and reply, keyed by their decode spans), with equal tokens. 2 are scenario E, whose 34,260-token prompt exceeds the --context 32768 I ran.
  • tf-qwen27-lanes-check (synthetic), test-qwen27, zig build test: pass.

Speed (aggregate tok/s, 128 tokens, bench_concurrent.py):

1 stream 2 4 8
greedy, code 199 182 213 245
greedy, chat 142 141 160 196
sampled, code 142 187 192 250
sampled, chat 124 107 139 190

One stream, tools/bench_openai.py --tokens 256 --reps 3, against 1.0.3 with only the macOS fix:

1.0.3 + fix this PR
greedy, code 214 215
greedy, chat 144 144
sampled, code 28 225
sampled, chat 28 102

tf-qwen27-bench on this chip: plain shared rounds take 21.5 ms for one stream and 27.1 ms for eight (46.6 to 295 tok/s), so the served 8-stream greedy figure leaves about 15% in the lane core and slot 0's trees. The projections-only one-row step is 16.8 ms GPU over 321 calls. One finding for you rather than this PR: on an M5 Ultra other K splits than the M5 table's are much faster but change the bytes (down 54 to 31 µs at split 8, gdn_qkv 33 to 20 µs at split 4), so a per-chip table would be your call.

@ashhart ashhart mentioned this pull request Oct 10, 2026
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @BobClawblaw. A status update while the gate finishes. On an M3 Ultra, one stream gives the same tokens as main and runs as fast (greedy within about 1%). A sampled request now drafts, at 47 to 119 tokens a second instead of 20 to 21, with the same tokens for the same seed. Greedy drafted output equals "draft": false, 2, 4 and 8 streams at once equal their solo runs, and multi-turn conversations with deletes, edits and regenerations resume exactly. Still to run: sampled concurrency, the 8-stream tf-qwen27-streams check and the prompt-processing ladder.

One question for you: at the default --parallel the engine allocates and wires eight slots of the full context, 17 GB more than one stream needs at 32k, before a second request arrives. Could the slots past the first take their memory when they're first used?

@BobClawblaw

Copy link
Copy Markdown
Contributor Author

Thank you for running it on an M3 Ultra.

Yes. Almost all of the 17 GB is each extra slot's K/V rows. At 32k that is about 2 GB a slot across the 16 attention layers, plus its taps ring. The DeltaNet pool is small next to that. I'll make the runner allocate a slot's K/V buffers and taps ring the first time a stream is bound to that slot, and add them to the residency set then. Only slot 0 will be allocated and wired at open.

After that, a slot keeps its memory for reuse rather than being freed when it goes idle, so a burst of requests doesn't allocate and wire again each time. If the memory check fails when a slot is first used, the request waits for a slot that is already allocated, as it waits today when --parallel slots are full. --parallel will still cap the slot count, and the open-time fit check will only report what would fit. I'll push it to this PR, with tf-qwen27-streams and the concurrency checks run again.

@BobClawblaw

Copy link
Copy Markdown
Contributor Author

I pushed the change you asked about (90d2ab9), and rebased onto main, so the branch has moved under your gate run:

  • Rebase. The macOS commit is gone; main has jkuepker's identical fix(metal): the 27B's prompt attention and tf_lane_reg compile on macOS 27 #573. The lane-host commit now takes main's lookupRewind and logprob rows.
  • Slots past the first take their memory when first used. Runner.initReady allocates slot 0's K/V at open. A later slot gets its K/V rows and taps ring when a stream is first bound to it. The host checks the room beside the weights and the 8 GiB margin first, then adds the new buffers to the residency set. A slot keeps its memory once it has it.
  • Memory check. If a slot's memory doesn't fit yet, the backend returns error.LaneMemory. The lane host puts that request back at the head of the queue and admits nothing further until a running lane frees. A lane-host test on the fake covers it.

M5 Ultra, --parallel 8 at 32k with DFlash2: the footprint is 44 GB at open and 66 GB once all eight slots have run.

On this head, everything matches its reference:

  • tf-qwen27-streams with 8 streams: 376 rows equal.
  • bench_concurrent.py --alone --serial, levels 1/2/4/8, greedy and sampled, 128 tokens: 180 of 180 replies equal their runs alone, and 36 of 36 equal "draft": false. Speeds are as before.
  • zig build test passes.

@BobClawblaw
BobClawblaw force-pushed the qwen27-concurrent branch 2 times, most recently from 90d2ab9 to b68a432 Compare October 10, 2026 21:04
@BobClawblaw

Copy link
Copy Markdown
Contributor Author

The branch moved again: b68a432 is the same three commits rebased onto main 56150e6. One behaviour change beyond the rebase, so your gate run sees it:

  • Main's chunked prompt pass (feat(lanes): a prompt pass a chunk a round, between the other streams' rounds #623) is a second way a request enters the engine. A slot's memory is taken at its first chunk, so error.LaneMemory can now come from fillStream too. fillOne handles it the way admitOne does: the job's fill state is reset (unfill) and it goes back to the head of the queue, admitting no further lanes until a running one frees. A new lane_host_test case covers it; it fails without the change and passes with it.

Related: #639 (GLM's streams sharing one MLA pool) meets the same situation, a request with no room yet, before admission instead (Info.admit: the queue's head waits while it doesn't fit). If you'd rather have one mechanism in the lane host, either PR can be moved onto the other's.

… shared rounds on real weights

Session gains `slot` (0 by default, so every caller is unchanged). tf-qwen27-streams decodes N
streams of unequal prompts alone, in a one-slot runner and in their own slot of an N-slot runner,
then together in shared rounds whose windows run 1 to 5 rows with every other round's last draft
wrong, and compares every kept row's logits bytes and draw with the stream alone. On an M5 Ultra:
4 streams, 188 rows; 8 streams, 504 rows; all equal.
…d the drafter on slot 0 of a wider runner

The drafter's committed taps become a Ring (tap_ring.zig) that a lane can own too, so a slot's
kept state carries the taps a drafted request needs. snapshot.zig saves, restores and moves any
slot's DeltaNet states, K/V rows and ring; the old drafter-based save/restore stay as wrappers,
so the serial host and its tests are unchanged. Draft and Generation no longer require a one-slot
runner: their rounds already name slot 0.
…them

A family that prefills a reply's earlier rows with decode arithmetic, as the serial host's
decode_chunk does, sets LaneHost.decoded_rows: each request's decode_spans then key its cache
lookups and keeps and reach the backend on the stream, with the cache on or off, so a resumed
prompt and a fresh one compute the same rows the same way. With info.warm_turns also set, a
prompt-only request (max_tokens 0) prefills and keeps its state without drawing a token. Neither
is set by Nemotron, GLM or the 2B, which behave as before. engine_api exports cache_modes for a
family's reply keeps.
…lots, DFlash2 for one stream

The 27B moves from the serial host to the lane host. A request alone takes the DFlash2 serial loop
as before (the lone driver); when another arrives it is handed to the lane core, and every stream
decodes in shared rounds, one runner slot each, up to --parallel (8 by default, fewer when their
caches do not fit). The stream in slot 0 keeps drafting DFlash2 trees in shared rounds: its kept
rows reach the drafter from the verify's taps before the keep. When slot 0's stream finishes,
another stream's state moves there and drafts from its next round. Other streams verify copies.
Sampled requests draw from the top-k candidates first (the 2B's draw, the same token), so they
draft too. Prompt reuse and warm turns work per slot; a finished reply is kept for the next turn.

On an M5 Ultra (macOS 27.0.1), --parallel 8 --context 8192, tools/bench_concurrent.py --alone
--serial, 128 tokens: 252 of 252 checks equal (each concurrent reply equals its run alone, each
run alone equals "draft": false). Aggregate tok/s at 1/2/4/8 streams: greedy code 199/182/213/245,
greedy chat 142/141/160/196, sampled code 142/187/192/250, sampled chat 124/107/139/190.
…tions floor, and shared rounds by stream count

ashhart#528's tf-qwen35-bench for the 27B engine. Each projection shape of the checkpoint is timed at 1, 8,
16 and 32 rows on the shipped split and every other split the lane kernel takes, with '=' where
the bytes equal the shipped split's; then every projection of a one-row step in one command
buffer; then shared decode rounds of 1, 2, 4 and 8 streams, one row each, verified and kept as
the lane core does, with wall and verify-GPU ms a round.
The runner allocates slot 0's K/V rows at open and each later slot's when a
stream is first bound to it (Runner.initReady, ensure), with that slot's taps
ring. The served host checks the room beside the weights and the 8 GiB margin
first and adds the new buffers to the residency set. A slot keeps its memory
once taken. When a slot's memory does not fit yet, the backend says
error.LaneMemory and the lane host puts the request back at the head of the
queue, admitting no further lanes until a running one frees.

--parallel 8 at 32k on an M5 Ultra: 44 GB footprint at open, 66 GB once all
eight slots have run (before: every slot at open).
@ashhart
ashhart merged commit fa05ed5 into ashhart:main Oct 11, 2026
2 checks passed
@ashhart

ashhart commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thank you, @BobClawblaw. Concurrent requests for the 27B are in 1.0.6: merge a25965d16 brings in your six commits
under your name (headed by b68a4320a, your push on an older main), and fa05ed51f merges your rebased head
0a529286d, so the PR shows as merged.

We gated it on two M3 Ultras, where every stream runs in the lane core, and an M5 Max, where a lone greedy request runs
the DFlash2 serial loop and moves to the lane core when a second request arrives.

  • One stream gives main's tokens for every greedy prompt, at main's speed: greedy medians within 1.1% of main on the M5
    Max and equal or better on the M3 Ultra. A sampled request now drafts, with the same tokens as main for the same seed:
    57 to 191 tok/s on the M5 Max and 47 to 119 on the M3 Ultra, where main decodes 19 to 21.
  • Prompt processing matches main. On the M3 Ultra a cold prompt of 2k to 32k tokens takes within 1.3% of main's time,
    with the same time to first token. On the M5 Max, alternating runs with the chip cooled in between put the default
    --parallel within 2% of main at every length.
  • Shared rounds pay off. With eight short prompts at 256 tokens each, aggregate greedy throughput against main (which
    runs one reply at a time) is 1.03x, 1.25x and 1.68x at 2, 4 and 8 streams on the M5 Max, and 1.02x, 1.30x and 1.79x on
    an M3 Ultra. The last of eight requests starts in under 1.5 s instead of 20 to 33 s.
  • Drafted replies equal "draft": false 8/8, and 2, 4 and 8 streams at once equal their runs alone, greedy and sampled,
    at the defaults on the M3 Ultra (eight 32k slots) and with 8k slots on the M5 Max. tf-qwen27-streams with 8 streams
    gives 376 equal rows on both chips, your count.
  • On the M5 Max, a lone reply that moves to the lane core when a second request arrives (after its 16th, 48th or 96th
    streamed round) gives the tokens it gives alone, and so does the second request.
  • Three-turn conversations with a delete, an edit, a regenerate and a second edit, two of them at once, give the same
    bytes at every step with the cache on, with it off, and on main.
  • Slots past the first cost nothing until used: at the defaults the server is ready at 39 GB on the M3 Ultra (main 37)
    and 44 GB on the M5 Max (main 42). Thanks for turning that round so quickly.

Our follow-ups, each its own commit after your merge:

  • f189ba4 moves a slot's prompt pass, restore, hand-over and the lone loop into qwen27_slots.zig, since
    qwen27_lanes.zig had passed our 600-line limit, and makes the comments one line each.

  • 32b14f0 moves the lane host's status counts into lane_host_status.zig, for the same limit once your warm turns and
    memory requeue met feat(lanes): a prompt pass a chunk a round, between the other streams' rounds #623's chunked prompts.

  • ec17ded holds the residency set before the prompt cache sizes its default budget, and counts the memory the later
    slots take on first use as already taken, so a full cache and eight running streams stay under 70% of RAM together.
    The default cache is smaller for it: 28.8 GiB instead of main's 48.3 on a 128 GB M5 Max at 32k, and none at a 256k
    context unless --parallel is lowered. Tell us if you'd rather size it another way.

  • 2603780 makes an explicit --parallel N refuse to start when N slots don't fit, as GLM and the CUDA engine do, and
    names the --parallel that fits; --parallel auto still serves what fits. de1a92a adds "serve a smaller
    --parallel" to the prompt cache's refusal when the streams' memory is what leaves no room.

  • 924104e lets a warm pass step aside for real work. A request sent right after a reply waited behind that reply's
    warm pass: about 115 ms on the M5 Max, where main's serial host waits about 45 because it yields the pass after its
    first chunk. On the lane host the pass now asks before each chunk whether a request waits or a stream decodes; if so
    the cache keeps what it prefilled and the pass ends. The wait now equals main's at every gap we tried (0 to 1000 ms),
    and the warm passes no longer stall shared rounds, which is part of the 2-to-8-stream numbers above. A new lane host
    test has a request arrive during a warm pass.

Two things for later, no need to hold anything for them:

Thanks again!

jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
lane_host.zig was at 596 lines with ashhart#578 and ashhart#596 still to add; the lesson queue and its idle-only step are their own job. A move, with words() made public and the two lock wrappers inlined.
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
…nds across runner slots, DFlash2 for one stream, and tf-qwen27-bench

On the 1.0.6 candidate: the stream spec and the fake backend carry ashhart#596's grammar beside ashhart#578's decode spans and memory
lanes, and the lane host gives a stream both. ashhart#596 gave the 2B's draw a grammar mask; the 27B's lane backend passes none,
as it serves no structured output.

Thanks @BobClawblaw.
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
…its comments are one line each

qwen27_lanes.zig was 763 lines after ashhart#578. A stream's prompt into its slot, a slot's taps ring, restore, a slot's
memory on first use, a free slot, unbind, promote and the lone stream's serial loop move unchanged (their calls to
each other become direct calls), so it is 590 lines. Comments in the backend, the served host, tap_ring, lane_host
and the 27B bench are one line under 120 columns; keepReply has its own comment back, and lane_host's loneFits
comment is indented as zig fmt writes it.
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
lane_host.zig was 641 lines once ashhart#578's warm turns and memory requeue met ashhart#623's prompt chunks. The status read and
the two counters behind it (tokens delivered in the last 2 s, each live stream's tokens) move unchanged, so it is
592 lines. lean_check reports main's 542 problems.
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
plotarmordev pushed a commit to plotarmordev/TensorFold that referenced this pull request Oct 11, 2026
…hout tensor units, as in 1.0.5

ashhart#578's lane host gives every stream a copy proposer, and on an M1 to M4 a lone 27B request stays on the lane core, so copied text took the place of the drafter's tree in some rounds and landed less often: one or two more rounds per 256 code tokens, 138 against 146 tok/s on an M3 Ultra. Model.lone_copies (default on) lets a family keep copies to shared rounds; the 27B turns it off unless TF_QWEN27_COPIES=1, the 1.0.5 opt-in.
@BobClawblaw
BobClawblaw deleted the qwen27-concurrent branch October 11, 2026 20:35
BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
… alone

The lane backend counts, by a node's own log-probability under the drafter, the DFlash2 nodes offered with their
parent row kept and those the target drew there, and allocation trims each tree by the chances these give. Since
sampled requests draft (ashhart#578), their rounds went into the same counts, which never forget, so a greedy request read
the sampled ones' history too. On an M3 Ultra, the release gate's second greedy code reply after two drafted sampled
prose replies took 33 rounds instead of 26 (146.4 against 159.8 tok/s), with the same tokens. The counts move to
qwen27_landing.zig as two tables, greedy rounds' and every round's: a greedy stream's chances read the first and a
sampled stream's the second, which is the table it read before. With the depth rule's greedy twins, the gate order's
greedy code replies decode as in the greedy-only order (34 and 26 rounds, 143.9 and 159.7 tok/s) and the sampled
ones as before (123.5 and 123.9).
BobClawblaw added a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
… alive goes

tf-qwen27-served-check, tf-qwen27-dflash-served-check, tf-qwen27-reuse and
tf-qwen27-lanes-* built against qwen27_host.zig, which stopped serving when ashhart#578
put the 27B on the lane host. They now build against qwen27_served.zig, the host
the server opens. Its `open` loads a checkpoint and calls a new `attach`, which
serves a model already in memory (and a drafter bound to it), so the synthetic
checks run the same code as a served request.

The checks keep their contracts where the served host keeps them:
- served: 8 greedy tokens equal the direct session after a chunked prompt.
- dflash-served: drafted, EOS, plain, sampled, custom-stop, BF16 and prepared-q4
  requests give the CLI's tokens and final state, on the serial loop and with
  TF_QWEN27_LANES=1. Sampled and custom-stop requests draft now (ashhart#578), so only
  "draft": false must report no drafts. A cancel lands at the end of a round: the
  reply is a prefix of the expected one and the state is the CLI's at its length.
  The round-callback section and the zero-token request tested the serial
  host's batch delivery, which nothing serves any more; reuse covers prompt-only
  passes, which are warm passes on the served host.
- reuse: the fresh run turns off both the store and the backend's reply keep.

qwen27_host.zig and qwen27_lane_decode.zig had no other users and are removed,
with the drafter's batch delivery, which only they called.

On an M5 Ultra: the three synthetic checks pass (dflash-served on both paths),
tf-qwen27-reuse on Qwen3.8-27B MLX-4bit with DFlash2 passes 9 of 9 by default
and with TF_QWEN27_LANES=1, and tf-qwen27-lanes-run gives equal tokens (2 of 2).
kinetick-labs pushed a commit to kinetick-labs/TensorFold that referenced this pull request Oct 12, 2026
… alive goes

tf-qwen27-served-check, tf-qwen27-dflash-served-check, tf-qwen27-reuse and
tf-qwen27-lanes-* built against qwen27_host.zig, which stopped serving when ashhart#578
put the 27B on the lane host. They now build against qwen27_served.zig, the host
the server opens. Its `open` loads a checkpoint and calls a new `attach`, which
serves a model already in memory (and a drafter bound to it), so the synthetic
checks run the same code as a served request.

The checks keep their contracts where the served host keeps them:
- served: 8 greedy tokens equal the direct session after a chunked prompt.
- dflash-served: drafted, EOS, plain, sampled, custom-stop, BF16 and prepared-q4
  requests give the CLI's tokens and final state, on the serial loop and with
  TF_QWEN27_LANES=1. Sampled and custom-stop requests draft now (ashhart#578), so only
  "draft": false must report no drafts. A cancel lands at the end of a round: the
  reply is a prefix of the expected one and the state is the CLI's at its length.
  The round-callback section and the zero-token request tested the serial
  host's batch delivery, which nothing serves any more; reuse covers prompt-only
  passes, which are warm passes on the served host.
- reuse: the fresh run turns off both the store and the backend's reply keep.

qwen27_host.zig and qwen27_lane_decode.zig had no other users and are removed,
with the drafter's batch delivery, which only they called.

On an M5 Ultra: the three synthetic checks pass (dflash-served on both paths),
tf-qwen27-reuse on Qwen3.8-27B MLX-4bit with DFlash2 passes 9 of 9 by default
and with TF_QWEN27_LANES=1, and tf-qwen27-lanes-run gives equal tokens (2 of 2).
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
lane_host.zig was at 596 lines with ashhart#578 and ashhart#596 still to add; the lesson queue and its idle-only step are their own job. A move, with words() made public and the two lock wrappers inlined.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…nds across runner slots, DFlash2 for one stream, and tf-qwen27-bench

On the 1.0.6 candidate: the stream spec and the fake backend carry ashhart#596's grammar beside ashhart#578's decode spans and memory
lanes, and the lane host gives a stream both. ashhart#596 gave the 2B's draw a grammar mask; the 27B's lane backend passes none,
as it serves no structured output.

Thanks @BobClawblaw.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…its comments are one line each

qwen27_lanes.zig was 763 lines after ashhart#578. A stream's prompt into its slot, a slot's taps ring, restore, a slot's
memory on first use, a free slot, unbind, promote and the lone stream's serial loop move unchanged (their calls to
each other become direct calls), so it is 590 lines. Comments in the backend, the served host, tap_ring, lane_host
and the 27B bench are one line under 120 columns; keepReply has its own comment back, and lane_host's loneFits
comment is indented as zig fmt writes it.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
lane_host.zig was 641 lines once ashhart#578's warm turns and memory requeue met ashhart#623's prompt chunks. The status read and
the two counters behind it (tokens delivered in the last 2 s, each live stream's tokens) move unchanged, so it is
592 lines. lean_check reports main's 542 problems.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
The author rebased ashhart#578 onto main after our merge; this keeps the PR's current head in the history with no change to the tree.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…hout tensor units, as in 1.0.5

ashhart#578's lane host gives every stream a copy proposer, and on an M1 to M4 a lone 27B request stays on the lane core, so copied text took the place of the drafter's tree in some rounds and landed less often: one or two more rounds per 256 code tokens, 138 against 146 tok/s on an M3 Ultra. Model.lone_copies (default on) lets a family keep copies to shared rounds; the 27B turns it off unless TF_QWEN27_COPIES=1, the 1.0.5 opt-in.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… alone

The lane backend counts, by a node's own log-probability under the drafter, the DFlash2 nodes offered with their
parent row kept and those the target drew there, and allocation trims each tree by the chances these give. Since
sampled requests draft (ashhart#578), their rounds went into the same counts, which never forget, so a greedy request read
the sampled ones' history too. On an M3 Ultra, the release gate's second greedy code reply after two drafted sampled
prose replies took 33 rounds instead of 26 (146.4 against 159.8 tok/s), with the same tokens. The counts move to
qwen27_landing.zig as two tables, greedy rounds' and every round's: a greedy stream's chances read the first and a
sampled stream's the second, which is the table it read before. With the depth rule's greedy twins, the gate order's
greedy code replies decode as in the greedy-only order (34 and 26 rounds, 143.9 and 159.7 tok/s) and the sampled
ones as before (123.5 and 123.9).
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… alive goes

tf-qwen27-served-check, tf-qwen27-dflash-served-check, tf-qwen27-reuse and
tf-qwen27-lanes-* built against qwen27_host.zig, which stopped serving when ashhart#578
put the 27B on the lane host. They now build against qwen27_served.zig, the host
the server opens. Its `open` loads a checkpoint and calls a new `attach`, which
serves a model already in memory (and a drafter bound to it), so the synthetic
checks run the same code as a served request.

The checks keep their contracts where the served host keeps them:
- served: 8 greedy tokens equal the direct session after a chunked prompt.
- dflash-served: drafted, EOS, plain, sampled, custom-stop, BF16 and prepared-q4
  requests give the CLI's tokens and final state, on the serial loop and with
  TF_QWEN27_LANES=1. Sampled and custom-stop requests draft now (ashhart#578), so only
  "draft": false must report no drafts. A cancel lands at the end of a round: the
  reply is a prefix of the expected one and the state is the CLI's at its length.
  The round-callback section and the zero-token request tested the serial
  host's batch delivery, which nothing serves any more; reuse covers prompt-only
  passes, which are warm passes on the served host.
- reuse: the fresh run turns off both the store and the backend's reply keep.

qwen27_host.zig and qwen27_lane_decode.zig had no other users and are removed,
with the drafter's batch delivery, which only they called.

On an M5 Ultra: the three synthetic checks pass (dflash-served on both paths),
tf-qwen27-reuse on Qwen3.8-27B MLX-4bit with DFlash2 passes 9 of 9 by default
and with TF_QWEN27_LANES=1, and tf-qwen27-lanes-run gives equal tokens (2 of 2).
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… alive goes

tf-qwen27-served-check, tf-qwen27-dflash-served-check, tf-qwen27-reuse and
tf-qwen27-lanes-* built against qwen27_host.zig, which stopped serving when ashhart#578
put the 27B on the lane host. They now build against qwen27_served.zig, the host
the server opens. Its `open` loads a checkpoint and calls a new `attach`, which
serves a model already in memory (and a drafter bound to it), so the synthetic
checks run the same code as a served request.

The checks keep their contracts where the served host keeps them:
- served: 8 greedy tokens equal the direct session after a chunked prompt.
- dflash-served: drafted, EOS, plain, sampled, custom-stop, BF16 and prepared-q4
  requests give the CLI's tokens and final state, on the serial loop and with
  TF_QWEN27_LANES=1. Sampled and custom-stop requests draft now (ashhart#578), so only
  "draft": false must report no drafts. A cancel lands at the end of a round: the
  reply is a prefix of the expected one and the state is the CLI's at its length.
  The round-callback section and the zero-token request tested the serial
  host's batch delivery, which nothing serves any more; reuse covers prompt-only
  passes, which are warm passes on the served host.
- reuse: the fresh run turns off both the store and the backend's reply keep.

qwen27_host.zig and qwen27_lane_decode.zig had no other users and are removed,
with the drafter's batch delivery, which only they called.

On an M5 Ultra: the three synthetic checks pass (dflash-served on both paths),
tf-qwen27-reuse on Qwen3.8-27B MLX-4bit with DFlash2 passes 9 of 9 by default
and with TF_QWEN27_LANES=1, and tf-qwen27-lanes-run gives equal tokens (2 of 2).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants