Skip to content

Fix the two backend guards that #9292 turned red on the 3.13 leg - #9348

Merged
danielhanchen merged 3 commits into
mainfrom
fix-backend-custom-llamacpp-tests
Aug 20, 2026
Merged

danielhanchen merged 3 commits into
mainfrom
fix-backend-custom-llamacpp-tests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Backend CI :: (Python 3.13) :: Backend tests has been red on every main run since
e99dfe5a2, "Studio: use a custom llama.cpp build (#9292)". Three failures, and all three
are the tests rather than the change.

Bisect: b38490f0a green at 15:06, e99dfe5a2 red at 15:09, nothing else in between.

One note on the leg name, because it misleads. The matrix is 3.13 scope=full and
3.11 scope=floor-spot-check (about 40 tests across three files), so "3.11 green, 3.13
red" is not a version difference. 3.13 is simply the only leg that runs these files.
Reproduced locally on 3.13.12.

test_metal_paravirtual_guard.py (2 failures)

Both tests forbade _kill_process and _find_llama_server_binary on a duplicate
/load, under a single message: "tore down a healthy server on a duplicate /load". Only
the first of those is teardown.

#9292 put _binary_changed_since_launch() on the duplicate-load fast path. It reads the
currently installed llama-server to compare it against the one the live process was
launched from, which is precisely what a custom build has to check: an otherwise identical
request must still reload when the binary underneath it changed. So the lookup is correct,
and forbidding it reported a read as a teardown.

_kill_process stays forbidden, which is the property the test names. The binary lookup
is now stubbed to a fixed path, so the revision comparison sees no change and the fast
path is still what gets exercised.

test_vram_budget_settings.py (1 failure)

This asserted that the compacted source of _serial_load_scope ends with
self._vram_fraction_pending=None. #9292 added a sibling clear, _binary_revision_pending,
so the vram release is still in the finally but no longer the last statement in it. The
assertion now checks it is inside the finally, which is what the test is about.

Mutation-tested: deleting the vram release from the finally still turns it red.

Verification

  • test_metal_paravirtual_guard.py 119 passed
  • test_vram_budget_settings.py 90 passed

Test files only, no product code touched.

Backend CI's "Repo tests (CPU)" has been red on main since 588405d, with 111
failures in two files. Both are the same defect, and neither is about what the
tests claim to be testing.

These harnesses replay real studio source with its import block stripped, so
every name the sliced region calls has to be defined in the harness. Two landed
without one:

  refresh-context-usage.ts  findLatestUserVideoBase64  (#9056, decline to price
                            a prompt carrying video)
  chat-runtime-store.ts     resolvePreserveThinkingOnLoad

Both product changes are right. The first is the more dangerous shape: with no
stub the replayed body throws a ReferenceError, the effect bails, `counts` stays
0, and the assertion reads "the empty New Chat view must be priced exactly once"
-- a pricing bug that does not exist. 41 tests failed that way, and bisecting
main was the only way to see it, because the message points at the wrong thing.

test_chat_autoload_failure_gate.py already guards this and said exactly what was
missing, which is why its 70 failures named resolvePreserveThinkingOnLoad
outright. test_new_chat_context_recount.py had no such guard; it does now, built
the same way -- parse the real import list, assert the harness defines each name.
Mutation-tested: dropping the video stub turns it red with the name in the
message.

The preserve-thinking stub is the real resolver's rule verbatim, since no
scenario here sets a stored preference.

tests/studio: 0 failures, from 111.
Backend CI's "(Python 3.13)" leg has been red on main since e99dfe5,
"Studio: use a custom llama.cpp build (#9292)", with three failures. All three
are the tests, not the change.

Two in test_metal_paravirtual_guard.py forbade BOTH _kill_process and
_find_llama_server_binary on a duplicate /load, under one message: "tore down a
healthy server on a duplicate /load". Only the first is teardown. #9292 put
_binary_changed_since_launch() on the fast path, which reads the current
llama-server to see whether a different one is installed than the live process
was launched from -- exactly what a custom build has to check, since an
identical request must still reload when the binary underneath it changed. So
the read is correct and forbidding it reported a lookup as a teardown.
_kill_process stays forbidden; the binary lookup now returns a fixed path, so
the revision comparison sees no change and the fast path is still what is
exercised.

One in test_vram_budget_settings.py asserted the compacted source of
_serial_load_scope ENDS WITH self._vram_fraction_pending=None. #9292 added a
sibling clear, _binary_revision_pending, so the release is still in the finally
but no longer last in it. The assertion now checks it is inside the finally,
which is the property the test names. Mutation-tested: deleting the vram release
from the finally still turns it red.

Note on the leg name: 3.11 is not a second copy of this suite. The matrix is
3.13 scope=full and 3.11 scope=floor-spot-check, about 40 tests in three files,
so "3.11 green, 3.13 red" is not a version difference -- 3.13 is simply the only
leg that runs these. Reproduced locally on 3.13.12.

test_metal_paravirtual_guard.py 119 passed, test_vram_budget_settings.py 90
passed. Test files only; no product code touched.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cccc06700c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +478 to +479
released = compact.split("finally:", 1)[1]
assert "self._vram_fraction_pending=None" in released

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the release remains inside the lock's finally block

This assertion searches the entire source suffix after finally:, so it still passes if self._vram_fraction_pending = None is moved outside the with self._serial_load_lock block. In that scenario, a queued load can acquire the lock and arm its marker before the previous call clears it, recreating the race this test is intended to prevent. Please inspect the finally body's boundaries (for example, via the AST) rather than accepting the value anywhere later in the function.

Useful? React with 👍 / 👎.

