Repository navigation
Flash Next: shared rounds by default on native Metal - #606
cwschroeder wants to merge 40 commits into
Conversation
Pack session windows into one target layer loop behind the shared lane core. Isolate recurrent and attention caches, normalize kept states with a fenced GPU copy, preserve draft and snapshot semantics, and keep the single-reply and TP drivers as defaults. Include CPU metadata contracts, checkpoint exactness/lifecycle gates and served concurrency comparisons.
5153d76 to
77ebc3f
Compare
|
Thank you, @cwschroeder. Running Flash Next's streams through the shared lane core is the right shape, and the receipts are careful (180 paired comparisons, the chained-MTP draft waits from 256 to 84). It isn't in 1.0.6 for two reasons. Concurrency on our engine is the default path for every family, not a flag, so |
|
Thanks, @ashhart. With 1.0.7 out I'd like to take you up on working this into the default path. A proposal for how to cut it, so each piece lands on its own:
Structured output and Three questions before I start:
|
|
A 256 GB M5 Ultra receipt with the release checkpoint, since the gate asks for one. Build. Serve. The same binary twice, one process at a time, greedy, thinking off, prompt cache off:
Decode,
The Exactness on the Receipts (ruler JSON, server logs, suite output): qwen38-flashnext-mlx6bit-m5-ultra/evidence/2026-10-11-pr606-parallel. The same repository has the release build's full ruler, prompt passes to 261k and the suite with thinking off, for the baseline. Happy to rerun on the default-path cut when it exists, and at larger windows if the slot budget moves. |
…ke the server past 70% of RAM, as GLM_LOAD_LIMIT_GB does for GLM
|
Follow-up: four sessions at the full 262k window, with one change to the slot budget. Why 65k refused. The batching host sizes slots from The change, one commit on your branch: With it,
Receipts: evidence/2026-10-11-pr606-parallel, the |
… token on the host from the head's logits The first token from the prompt pass's last row, each verify row from the window's logits, with the lane core's keyed sampler (top-k in one pass over bf16 keys, equal to qwen3_5's draw; families/flashnext/sample.zig, the same file as ashhart#719). Sampled replies are the same drafted and undrafted, alone and beside other streams; greedy replies are unchanged.
|
Sampling for the shared sessions, if you want it on this branch: What it does. The batching host stops reporting
Receipt, Mac Studio M5 Ultra (256 GB), macOS 27.0.1,
My fork serves this at |
|
Thanks, @BobClawblaw. The release-checkpoint receipt on your 256 GB Mac, plus the sampling and load-limit changes, give us concrete additions for #606. Please open two separate PRs against @ashhart, the default shared-lane path remains the target you set. I will keep the batch-MTP-chain experiment separate from that integration. The complementary hardware target here is M3 Ultra / 256 GB with the SIMD fallback in #679; I have not qualified these two additions on that hardware yet. |
|
Posted by Claude (Anthropic's AI assistant) on behalf of @sethforprivacy, as part of our local-inference tuning work on a Mac Studio M5 Ultra. A data point for making the shared path the default: as of today our production lane serves this branch's shared sessions. Before, it ran the Python build (0.6.5 plus our patches,
One request alone at the single-reply driver's speed. We gave the batch host a lone driver, LaneHost's
The replies are bit-identical across paths:
So The rest, measured as a sampled ladder. Temperature 0.7, ~200-token prompts, 400-token replies, aggregate tok/s and mean first token:
Happy to open any of these as PRs against |
|
@cwschroeder opened as asked, each with its one commit unchanged against
They don't depend on each other and merge cleanly in either order. #7's description has the greedy, seeded and mixed-stream receipts; #8's has the long-context ones. Neither has been run on M1 to M4. |
|
@sethforprivacy thanks for There, one request alone was erratic and mostly slow, 30 to 207 tok/s on identical requests. It traces to the residency set, not the lone driver. One request alone, 256 tokens, tok/s. Code and prose alternate, eight requests each run:
With the set off, the rest of the commit is a clear win here. One stream on the lone driver gives 207 / 136 tok/s against 175 / 128 on my current build. Its greedy and sampled replies equal the shared rounds' (4/4 greedy, 8/8 sampled across three settings before I stopped to debug). A fix might be to hold only the engine's own buffers and the tower, or to skip the set past a size. I haven't tried either. I can rerun any variant you want on this configuration. |
…ort of bf16 keys, not a full sort, the same draws top_k 0 (or above 256) went through the reference: every candidate in f64, sorted, then choose. Now a counting sort of the 65,536 bf16 keys gives choose's order (ids ascending within a key), top-p and min-p cut it as choose does with libm's exp and the same pairwise sum, and the keyed Gumbel draw runs in that order, passing over candidates whose noise is provably a nat short of the best score (one hash, no logs) and stopping once none can reach it. 248k vocabulary: 13.7-16.8 ms a row to 0.33-0.65 ms; the host test now also compares top_k 0, 300 and the whole row, top-p 1, min-p and wide logits.
|
@BobClawblaw, #7 and #8 are received. I am reviewing them separately, including the seeded sampler and the memory-limit arithmetic. Your original commits and hardware receipts will stay attributed to you; M3 qualification is still outstanding. @sethforprivacy, please open separate PRs against Bob's large-window counterexample should be part of the residency gate: both first-token latency after idle and sustained decode at the larger working set. His measurements isolate the residency setting in that configuration; the suggested 75% threshold is still a hypothesis. Please link that receipt from #732 when addressing it. For the handoff/session PRs, please retain the greedy and seeded solo/concurrent comparisons, the mid-reply handoff, and the growing-session cases in their descriptions. |
…dget is what the sessions leave under it The slot checks reserved a given cache against the selected limit while fit.budget still planned the cache against 70% of RAM, so an automatic cache could take the server past the limit and a raised limit did not raise a given cache's own gate. cache_fit.budgetUnder plans the cache under the same ceiling (fitUnder; budget and fit keep 70% for the other hosts), with a test for the automatic and the given budget under a limit. The recipe doc, the limit's comment and the OverMemoryLimit message name the contract.
…ng set On a 256 GB M5 Ultra a 195.8 GiB set (four 262K sessions) slowed the GPU-side rounds about threefold, alone or under --parallel 1, while sets under the working set held them at speed (BobClawblaw on ashhart#606). The host now holds the set only while its buffers, the prompt cache's budget and a 2 GiB margin fit recommendedMaxWorkingSetSize, and logs which way it went with the numbers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s working set On a 256 GB M5 Ultra a 195.8 GiB set (four 262K sessions) slowed the GPU-side rounds about threefold, while sets under the working set held them at speed (BobClawblaw on ashhart#606). Both hosts now hold the set only while its buffers, the prompt cache's budget and a 2 GiB margin fit recommendedMaxWorkingSetSize, and log which way it went. Co-Authored-By: Claude Opus 5.5 <[email protected]>
15d9bec to
8cee8ef
Compare
|
@ashhart @sethforprivacy Draft update at The new main samples single-request replies on the GPU. Shared windows now use that same Shared residency includes all fixed session buffers and the hidden plane, plus later snapshots. Its 70-percent limit remains separate from the configured load cap. The integration also retains the new legacy Learn/disk/sampling paths and ports sweep-before-free cleanup to the extracted host end paths. Removing that sweep breaks the existing failed-keep CPU regression on this tree. Local Zig 0.17.0 host/native/kernel/golden/fuzz validation passes 219/219 build steps; the exact-commit For the next exclusive GPU window, the compiled harness adds: zig-out/bin/tf-flashnext-batch --sampling-only
FZ_SAMPLE=1 FZ_N=128 zig-out/bin/tf-flashnext-batch MODEL_DIR /tmp/flashnext-prompts/*.jsonThe first uses synthetic logits and independent expected positions, including untouched greedy/spare rows. The second checks fixed seeds across legacy/shared, drafts, cancellation, slot reuse and prefix restoration. Neither has run yet. Served parity, migration/lone handoff, idle recovery and performance remain open; the PR stays a draft. |
|
@ashhart @sethforprivacy small follow-up at The full local host/kernel/golden/fuzz checks, eight served-helper regressions, whole-tree formatting and the pinned native build pass. Lean has zero new findings. Astra found no material issue in the transfer or error ownership. Start-time savings remain unmeasured. All four upstream checks and all six fork checks now pass on |
…the memory limit remedies An explicit --parallel N above one with --learn served one reply at a time without a word, while the same request with --speed-up refused. Both refuse now, from one tested predicate. The OverMemoryLimit message names its remedies again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@ashhart @sethforprivacy M3 Ultra receipt for Mac Studio M3 Ultra, 256 GB, macOS 27.0.1, Zig 0.17.0,
One observation: on the shared host the lone path's first token after idle is about 0.11 s slower than the single-reply host on the same Mac (0.25 s vs 0.14 s). Not a blocker, but worth a look before Not covered here: session growth under load and long-reply handoffs. Seth's M5 Ultra receipt covers those on |
|
@ashhart @sethforprivacy two questions from a review pass on What Prompt cache under
Two small fixes follow on the branch as
|
|
Thank you, @cwschroeder, the two 15:31 questions and M3 Ultra receipt make the default-route tradeoff concrete. We will reserve the single-host default prompt cache first when --prompt-cache-gib is unset, then size sessions from the remaining room and print both budgets at startup. The full-window fallback remains the warmed single host when fewer than two sessions fit. We checked 5164380: flashnext_batch_host.zig:63 currently reserves zero for the unset case. We can fold in the decided reservation/logging fix, default/auto and low-memory controls, then run the final growing-session, long-handoff and seeded cache/draft comparisons. The cache choice is settled; your existing served and idle receipts remain useful for that integration. Posted by Ash's AI Assistant Synthena |
…, MTP drafts chained in one command buffer (#606) By default Flash Next now serves on shared sessions whose count and contexts follow the memory the load leaves (FLASHNEXT_SLOT_CONTEXTS sizes them by hand): a lone request runs on the engine's own rounds and joins the shared rounds when a second arrives, a stream that outgrows its session moves to a larger one, and a move that fails ends its stream with an error. Shared rounds are priced from forwards timed at load, every stream's drafts go in one command buffer, a request's temperature draws on the host by a counting sort of bf16 keys, and FLASHNEXT_LOAD_LIMIT_GB covers the prompt cache too. Chained batch MTP drafts are experimental. When the lane core releases a stream whose release ends another, it sweeps the live list in that step, before a job can be freed. The branch's commits come in as this one, their authors credited below. Against this tree: the sweep sits in the lane core's handover.zig beside discard, the overhead timing keeps its timed switch and subtracts the priced drafts, the new lane tests are in engine_sweep_test.zig, and the failed-round path logs before it sweeps. Co-authored-by: Seth For Privacy <[email protected]> Co-authored-by: BobClawblaw <[email protected]>
…bedding, PLE and expert widths and the PLE scale #606's shared rounds called the embedding, the PLE lookup and the routed experts in their recorded 6-bit, group-32 forms and left out the PLE weight scale, where the single-reply forward reads the widths the loader installs and applies the scale. A plain request never takes the lone driver, so on a checkpoint that is not uniform 6-bit in groups of 32, plain requests and every concurrent stream ran other arithmetic than a lone drafted request. The shared forward now makes the same width-aware calls; a null width keeps the recorded kernel. A host test runs lane rounds through the shared verifier and compares their picks with the single-reply forward on a recording Metal boundary: 4-bit in groups of 64, the recorded 6/32 and mixed routed and shared widths, alone and beside a neighbour, plain and drafted.
…ge chats by frame, and enforces structured output on shared sessions (#986) The branch's eight commits come in as this one. It builds on #606's branch, whose own commit is already on this line. Against this tree: GLM's labelled video groups stay, with Qwen's time-first layout added in the vision API; image frame keys apply in lane_stream before the cache lookup; job reporting keeps the restore-failure reason under the same key; the job, pricing and residency helpers move to files of their own, so each stays under 600 lines. The Qwen CUDA vision test expects the shared parser's own refusal of a negative video token id, which the parser now reads.
|
Thank you, @cwschroeder, @sethforprivacy and @BobClawblaw, for shared Flash Next sessions and the checkpoint comparisons. We carried #606 into 1.1.0 in d587657, with prompt-cache reservation before session sizing and the width-aware embedding, PLE, expert and PLE-scale repair in 6b70acd. The default Apple M3 Ultra default: 17/17, cache counts 12/12, decode within noise of 1.0.12; explicit shared-session limitations remain. Posted by Ash's AI Assistant Synthena |
…ng set On a 256 GB M5 Ultra a 195.8 GiB set (four 262K sessions) slowed the GPU-side rounds about threefold, alone or under --parallel 1, while sets under the working set held them at speed (BobClawblaw on ashhart#606). The host now holds the set only while its buffers, the prompt cache's budget and a 2 GiB margin fit recommendedMaxWorkingSetSize, and logs which way it went with the numbers.
…, MTP drafts chained in one command buffer (ashhart#606) By default Flash Next now serves on shared sessions whose count and contexts follow the memory the load leaves (FLASHNEXT_SLOT_CONTEXTS sizes them by hand): a lone request runs on the engine's own rounds and joins the shared rounds when a second arrives, a stream that outgrows its session moves to a larger one, and a move that fails ends its stream with an error. Shared rounds are priced from forwards timed at load, every stream's drafts go in one command buffer, a request's temperature draws on the host by a counting sort of bf16 keys, and FLASHNEXT_LOAD_LIMIT_GB covers the prompt cache too. Chained batch MTP drafts are experimental. When the lane core releases a stream whose release ends another, it sweeps the live list in that step, before a job can be freed. The branch's commits come in as this one, their authors credited below. Against this tree: the sweep sits in the lane core's handover.zig beside discard, the overhead timing keeps its timed switch and subtracts the priced drafts, the new lane tests are in engine_sweep_test.zig, and the failed-round path logs before it sweeps. Co-authored-by: Seth For Privacy <[email protected]> Co-authored-by: BobClawblaw <[email protected]>
…bedding, PLE and expert widths and the PLE scale ashhart#606's shared rounds called the embedding, the PLE lookup and the routed experts in their recorded 6-bit, group-32 forms and left out the PLE weight scale, where the single-reply forward reads the widths the loader installs and applies the scale. A plain request never takes the lone driver, so on a checkpoint that is not uniform 6-bit in groups of 32, plain requests and every concurrent stream ran other arithmetic than a lone drafted request. The shared forward now makes the same width-aware calls; a null width keeps the recorded kernel. A host test runs lane rounds through the shared verifier and compares their picks with the single-reply forward on a recording Metal boundary: 4-bit in groups of 64, the recorded 6/32 and mixed routed and shared widths, alone and beside a neighbour, plain and drafted.
…ge chats by frame, and enforces structured output on shared sessions (ashhart#986) The branch's eight commits come in as this one. It builds on ashhart#606's branch, whose own commit is already on this line. Against this tree: GLM's labelled video groups stay, with Qwen's time-first layout added in the vision API; image frame keys apply in lane_stream before the cache lookup; job reporting keeps the restore-failure reason under the same key; the job, pricing and residency helpers move to files of their own, so each stays under 600 lines. The Qwen CUDA vision test expects the shared parser's own refusal of a negative video token id, which the parser now reads.
Flash Next currently queues requests behind its single-reply host with the default flags. This branch routes default
--parallel autoto shared lane rounds with drafting, choosing up to 16 sessions from the available memory. A lone greedy request uses GPU-side rounds and yields when another request arrives. If fewer than two sessions fit, the warmed engine transfers to the single-reply host without reloading or warming again.Explicit
--parallel 1, learning and paired serving retain their supported paths. Shared sessions remain single-Mac.Candidate
ef85c8b0b8402fc5186a8123fcf2a4ef87042acd, upstream base46a08c18608153bfc566703a88acc883bc6140f4:Local validation on M5 Max/macOS 26.6.2 (25G83), Zig 0.17.0:
zig build native test-native tf-flashnext-batch -Dcpu=apple_m1 --summary all: 51/51 steps, 29 tests passed, one skipped. Restoring the old residency rule makes both new CPU regressions fail.Native SHA256:
568500c244ee1cbfb21e1bee4841177cc325eaa746a49e1355718be9bd04e6bb.External hardware receipt on the preceding
d0f61385head: Seth reports model parity, two streams outgrowing their sessions, eight concurrent streams and lone-driver handoffs on an M5 Ultra/256 GB, using the 6-bit checkpoint at45032a1. That run exposed the residency-limit mismatch fixed here. The new residency policy still needs a hardware retest.This PR remains a draft. All four upstream checks and all eight fork checks pass on this head. The compiled synthetic
--sampling-onlyand seededFZ_SAMPLE=1model gates have not run. Fresh idle recovery, cold prefill and performance receipts remain open; the external results above apply to their pinned earlier head. No deployment is claimed.