Repository navigation
Studio: answer current llama.cpp, whisper.cpp and Node installs from their markers - #10648
Conversation
existing_install_matches spawned `node -v` and `npm --version` on every installer run to re-derive an answer that cannot have changed while the binaries have not: two interpreter starts of a 110 MB runtime, per run, on every platform. The marker now records the size, mtime and digest of the node binary and the npm cli beside the version and npm major those exact bytes reported, written after the swap (_ensure_npm_floor rewrites npm inside the staged tree, so a record taken there describes bytes about to be replaced). A run whose records still describe what is on disk believes them; anything else spawns as before and then records the result, so an install predating this pays it once. Version and pinned digest still decide on their own -- the short-circuit is only about the two spawns.
The no-network re-check compared only the recorded backend_request and
force_cpu, and backend_request is "auto" on every automatic install. Since
the release tag does not move when hardware does, an auto install kept its
CPU bundle after a GPU was added, kept its CUDA bundle after the card or the
driver went away, and kept a coverage bundle after a card outside its
supported_sms replaced the old one, in each case until the fork happened to
publish a new release.
So record what detection actually said. write_prebuilt_metadata now stores a
host_profile (usable NVIDIA, driver CUDA version, sorted compute caps, ROCm
and its gfx targets, Intel GPU, AMD without ROCm, macOS version) taken from
the routed HostInfo the selection was made from, and the re-check re-derives
the host through route_backend_request, the same no-network routing _select
uses, with the same overrides and the same CPU mechanism. A marker with no
host_profile cannot answer and takes the full path. The route is computed
once in install_prebuilt and handed to both, so an update that does find a
new release does not run nvidia-smi twice.
Two smaller holes in the same check:
* the payload half only globbed for existence, so a truncated
libggml-cuda.so, ggml-cuda.dll or cudart DLL passed it -- and those
libraries are where most of a CUDA bundle's bytes live, which is exactly
what a full disk or an interrupted extract leaves behind. runtime_files
now records size and mtime_ns for every file the bundle's own copy
allowlist matches, stat only, and sizes are compared; the three binaries
keep their sha256. mtime is recorded but never compared, since a restore
or an rsync rewrites it without changing a byte.
* a marker's backend and backend_request must be a pair
persisted_marker_backend_request could have written, and the backend must
name an install kind this platform has.
"latest" keeps one documented lag: /releases/latest resolves by
make_latest/created_at while the macOS path orders by published_at, so a
re-published release can leave this reporting "current" for one update. That
is now written down next to the check, an explicit
UNSLOTH_LLAMA_DISABLE_DOWNLOAD_HOST_RESOLVE gets the API's published_at
answer instead of a flat refusal, and a releases payload this process already
fetched is compared for free.
The reuse path backfills runtime_sha256, runtime_files and host_profile onto
a marker written before these existed, so a pre-existing install pays the
full path once rather than on every update.
…eused existing_install_current_without_plan refuses a slim install whose marker cannot say which llama ggml runtime it hardlinks, and only installs made after that key existed carry it. So every whisper install made before this branch fetched the release, its manifest and its checksum index on every update rather than once. The reuse path is the only place that re-examines a slim install without reinstalling it, and it gets there having just confirmed the fingerprint and the wiring, so that is where the tree is recorded. Added, never corrected: a marker that already names a tree was written by the run that installed against it, and a llama runtime that moved since is exactly what the pre-check exists to notice. The write goes through the same atomic, never-raising marker writer the llama installer uses, so a read-only or full disk warns rather than failing setup.
record_runtime_verification read the marker, added the verification records and wrote it back with write_text. load_metadata reads a truncated or unparseable file as "no install", so a crash or a full disk partway through that write retires an install that was fine and buys a ~110 MB refetch -- and unlike the install-time write, this one is rewriting a file that already describes a good tree, so a torn write is strictly worse than not writing at all. Both marker writes now go through one helper: a sibling temp file, flushed and fsynced, then the module's existing atomic_replace_from_tempfile, with the temp file removed on every failure path so a stranded .tmp- sibling cannot be carried into the live tree by _swap_into_place. The bytes are unchanged, including the platform newline, because the setup fast path and the idempotency harness both compare this file byte for byte. record_runtime_verification still never raises; write_metadata still does, since it writes into a staging tree that is discarded.
…alth The recorded-runtime shortcut accepted two installs that do not work. chmod -x moves ctime only, so the recorded size and mtime_ns both survive it and the record still matched a node binary nobody can execute. The spawn the record stands in for would have failed and the install would have been repaired, so re-derive that one answer with os.access rather than trust bytes that are no longer reachable. Not asked of npm-cli.js, which node reads rather than executes, and not asked on Windows, which has no execute bit. The npm record covers npm-cli.js, a launcher that bootstraps thousands of files under npm/lib: deleting npm/lib/cli.js leaves the recorded launcher byte identical while `npm --version` fails, and the shortcut kept it. No cheap record of the launcher can show the tree behind it is intact, so the npm probe is paid again on every run. That still saves one interpreter start of a 110 MB runtime out of two, and a damaged npm is rejected instead of kept. The docstrings now say what the record does and does not prove.
On a strictly offline update, with UV_OFFLINE set and a proxy refusing every connection, llama.cpp reported "update unavailable, existing prebuilt kept" and moved on while whisper.cpp printed "prebuilt install failed; curated whisper.cpp dictation is unavailable" over a healthy install it had never touched. Nothing was wrong with the install; the release lookup simply had no answer to give. whisper now mirrors llama's rule for the identical outcome. The checks that do not depend on knowing which release is newest are split out of the pre-check into _existing_install_is_intact, so the keep path makes exactly those demands and no others rather than carrying a second copy of them: the marker was written by this installer for this repo and this backend, a slim bundle still hardlinks the llama ggml tree it was wired against, and the tree on disk is the shape the marker describes. That helper runs before the "latest release" HEAD now, so a damaged tree no longer pays a round trip to learn it must reinstall anyway. ReleaseCompatibilityError is re-raised ahead of the handler: there the lookup did answer, and the answer is real release skew that setup reports from exit 2. So is anything this run asked for that keeping the tree would silently ignore, which is --force, --cpu-fallback, and any pinned tag. --has-rocm and --rocm-gfx are not on that list, for llama's reason: both entrypoints forward detected hardware on every AMD host, including the one this was observed on. The kept line carries both tokens the shells need, and both setup scripts gain the whisper arm their llama one already had, so exit 0 after a lookup that could not answer no longer reads as "prebuilt installed".
…elf is unreachable The keep path added for an offline update only reads PrebuiltFallback, but the shared release fetch raises the network error as is (URLError from a refused connection or a proxy answering 403), so a strictly offline update still printed "unexpected error" and "prebuilt install failed" over a healthy install. Wrap those at this module's fetch seam with the wording the keep path already reports, and test through the seam rather than a stand-in that spoke PrebuiltFallback already. Reproduced and confirmed in a CUDA sandbox with a dead proxy.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…u architecture, rate limits The no-network re-check answered current for four installs the full path would have changed: - a bundle kept only because the preferred one could not be fetched (prebuilt_fallback_used) was never retried - a pinned UNSLOTH_LLAMA_RELEASE_TAG ignored a concrete UNSLOTH_LLAMA_TAG - host_profile carried no cpu architecture, so a home directory moved between an x86_64 and an arm64 box kept a bundle the loader cannot run; the whisper intact check now also requires the recorded asset to carry this host's os and arch tokens - a stale host_profile was never refreshed by the reuse path, so a hardware change sent every later update down the full path forever The whisper keep path also reads the RuntimeError fetch_json raises on an HTTP 403/429 from api.github.com, not only URLError, so a rate-limited update keeps an intact install instead of failing.
iter_resolved_published_releases takes the download-host fast path for the default repo only and orders any other repo's releases by published_at, so the llama pre-check now asks the API for that ordering on a custom repo instead of following /releases/latest, which a custom repo can leave pointing at the installed release forever. The whisper fork publishes several packaging revisions of one upstream tag and _release_plan_for_host takes the newest that matches, so a whisper upstream pin is now current only when the installed release is also the one the download host HEAD names; the marker's upstream_tag still refuses a wrong pin outright.
…ees to what they asked, and write marker refreshes under the lock The host profile gains has_physical_nvidia: the Intel and ROCm-less AMD routes go to Vulkan only when no NVIDIA adapter is present at all, so an adapter that appeared or went without becoming usable changed the selection with every recorded field equal. whisper's shortcut checks an upstream pin whether or not the release is pinned too, as the full path does, and --cpu-fallback no longer counts as an explicit release request: it is a backend request the intact check already compares, so a kept CPU tree honours it as --backend cpu does and an offline update with it is recoverable. The two marker refreshes that ran before the install lock (node's runtime record, whisper's slim pairing backfill) now write under it and only over the marker they read; the node marker keeps its mode across a refresh instead of NamedTemporaryFile's 0600. The llama full path holds a marker to the runtime sizes and digests it recorded, so a truncated llama-server.exe is repaired on Windows, which has no image preflight.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9225d1a17e
ℹ️ 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".
| # next run can compare it against the live one. Absent means "written before | ||
| # this key existed", which reads as "cannot say" and takes the full path. | ||
| paired_tree = getattr(ops, "installed_paired_runtime_tree", None) | ||
| paired_tree = paired_tree() if callable(paired_tree) else None |
There was a problem hiding this comment.
Record the ggml tree that was actually linked
When llama.cpp is updated concurrently with a slim Whisper installation, prepare_runtime_payload can hardlink libraries from one llama tree while this later callback reads a different live llama marker after the directory swap. The Whisper marker then claims the new tree even though its linked libraries came from the old one; because the marker-only check compares only this recorded tree with the live llama marker, later updates can report the potentially ABI-incompatible installation current. Carry the tree identity from the pairing/link operation rather than re-reading the mutable live install here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Declined. setup runs the llama.cpp and whisper.cpp installers one after the other, and the pairing record is written after the wiring it describes was verified against the live llama marker; a llama update landing in the milliseconds between the hardlink and the marker write would need a second installer racing the one setup is running, which the install locks and the CLI's idle scan are there to prevent. The next update compares the recorded tree against the live one and re-pairs if llama moved.
…isting as a lookup, the selector's page depth, and the post-install record under the lock whisper's intact check applies the bundle's recorded min_os on macOS, as the selector does, so an install restored onto an older Mac is not reported current. An upstream pin is compared normalised (v1.9.2 and 1.9.2 are one tag). A failing compatibility listing (an API limit or a network error) is a lookup that could not answer and takes the keep-existing path instead of failing an intact install. llama's API fallback scans the pages the full selector scans. Node's post-install runtime record takes the install lock again and writes only over the marker this install wrote.
…atch _record_runtime_verification_under_lock now reports whether the marker was still the one it read, and the pre-lock check answers False when it was not: the tree another installer swapped in while this one waited is not the version that was verified, and the locked re-check decides about it.
The whisper intact check reads the macOS floor where write_prebuilt_metadata records it, the marker's top-level min_os, and still accepts one nested under coverage. A pre-lock keep whose re-check under the lock finds another install falls through to the locked validation and install path instead of reporting the replaced release as installed. For latest on the upstream repo on a Mac below the floor, the llama marker check expects the pinned fallback release the selector would choose, so a current pinned install takes the fast path.
Multi-line rationales collapsed to the fact they carry, decorative rules and bare section banners dropped. Added comment lines 577 to 459. No code, and the install suite is unchanged at 4613 passed, 21 skipped.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00adf60dd3
ℹ️ 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".
| except (OSError, RuntimeError) as exc: | ||
| raise PrebuiltFallback(f"could not list {published_repo} releases: {exc}") from exc |
There was a problem hiding this comment.
Catch malformed release-list responses
When an unpinned macOS install must scan older releases and the GitHub releases endpoint returns a truncated or otherwise malformed JSON response, fetch_json raises json.JSONDecodeError (a ValueError), which this handler does not convert to PrebuiltFallback. The exception therefore bypasses the new keep-existing path, causing an update to fail or fall back to a source build despite an intact installed Whisper runtime; handle ValueError here as another lookup that could not answer.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
json.JSONDecodeError cannot reach this handler. fetch_json catches (UnicodeDecodeError, json.JSONDecodeError) at prebuilt_core.py:783 and re-raises the failure as a RuntimeError, which is already in the except clause on the line below.
I checked it rather than reading it, driving _published_release_tags with the three shapes a truncated or corrupted response can take:
truncated -> RuntimeError: downloaded invalid JSON from https://api.github.com/...
not utf-8 -> RuntimeError: downloaded invalid JSON from https://api.github.com/...
empty -> RuntimeError: downloaded empty JSON payload from https://api.github.com/...
All three become PrebuiltFallback here and take the keep-existing path, which is the behaviour the item asks for. The one other way out of _published_release_tags is its own PrebuiltFallback for a well-formed payload that is not a list, and that is the keep path's own signal, so it propagates on purpose.
Adding ValueError to the clause would catch nothing that reaches it and would widen the handler over the loop body below, where a ValueError is a bug worth surfacing rather than a lookup that could not answer.
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
A staging Windows run of the whole install suite, differenced against the same run on the merge base, left exactly four head-only failures, all of them tests this branch adds: - two mode-bit corruptions (llama and whisper), where os.chmod cannot clear an execute bit Windows does not have and os.access(X_OK) answers "does this exist", so the damaged tree is correctly still current - the end-to-end setup.sh status check, whose local bash guard let Git Bash on a Windows runner into a block the requires_bash marker already excludes - the About-tab marker rewrite, which monkeypatched os.chown, absent on Windows No pre-existing test changed verdict: the other 45 failures are present on the merge base too and are the bare runner, not this branch.
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Cross-platform evidence, and the one red checkThe org queue cannot answer everything this branch touches, so I ran the whole install suite on owned staging runners and differenced it against the merge base rather than reading head in isolation. Linux, Apple Silicon macOS, Intel macOS: green. ARM64 Windows never reaches pytest, because Windows x64 is the interesting one, and it is the first time these suites have run there at all: the org's Windows parity job runs
Gated in e133dfe. The re-run is 45 failed, 1058 passed, byte-identical to the base set: zero head-only failures. The 45 are the bare runner (no pwsh module set, a network-restricted box, POSIX archive semantics) and are present on the merge base too. The red check is Everything else on head: 49 green, 3 skipped. |
…mitted Three follow-ups from an adversarial re-review of this branch. An explicit release pin was satisfied by a walked-back install. The macOS walk-back records why AUTOMATIC selection settled on an older release, and _release_expectation_met consulted it whatever the caller asked for, so a run that named b9999 on a Mac holding b9998 was told "already matches selected release b9999". The full path disables older-release fallback as soon as published_release_tag is supplied; the fast path now does the same. The marker writers asked chown for the group alone. That was right for the non-root member of a group-shared install, whose combined call chown refuses outright, and wrong for root, the one caller that can restore the owner: it left the marker owned by root, so an 0600 marker stopped being readable by the user who owns the install. All three writers now try owner and group first and fall back to the group. Node swallowed a failed chmod and swapped the temp file in anyway, publishing NamedTemporaryFile's 0600 over a marker other users read. It now abandons the replacement, as core and llama already did.
Second verification pass: five independent adversarial reviews, plus determinism and upgrade proofsI put this branch through a second round aimed specifically at the claim that it is hardening with no effect on real installs. Three genuine defects came out of it, all now fixed in b9a0c25. The claim itself needs one correction, stated first because it is the important one. The one intended behaviour changeThis is not a pure no-op, and it should not be described as one. Over an intact whisper install with no network, measured by driving the real
A failed release lookup over a healthy install used to be reported to the user as a failed update. That is the fix, not a side effect, and it is the only case where the two sides say different things to a user. Three defects found and fixedAn explicit release pin was satisfied by a different release. On a Mac that walked back from b9999 to b9998, a run that explicitly asked for b9999 was told The marker writers asked chown for the group alone. That was my earlier fix for the non-root member of a group-shared install, whose combined call chown refuses outright. It is wrong for root, the one caller that CAN restore the owner: it left the marker owned by root, so an 0600 marker stopped being readable by the user who owns the install. All three writers now try owner and group first and fall back to the group. This one came from a reviewer arguing against a change I had already made, and it was right. Node swallowed a failed chmod and swapped the temp file in anyway, publishing Determinism: same host, same choiceBoth sides loaded side by side and driven over 66 host shapes (Linux, Windows and macOS x86_64/aarch64/arm64, CPU, CUDA 12 sm89, CUDA 13 sm100 and sm120, ROCm gfx1100/gfx942/gfx1151, AMD without ROCm, Intel, Metal, macOS 13/14.7/15/26) against the REAL published release The non-vacuity assertion is part of the script, because an earlier version of this check passed with 43 of 45 cells returning the same HTTP 404 and "identical" meaning "identically broken". AST surface diffStructural rather than a diff read, over the four installers and the backend's marker reader: The setup scripts add exactly five lines each: one whisper Upgrading from the shipped Desktop buildsRan for real against v0.1.806-beta, v0.1.807-beta and v0.1.808-beta: each tag's OWN writer produced a marker, in its own interpreter, and this branch's readers were pointed at it.
PlatformsEight OS legs on staging runners: Linux x64, Linux ARM64 (24.04 and 22.04), macOS 15 and macOS 26 on Apple Silicon, macOS 15 and macOS 26 on Intel, Windows x64. All green except Windows, which is 45 failed / 1062 passed and identical to the merge base's failure set on the same runner, so zero head-only failures. WSL has no hosted runner anywhere; it is Linux with On MLX I will not claim coverage I do not have: the leg I ran deselected everything because the runner had no Known limits, stated rather than buried
|
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
The previous commit stopped Node swallowing a failed mode restore, which was right for a REFRESH: swapping the temp file in anyway publishes a marker only its writer can read over one other users already read. It was wrong for the FIRST write, which has no mode to preserve and no other readers, and where write_metadata is not wrapped, so the exception aborts the whole Node install. On Windows that is reachable rather than theoretical: a scanner holding the freshly written temp file is the same sharing violation atomic_replace_from_tempfile already retries for, and it would have taken down an install that has nothing wrong with it. The refresh still abandons and leaves the good marker exactly as it was. Three tests, and each half of the split fails a different one when neutralised.
The chown rationale was repeated verbatim in all three marker writers. It now lives once, in the shared module the other two mirror, and they point at it. Added comment lines since that pass: 41 to 22. No code.
A release whose checksum index cannot be fetched is skipped by the iterator and logged, and the planner never sees it, so a macOS walk-back records only that the newest release was unusable. A middle release passed over for a transient failure is then not reconsidered until something newer publishes, where the pre-PR path would have taken it on the next update. Same consequence as the pointer lag documented beside it and left alone for the same reason: both releases are compatible, so it is one deferred update and never a wrong install, and it clears on the next publish. The docstring names the fix if it is ever worth closing. Docstring only.
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
ConvergedCodex is clean on Two things closed since the last update, both worth recording because one of them was my own mistake. The red check was half flake and half me
The failure itself is infrastructure: the chat lane passed 38/38 in the same job, the server was answering 200s throughout, and the extra lane died on But looking for the link turned up a real defect I had introduced one commit earlier. I had stopped Node swallowing a failed mode restore, which is right for a refresh: swapping the temp file in anyway publishes a marker only its writer can read over one other users already read. It is wrong for the first write, which has no mode to preserve and no other reader, and where A second deferral of the accepted-lag class, documented rather than fixed
I left it alone and documented it beside the pointer lag it matches, for the same reason: both releases are compatible with the host, so it is one deferred update and never a wrong install, and it clears on the next publish. Closing it means threading a flag out of the iterator to suppress the walk-back whenever anything was skipped transiently; the docstring says so, in case it is ever worth doing. Evidence refreshed against the current headThe About tab parity pair was photographed against A comment-reduction pass ran over everything added since the last one: the |
|
CI is fully green on |
The keep-existing paths hold an install and report success because a lookup
that could not ANSWER says nothing about the tree on disk. Two refusals are not
that: an asset absent from the checksum index, and a manifest digest that
disagrees with it. Both mean the release was fetched and found untrustworthy,
and both arrived as a plain PrebuiltFallback, so the keep arm swallowed them.
Measured over an intact install with a manifest digest conflict:
merge base exit 1 prebuilt install failed ... refusing a possibly
tampered release
before this exit 0 whisper.cpp update unavailable, existing prebuilt kept
which also picks the yellow setup message instead of the red one. A tamper
signal became a routine offline notice.
prebuilt_core now raises ReleaseIntegrityError, a PrebuiltFallback subclass so
every existing handler still catches it, and the two keep paths single it out.
Whisper's keep arm is new on this branch, so that one is a regression this work
introduced; llama's predates it and had the same hole, closed here so the two
installers cannot disagree about what a keep is allowed to hide.
Offline over an intact install still keeps and exits 0; a tampered release now
exits 1 on both sides exactly as the merge base did. Six tests. Neutralising
either guard fails one, which the unit tests alone did not: with the whisper
re-raise removed the entire install suite stayed green and only an end-to-end
run through the CLI noticed, so both tests drive the real entry point.
…ring A legacy slim marker carries no pairing identity, so the migration run records the llama runtime that is live at that moment. If llama was replaced after whisper was wired -- a per-gfx ROCm reselection, or another installer swapping llama's directory while this one holds only whisper's lock -- the hardlinks still point at the previous libraries, and recording the live identity writes a pairing that is simply false. The runtime-id check then believes it, so the reselection this key exists to catch becomes permanently invisible rather than merely unnoticed once. The backfill now proves the wiring first. link_ggml_runtime hardlinks, so a shared (st_dev, st_ino) IS proof that whisper's name and llama's name are one file; it falls back to shutil.copy2 across filesystems, where the inodes differ legitimately, so an inode mismatch drops to a size and sha256 comparison rather than a verdict. Anything unverifiable records nothing and logs why: a missing record costs the fast path on the next update, a wrong one costs the install.
…iled setup The runtime-verification record is written under the install lock, and a lock that was busy was being read as "another installer replaced the tree". It is not: the evidence for a replacement is the marker no longer being the one that was read, and that check answers False by itself. Busy says only that nothing was written. The cost of reading it as a mismatch falls on exactly the installs that have a record to backfill, which is every Node install made before this branch. Beside a running installer, the pre-lock check answered "not matching", the outer install lock then failed against the same holder, and setup.sh treats Node exit 3 as fatal -- so the first update after upgrading could report a failed launch over an install that was complete and running. Before the record existed there was no lock on this path at all and the answer was exit 0, which is what it is again. The wait is now short as well. Blocking a launch for the full 300s install timeout to write a record whose only purpose is to save two subprocess spawns next time is worse than never writing it, so install_lock takes a timeout and the record asks for 5s.
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
record_runtime_verification rewrote the marker every time it ran. Under UNSLOTH_PREBUILT_FULL_CHECK that is every run, which re-proves what the record already says and then publishes it again: a new inode, a new mtime, and the mode and owner re-applied, forever, for a file whose bytes do not change. It now returns when the four fields it would write are already the four fields that are there. Also pins, with a test, why the record can afford to compare stat fields and not the digest it stores. npm-cli.js is run BY the node binary and that probe is never skipped, so a node that cannot run is rejected whatever the record says -- the case an update can actually repair is not the case being skipped. The rest is stated in the docstring rather than implied: the record lives in a marker beside the binary, writable by anyone who could rewrite the binary in place, so it is a staleness check and never a tamper defence. Neither was the `node -v` it replaces.
The catch-up takes the install lock because it is a read-modify-write of the marker and a concurrent installer can be mid-swap. It was asking for the full 300 second install timeout, which is the wrong price for it: it runs on the FIRST update after an upgrade, for every existing user, and everything it writes only spares the next run some work. Beside a running installer that made an otherwise finished launch sit for five minutes before reporting the install it had already validated. It now asks for five seconds, the same as the Node record, and the give-up path is unchanged: the install is kept, the exit code is 0, and the next run settles it.
Third verification round: five more independent adversarial reviews, four more fixesFive reviewers were pointed at the branch again, one question each (idempotency, byte exactness, A busy install lock could turn a matching install into a failed setupThe Node runtime-verification record is written under the install lock, and a lock that was merely The cost fell on exactly the installs that have a record to backfill, which is every Node install Two paths waited for the full install timeout to write an optimisationThe Node record asked for 300s; the shared metadata catch-up over a kept install asked for 300s. A slim whisper pairing could be recorded without being trueA legacy slim marker carries no pairing identity, so the migration run recorded whichever llama The backfill now proves the wiring first. Node republished an identical marker forever under UNSLOTH_PREBUILT_FULL_CHECKThe record writer rewrote the marker every time it ran, which under the full-check flag is every Three findings answered rather than changed"Node compares size and mtime, not the digest it records." Two reviewers reproduced the same "An unchanged release tag does not prove unchanged published bytes." Correct, and it is the "Whisper can keep a fat CPU install where the base would migrate it to slim." Reproduced only |
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Confirmed the no-op update path still re-resolved and re-validated releases on every run, and the marker fields here cover the backend, tag and runtime digests. The one thing I want stated plainly before merge is the accepted lag: |
Summary
Every
studio updatere-validated the prebuilt llama.cpp install (13 to 63 s on macOS, about 5 s on Windows), re-fetched the whisper.cpp release listing, and re-spawnednode -vandnpm --versionfor the isolated Node runtime, even when the installed release already matched what the update would select. This PR answers those three questions from the install markers first, and falls back to today's path whenever the marker cannot answer.Scope of the saving, stated precisely so the numbers above are not read as the whole cost. What the fast path removes is the release resolution, the manifest and sha256 fetches, the macOS paginated listing walk-back, and one of Node's two spawns. What it deliberately keeps is
preflight_macos_installed_binaries, which still runsllama-server --versionandllama-quantize --versionper update on macOS, and Node'snpm --version. A digest proves the bytes did not change; only a load proves the OS can still resolve the link graph, and onlynpm --versioncovers a launcher spread over thousands of files. The 13 to 63 s figure is the whole pre-PR re-validation, and the retained preflight is a part of it, so a no-op macOS update still pays the two cold process launches. The macOS saving is the release resolution and the listing walk-back, not the spawns.Before
install_llama_prebuilt.pyalways resolved the release, selected an asset, downloaded or compared it, and re-ran the binary preflight.install_whisper_prebuilt.pyalways fetched the release for install.install_node_prebuilt.pyalways spawned node and npm to check a runtime it had verified on the previous run.After
_select,existing_install_current_without_planchecks the recorded marker: same published repo, a recorded install fingerprint, the same backend request and force-cpu flag, the release tag the pin or the latest-release lookup names, an intact tree with the executable bits set, and the recorded sizes and sha256 ofllama-serverandllama-quantize(and the diffusion server when present). Only then does it print the existingalready matches selected releaseline and return. A lookup failure, a missing field or a pre-PR marker (noruntime_files) falls through to the full path once, which then records the new fields.UNSLOTH_LLAMA_FORCE_COMPILE*,UNSLOTH_LLAMA_KEEP_PREBUILTand a newUNSLOTH_PREBUILT_FULL_CHECK=1bypass the short-circuit.Compatibility
UNSLOTH_LLAMA_CPP_BACKENDchange still re-selects. The AMD runs below exercised the ROCm asset selection on gfx1151 for Linux and Windows.setup.shandsetup.ps1grep for (already matches,nothing to do) are unchanged.How it was tested
tests/studio/install/test_install_llama_prebuilt_logic.py,test_install_whisper_prebuilt_logic.py,test_install_node_prebuilt_logic.pycover the marker match, each mismatch, the fallthrough on missing fields, the bypass variables and the atomic write.github.comrelease assets,release-assets.githubusercontent.comornodejs.org. Fault injection: a truncatedllama-quantizemakes only llama.cpp reinstall.prebuilt up to date and validatedwithout a download.Review follow-ups
host_profilerecords the CPU architecture, and the whisper intact check requires the recorded asset name to carry this host's os and arch tokens, so a home directory carried between an x86_64 and an arm64 machine takes the full path.prebuilt_fallback_usedtakes the full path, which is what retries the preferred bundle.UNSLOTH_LLAMA_TAG, as the full path does.host_profileto the routed host the reuse was decided on (the hashes stay added-only), so a hardware change costs one full pass rather than every update.RuntimeErroran HTTP 403 or 429 from api.github.com produces, not onlyURLError.published_atordering, which is what the selector uses for any repo other than the default.min_os); a kept install whose re-check under the lock finds another tree falls through to the locked install path; on a Mac below the floor the llama marker check expects the pinned upstream fallback the selector would choose.UI evidence: a parity pair, because the claim is that nothing moves
This changes no frontend and no backend file, so the only way it can reach the UI is the
one it genuinely does reach: Settings > About renders the llama.cpp version from
/api/system/hardware, which callsget_installed_llama_version(), which returns theinstall marker's
release_tag. This PR rewrites that marker -- new keys, a backfill, anda retrying atomic swap -- so a rewrite that dropped
release_tagwould change whatStudio displays. The pair below rules that out.
Two isolated installs, each built by
install.sh --localfrom its own tree (BEFORE isthe merge base, not
main), each logged into with its own credential on its own port sothe half being photographed is provably the half that was built. Both show
llama.cpp Version b10909-mix-bea84f7, and
api_llama_cppreads that same string onboth sides with
row_renderedtrue. No fact moved between the halves.The version row is rendered conditionally (
{llamaCppVersion ? ... : null}), so with nollama.cpp installed both halves come out blank and match -- passing a parity check while
proving nothing. Both Studios are therefore pointed at a real install produced by
install_llama_prebuilt.pyagainst releaseb10909-mix-bea84f7, and the scene failsrather than returning empty if the version is missing or the row does not render.