Skip to content

fix(llm): vary the request seed per iteration in workers - #582

Merged
codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
SUPR1M3:fix/llm-request-seed
Nov 2, 2026
Merged

codelion merged 1 commit into
algorithmicsuperintelligence:mainfrom
SUPR1M3:fix/llm-request-seed

Conversation

@SUPR1M3

@SUPR1M3 SUPR1M3 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Problem

With random_seed set (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), LLMEnsemble sends a seed derived from the sampled model's random_seed and the iteration (a SHA-256 hash, truncated to a non-negative 31-bit int).

  • Reproducible: the same config and iteration always send the same seed, whichever worker runs it, so the reproducibility from Support seed for reproducibility #97 is kept.
  • An explicit seed kwarg still wins.
  • No seed configured, no seed sent: requests carry no seed, as before.
  • Ensembles that are never reseeded are unchanged, such as the evaluator's LLM-feedback ensemble.

_sample_model() now delegates to a new _sample_index(), so generate and generate_with_context know which model's seed to use.

Tests

Adds tests to tests/test_ensemble_worker_seed.py, which runs fresh worker processes and checks that:

  • identical prompts get a different seed on each iteration
  • the request seed depends only on the iteration, not on which worker runs it
  • unseeded configs send no seed, and their model selection stays random

python -m unittest discover tests: 1016 tests, OK.

Related

Found while running the full_rewrite_probability experiment for #116 (#580). Independent of that PR, the two merge cleanly in either order.

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.
@codelion
codelion merged commit 443132e into algorithmicsuperintelligence:main Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants