Repository navigation
feat(server): TF_SEED=random — an opt-in re-roll when a request omits the seed - #2
Merged
bertholomus merged 1 commit intoOct 17, 2026
Conversation
…the seed An omitted seed is keyed to the prompt (seed_for), which is right for reproducible evals and a trap for a retrying agent harness: the same history samples the same trajectory, so a retry replays the same loop at the same character. Measured on a long tool-heavy session: derived seed looped 2/2 bit-identical; explicit seeds answered 4/5. The choice now lives in one default_seed() routed through all three seed sites (exact_sampling, request_options, and cuda/server, the one that answers on CUDA serves); per-request seed still wins; TF_SEED=prompt is the unchanged default.
Owner
|
Thank you @Capicua25x — the "a retry is not a re-roll, it is the same trajectory replayed" framing, with the identical novelty curves to prove it, makes the problem very clear. We're not merging it now: it adds a new runtime knob, and in maintenance mode we're only taking small fixes that keep existing behavior untouched. Leaving it open for the maintainers — the measurements you attached should make that call easy when there's a development window again. Thanks again. |
Owner
|
Thank you @Capicua25x, merged. Development is back on, so this opt-in switch fits now. With |
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.
Motivation
Following up on the loop guard (
dfbe519f, and the #9 novelty signal it carries) — the guard makes a collapse graceful: it closes thinking and the reply goes on to answer. This PR is about what happens to the retry after a turn fails, which the guard does not reach.When a request omits
seed, the engine derives one from the prompt hash —exact_sampling.seed_for, whose docstring states the intent: "the same conversation samples the same reply." For evals that is exactly right. For an agent harness that re-sends an unchanged history it is a trap:a retry is not a re-roll — it is the same trajectory, replayed.
Measured on a real long tool-heavy agentic session (~400k tokens, DeepSeek-V4.1-Flash, TP2 on 2x GB10, t=0.6 / top_p=0.95):
seed_for)So the collapse base rate on that history is real but modest (~20%); the prompt-keyed seed pins this particular conversation into it, deterministically, on every retry. Turning off the drafter (
--mtp-drafts 0) changed nothing — same char, same trajectory — so this is not a speculation about drafting; it is the sampling seed. The v0.5.1 fp32 fix addresses the greedy class; it does not change this one (verified on 90b68e0: guard+fp32 present, three replays still bit-identical).What this PR does
Adds an opt-in re-roll for the omitted-seed path, in the house convention of
TF_LOOP_GUARD— env flag, default = current behavior, validated at import likeTENSORFOLD_SEED_SALT:A per-request
"seed"still wins in both modes.seed_foritself is untouched — reproducible evals keep their guarantee.One function, three sites (the trap this PR also removes)
The omitted-seed choice is currently open-coded at three places, and they are not all on every serve's path:
engine/exact_sampling.py::seed_for— the helper.server/request_options.py::_resolve_sampling— the shared options layer.cuda/server.py::sampling_for— the site that answers on CUDA serves.We learned this the hard way: patching only
request_optionsmadeTF_SEED=randoma silent no-op on the TP2 CUDA path — measured, three identical replays with the flag set. This PR factors the choice intodefault_seed()and routes all three sites through it, so they cannot drift.Tests
TF_SEED=prompt: identical.TF_SEED=random: diverge. (Comparing only a truncated reply is a false positive — the first tokens are shared; we hit that trap too.)Unrelated observation found while testing (no code change here)
RankCache.opendeletes priorrank{r}of{w}-*files on a key miss before checking disk room. The key includesbool(dspark)and the layer count, so a one-flag experiment (--mtp-drafts 5 -> 0) unlinks a ~100 GB cache that may not fit to rebuild on a tight disk — fast boots lost permanently, silently. (We had to rename caches by hand across such an A/B: 106 GB/rank, 90 GB free.) Keep-old-until-new-verifies, or a loud log line before unlinking, would close it.Notes
random.getrandbits(63)keeps the exactseed_forrange; the seed stays a non-negative int63 wherever it is packed (multi._pack— unchanged).TF_SEED=random, batched streams carry distinct seed rows in_pack— per-stream admission data, not a compatibility key; no concurrency cost measured.