meefs pushed a commit to meefs/unsloth that referenced this pull request Aug 20, 2026
…ard them (unslothai#9353)

* Put back the AppleDouble GGUF filters unslothai#9074 reverted, and guard them

Backend CI's 3.13 leg has six failures on main beyond the two in unslothai#9348. Three
separate causes, all of them in the tests or in a merge resolution rather than
in anything a PR meant to change.

1. llama_cpp.py lost every line of unslothai#8919
------------------------------------------------------------------------
unslothai#8919, "never pick a macOS AppleDouble sidecar as a GGUF", touched 49 files.
18b97f8 ("keep and search the turns rolling context evicts", unslothai#9074) reverted
all five of its hunks in core/inference/llama_cpp.py and nothing else. That is
the signature of a branch cut before unslothai#8919 landed and merged whole-file: unslothai#9074
is a rolling-context PR, its diff carries no replacement for any of this, and it
did not revert the tests, which is the only reason CI said anything at all.

Checked the rest of unslothai#8919 line by line against main: of the 49 files it changed,
llama_cpp.py is the only one that lost anything. All five hunks are restored
here, and the file now contains every line unslothai#8919 added.

Four of the five are the selection sites, and they are the half that was silent:

  _gguf_snapshot_files      a local walk now skips the companion on its bytes
  _pick_mmproj              "._mmproj-F16.gguf" satisfied the F16 preference and
                            sorted ahead of the real adapter
  _pick_dspark              every GGUF under dspark/ qualifies, so a sidecar
                            ranked equal to its sibling and sorted first; also
                            back at module level, where unslothai#8919 put it because it
                            is handed a live repo listing as well as a snapshot
  the HF list_repo_files    a repo listing has no bytes to read

The fifth is the one CI caught: the "invalid magic characters" branch in
_classify_llama_start_failure. Without it a user who points llama-server at a
"._model.gguf" sidecar gets "Check that the GGUF file is valid and you have
enough memory" and goes off to free memory they already have, which is issue
unslothai#8566 exactly. Restored verbatim at its original anchor, below the dyld branch
so test_a_dyld_failure_still_outranks_it keeps holding.

Five new tests in test_appledouble_guards.py cover the four selection sites
behaviourally, including that _pick_dspark is reachable from module scope, since
nesting it back inside the method is how it was reverted. Each also pins that a
file a user genuinely named "._something" still resolves: nothing may be refused
for its name alone.

Mutation-tested by restoring llama_cpp.py to its current main state: 7 failed,
all five new guards plus the two that were already red.

2. The refactor guard baseline
------------------------------------------------------------------------
unslothai#9074 added RAG_SEARCH_TOOLS to core/inference/tool_call_parser, which is one of
the two strict modules the guard runs with additions_matter, so a new public name
there is a deliberate re-baseline by design. The symbol is correct: three modules
import it, and test_conversation_recall_injection.py already pins its value.

Re-baselined through the tool's own `snapshot`, then trimmed to just this entry.
The full snapshot also absorbed 52 unreviewed new names in core.inference.llama_cpp,
3 in safetensors_agentic and 151 lines of patch_targets churn. Those are additive
drift the guard tolerates on purpose, so recording them fixes nothing and pins
symbols nobody looked at.

Mutation-tested: an added throwaway public symbol still turns both tests red, so
the strict-addition behaviour survived the re-baseline.

3. The research opt-out payload
------------------------------------------------------------------------
28b8880 ("compact a chat by resetting the epoch", unslothai#9162) added tools_withheld
to the generation kwargs. test_the_opt_out_changes_nothing_a_default_install_does
compared the two payloads whole, which was right when every kwarg was
model-facing.

tools_withheld is not. Its only consumer is _can_reset_epoch, which picks a
compaction strategy; it never reaches the prompt, the sampling params or the tool
catalogue. And it has to differ: without the opt-out a compacted thread can still
re-admit search_conversation through the checkpoint-repair branch, so resetting
the epoch is safe, while with the opt-out that repair is closed on this turn and
every identical turn after it, so a reset would strand the epoch behind a tool
that never arrives. Forcing the two equal is what would break Deep Research,
which sends a real thread_id.

The 17 model-facing fields are identical and neither side carries a `tools` key,
so the asymmetry this test exists to catch is not present. Rather than just
excluding the key, it is now pinned in both directions plus an explicit
no-tool-catalogue assertion, so the file catches more than before.

Mutation-tested: pinning tools_withheld = False in routes/inference.py fails the
new assertion for both parameters.

Verification
------------------------------------------------------------------------
test_appledouble_guards.py, test_llama_cpp_start_failure_classification.py,
test_refactor_guard.py, test_research_internal_call_tool_gate.py and
hub/tests/test_model_services.py: 508 passed, from 6 failed.
Wider sweep over tests/test_llama*.py and the hub model services: no collateral.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@danielhanchen

Copy link
Copy Markdown
Member Author

(Python 3.13) passes at 11m5s and Repo tests (CPU) at 13m32s. Fully green. Merging.

Together with #9353 that takes the 3.13 leg from 9 failures to 0.

@danielhanchen
danielhanchen merged commit 149d297 into main Aug 20, 2026
32 of 33 checks passed
@danielhanchen
danielhanchen deleted the fix-backend-custom-llamacpp-tests branch August 20, 2026 06:17
danielhanchen added a commit that referenced this pull request Aug 20, 2026
The branch was 60 commits behind main, which is the only reason the stack was
red: main has since fixed the four failure families this stack's CI was
inheriting (#9342 for the sliced chat-adapter harness and the install.sh
fallback range, #9348 for the two backend guards on the 3.13 leg, #9335 for the
3.9 union floor).
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.

1 participant