Repository navigation
Seed ensemble model sampling per iteration in worker processes - #559
Merged
codelion merged 1 commit intoOct 29, 2026
Conversation
With random_seed set, every worker process built its LLMEnsemble from the same model seed, so each worker replayed the same sequence of model picks whatever iterations it ran, and a recycled worker restarted it. Reseed the worker ensemble at the start of each iteration from the configured seed and the iteration number, so a pick depends on the iteration alone. Unseeded runs are unchanged. Fixes algorithmicsuperintelligence#554
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.
Summary
When
random_seedis set (it defaults to 42), every worker process samples the same sequence of ensemble models. The controller writes one derivedllm_seedinto everyllm.models[*].random_seed, each worker builds its ownLLMEnsemblein_lazy_init_worker_components, andLLMEnsemble.__init__seeds its sampler once frommodels_cfg[0].random_seed. A pick therefore depends on how many picks that worker has already made, not on the iteration: workers running even and odd iterations replay identical picks, and a recycled worker (max_tasks_per_child) restarts the same stream.This adds
LLMEnsemble.reseed(iteration), which reseeds the sampler from the configured seed and the iteration number, and calls it at the start of_run_iteration_worker. A pick now depends on the iteration alone, so it is the same whichever worker runs it, and seeded runs stay reproducible. When no seed is configured nothing changes. Thestrseed goes throughrandom.seed's SHA-512 path, so it does not depend onPYTHONHASHSEED. The evaluator ensemble only callsgenerate_all_with_context, which never samples, so it is left as is.Tests
New
tests/test_ensemble_worker_seed.pyruns the real_serialize_config,_worker_initand_run_iteration_workerwith the realLLMEnsemble, stubbing onlyOpenAILLM.generate_with_contextto record the sampled model:Three of the four fail without the fix.
python -m unittest discover tests: 916 tests OK (2 skipped).black --checkis clean.Fixes #554