Repository navigation
server: one step's sequences sample at once on lanes (528.6 -> 123.2 us/step at six minds, same tokens); the server is C++20 - #125
Conversation
…us per step at six minds, same tokens); the server is C++20 Every sequence a decode step produced was sampled one after another on the main thread while the GPU waited for the next submit. Each slot's sampler is its own state, so they need not wait on each other. - common_sampler_row: one output row's pointers, gathered by the thread that owns the context (one synchronize). common_sampler_sample_row / _and_accept_rows read only the sampler and the row, never the context; common_sampler_sample(ctx, idx) is gather + sample_row, so there is one path. - presample(): at the head of post_decode it finds every slot this view samples (plain or the MTP verify, the same predicate as the loops), gathers rows, and samples and accepts all of them at once on the lanes; the loops then emit in slot order exactly as before (an assert keeps the predicate in step). A sampling error is carried to its own slot's step, as the serial path raised it. - server_lanes (server-lanes.h): claims are lock-free from one (run id << 32 | index) word, so a lane finishing an earlier run can never claim in a new one; each lane has its own wake word, and a run wakes only as many lanes as it has jobs beyond the caller's (atomic notify: a futex, not a mutex and condition variable); the caller runs jobs and never sleeps; idle lanes burn nothing; on macOS lanes run at user-interactive QoS (performance cores). Lanes = min(slots - 1, cores the OS reports - 1). - The server targets C++20 (atomic wait/notify); u8path, deprecated in C++20, becomes a char8_t path. Receipts (qwen35-0.8b, M5, 2026-11-16): test-server-lanes: every job runs once at 1..1000 jobs, a job's exception reaches the caller; one decode of six sequences, 400 reps alternating order: serial 528.6 us/step, laned 123.2 us/step (4.29x), the same token every rep. Six concurrent MTP streams at temperature 0: text identical to the serial build on every stream. End-to-end tok/s on the M5 is not a receipt here: the live residents share the GPU, and serial runs alone ranged 72-219 tok/s. 0 warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…en, the exact path); a row is sampled without the context Codex's review of #122: `while (n < cap)` never ended when fewer than cap logits are not NaN (NaN never compares at or above any threshold, even -inf), so an all-NaN or mostly-NaN model output wedged the slot. Now, once the threshold reaches -inf with fewer than cap candidates, every non-NaN logit is already in: coarse_candidates reports that and the step samples the full array, which is the exact path itself, so NaN input behaves exactly as it does without the ballpark (never a different sampler). The strided seed sample skips NaN (it breaks nth_element's ordering), and the miss margin is capped at the vocabulary (an unbounded margin made the rank cast undefined). The row seam (common_sampler_row, sample_row, sample_and_accept_rows) moves down from #125: sampling from a gathered row reads only the sampler, which is what lets the test feed fabricated logits. test-sampler-coarse "NaN logits": 0, 100 and 247,320 finite of 248,320 (distinct values, NaN for the rest): the step ends and matches the full array over 8 steps each. With the bound removed the test hangs until a 60 s alarm kills it, printing no NaN line. Every earlier case still identical over 400 steps; penalties ok; 0 warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
Independent source review of exact cc21b09: BLOCK in server-lanes.h.
The measured parallel speedup is useful; these lifecycle races need fault replay before this can replace serial sampling. Parent #122 is also still under review; rebase its latest corrections before final exact-head review. |
… stop checked before every sleep (Codex's review of #125) - A lane holding an earlier run's claim word could read the next run's job count (stored before the new claim word) and claim against the old word, running one of the new run's jobs twice. Now each run's job, count and id are one record, published (release) BEFORE the run's claim word; a lane reads the claim word, then the record, and claims only when the word's run id equals the record's. Records alternate in two places with atomic fields: one is rewritten only two runs later, when a stale lane's claim word is two runs old and its compare-exchange fails. - A lane started from a load of its wake word and never checked stop before its first wait, so a destructor that signalled before the lane ran was missed and the join hung. Now a lane starts from 0 and checks stop before every sleep. Receipts (M5, 2026-11-16): a ThreadSanitizer build of the lanes alone (500 construct/destroy, then 20,000 back-to-back runs of 2-7 jobs, each job checked exactly once): clean, every job once; the same harness against the previous header hangs until a 120 s alarm. test-server-lanes adds the regression (2,000 construct/destroy; 50,000 back-to-back runs exactly once) and still picks the serial token every rep (3.79x-4.89x per step across runs on the shared M5). 0 warnings. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
Stacked on #122. It retargets to
codex/s4-per-mind-integrationwhen #122 merges. The commit message has the full design.What changes
presample(). It samples every slot of a view at once on the lanes: plain sampling and the MTP verify alike. The existing loops then emit in slot order, unchanged.server_lanes. Claims are lock-free and tagged with a run id. Each lane has its own futex wake word, and a run wakes only as many lanes as it has jobs. The caller never sleeps, and on macOS lanes run at user-interactive QoS.Measured (qwen35-0.8b, M5, 2026-11-16)
test-server-lanes: one decode of six sequences, 400 repetitions alternating which runs first. Serial 528.6 µs/step, laned 123.2 µs/step (4.29×), the same token every repetition. The lane runs themselves are checked too: every job runs once at 1 to 1,000 jobs, and a job's exception reaches the caller.Measured after deploy
Owner: Fable, in the #122/#123 window. The host gap between GPU steps (
/propsstep_budget where present) and acts/h at four or more residents.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo