Repository navigation
fix(llm): vary the request seed per iteration in workers - #582
Merged
codelion merged 1 commit intoNov 2, 2026
Merged
Conversation
With random_seed set (the default is 42), every LLM request carried the same seed. On providers that honour it (Ollama, vLLM, OpenAI best effort) identical prompts, common early in a run when iterations share a parent, returned identical responses, so those iterations produced duplicate children. In a 10-iteration pilot on Ollama, up to four iterations of one run returned byte-identical programs. After reseed(iteration) (algorithmicsuperintelligence#559), the ensemble now sends a seed derived from the sampled model's seed and the iteration. Runs stay reproducible, an explicit seed kwarg still wins, and ensembles that are never reseeded (the evaluator's LLM feedback) are unchanged.
This was referenced Nov 1, 2026
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
With
random_seedset (the default is 42), every LLM request carries the same seed. On providers that honour it (Ollama, vLLM, and OpenAI on a best-effort basis), identical prompts return identical responses. Identical prompts are common early in a run, when several iterations share the same parent, so those iterations produce duplicate children and waste their evaluations.In a 10-iteration pilot on Ollama, up to four iterations of one run returned byte-identical programs. (How deterministic a backend is varies: under concurrent GPU load, Ollama can diverge even with the same seed. Where it is deterministic, a fixed seed causes duplicates; where it isn't, a per-iteration seed costs nothing.)
This is a follow-up to #554/#559, which fixed the same problem for model selection (
reseed(iteration)). The request seed itself was still fixed.Fix
After
reseed(iteration),LLMEnsemblesends a seed derived from the sampled model'srandom_seedand the iteration (a SHA-256 hash, truncated to a non-negative 31-bit int).seedkwarg still wins._sample_model()now delegates to a new_sample_index(), sogenerateandgenerate_with_contextknow which model's seed to use.Tests
Adds tests to
tests/test_ensemble_worker_seed.py, which runs fresh worker processes and checks that:python -m unittest discover tests: 1016 tests, OK.Related
Found while running the
full_rewrite_probabilityexperiment for #116 (#580). Independent of that PR, the two merge cleanly in either order.