Repository navigation
fix(server): unseeded sampled requests no longer repeat under concurrency - #876
Merged
Merged
Conversation
Graffioh
force-pushed
the
fix/parallel-unseeded-sampling
branch
from
October 22, 2026 10:52
c1bed53 to
d23a505
Compare
Graffioh
marked this pull request as ready for review
October 22, 2026 11:42
davide221
reviewed
Oct 22, 2026
davide221
left a comment
Contributor
There was a problem hiding this comment.
Code review
No issues found. Checked for bugs and logic errors in the changed code.
Reviewed d23a5056 · 0 candidate issues checked, kept at ≥70% confidence · add the code-review label to review again
…ency With --max-concurrency > 1, the slot manager seeded every sampled request's rng from sampler.seed, which is 0 when the request has no "seed" field. Every unseeded request for the same prompt then drew the same tokens: 200 requests at temperature 1.0 returned 2 distinct outputs on the R9700. SamplerCfg gains has_seed (set when the HTTP body names a seed) and seeded(). request_rng_seed() returns the seed when seeded() and 64 fresh random bits otherwise. Every sampled request now starts its stream from it: the slot manager, the single-lane backends, the layer-split adapters and qwen4exp. Single-lane unseeded requests used to continue the backend's stream instead, so one after a repeated seeded request repeated with it. An explicit seed, 0 included, is reproducible on every in-process path. Transports that carry only the seed value (daemon samp= tail, cluster wire) keep treating 0 as "no seed". Co-Authored-By: Claude Opus 5.5 <[email protected]>
Graffioh
force-pushed
the
fix/parallel-unseeded-sampling
branch
from
October 22, 2026 17:36
d23a505 to
cf8e5b6
Compare
davide221
added a commit
to dusterbloom/lucebox-hub
that referenced
this pull request
Oct 25, 2026
…lash DeltaNet ladder branch Clean 3-way merge against the tested Luce-Org#850 head: Luce-Org#851 changes and the main-side changes (Luce-Org#876 sampler seeding, Luce-Org#863 PFlash cleanup) are both kept exactly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
davide221
added a commit
to dusterbloom/lucebox-hub
that referenced
this pull request
Oct 25, 2026
…rg#850, Luce-Org#876, Luce-Org#863) into kvflash turn checkpoints branch Clean 3-way merge against the tested Luce-Org#851 head: Luce-Org#852 changes and the main-side changes are both kept exactly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Measured on the R9700 on 2026-10-22, on a build of origin/main 727fa95 plus an unrelated branch that does not touch this code. The server ran with
--max-concurrency 4. We sent 200 chat requests with the same prompt at temperature 1.0, top_p 0.95 and top_k 20, with noseedfield. They returned 2 distinct outputs, and 192 of them were identical. With aseedper request, the outputs differ. At concurrency 1, 3 unseeded sampled requests on the same build gave 3 different outputs.Cause:
server/src/server/http_server.cpp:1801setssampler.seedonly when the body has"seed". OtherwiseSamplerCfg::seedstays at its default of 0 (server/src/common/sampler.h:31).server/src/common/concurrency/seq_slot_manager.cpp:193-197callss.rng.seed(sampler.seed)wheneversampler.needs_logit_processing()is true. So every unseeded sampled request starts from seed 0 and repeats the same draws for the same prompt.sampler_.seed != 0. Otherwise they keep using theirrandom_device-initialisedsampler_rng_, which is why concurrency 1 was fine.Why it matters: RL group rollouts sample one prompt many times. When the samples are identical, every reward in the group is the same and the advantage is zero.
Fix and semantics
This follows OpenAI: with no
seed, each request gets a fresh random stream. An explicitseedis reproducible, and that includesseed: 0.SamplerCfggainshas_seedandseeded()(has_seed || seed != 0).parse_request_samplersetshas_seedwhen the body contains"seed".request_rng_seed(cfg)returnscfg.seedwhenseeded(), and otherwise 64 fresh bits fromstd::random_device. Every sampled request starts its stream from it: the slot manager, the single-lane backends (qwen35, qwen35moe, qwen3, gemma4, laguna, deepseek4), the layer-split adapters and qwen4exp. The qwen35 layer-split daemon loop parsessamp=but decodes greedily, so it is left as it is.A(seed 7), B, A(seed 7), Bgave B the same output twice. Every unseeded request now starts fresh, on every path, at any concurrency.seed: 0is reproducible on every in-process path.samp=temp,top_p,top_k,rep_pen,seedtail and the clusterRequestMsg. Their wire formats are unchanged. There, a nonzero seed stays reproducible and 0 still means "no seed", as before.Tests
Both are CPU-only.
test_seq_slot_manageris already in thecpuctest label.test_seq_slot_manager: a new case admits two unseeded sampled requests and asserts that their rng streams differ, then reuses one slot and asserts that the next request's stream differs too. The existing seed-0 case now setshas_seed, and the greedy and explicit-seed cases are unchanged.seq_slot_manager.cpp):FAIL test/unit/test_seq_slot_manager.cpp:566: mgr.slot(a.slot).rng() != mgr.slot(b.slot).rng()OK test_seq_slot_manager (311 checks)g++ -std=c++17from the test,seq_slot_manager.cppandpaged_kv_pool.cpp.test_server_unit: a new case goes from the request body to the stream seed. With noseed,request_rng_seeddiffers on every call;seed: 0gives 0 andseed: UINT64_MAXgivesUINT64_MAX.luce_server,test_server_unit,test_seq_slot_manager) on main 32a3137:test_seq_slot_managerOK (311 checks),test_server_unit0 failures.Not yet re-measured on GPU. The 200-request run at concurrency 4 still needs repeating: expect about 200 distinct outputs without a seed, and identical outputs for a repeated explicit seed.
🤖 Generated with Claude Code