Skip to content

CI: fix llama.cpp seed caching, Diffusers wheel installs, and isolated test coverage - #9979

Merged
danielhanchen merged 32 commits into
unslothai:mainfrom
oobabooga:fix/ci-runtime-installer-coverage
Aug 31, 2026
Merged

danielhanchen merged 32 commits into
unslothai:mainfrom
oobabooga:fix/ci-runtime-installer-coverage

Conversation

@oobabooga

@oobabooga oobabooga commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Restore the affected Studio and repository CI coverage by fixing the underlying runtime and installer issues, updating stale assertions, and isolating tests whose timing or module state is process-sensitive.

Changes

  • Make fixed-seed llama.cpp generation reproducible across serving slots for OpenAI, Responses, Anthropic, and tool-loop requests. The -1 random-seed sentinel retains prompt-cache reuse.
  • Keep MCP server management accessible when tools are unavailable for the loaded model.
  • Preserve a complete llama.cpp installation after a transient unpinned update failure, while explicit version requests still fall back to a source build.
  • Keep Diffusers 0.40.0 on its published wheel path and pass the Windows staging root explicitly through llama.cpp resolution and preflight. The nobuild allowlist entry stays until a release carries the wheel pin, because the overlay: false legs install the released wheel and its pre-0.40.0 archive pin.
  • Add the matching CPU torchaudio dependency, isolate process-sensitive test groups, and give async handoff assertions enough scheduling margin on slower runners without changing production timeouts.
  • Refresh structural and audio assertions after the corresponding implementation changes, and bind context-dependent security approvals to both their matched evidence and reviewed file contents.

Verification

  • Frontend: 5,958 tests passed, plus typecheck, production build, and focused ESLint.
  • Seeded inference and API compatibility: 972 tests passed.
  • Installer, prebuilt, and managed-path checks passed, including the 177-test follow-up suite and 57 shell assertions.
  • GitHub-hosted Windows: 171 passed, 6 skipped for installer checks; 34 staged-root checks passed; native PowerShell denied-path checks passed; 972 inference and API tests passed.
  • GitHub-hosted macOS: 177 installer checks, 34 staged-root checks, and 972 inference and API tests passed.
  • Security: 409 passed, 26 skipped.
  • Media auto-switch: 104 passed, 1 skipped.
  • Isolated unsloth_zoo groups: 43 passed, 63 skipped.
  • Python compilation, Ruff, shell parsing, workflow YAML parsing, JSON parsing, and diff checks passed.

Follow-up commits

Review and CI triage after the first commit. The verification above describes 40099b07ea; the runs below are the ones for these.

  • 8fc7f01f00, ad6d622eb2, d59f907b5d make the new keep-the-existing-install path prove the tree is runnable before reporting success. confirm_install_tree is exists() only, so on a complete tree whose binaries are not executable the merge base exited 2 and 40099b07ea returned success. Exit 2 is what hands the decision to setup.sh, whose reuse gate is -x build/bin/llama-server; exit 0 is announced as "prebuilt installed and validated" and re-checks nothing. The path now requires the structural check, os.access(X_OK), the platform installed-binary preflight, and the runtime payload the tree's own marker implies, which is the same set existing_install_matches_choice demands minus the release fingerprint. write_prebuilt_metadata records runtime_asset so a paired Windows CUDA install must still hold its cudart trio while a pair-less one need not. An advisory stored backend the install already runs is kept rather than exiting 5; a backend named on the run, or one the tree does not satisfy, still exits 5.
  • 9d16b0cd6d clears three CI legs. assert-prompt-cache.sh no longer sends a request seed: it measures cache surfacing, not determinism, and asserting cached_tokens > 0 on a seeded request contradicts the cache_prompt=false policy this PR introduces. The MCP preset rows lose their !usable gate, which had made the newly reachable menu useless and failed MCP arguments end to end. The Diffusers allowlist entry is restored for the released-wheel legs.
  • 9690a966f7 points six unsloth_cli launch tests at a writable STUDIO_HOME. They fail identically at the merge base: _studio_runtime_launch_guard (Studio: update in the background and restart when ready #9890) creates STUDIO_HOME before run() reaches run_server, and the tests pinned it under a literal /fake. They were invisible because Repo tests (CPU) stopped at an earlier step, which this PR fixes.
  • 8c51ac6d96 gives each isolated unsloth_zoo file its own pytest process. Sharing one rerun process is its own contamination: test_mlx_generate.py installs the MLX-on-torch shim into sys.modules at import time, which un-skips test_mlx_neftune_quant_map.py and breaks the transformers patching test_gemma3_forced_float32_boundary_dtype.py asserts on. test_zoo_suite_parallel_isolation.py now registers all six files and guards the split.

Follow-up verification

  • tests/studio/install and tests/python/test_install_python_stack.py: 2,801 passed, 100 skipped.
  • unsloth_cli/tests: 1,102 passed, 11 skipped (11 failures at the merge base).
  • tests/studio: 6,298 passed, 548 skipped.
  • The touched studio/backend suites: 1,028, 578 and 199 passed.
  • Frontend node --test locally is missing node_modules for most files; against the merge base the failure set is identical and five audio assertions move to passing.
  • Cloned unsloth_zoo at 52aff0d: the six isolated files give 14 failures and 6 errors in one process and none when each gets its own.

Known red, not addressed here

streaming-latex-retro-edit.test.ts asserts a math/plain streaming ratio under 4. Bisecting from 8395e4602d, where the guard was written, to this PR's merge base puts the ratio at 1.2x then and 3.7x now, first bad commit e584ffc49f (#9796). The guard is working; the cost it measures tripled, so it now flips on a loaded runner. Raising the threshold would accept the regression silently, so it is left for a separate change. AppImage model download E2E is red on main too.


Update (danielhanchen)

Took this over to get it verified and mergeable. Seven commits added on top of 184bafe0f.

The red Core step was stale, not this branch

All three cells failed at unsloth_zoo @ main - full pytest (CPU), the step this PR rewrites. That was an upstream race, not this PR.

CI here cloned unsloth_zoo at 847f893d (2026-08-30T04:54Z). Thirty-three minutes later unsloth_zoo merged unslothai/unsloth-zoo#1134, "Restore parent package attributes when the mlx shim fixtures put sys.modules back". Running both arrangements in one venv on one SHA, 4 cores:

unsloth_zoo SHA this branch main
847f893d, what CI got mlx_group: 10 failed xdist: 6 failed, 4 of them MLX contamination
current mlx_group: 939 passed, 0 failed clean

The 10 match this PR's CI exactly. main was red at that SHA too, with different victims, which matches the record: main's own Core run at 04:12Z was red in 2 of 3 cells and every run from 06:14Z on is green.

The conflicts were blocking CI entirely

While the branch was unmergeable, GitHub could not build the merge commit that pull_request workflows run against, so it ran no workflows at all. Every check reported "error during mergeable check". After merging main: mergeable went to MERGEABLE and 90 checks started.

Six of the seven conflicts were the same fixes landing twice, with main's version being the more thorough, so main's side won and this branch's copies went. scripts/scan_packages_baseline.json went the other way, since this branch's side is the superset that carries the file_sha256 pins.

Defects fixed

  • _choice_seed disagreed with _apply_seeded_llama_request. The new helper compares in llama.cpp's uint32 domain; _choice_seed still tested the literal -1. For seed=4294967295, n=3 it served [4294967295, 1, 2], so choice 0 was random and cached while choices 1 and 2 were fixed and uncached inside one request. llama.cpp applies the same uint32 test at its own multi-choice offset in tools/server/server-task.h.
  • Exit 0 no longer means something was installed, but both setup scripts only special-cased already matches, so a kept install printed "prebuilt installed and validated" and setup.ps1 announced the old release as newly installed. The in-app updater had the same problem on macOS, where start_update passes no pin_release_tag so the pinned-tag guard does not run, and it reported "Updated llama.cpp to ".
  • An empty mlx_group glob would have made pytest collect the whole rootdir serially, since the group is passed unquoted. Now fails loudly. _keep also names the file, because an expected module-level skip and a file that stopped collecting for a new reason both exit 5.

Evidence that the seed change fixes a real problem

Measured on a real llama-server (b10698, CUDA 13) with gemma-3-270m Q8_0, --parallel 4. 30 requests at seed=3407, temperature=0.8:

  • cache_prompt default: 2 distinct completions
  • cache_prompt: false: 1

The sentinel handling is right too. Against the live server, -1, 4294967295 and 2**64-1 all draw at random, while 0, 4294967294, 2**31, 2**32 and -(2**40) are all fixed.

The cost is worth stating. Same prompt repeated, cache on against off: 1.11x at 267 prompt tokens, 2.50x at 2,003, 4.59x at 7,955. A 25 round tool loop was 1.48x. So any pinned seed loses prefix reuse, including seed=0 and the whole range the UI can emit (MAX_SAMPLING_SEED = 4294967294, min 0), and no UI copy says so. Worth deciding separately. Also worth noting in the description: seed on the Responses and Anthropic endpoints was previously swallowed by extra="allow" and dropped, so a client that has always sent one loses prompt caching on upgrade.

Tests added

  • tests/studio/install/test_keep_install_backcompat_9979.py, 96 cases. _kept_install_payload_is_healthy and _existing_install_runs had no direct tests. Covers all twelve marker shapes since Use prebuilt llama.cpp for unsloth studio setup #4562, the [Windows, Linux, WSL, macOS] x [NVIDIA, AMD, CPU, Vulkan] product, and the exit contract the setup scripts branch on. Five install kinds had no payload coverage anywhere before: linux-arm64-cuda, windows-hip, windows-rocm, windows-arm64, windows-vulkan.
  • Two guards on the workflow step, both confirmed failing against its previous form.
  • One case each for the seed and updater fixes, both confirmed failing before the fix.

Backwards compatibility

Checked against a real install rather than a fabricated one: took the tree studio/install_llama_prebuilt.py actually wrote (450 MB, real binaries), rewrote its marker to each shipped shape, and ran the real installer with the network dead. Every shape from S1 (March) through S11, plus empty, corrupt and future-key markers, exits 0 with byte-identical binaries that still run. A marker claiming a backend the tree does not carry exits 5 rather than letting a source build substitute a different one.

Other checks

studio/backend 37,196 passed. Frontend npm test 5,977 passed, typecheck clean. tests/sh staged-root and node-dir suites pass. The MCP composer accessibility change was checked in chromium, firefox and webkit: the existing get_by_role("button", name="MCP servers") still matches, but before the change assistive tech saw a disabled control and after it sees an enabled one, with the reason moved into the accessible name. That is a product and accessibility change rather than a CI fix and reads better argued as one.

diffusers 0.40.0 does publish a py3-none-any wheel, so the pin resolves to a wheel. assert-nobuild.ps1 was executed against ten synthetic logs and behaves correctly on all of them, so the by-name Diffusers allowlist entry is not a hole; the name-independent compiler check still fires.

Not verifiable on Linux and left explicitly open: real Windows DLL loading and ACLs, os.access(X_OK) on Windows, macOS dyld and codesigning, real ROCm hardware, and Safari as opposed to the WebKit engine.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-31T10:23:11.886264Z 3476a89 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@oobabooga

Copy link
Copy Markdown
Member Author

@codex review

@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: 40099b07ea

ℹ️ 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 +334 to +338
onClick={(e) => {
if (e.currentTarget.closest('[data-pill-compact="true"]'))
return;
e.stopPropagation();
setMcpEnabledForChat(false);

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 Let the unavailable MCP glyph open management

When a loaded model lacks tool support (usable is false) on the non-compact composer, clicking the MCP glyph still stops the dropdown-trigger event and calls setMcpEnabledForChat(false). Because the pill is rendered only while that flag is true, this click removes the pill instead of opening the newly reachable menu and its “Manage MCP servers” action; let the click bubble when !usable rather than applying the active-state off switch.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The click does turn MCP off, but that is the glyph's job on every composer pill, and the menu is not lost: the label and caret still open it, and compact mode already lets glyph clicks fall through to the trigger. The affordance is shown in this state too - index.css:1885-1894 reveals the hover X for any pill whose glyph is role="button", independent of data-active, so an unusable MCP pill still swaps to an X under the cursor. Special-casing the off switch away exactly when the pill is least useful is the wrong trade, so no change there.

There was a real problem next to it, though: the preset rows carried disabled={!usable || ...}, which made the newly reachable menu useless and failed MCP arguments end to end (Playwright) at playwright_mcp_arguments.py:359 (expect(preset).to_be_enabled()). Note that check reached line 359 at all only because of this PR - on main it dies at line 106 clicking the aria-disabled button this PR removes. Dropped the !usable gate in 9d16b0c: a row is persistent server configuration, not a tool call, and the new menu label already states that the loaded model cannot run them.

@oobabooga oobabooga changed the title CI: fix llama.cpp seed caching, Diffusers wheel installs, and isolated test coveraged test coverage CI: fix llama.cpp seed caching, Diffusers wheel installs, and isolated test coverage Aug 29, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 29, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 0d232b03e4

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 30, 2026
_apply_seeded_llama_request compares the seed in llama.cpp's uint32 domain,
so -1, 4294967295 and 2**64-1 are all LLAMA_DEFAULT_SEED and all keep prompt
caching. _choice_seed still exempted the literal -1, so for n > 1 the two
helpers disagreed inside one request: choice 0 kept the caller's random seed
and its cache, while choice 1 was offset to ((seed & 0xFFFFFFFF) + 1) % 0xFFFFFFFF,
a fixed seed with the cache turned off. seed=4294967295 with n=3 served
[4294967295, 1, 2].

Confirmed against a real llama-server: -1, 4294967295 and 2**64-1 each varied
across repeated requests, while 4294967294 and 0 did not. llama.cpp applies the
same test at its own multi-choice offset in tools/server/server-task.h, where
the guard is seed != LLAMA_DEFAULT_SEED rather than a literal.
The keep path answers a transient update failure by exiting 0 with the tree
already on disk. Both setup scripts only distinguish exit 0 by looking for
"already matches", so a kept install took the other branch and printed
"prebuilt installed and validated", naming a release that was never fetched.
setup.ps1 also went on to print the old release as the installed one.

The in-app updater had the same problem on macOS. start_update passes no
pin_release_tag there, so the "pinned release X but installer produced Y"
check that catches this on Linux and Windows does not run, and the phase
reported "Updated llama.cpp to <the tag the user already had>". It now
compares the marker before and after and says the install is already up to
date, which is what happened.
mlx_group is passed to pytest unquoted so the list word-splits into file
arguments, which means an empty list passes no files at all and pytest
collects the whole rootdir serially instead: green, much slower, and no
longer the group the step describes. The glob only has to stop matching
once, upstream renaming the family for instance, for that to be what runs.

Also pass each rerun's own filename to _keep. Exit 5 stays tolerated, but a
module-level skip and a file that stopped collecting for a new reason both
produce it, and only the log says which file it was.
_existing_install_runs and _kept_install_payload_is_healthy decide whether an
install the user already has survives a transient update failure, and they had
no direct tests: the existing keep-path cases drive install_prebuilt with a
hand-built two-key marker. UNSLOTH_PREBUILT_INFO.json has grown twelve shapes
since unslothai#4562 with no version field and no migration, so an absent key is the
normal case for anything installed before the release that added it.

Covers each shipped shape on Linux, Windows and macOS hosts, including the
S1-S8 markers that carry no backend key and resolve through the asset name,
and the S1-S11 Windows CUDA installs that predate runtime_asset and so must
not be asked for a cudart trio they cannot record. Also pins two boundaries
that were unasserted: a source build has no marker, so confirm_install_tree
rejects it and it still falls through to the source-build fallback, while a
corrupt marker keeps the tree eligible and holds it to every kind's shared
payload. Adds the missing SIGSEGV and hang cases for the --version probe.

Platforms are simulated through HostInfo, as the rest of this suite does. That
covers the path decisions and the payload tables; it does not cover the Windows
loader or macOS dyld, which no Linux runner can answer.
@danielhanchen

Copy link
Copy Markdown
Member

Went through this end to end: reproduced the red CI, validated each of the four changes against real hardware and real tooling where possible, and pushed four commits to this branch (184bafe0f..49b868305).

The red Core step is stale, not yours

All three cells fail at unsloth_zoo @ main - full pytest (CPU), the step this PR rewrites. That is not this PR.

Your CI run started 2026-08-30T04:54Z, so its shallow clone got unsloth_zoo 847f893d. At 05:27Z unsloth_zoo merged unslothai/unsloth-zoo#1134, "Restore parent package attributes when the mlx shim fixtures put sys.modules back". Running both arrangements in one venv, same SHA, 4 cores:

zoo SHA this PR's arrangement main's arrangement
847f893d (what CI got) mlx_group: 10 failed xdist: 6 failed, 4 of them MLX contamination
acee5087 (current) mlx_group: 939 passed, 0 failed clean

The 10 match your CI exactly (9 in test_mlx_save_export_regressions.py, 1 in test_mlx_text_path_contract.py). main was red too at that SHA, with different victims, which matches the record: unsloth main's own Core run at 04:12Z was red in 2 of 3 cells and every run from 06:14Z on is green. A re-run should go green with no code change.

The seed change is solving a real problem, and I measured it

B200, real llama-server b10698, gemma-3-270m Q8_0, --parallel 4. 30 requests, seed=3407, temperature=0.8:

  • cache_prompt default: 2 distinct completions
  • cache_prompt: false: 1

So the premise holds, and the fix works. The uint32 comparison is also exactly right: -1, 4294967295 and 2**64-1 all draw at random on the live server, while 4294967294, 0, 2147483648, 2**32 and -(2**40) are all fixed. A literal -1 test would have got the first three wrong.

The cost is worth putting in the PR body. Same prompt, repeated, cache on vs off:

prompt tokens median cache on median cache off slowdown
267 0.0256s 0.0285s 1.11x
2003 0.0233s 0.0582s 2.50x
7955 0.0354s 0.1623s 4.59x

A 25 round tool loop was 1.48x. It scales with prompt length. Two things I would call out in the description: any pinned seed disables prefix reuse, including seed=0 and the whole range the UI can emit (MAX_SAMPLING_SEED = 4294967294, min 0), and no UI copy says so; and seed on Responses and Anthropic was previously swallowed by extra="allow" and dropped, so a client that has always sent one silently loses prompt caching on upgrade.

install.ps1's dangling $StageRoot was a real latent bug

Dot-sourced the real resolvers with pwsh 7.6 under Set-StrictMode -Version Latest. On the merge base both studio/setup.ps1 and install.ps1 throw "The variable '$StageRoot' cannot be retrieved because it has not been set". On this head both run and resolve correctly. Good change, and executed proof rather than a source grep.

Four commits pushed

  1. 69a74391f _choice_seed exempted the literal -1 while _apply_seeded_llama_request compares in uint32, so the two disagreed inside one request. seed=4294967295 with n=3 served [4294967295, 1, 2]: choice 0 random and cached, choices 1 and 2 fixed and uncached. llama.cpp applies the same uint32 test at its own multi-choice offset in tools/server/server-task.h.
  2. 620180460 Exit 0 no longer means something was installed, but both setup scripts only special-case already matches, so a kept install printed "prebuilt installed and validated" and setup.ps1 then printed the old release as newly installed. Same class of thing in the in-app updater on macOS, where start_update passes no pin_release_tag so the "pinned release X but installer produced Y" guard does not run and it reported "Updated llama.cpp to <the tag you already had>". Both fixed, with a test that reproduces the macOS case.
  3. 0b63166be mlx_group is passed unquoted so it word-splits into file arguments, which means an empty glob passes no files and pytest collects the whole rootdir serially instead: green, much slower, and testing something else. Now fails loudly. Also passes each rerun's filename to _keep, since a module-level skip and a file that stopped collecting for a new reason both exit 5.
  4. 49b868305 _kept_install_payload_is_healthy and _existing_install_runs had no direct tests. 51 cases across all twelve marker shapes the installer has ever written, on Linux, Windows and macOS hosts. Confirms old installs are safe: S1-S8 have no backend key and resolve via the asset name; every Windows CUDA install predating runtime_asset is correctly not asked for a cudart trio it cannot record. Also pins two unasserted boundaries, that a source build has no marker and so is never kept, and that a corrupt marker keeps the tree eligible against every kind's shared payload.

Each fix has a test that fails on the pre-fix code.

Everything else I ran

studio/backend/tests 37,196 passed; tests/studio/install + tests/studio + tests/python + tests/security 3,557 passed; frontend npm test 5,977 passed and typecheck clean; tests/sh staged-root and node-dir suites pass; the isolation guard is 31 passed.

Checked the MCP composer accessibility change in chromium, firefox and webkit, all three agreeing: the existing get_by_role("button", name="MCP servers") still matches after the label change so CI is fine, but before the change assistive tech saw a disabled control and after it sees an enabled one. The reason does move into the accessible name, so it is defensible, but it is a product and accessibility change rather than a CI fix and reads better argued as one.

One thing I looked at and decided against: the new triton reverse-shell baseline entry has no file_sha256, but so do the two pre-existing triton entries, and pinning a third-party file's digest would break CI on every triton release. Pinning is right for the first-party unsloth-zoo entries, which you did. No change needed.

Still outstanding: the branch conflicts with main in 7 files, and all the green checks predate those conflicts.

@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: 49b868305e

ℹ️ 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 +739 to +743
elif kept_existing:
# Say what happened. Claiming an update that did not happen is worse than
# saying nothing changed, because the next thing the user does is look for
# a fix that shipped in the release they think they just installed.
message = f"llama.cpp is already up to date on {new_tag}."

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 Report retained installs as update failures

When macOS has already offered a newer release but the installer encounters a transient release/network failure, it exits successfully after retaining the old tree, making new_tag == prior_tag here. The resulting message says the old release is “already up to date,” contradicting the freshness check that launched the update and concealing that the user should retry; report that the update was unavailable and the existing release was retained instead.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Correct, fixed in 3476a89. The llama phase only starts once the freshness check has offered a newer release, so kept_existing always means the update did not happen. It now reads "llama.cpp could not be updated right now, so the existing install was kept. Try again later." and the test asserts the string no longer contains "up to date".

…tract

Extends the marker-shape cases with the product the installer actually has to
serve. Fifteen cells across Linux, WSL, Windows and macOS by NVIDIA, AMD, CPU
and Vulkan, each asserted three ways: a complete tree is kept, a gutted one is
refused, and an accelerator tree missing only its own backend library is
refused. That last case is the one that matters after a partial extraction,
where the binaries still start and only fail once a model is loaded. Vulkan,
windows-hip, windows-rocm, windows-arm64 and linux-arm64-cuda had no payload
coverage at all before this.

WSL is asserted to behave exactly like Linux, which is the claim worth pinning:
HostInfo carries no WSL field and the WSL2 ROCDXG handling lives in host
detection and setup.sh, upstream of the keep path.

Adds the exit contract the setup scripts branch on, driven through
install_prebuilt rather than the deciders: a transient failure returns 0 for
every shipped marker shape, a tree that is not runnable still reaches
EXIT_FALLBACK so a source build can proceed, an explicit version request is
never answered with the old install, and a marker recording a backend this
build cannot install exits EXIT_ERROR before the keep branch is reached. That
last ordering was untested and is what stops a newer marker being answered with
the tree already on disk.

Also covers a marker whose keys were grafted on by sync_marker_selection rather
than written in one go, which is the shape a long-lived install really has, and
a marker naming another platform's backend, which falls open rather than being
judged by a table that does not apply.
@danielhanchen

Copy link
Copy Markdown
Member

Second pass, filling in what I had only simulated lightly last time. One more commit, 2051afb06.

Old installs, tested against a real one

The tests I added first time build install trees out of stub binaries, which covers the decision logic but cannot answer "does an install a previous release actually produced survive this upgrade". So I took the tree studio/install_llama_prebuilt.py really wrote on this box (b10698, CUDA 13, 450 MB of real binaries), hardlink-cloned it per case, rewrote UNSLOTH_PREBUILT_INFO.json to each shape that has shipped since #4562, and ran the real installer with HTTP(S)_PROXY pointed at a closed port so the release listing fails the way a flaky connection does.

install originally from exit binaries unchanged still runs
S1 (#4562, Mar) no release_tag, no backend 0 yes yes
S2 (#4741, Apr) 0 yes yes
S5 (#7228, Jul) force_cpu 0 yes yes
S6 (#7373, Jul) legacy Vulkan 0 yes yes
S6 with a marker claiming Vulkan on a tree that has none 5 yes yes
S9 (#8520, Aug) first backend key 0 yes yes
S11, what main writes today 0 yes yes
empty {} / corrupt JSON / unknown future keys 0 yes yes

Every real old install survives with byte-identical binaries that still execute. The exit-5 row is the one I want to highlight, because I guessed wrong and the code was right: a marker recording a Vulkan choice on a tree carrying no Vulkan library is refused, and because a concrete backend is recorded it fails closed with 5 rather than letting a source build quietly substitute a different backend. Nice.

The full [Windows, Linux, WSL, macOS] x [NVIDIA, AMD, CPU] product

Fifteen cells, each asserted three ways: a complete tree is kept, a gutted one is refused, and an accelerator tree missing only its own backend library is refused. That third case is the one that bites after a partial extraction, because the binaries still start and only fail once a model loads. Five install kinds had no payload coverage anywhere in the repo before this: linux-arm64-cuda, windows-hip, windows-rocm, windows-arm64, windows-vulkan.

WSL is asserted to behave exactly like Linux, which is the claim worth pinning: HostInfo carries no WSL field and the WSL2 ROCDXG handling lives in host detection and setup.sh, upstream of the keep path. So a WSL ROCm install needs libggml-hip.so for the same reason a bare-metal one does.

The exit contract, driven through install_prebuilt

Exit codes are what setup.sh and setup.ps1 actually branch on, so these go through the real entry point rather than the deciders:

  • transient failure + any shipped marker shape gives 0 and keeps;
  • a tree that is not runnable still reaches EXIT_FALLBACK, so a source build can proceed. Without that the keep path would tell someone with a half-deleted install that everything is fine;
  • an explicit version request is never answered with the old install;
  • a marker recording a backend this build cannot install (backend_request: "sycl") exits EXIT_ERROR via UnknownBackendRequest before the keep branch is reached. That ordering was untested, and it is what stops a newer marker being answered with the tree already on disk.

Diffusers and the nobuild guard

diffusers 0.40.0 does publish diffusers-0.40.0-py3-none-any.whl on PyPI, so the pin resolves to a wheel and your comment is accurate.

Ran .github/scripts/assert-nobuild.ps1 under real pwsh 7.6 against synthetic logs. It behaves correctly on all ten: clean passes; Building diffusers==0.40.0 and Building wheel for diffusers both pass (allowlisted, and both the pip and uv phrasings parse); an unexpected Building numpy== fails; Building unsloth @ file:// is correctly not treated as a resolved sdist; a gcc error and the MSVC message each fail on their own; an ANSI-coloured line still fails, so the escape strip works; UNSLOTH_ALLOW_SDIST works; a missing log fails. So the broad-by-name Diffusers entry is not a hole, because the name-independent compiler check still fires. My earlier point about it stands only as an expiry concern.

Seed encodings after the fix

Twelve encodings through the real helpers, checking that all n choices of one request agree. -1, 4294967295 and 2**64-1 all stay random and keep caching across every choice; 0, 1, 3407, 4294967294, 2**31, 2**32, -(2**40) and -(2**63) all offset and disable caching for every choice. A seeded n>1 request still yields distinct uint32 seeds and never lands on the sentinel.

Correction to my own earlier comment

I said an unknown backend value "fails open". More precisely it falls back to the asset name first, and only falls open when that names no backend either. Both branches are now tested. The behaviour is better than I described it.

Everything still passing: 37,196 backend tests, 96 in the new back-compat file under both xdist and serial, 5,977 frontend, typecheck clean.

The branch still conflicts with main in 7 files, and that is now the only thing gating a clean CI read.

The branch has been unmergeable, which meant GitHub could not compute a merge
commit and so ran no workflows at all: every check on the last few pushes was
"error during mergeable check" rather than a real result.

Six of the seven conflicts are the same fixes landing twice. main got there
first and with more detail, so its side wins and this branch's copies go:

- unsloth_cli cloudflare and parallel flag tests, both pointing STUDIO_HOME at
  a writable path instead of /fake;
- test_inherited_custom_dtype_is_neutralized, which main pins with setdefault;
- test_studio_home_node_dir, where main's block extraction walks back from the
  NODE_DIR assignment instead of anchoring on one branch's text, so it survives
  a branch being added or reordered;
- the AppImage fixture CORS pair, where main echoes the requested headers
  rather than keeping a second copy of the backend's allow_headers list.

scan_packages_baseline.json goes the other way. This branch's side is a
superset: it carries the file_sha256 pins on the three unsloth-zoo entries and
the triton entry that main does not have, so taking main there would delete the
digest pinning this PR added.

Verified on the resolved tree: 3,584 install, security, python-stack and
unsloth_cli tests, 585 security tests where unsloth is installed, and both
tests/sh suites.

@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: 62fef15c4d

ℹ️ 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 +6986 to +6990
except OSError as exc:
if exc.errno == errno.ENOEXEC or getattr(exc, "winerror", None) == _ERROR_BAD_EXE_FORMAT:
log(f"kept install rejected: {path.name} is not an executable image ({exc})")
return False
return True

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 Reject inaccessible root entrypoints before keeping install

When build/bin/llama-server remains executable but the separate root llama-server copy has lost its execute permission, probing the root copy raises EACCES, which this branch treats as healthy. _existing_install_runs then keeps the old installation and returns success, even though inference prefers the root entrypoint and therefore cannot launch it; reject permission-related spawn failures or explicitly require root copies to be executable.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The premise does not hold, so no change here. Inference does not prefer the root entrypoint unconditionally: _scan_pinned in studio/backend/core/inference/llama_cpp.py classifies a root copy without the execute bit as non_executable, remembers it, and keeps scanning the rest of that layout, so build/bin/llama-server still wins.

Reproduced both branches on this host against the real discovery code:

  • non-executable root copy, executable build/bin copy -> _find_llama_server_binary() returns the build/bin path and the server launches.
  • both copies non-executable -> returns None, but that case is already rejected by the keep path, which runs os.access(..., os.X_OK) over the build/bin llama-server and llama-quantize before any probe.

So the EACCES spawn result the probe treats as healthy never keeps an install inference cannot launch. Treating it as fatal would also cost accuracy on Windows, where ERROR_ACCESS_DENIED is routinely a transient antivirus or in-flight-replace lock rather than a permanent state, and a false negative there spends a full source build on a working install.

@danielhanchen

Copy link
Copy Markdown
Member

Resolved the conflicts with main and pushed the merge (62fef15c4), because they turned out to be blocking more than merging.

The conflicts were stopping CI from running at all

After my last few pushes gh pr checks reported exactly one check, pre-commit.ci, saying "error during mergeable check", and the Actions API returned zero workflow runs for the head SHA. That is the mechanism rather than bad luck: GitHub cannot build the merge commit that pull_request workflows run against while the branch conflicts with its base, so it runs no workflows. Every green check currently shown on this PR predates the conflicts.

After the merge: mergeable went UNKNOWN to MERGEABLE, and the check count went from 1 to 90 running. The suite is now actually executing against this branch for the first time in a while. The org queue is congested at the moment (about 330 queued against 22 in progress) so it will take a few hours to drain, and I did not cancel anyone else's runs to jump it.

How I resolved them

Per hunk, keeping git's auto-merged content rather than taking whole files.

Six of the seven are the same fix landing twice, which is what you would expect from a branch that has been open while main moved. main got there first and with more detail, so its side won and this branch's copies went:

  • the two unsloth_cli flag tests, both moving STUDIO_HOME off /fake;
  • test_inherited_custom_dtype_is_neutralized, where main pins UNSLOTH_ALLOW_CPU with setdefault;
  • test_studio_home_node_dir, where main's block extraction walks back from the NODE_DIR assignment instead of anchoring on one branch's text, so it survives a branch being added or reordered;
  • the AppImage fixture CORS pair, where main echoes Access-Control-Request-Headers rather than keeping a second copy of the backend's allow_headers.

scripts/scan_packages_baseline.json went the other way. Your side is the superset: it carries the file_sha256 pins on the three unsloth-zoo entries plus the triton entry that main does not have. Taking main there would have deleted the digest pinning this PR added, which is why I did this per hunk rather than with --theirs.

Verified on the resolved tree before pushing: 3,584 install, security, python-stack and unsloth_cli tests; 585 security tests in the venv that has unsloth installed; both tests/sh suites (34 passed, all passed). All five earlier commits confirmed still in history.

Where the branch stands

commit
69a74391f uint32 sentinel in _choice_seed
620180460 stop reporting a kept install as a fresh one
0b63166be fail the zoo step on an empty mlx glob, name the file on exit 5
49b868305 marker-shape back-compat tests
2051afb06 OS x accelerator matrix and the exit contract
62fef15c4 merge main, dropping the duplicates it landed first

Happy to drop or rework any of these if you would rather take them differently. The two things I deliberately did not touch, because they are yours to decide, are the seed cost trade-off (any pinned seed disables prompt caching, at 1.1x to 4.6x depending on prompt length, with no UI copy saying so) and the MCP !usable removal, which is a real product and accessibility change rather than a CI fix.

Same behaviour, fewer lines. AST comparison confirms every changed .py file is
identical once docstrings are stripped, so this is comments only. setup.sh
passes bash -n, setup.ps1 parses, the workflow YAML parses and its zoo step body
still passes bash -n.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Aug 31, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 3476a89b42

ℹ️ 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".

@danielhanchen
danielhanchen merged commit 1400031 into unslothai:main Aug 31, 2026
27 of 106 checks passed
danielhanchen added a commit that referenced this pull request Sep 1, 2026
danielhanchen added a commit that referenced this pull request Sep 1, 2026
danielhanchen added a commit that referenced this pull request Sep 1, 2026
* Reduce the comments added by PR #9979

* Shorten the docstrings added by PR #9979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants