You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Studio CI: multi-turn determinism smoke fails intermittently on the merge base, not just on PRs #10004
GGUF inference smoke (API, tools, vision) fails intermittently on the determinism assertion in .github/scripts/studio_smoke/multi_turn_chat.py, on the merge base as well as on PR branches.
What fails
The four-turn conversation is run twice at temperature=0.0 with seed=3407, and the two runs must match. Turn 2 diverges:
[openai turn 1] '1 + 1 = 2\n'
AssertionError: openai non-deterministic at turn 2 with temperature=0.0:
run1: 'I am doing not have the ability to ask questions before.'
run2: 'I am doing not understand.'
Running the merge base alone, no PR changes, same workflows, reproduces the identical assertion and the identical strings.
Turn 1 is byte identical across both runs, so the same model and quant is serving. The divergence starts at the first turn that carries conversation history.
ubuntu-latest and macOS both fail. Windows Unsloth GGUF CI passes consistently.
That points at llama-server prompt cache reuse: run 1 leaves a cached prefix that run 2's turn 2 partially reuses, so the two passes decode from different KV states even though the request bytes are identical.
Why it matters beyond the noise
The check is the only place anywhere that asserts greedy decoding is reproducible, and the file's own docstring records that it was already relaxed once on Linux for three months without anyone noticing. As written it cannot tell a real determinism regression from cache-state reuse, so the failure mode is either a red check people learn to ignore or a real regression that hides in the noise.
Suggested direction
Either reset the server's prompt cache between the two passes so the comparison starts from the same state each time, or run the two passes against separate server processes. Both make the assertion mean what it says. Relaxing it again would give up the only coverage of this property.
Reproducing runs are on the staging repos rather than the org queue; I can point at specific run ids if useful.
AssertionError: openai non-deterministic at turn 2 with temperature=0.0:
run1: 'I am not sure what you asked before. Could you please tell me what you were asking?\n'
run2: 'I am doing not understand.'
Two things worth noting from the full set.
run2 is the same string, 'I am doing not understand.', on Linux and on macOS and across all three branches. The second pass converges on one answer while the first pass varies. That is what you would expect if the second pass is decoding from a KV state the first pass left behind, rather than from the prompt as sent.
Windows passes consistently across all three. Whatever differs there, in runner speed or in how the server is started or torn down between the two passes, is the thing that makes the difference, so it is probably also the shortest route to a fix.
#10009 has since strengthened this check, and the nondeterminism survives the new prompts.
On main at ad1a74bee, the commit that introduced the stronger turn 2:
AssertionError: openai non-deterministic at turn 2 with temperature=0.0:
run1: 'The answer to your previous question was 95.\n'
run2: 'The previous question was about the sum of 58 and 27.'
That is Windows Unsloth GGUF CI on main, not on a branch. Worth noting because Windows was the one leg that passed consistently under the old prompts, so the new turn 2 has made the check more likely to trip rather than less. The Linux leg passed on that same commit.
The two failure shapes are now distinguishable, which is an improvement:
run1 is correct and run2 is not. Both are grounded in the history, so this is decode variance between the two passes, not history loss.
The first shape is what this issue is about, and it is unchanged: identical request bytes, temperature=0.0, a fixed seed, two passes against one server process, different output. Resetting the prompt cache between passes or using a separate server process per pass would settle it. As it stands the check cannot separate a real determinism regression from cache reuse, and it now fails often enough on main that it is easy to wave through.
The stronger turn 2 from #10009 is now failing on main as well, and in the other of the two shapes.
Mac Unsloth UI + API + Update + Inference CI on main, two separate commits, byte-identical including the model's reply:
AssertionError: openai: turn 2 must carry turn 1's answer '95', so history reached the model.
Got "You haven't provided the previous question. \n"
Runs 33312992830 (f1fc268bf) and 33312981952 (6f2f2d2f9).
So both failure modes of this script now reproduce on main:
Shape
Where it reproduces on main
Nondeterministic turn 2 (run1 correct, run2 not)
Windows Unsloth GGUF CI at ad1a74bee
History apparently not reaching the model
Mac Unsloth UI + API + Update + Inference CI at f1fc268bf and 6f2f2d2f9
The second one is worth separating from the flakiness this issue started with, because it is either a real history bug on macOS or an assertion gemma-3-270m-it cannot reliably satisfy. The reply "You haven't provided the previous question." is a plausible thing for a 270m model to say even with the history attached, given the earlier finding in #10009 that this model answers the old turn 2 identically with and without history. If that is what is happening, the new assertion has traded a check that could not fail for one that fails on a healthy server, and pinning it on model output may not be sound at this size.
Worth deciding which before it is treated as noise, since a genuine history regression on macOS would look exactly like this.
The prompt-cache half of the suggested direction looks like it is already in place for these
requests, which would rule it out as the cause rather than confirm it. Tracing the seed the
smoke script sends:
multi_turn_chat.py passes seed = 3407 on both SDK paths. On the OpenAI leg that is ChatCompletionRequest.seed (studio/backend/models/inference.py:1940), which reaches _choice_seed(3407, 0) — choice_index is 0, so it returns the seed unchanged
(routes/inference.py:640) — and is forwarded as seed = _seed into generate_chat_completion (the call at routes/inference.py:21337, the argument at :21355).
That method calls _apply_seeded_llama_request (core/inference/llama_cpp.py:27394), whose whole job is this:
def_apply_seeded_llama_request(payload: dict, seed: Optional[int]) ->None:
"""Disable prompt caching for fixed seeds so repeated requests stay reproducible."""
...
if (seed&0xFFFFFFFF) !=_LLAMA_RANDOM_SEED:
payload["cache_prompt"] =False
3407 is not the 0xFFFFFFFF sentinel, so the branch is taken. There is already a test pinning
exactly this, on exactly this seed:
studio/backend/tests/test_llama_cpp_tool_loop.py::test_plain_fixed_seed_disables_slot_prompt_cache_reuse
assert payloads[0]["seed"] == 3407
assert payloads[0]["cache_prompt"] is False
I ran it against main at 1400031e2 — passes, along with the two sentinel cases beside it.
So if cache_prompt: false is reaching llama-server on the smoke path, run 2's turn 2 is not
decoding from a prefix run 1 left behind, and resetting the cache between passes would change
nothing.
What I could not check from here: whether that field is actually on the wire in CI. Every
step above is payload construction, verified by reading and by that unit test; I have no way
to observe the real HTTP body the smoke run sends. That seems like the measurement worth taking
first, because it splits the question cleanly — if cache_prompt: false is present on the
diverging turn, prompt-cache reuse is excluded and the cause is downstream of the request.
One thing that argues against the cache explanation independently: the macOS leg is CPU-only
for every phase — studio-mac-ui-smoke.yml sets --gpu-layers 0 --device none at job level,
because GitHub's macOS runners expose a paravirtual Metal device — and it fails too. All three
legs are CPU, so the Windows/Linux+macOS split is not GPU vs CPU, and a GPU-side reduction-order
argument does not cover it either.
For what it is worth, main() in the smoke script already names the same mechanism your issue
does, as the reason for ATTEMPTS = 3:
the second replay meets the server holding cache and slot state the first one left behind, so
a token the model is near-tied on can land differently without decoding being broken
If the cache is in fact already disabled, then that comment's reasoning — and the retry built on
it — rests on the same assumption, which would explain why the retry has not made the check
reliable.
Happy to take this further in whichever direction is useful: adding the wire-level assertion to
the smoke run, or driving the two passes against separate server processes as you suggested,
which is robust regardless of which explanation holds.
Closing this one. The three inference smoke workflows now pin speculative decoding off and a single parallel slot when they load the model, and the script checks the pin actually took before it generates anything, so the cold vs warm draft batch flake is gone rather than papered over. The turn 2 history assertion moved to the last turn too.
Activity
danielhanchen commentedon Aug 30, 2026
The base control has now finished both failing legs, so the picture is complete.
Merge base only, zero PR changes, same workflows:
Unsloth GGUF CI(ubuntu-latest)Mac Unsloth UI + API + Update + Inference CIWindows Unsloth GGUF CISame assertion every time. The Mac control:
Two things worth noting from the full set.
run2is the same string,'I am doing not understand.', on Linux and on macOS and across all three branches. The second pass converges on one answer while the first pass varies. That is what you would expect if the second pass is decoding from a KV state the first pass left behind, rather than from the prompt as sent.Windows passes consistently across all three. Whatever differs there, in runner speed or in how the server is started or torn down between the two passes, is the thing that makes the difference, so it is probably also the shortest route to a fix.
danielhanchen commentedon Aug 30, 2026
#10009 has since strengthened this check, and the nondeterminism survives the new prompts.
On
mainatad1a74bee, the commit that introduced the stronger turn 2:That is
Windows Unsloth GGUF CIonmain, not on a branch. Worth noting because Windows was the one leg that passed consistently under the old prompts, so the new turn 2 has made the check more likely to trip rather than less. The Linux leg passed on that same commit.The two failure shapes are now distinguishable, which is an improvement:
run1is correct andrun2is not. Both are grounded in the history, so this is decode variance between the two passes, not history loss.Got "You haven't provided the previous question."failure is history genuinely not reaching the model, which is what Make the multi-turn smoke actually assert that history reached the model #10009 set out to catch.The first shape is what this issue is about, and it is unchanged: identical request bytes,
temperature=0.0, a fixed seed, two passes against one server process, different output. Resetting the prompt cache between passes or using a separate server process per pass would settle it. As it stands the check cannot separate a real determinism regression from cache reuse, and it now fails often enough onmainthat it is easy to wave through.danielhanchen commentedon Aug 30, 2026
The stronger turn 2 from #10009 is now failing on
mainas well, and in the other of the two shapes.Mac Unsloth UI + API + Update + Inference CIonmain, two separate commits, byte-identical including the model's reply:Runs
33312992830(f1fc268bf) and33312981952(6f2f2d2f9).So both failure modes of this script now reproduce on
main:mainrun1correct,run2not)Windows Unsloth GGUF CIatad1a74beeMac Unsloth UI + API + Update + Inference CIatf1fc268bfand6f2f2d2f9The second one is worth separating from the flakiness this issue started with, because it is either a real history bug on macOS or an assertion
gemma-3-270m-itcannot reliably satisfy. The reply"You haven't provided the previous question."is a plausible thing for a 270m model to say even with the history attached, given the earlier finding in #10009 that this model answers the old turn 2 identically with and without history. If that is what is happening, the new assertion has traded a check that could not fail for one that fails on a healthy server, and pinning it on model output may not be sound at this size.Worth deciding which before it is treated as noise, since a genuine history regression on macOS would look exactly like this.
Sletch commentedon Aug 31, 2026
The prompt-cache half of the suggested direction looks like it is already in place for these
requests, which would rule it out as the cause rather than confirm it. Tracing the seed the
smoke script sends:
multi_turn_chat.pypassesseed = 3407on both SDK paths. On the OpenAI leg that isChatCompletionRequest.seed(studio/backend/models/inference.py:1940), which reaches_choice_seed(3407, 0)—choice_indexis 0, so it returns the seed unchanged(
routes/inference.py:640) — and is forwarded asseed = _seedintogenerate_chat_completion(the call atroutes/inference.py:21337, the argument at:21355).That method calls
_apply_seeded_llama_request(core/inference/llama_cpp.py:27394), whose whole job is this:3407 is not the
0xFFFFFFFFsentinel, so the branch is taken. There is already a test pinningexactly this, on exactly this seed:
I ran it against
mainat1400031e2— passes, along with the two sentinel cases beside it.So if
cache_prompt: falseis reaching llama-server on the smoke path, run 2's turn 2 is notdecoding from a prefix run 1 left behind, and resetting the cache between passes would change
nothing.
What I could not check from here: whether that field is actually on the wire in CI. Every
step above is payload construction, verified by reading and by that unit test; I have no way
to observe the real HTTP body the smoke run sends. That seems like the measurement worth taking
first, because it splits the question cleanly — if
cache_prompt: falseis present on thediverging turn, prompt-cache reuse is excluded and the cause is downstream of the request.
One thing that argues against the cache explanation independently: the macOS leg is CPU-only
for every phase —
studio-mac-ui-smoke.ymlsets--gpu-layers 0 --device noneat job level,because GitHub's macOS runners expose a paravirtual Metal device — and it fails too. All three
legs are CPU, so the Windows/Linux+macOS split is not GPU vs CPU, and a GPU-side reduction-order
argument does not cover it either.
For what it is worth,
main()in the smoke script already names the same mechanism your issuedoes, as the reason for
ATTEMPTS = 3:If the cache is in fact already disabled, then that comment's reasoning — and the retry built on
it — rests on the same assumption, which would explain why the retry has not made the check
reliable.
Happy to take this further in whichever direction is useful: adding the wire-level assertion to
the smoke run, or driving the two passes against separate server processes as you suggested,
which is robust regardless of which explanation holds.
danielhanchen commentedon Sep 9, 2026
Closing this one. The three inference smoke workflows now pin speculative decoding off and a single parallel slot when they load the model, and the script checks the pin actually took before it generates anything, so the cold vs warm draft batch flake is gone rather than papered over. The turn 2 history assertion moved to the last turn too.