Skip to content

feat(lanes): a prompt pass a chunk a round, between the other streams' rounds - #623

Merged
ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:core-lanes
Oct 10, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:core-lanes

Conversation

@BlivionIaG

Copy link
Copy Markdown
Contributor

What this changes

The lane core's chunked prompt rounds. This is the lane_host.zig shared-code slice tracked in #491. It doesn't depend on any HIP PR, and no backend uses it yet; the Qwen3.5 HIP engine will be the first.

  • Backend.VTable.prefill_step (optional): one chunk of the prompt pass, returning false while chunks remain. With it, LaneHost puts an admitted request in a filling queue and runs one chunk per loop, between the other streams' rounds. Streams already decoding keep their rounds through a long prompt instead of waiting for all of it. A cancel between chunks releases the lane.
  • Without prefill_step, nothing changes: the pass runs whole, as today.
  • The stream's opening (first token, first drafts) moves from engine.zig to lanes/open.zig. Both the whole pass and the chunked pass use it, and engine.zig stays under 600 lines. Engine.addStream is the same code as before.

Receipt

  • Environment: base main at bec00ae, head d7b134c. Zig 0.17.0, on macOS (Apple silicon) and Linux 7.1.7.
  • Exactness:
    • "a prompt pass a chunk a round between other streams' rounds gives the whole pass's tokens": on the fake target, two streams are filled a chunk a round, with rounds between the chunks. They emit exactly the tokens they emit when both are prefilled whole, greedy and sampled.
    • "a lane host fills prompts a chunk a round, serves their tokens, and cancels between chunks": two filling requests get the fake's exact tokens. A third is cancelled between chunks, gets no tokens, and its lane is freed.
    • Each test fails with the change broken: with the lane not released on a cancelled chunk, the host test fails (expected 0, found 1); with the stream opened before its last chunk, both tests fail.
  • Decode and prompt speed: not applicable (no backend gives prefill_step yet; the whole-pass path is unchanged).
  • Tests run:
    • macOS zig build test test-golden -Dcpu=apple_m1: 137/137 steps, 761/762 tests (1 skipped); golden 309/319 equal, 0 unexpected.
    • Linux zig build test: 37/37 steps, 372/372 tests.
    • zig fmt --check is clean on the changed files. On the whole tree it reports tokenizer.zig, native/cuda.zig and tests/moe_bench.zig, the same as main at bec00ae.
    • lean_check.py: 542 problems, the same as main.
  • Not run, and why: device runs (no backend calls it in this change).

Checklist

  • 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. (A chunked pass is held to the whole pass's tokens, with other streams' rounds between its chunks.)
  • No precision traded for speed.
  • Prompt processing is no slower than the last release. (Backends without prefill_step run the same path.)
  • The description says which platforms I ran and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

…' rounds

A backend may give `prefill_step`: one chunk of the prompt pass, false while chunks remain. The lane host then
queues an admitted request as filling and runs one chunk per loop, so streams already decoding keep their rounds
during a long prompt instead of waiting for it. A cancel between chunks releases the lane. Backends without
`prefill_step` run the pass whole, as before.

The stream's opening (first token, first drafts) moves from engine.zig to lanes/open.zig, shared by the whole
and the chunked pass; engine.zig stays under 600 lines. Exactness: on the fake target, two streams filled a
chunk a round with rounds between emit the same tokens, greedy and sampled, as both prefilled whole; the lane
host serves the fake's exact tokens for two filling requests and cancels one between chunks with its lane freed.
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @BlivionIaG. This is merged into main (1184cdb), your commit as it was, and it ships in 1.0.6. It's the hook we want for chunked prompts with lane batching: streams already decoding keep their rounds through a long prompt. We'll wire our own families to it.

We checked that the whole-pass path is unchanged. engine.zig's removed lines reappear verbatim in open.zig apart from the function headers, the Mac host gates pass (golden 309 of 319, no unexpected differences), and the Linux tests pass 398 of 398. On a GB10 with Nemotron against main: 29 of 29 served replies are equal, with drafted == plain and concurrent == solo 10 of 10 in each arm, the four release prompts keep their SHAs, and decode and cold prompts are within noise.

BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 10, 2026
… and model checks

The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
@ashhart ashhart mentioned this pull request Oct 10, 2026
jschmied pushed a commit to jschmied/TensorFold that referenced this pull request Oct 11, 2026
…loaded at runtime), masks in the lane core, enforced by Qwen3.5-2B on Metal

Thanks @BobClawblaw. Conflicts with ashhart#623 kept both (lane_host.zig's fillOne/unfill beside the constraint; addStream's two changes ported into lanes/open.zig: drawFirst for the first token, no pipelined first step under a grammar; both engine tests kept).
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.
ashhart pushed a commit that referenced this pull request Oct 16, 2026
… and model checks

The HIP branch's engine (#490) on #463's runtime and the kernel launches of #617 and #621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (#625), chunked prompts (#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
ashhart pushed a commit that referenced this pull request Oct 16, 2026
… and model checks

The HIP branch's engine (#490) on #463's runtime and the kernel launches of #617 and #621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (#625), chunked prompts (#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
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
…loaded at runtime), masks in the lane core, enforced by Qwen3.5-2B on Metal

Thanks @BobClawblaw. Conflicts with ashhart#623 kept both (lane_host.zig's fillOne/unfill beside the constraint; addStream's two changes ported into lanes/open.zig: drawFirst for the first token, no pipelined first step under a grammar; both engine tests kept).
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 added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… and model checks

The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… and model checks

The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
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