Skip to content

The 27B's checks drive the served host, and the serial host they kept alive goes - #659

Merged
ashhart merged 1 commit into
ashhart:mainfrom
BobClawblaw:qwen27-checks-served
Oct 12, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
BobClawblaw:qwen27-checks-served

Conversation

@BobClawblaw

Copy link
Copy Markdown
Contributor

The follow-up from #578's merge: tf-qwen27-reuse, the served checks and tf-qwen27-lanes-* still built against qwen27_host.zig, which no longer serves. They now build against qwen27_served.zig, the host the server opens, so they test what ships.

The change

  • qwen27_served.open loads the checkpoint and calls a new attach, which serves a model already in memory, with an optional drafter bound to it. The synthetic checks use attach, so they run the same code as a served request.
  • qwen27_host.zig and qwen27_lane_decode.zig had no other users and are removed, with the drafter's batch delivery that only they called. 67 lines in, 396 out.
  • lanes_check and lanes_run only change their import: qwen27_served exports the lane backend as the old host did.

What the checks hold now

The contracts stay where the served host keeps them. Three changed with what the served host does:

  • Sampled and custom-stop requests draft since Qwen3.8-27B serves concurrent requests: shared rounds across runner slots, DFlash2 for one stream, and tf-qwen27-bench #578, so only a "draft": false request must report no drafts. All three still give the CLI's tokens and state.
  • A cancel lands at the end of a round. The old host delivered the first token alone, so a cancel after one token stopped exactly there. Now the check is that the reply is a prefix of the expected one, at least as long as where the cancel was sent, and the state is the CLI's at that length.
  • The round-callback section and the zero-token request are gone. They tested the serial host's batch delivery, which nothing serves. On the served host a prompt-only request is the cache's warm pass, which tf-qwen27-reuse covers.

In tf-qwen27-reuse, the fresh run turns off both the store and the backend's reply keep, so a cache-off run can't leave a state a later turn resumes from.

Measured

On an M5 Ultra:

check result
tf-qwen27-served-check pass
tf-qwen27-dflash-served-check pass, default and TF_QWEN27_LANES=1
tf-qwen27-lanes-check pass
tf-qwen27-reuse, Qwen3.8-27B MLX-4bit + DFlash2 (q4) 9 of 9, default and TF_QWEN27_LANES=1
tf-qwen27-lanes-run, same weights, 256 tokens equal tokens 2 of 2, serial 89 tok/s, lanes 90 tok/s

zig build test, test-native, test-qwen27 and zig build native pass.

Found on the way, not changed

lanes.Metal.measure times the drafter's windows on a build's first start: a 192-token prefill, then about 260 timed windows that each keep a row. So that first start needs a context of about 450 tokens or more. A server started with --drafter and a small --context (256, say) fails with BadRoundPlan until the costs are cached. The drafted check hit it at its old 384-token context, so it now uses 1024. Measuring at a fixed position, or re-prefilling when the slot fills, would fix it. Would you like that as its own PR?

… 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).
@ashhart
ashhart merged commit 22840f8 into ashhart:main Oct 12, 2026
2 checks passed
@ashhart

ashhart commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Thank you, @BobClawblaw. These checks had been testing a host nothing serves since #578, and now they test the one that ships. Each of the three contracts you changed follows what the served host does, and your description says why for each. Your commit 611b15d86 landed in 1.0.8 under your name, so GitHub shows this PR as merged. We rebased it onto our 1.0.8 work, which by then gave each 27B slot 16 rows past --context. The only conflict was the slot-cost line in qwen27_served.zig, where we kept both changes.

What we ran, Qwen3.8-27B MLX 4-bit with DFlash2 (q4), on an M3 Ultra (no tensor units, so drafted requests run on the lane core) and an M5 Max (tensor units, so a lone greedy request takes the serial loop unless TF_QWEN27_LANES=1):

  • tf-qwen27-served-check, tf-qwen27-lanes-check: pass on both.
  • tf-qwen27-dflash-served-check: passes on both, default and TF_QWEN27_LANES=1, each run from an empty cost cache. On the M5's serial loop the served rounds equal the command line's (7 and 7, 26 drafts matched in both branches). On the lane core the rounds can differ while tokens and state match, as your lanesMode rule allows. For comparison, the old check fails on the build before yours at its cancel cases on the lane core (both modes on the M3 Ultra, TF_QWEN27_LANES=1 on the M5 Max), because a cancel now lands at a round's end. That is the contract you changed.
  • tf-qwen27-reuse (the 8,192-token prompt, 64-token replies): 9 of 9 on the M3 Ultra in both modes and on the M5's serial loop. On the M5 Max with TF_QWEN27_LANES=1 it failed one case three runs out of three: "drafted 2600: turn 2's reply" resumed in 12 rounds with 51 drafts accepted against the fresh reply's 13 and 50, with the same tokens and final state. The build before yours fails it the same way through the old host. On the lane core a reply's trees are sized from the server's history (how often drafted nodes landed, and round times), and that fresh reply was the server's first drafted reply. A fourth run on the same machine gave 14 and 49 for both. So on the lane core the check now compares tokens, final state, finish reason and the resume point, and leaves rounds to the serial loop, the same rule your drafted check uses. With that it passes 9 of 9 everywhere.
  • tf-qwen27-lanes-run (a 2,048-token prompt, 256 tokens, two repeats): equal tokens 2 of 2 on both. On the M3 Ultra the lane core ran at 41.1 tok/s against the serial loop's 32.6.
  • The served server itself: the 17 release prompts give the same tokens as the build before, drafted equal to "draft": false, on both chips.

Three changes on our side, in commits after yours. With qwen27_lane_decode.zig gone, the 27B backend's attach and the lane core's adoptPrefilled had no caller left, so they went too. With #661 in the same release, the drafted check starts at a 256-token context rather than 1024, so a new build's first run of it goes through the timing refill #661 adds. And the reuse check compares rounds on the serial loop only, as above.

BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
…adoptPrefilled)

Only qwen27_lane_decode.zig, which ashhart#659 removes, handed a stream prefilled by another driver to the lane core. Nothing else calls the 27B backend's attach or the lane core's adoptPrefilled, on this branch or any other local one.
BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
…ashhart#661 lets start

ashhart#659 raised the check's context from 384 to 1024 because a new build's first start with a drafter could not time its windows in a small context. With ashhart#661 the timing refills its slot, so the check now starts at 256, where every first start refills it, and fails if that path breaks.
BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
tf-qwen27-reuse asks a resumed reply for the fresh reply's tokens, final state, rounds and accepted drafts. On the lane core (TF_QWEN27_LANES=1, or a Mac without tensor units) a drafted reply's trees are sized from the landing counts of every reply the server has drafted, so the first case's fresh reply, the server's first, drafts from empty counts and its resumed twin from two replies' worth. On an M5 Max with TF_QWEN27_LANES=1 that case resumed in 12 rounds with 51 drafts accepted against the fresh 13 and 50, every run, with the same tokens and final state; the build before ashhart#659 fails it the same way through the old host. The serial loop's rounds depend only on the drafter's and the target's state, which a resume restores, so that comparison stays there, as dflash_served already does for rounds.
BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
…e served host (ashhart#659) and Nemotron's masked CUDA windows replaying graphs (ashhart#660)
BobClawblaw pushed a commit to BobClawblaw/TensorFold that referenced this pull request Oct 12, 2026
core/serial_host.zig served one request at a time through a driver of callbacks. Its last engine was the 27B's
single-stream host, qwen27_host.zig, which no server had opened since 1.0.6 and ashhart#659 removed with the drafter's
batch path, so only its own tests used it. It goes with them: serial_host_test.zig, serial_batch_test.zig and
cache_mode_host_test.zig, 1,113 lines in all and 20 tests, every one in the binary rooted at engine_api.zig. No
build step, tool or doc named it, and its choose()/Logits sampling helper had no caller either. cache_modes keeps
its callers: Engine.submit validates spans and the 27B's host keeps reply states.

Three mentions follow it: the rewind test's comment names the 27B's host, the 27B's slot prefill comment drops its
pointer to the serial host's rule, and ashhart#658's CHANGELOG line compares with Qwen's draws alone.
@ashhart ashhart mentioned this pull request Oct 14, 2026
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…adoptPrefilled)

Only qwen27_lane_decode.zig, which ashhart#659 removes, handed a stream prefilled by another driver to the lane core. Nothing else calls the 27B backend's attach or the lane core's adoptPrefilled, on this branch or any other local one.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…ashhart#661 lets start

ashhart#659 raised the check's context from 384 to 1024 because a new build's first start with a drafter could not time its windows in a small context. With ashhart#661 the timing refills its slot, so the check now starts at 256, where every first start refills it, and fails if that path breaks.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
tf-qwen27-reuse asks a resumed reply for the fresh reply's tokens, final state, rounds and accepted drafts. On the lane core (TF_QWEN27_LANES=1, or a Mac without tensor units) a drafted reply's trees are sized from the landing counts of every reply the server has drafted, so the first case's fresh reply, the server's first, drafts from empty counts and its resumed twin from two replies' worth. On an M5 Max with TF_QWEN27_LANES=1 that case resumed in 12 rounds with 51 drafts accepted against the fresh 13 and 50, every run, with the same tokens and final state; the build before ashhart#659 fails it the same way through the old host. The serial loop's rounds depend only on the drafter's and the target's state, which a resume restores, so that comparison stays there, as dflash_served already does for rounds.
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
ashhart#659 landed above as ab2aaff8e (the author's commit, rebased onto this candidate), with our d61ad4d3e, c6d5fbf02 and 7416e6bd5 after it. This keeps the PR's own head commit in the history, with no change to the tree.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…e served host (ashhart#659) and Nemotron's masked CUDA windows replaying graphs (ashhart#660)
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
core/serial_host.zig served one request at a time through a driver of callbacks. Its last engine was the 27B's
single-stream host, qwen27_host.zig, which no server had opened since 1.0.6 and ashhart#659 removed with the drafter's
batch path, so only its own tests used it. It goes with them: serial_host_test.zig, serial_batch_test.zig and
cache_mode_host_test.zig, 1,113 lines in all and 20 tests, every one in the binary rooted at engine_api.zig. No
build step, tool or doc named it, and its choose()/Logits sampling helper had no caller either. cache_modes keeps
its callers: Engine.submit validates spans and the 27B's host keeps reply states.

Three mentions follow it: the rewind test's comment names the 27B's host, the 27B's slot prefill comment drops its
pointer to the serial host's rule, and ashhart#658's CHANGELOG line compares with Qwen's draws alone.
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