Repository navigation
server: one step's sequences sample at once on lanes (552.8 -> 129.3 us/step at six minds, same tokens); the server is C++20 - #129
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 (cherry picked from commit cc21b09)
… 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
…able/parallel-sampling-lanes
…able/parallel-sampling-lanes # Conflicts: # tools/server/server-context.cpp
|
Review exacta5251aa27bd893769c1183e04242363f7ecf796b: BLOCK on partial thread-start failure (P2). server-lanes.h constructor creates workers in a loop. If a later std::thread creation throws std::system_error, the object destructor does not run and vector destruction encounters earlier joinable threads, calling std::terminate. Stop/wake/join started workers on constructor failure before rethrowing; add injected partial-start failure coverage. Prior wake/startup and cross-generation job races are addressed by seen=0, stop checks, atomic tagged run records and CAS claim. Presampling predicates/row gathering/distinct sampler ownership and serial emission/rollback look consistent. Prior ARM compile failure was missing cmath, now fixed; current exact CI pending. Reviewer checkpoint_close_review. |
…ready started before the error leaves (Codex's review of #129) A std::thread construction that threw after earlier lanes started destroyed joinable threads (std::terminate). The constructor now catches, runs the same shutdown the destructor does (stop, wake, join every joinable lane), and rethrows. Lane threads start through an injectable spawn (std::thread by default) so the test fails the third start: the error reaches the caller after the two started lanes are joined. TSan-clean header unchanged otherwise; test-server-lanes ok (6 sequences: 5.37x on the M5). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
|
Independent reviewer identity_crypto_review APPROVE partial-startup fix exact229c7856420f3f25043329c479043ea1230deadf. Catch stops/wakes/joins before member unwind; delayed workers observe stop; preallocated lane records and nonthrowing move avoid unowned-thread gap. Third-spawn failure regression covers identified defect. Prior concurrency/presampling review stands. Exact-head CI remains required. |
#125, rebuilt on #122's new head. The row seam now lives in #122 (the NaN test needed it), so this PR is the server lanes alone:
server-lanes.h,presample()inpost_decode, C++20 for the server, and the validator. It retargets tocodex/s4-per-mind-integrationwhen #122 merges.Measured on this head (qwen35-0.8b, M5, 2026-11-16)
test-server-lanes: one decode of six sequences, 400 repetitions alternating order. Serial 552.8 µs/step, laned 129.3 µs/step (4.28×), the same token every repetition. Every job runs once at 1 to 1,000 jobs, and a job's exception reaches the caller.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo