Skip to content

Studio: require a published digest on upstream llama.cpp prebuilts too - #11402

Merged
danielhanchen merged 5 commits into
mainfrom
security-upstream-prebuilt-digests
Sep 21, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
security-upstream-prebuilt-digests

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

The problem

studio/install_llama_prebuilt.py applies two different integrity policies depending on
which GitHub repository it resolved to, and the weaker one is reachable with no override at
all.

For the default fork unslothai/llama.cpp, every candidate archive must carry a sha256 from
the release checksum index llama-prebuilt-sha256.json, and an attempt that has none is
dropped or the whole plan is refused.

For any other repository the installer falls through to direct_upstream_release_plan, which
constructed every AssetChoice with expected_sha256 left at its None default and attached
synthetic_checksums_for_release, an ApprovedReleaseChecksums whose artifacts map is empty
by construction. Those hashless attempts go to download_file_verified, which is fail-open: a
falsy digest makes it download the bytes, log one line reading "downloaded ... without a
published sha256; relying on install validation", and return. install_from_archives then
extracts the archive, os.chmod(0o755)s llama-server and llama-quantize, and the Studio
backend runs them for every inference request.

This is not override-only. _route_to_vulkan_prebuilt rewrites the repository from the fork
default to ggml-org/llama.cpp for any Linux ARM64 host that routes to Vulkan, which covers
the documented UNSLOTH_LLAMA_CPP_BACKEND=vulkan and legacy UNSLOTH_FORCE_VULKAN settings
and the automatic Intel GPU route. The reroute needs no flag a user would read as lowering
integrity.

The in-code comment that documents the gap says hashless external prebuilts rely on the
functional smoke test as their only integrity gate. That smoke test subprocess.runs
llama-quantize and launches llama-server, so the stated compensation is execution of the
unverified binary, it is off by default, and any tampered binary that answers one completion
passes it.

The fix

The installer was never short of a digest on this path. The GitHub releases API returns a
per-asset digest field, and this same file already reads it through _apply_release_digests
for the Windows ARM64 CUDA bundle. The upstream planner just never consulted it.

direct_upstream_release_plan now runs its attempts through _apply_release_digests against
the digests on the release object it was already handed, so this costs no extra request, and
raises PrebuiltFallback when nothing survives. That applies the same two rules the fork path
uses: an attempt with no digest is dropped rather than installed unverified, and a paired
runtime archive with no digest unpairs rather than riding along unchecked.

release_asset_digests already refuses a digest whose algorithm GitHub did not state as
sha256, so a future algorithm cannot be read as one.

Tests

TestDirectUpstreamRequiresAssetDigests in tests/studio/install/test_selection_logic.py:
every attempt in a returned plan carries a digest, a release publishing no digest is refused,
and an asset whose digest names another algorithm is not accepted. All three fail on the
unpatched tree.

Existing selection fixtures built releases with no digest field, which the planner now
refuses, so they gained one. That is the fixtures catching up with the production rule rather
than a test relaxation; the assertions themselves are unchanged.

tests/studio/install/ is 6879 passed, 32 skipped.
studio/backend/tests/test_install_resolve_prebuilt.py is green.

Deliberately not included

prebuilt_core.download_file_verified still treats a missing digest as a pass by default.
Inverting that, so callers must pass an explicit allow_unverified = True, would remove this
whole class of fail-open call sites added by omission, but it changes behaviour for the node
and whisper installers too, which legitimately have no digest source today. That belongs in
its own change with those installers' paths thought through, rather than riding along here.

install_llama_prebuilt applies two integrity policies depending on which repository it
resolved to, and the weaker one needs no override to reach.

For the fork, unslothai/llama.cpp, every candidate archive must carry a sha256 from the
release checksum index, and an attempt with none is dropped or the plan is refused. For
any other repository, direct_upstream_release_plan built every AssetChoice with
expected_sha256 left at its None default and paired them with an
ApprovedReleaseChecksums whose artifacts map is empty by construction.
download_file_verified treats a falsy digest as a pass: it downloads the bytes, logs one
line, and returns. install_from_archives then extracts, chmod 0o755's llama-server and
llama-quantize, and the backend runs them.

_route_to_vulkan_prebuilt rewrites the repository from the fork default to
ggml-org/llama.cpp for any Linux ARM64 host that routes to Vulkan, which covers the
documented UNSLOTH_LLAMA_CPP_BACKEND=vulkan and UNSLOTH_FORCE_VULKAN settings and the
automatic Intel GPU route, so this is not an override-only path.

The installer was not short of a digest either. The GitHub releases API returns a
per-asset digest, and this same file already reads it through _apply_release_digests for
the Windows ARM64 CUDA bundle. The upstream planner simply never consulted it.

direct_upstream_release_plan now runs its attempts through _apply_release_digests against
the digests on the release it was already handed, so no extra request, and raises
PrebuiltFallback when nothing survives. That is the same pair of rules the fork path
uses: an attempt with no digest is dropped, and a paired runtime archive with no digest
unpairs rather than riding along unchecked.

The existing selection fixtures built releases with no digest field, which the planner
now refuses, so they gained one. That is the fixtures catching up with the production
rule, not a test relaxation.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 21, 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-09-21T02:33:37.674060Z 1179f08 PR opened
ℹ️ 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.

…ebuilts

Requiring a published digest on the upstream path had a side effect the change did
not intend: it turned off the functional smoke test for every upstream prebuilt
install.

validate_prebuilt_choice skipped the staged smoke test for any attempt carrying a
sha256, because until now a sha256 meant the approved checksum manifest covered the
bundle, and Unsloth's own release process builds and exercises those. Upstream
attempts reached that branch with expected_sha256 None, so they always validated.
Binding them to GitHub's per-asset digest silently moved them into the skip branch,
and staged_validation_enabled() is off by default, so llama-quantize and llama-server
were no longer exercised at all before activation.

The two checks are not interchangeable. A release digest proves the bytes are the
ones upstream uploaded; it says nothing about whether they run on this host, and the
upstream path is exactly where that mismatch lands, since it is what hosts the fork
does not cover fall to: Linux ARM64 Vulkan, Intel, the pinned macOS tag, and any
--published-repo. Losing the smoke test also loses the source-build fallback it
triggers, so a bundle that downloads intact but cannot load would now be activated
instead of rejected.

AssetChoice records whether its digest came from the release rather than the manifest,
and prebuilt_needs_functional_validation states the rule in one place: no digest
always validates, a release digest always validates, and only a manifest-approved
bundle keeps skipping behind staged_validation_enabled(). Selection is untouched,
over a 420-cell host-by-digest-coverage matrix no attempt changes.

The two probe pre-resolution gates read the same predicate now. They decide whether to
resolve the validation model up front, and their own comments say why that matters:
the per-candidate handler catches Exception, so a probe resolved lazily inside it
reads as a bad bundle and demotes a healthy GPU pick to CPU, re-downloading once per
attempt. Leaving them on the narrower test would have validated upstream attempts with
an unresolved probe and walked into precisely that.

Tests in TestUpstreamDigestKeepsTheFunctionalSmokeTest cover the marking, the
validation decision for all three bundle classes, and that the three gates agree; all
six fail without this change. tests/studio/install/ plus
studio/backend/tests/test_install_resolve_prebuilt.py is 7192 passed, 33 skipped.
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 21, 2026
pre-commit-ci Bot and others added 2 commits September 21, 2026 09:19
Comments only, no behaviour change. The rationale was stated at more length than it
earns and in several places twice, once in a docstring and again at the call site.

The stand-in digest helper carried the same five-line docstring in four test files; it
is one line now. The predicate docstring enumerated three cases the three lines of code
below it already enumerate, so it keeps only what the code cannot say: a release digest
proves the bytes, not that they load here. The call-site comments drop the parts that
restate _apply_release_digests and synthetic_checksums_for_release.

tests/studio/install/ plus studio/backend/tests/test_install_resolve_prebuilt.py is
7192 passed, 33 skipped, unchanged. ruff 0.15.18 clean.
@danielhanchen
danielhanchen merged commit 0ec1e92 into main Sep 21, 2026
50 of 54 checks passed
@danielhanchen
danielhanchen deleted the security-upstream-prebuilt-digests branch September 21, 2026 11:51
pull Bot pushed a commit to Penguinjanator/unsloth that referenced this pull request Sep 21, 2026
Backend CI and Frontend CI have been failing on main since this morning, so
every open PR inherits them. Four separate causes, none of which is a defect in
the behaviour being guarded.

tests/test_source_read_encoding.py, two offenders. unslothai#11398 added a read of
run.py in test_reset_password_command.py and unslothai#11402 added a read of the llama
prebuilt module in test_selection_logic.py, both with the platform default
encoding, which breaks on Windows the moment either file gains a non-ASCII
byte. The guard is right and the reads are wrong. Both now pass
encoding = "utf-8".

test_sidebar_exposes_queue_activity_for_each_thread pinned the literal
"{showWorkSpinner && (". unslothai#11408 moved the working row's spinner to the trailing
column and wrote the same gate as "{showWorkSpinner ? (", which mounts the same
element under the same condition, so a correct change failed. It now asks
gates_the_markup whether showWorkSpinner conditions mounted markup, which reads
both spellings and rejects the inverted ternary that only looks like a guard.
That is stricter than the old literal in the way that matters here:
showWorkSpinner also picks class strings in this file, so a plain substring
search would have gone on passing after the spinner stopped being rendered at
all.

The ANSI browser smoke failed with "element(s) not found". The real cause is
that unslothai#11425 gave the transcript code cell an icon button with a tooltip, and
CodeExecutionResultOutput renders it. Tooltip throws outside TooltipProvider,
which takes the whole React root down, so every pane on the page went missing.
The app mounts these components inside the provider tree in app/provider.tsx;
the smoke page mounts them bare and had no provider of its own. It does now.

The second half of that one is the reason it was hard to read. echo_browser_errors
printed the pageerror and nothing acted on it, so the run failed fifteen seconds
later on a locator timeout, with the real message sitting further up a log that
otherwise looked fine. It now returns the uncaught errors and the smoke fails
with them, which is what its own docstring says it exists to prevent. Returning
is additive; callers that ignore it are unchanged.

Verified by running the smoke both ways against a real browser: with the
provider all five panes render clean text, and without it the run now stops
immediately with "the smoke page threw before rendering, so no pane exists to
check: `Tooltip` must be used within `TooltipProvider`".

The four checks still red after this are the ones unslothai#11404 fixes.
danielhanchen added a commit that referenced this pull request Sep 21, 2026
…ut the GitHub API

The redirect-only fallback this branch opened with no longer resolves anything
installable, and could not install it if it did.

github.com/ggml-org/llama.cpp/releases/latest now redirects to v0.4.1, a pointer
release whose single asset is nightly-tag.txt, so the bNNNN guard rejected it and
the fallback never fired. Main has also since required a published per-asset
sha256 for upstream prebuilts (#11402), which a release payload synthesized from a
tag alone cannot supply, so even a bNNNN redirect would have been refused.

Resolve the whole release from the web host instead of guessing filenames:

- web_release_tags reads github.com/<repo>/releases.atom, which orders releases,
  so the newest build tag and the older-release walk-back both survive the API
  being unavailable.
- web_release_payload reads github.com/<repo>/releases/expanded_assets/<tag> and
  returns an ordinary release payload: real asset names, tag-pinned download URLs
  and the sha256 GitHub published for each one. Digests are read off the
  copy-to-clipboard control, which names its asset in the same element, so no
  asset can be handed another asset's hash.

Because the payload has the shape the REST one does, direct_upstream_release_plan
and _apply_release_digests are untouched and digest enforcement stays
authoritative: an asset the release states no sha256 for is still dropped, and a
release with none is still refused rather than installed.

Scope: upstream only, REST first, source build still the final fallback, and
UNSLOTH_LLAMA_DISABLE_DOWNLOAD_HOST_RESOLVE opts out. The fork keeps its own
API-free download-host path. Real asset names also retire the Windows CUDA and
AMD carve-out the filename-guessing version needed, and a pinned tag now resolves
through the same path, which is what the macOS version floor pin b9415 needs.

Verified live with api.github.com blocked: macOS arm64, Linux x64 and Windows x64
NVIDIA each resolve b11071 and a digest that matches the REST payload exactly.
danielhanchen added a commit that referenced this pull request Sep 22, 2026
…ut the GitHub API (#5886)

* Studio: fall back to a tokenless release redirect when the llama.cpp REST API is rate limited

unsloth studio update discovers the llama.cpp prebuilt through the GitHub REST
API, which is rate limited to 60 requests per hour per IP for anonymous callers.
Without GH_TOKEN or GITHUB_TOKEN, users on shared, NAT, or cloud IPs hit HTTP 403
and the installer falls back to a slow source build.

Keep the REST API as the primary path. When it is unavailable (for example a
tokenless 403), fall back to resolving the latest upstream release from the
unauthenticated github.com/<repo>/releases/latest redirect and build
deterministic asset download URLs, so the prebuilt path still works with no
token. The redirect is only a fallback and is always unauthenticated.

Scope is narrow: the fallback only applies to the upstream repo plus latest plus
the simple policy path, on platforms whose asset choice is a single deterministic
file. Pinned tags, the Linux CUDA manifest path, the token path, and Windows x64
NVIDIA or AMD asset selection are unchanged.

Add tests covering redirect parsing, REST first resolution, the redirect fallback
on a 403 and on a missing tag, the Windows CUDA opt out, and end to end macOS and
Linux latest resolution when the REST API 403s.

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

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

* Studio: fail closed on bad redirect tag and report both failures (PR #5886)

Harden the tokenless llama.cpp release-redirect fallback:

- Guard the redirect-resolved tag with is_release_tag_like so an unexpected
  redirect target fails closed to the REST/source path instead of building a
  404-bound download URL.
- When the REST listing and the redirect both fail, raise a chained error that
  names both causes instead of only the REST 403.
- Drop a no-op except branch in the specific-tag path and clarify the
  synthetic-release comment.

Add negative tests: both paths failing, a pinned tag never using the redirect,
a malformed redirect target being rejected, and a real REST asset URL taking
precedence over the synthetic one.

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

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

* Studio: harden tokenless release redirect fallback (PR #5886)

Implement the hardening the added tests cover:

- Guard the redirect-resolved tag with is_release_tag_like so an unexpected
  redirect target fails closed to the REST/source path instead of building a
  404-bound download URL.
- When the REST listing and the redirect both fail, raise a chained error that
  names both causes instead of only the REST 403.
- Drop a no-op except branch in the specific-tag path and clarify the
  synthetic-release comment.
- Unpack the (requested_tag, plans) return in the asset-precedence test.

* Studio: tidy redirect handler signature and align test import (PR #5886)

* Studio: resolve upstream llama.cpp releases, assets and digests without the GitHub API

The redirect-only fallback this branch opened with no longer resolves anything
installable, and could not install it if it did.

github.com/ggml-org/llama.cpp/releases/latest now redirects to v0.4.1, a pointer
release whose single asset is nightly-tag.txt, so the bNNNN guard rejected it and
the fallback never fired. Main has also since required a published per-asset
sha256 for upstream prebuilts (#11402), which a release payload synthesized from a
tag alone cannot supply, so even a bNNNN redirect would have been refused.

Resolve the whole release from the web host instead of guessing filenames:

- web_release_tags reads github.com/<repo>/releases.atom, which orders releases,
  so the newest build tag and the older-release walk-back both survive the API
  being unavailable.
- web_release_payload reads github.com/<repo>/releases/expanded_assets/<tag> and
  returns an ordinary release payload: real asset names, tag-pinned download URLs
  and the sha256 GitHub published for each one. Digests are read off the
  copy-to-clipboard control, which names its asset in the same element, so no
  asset can be handed another asset's hash.

Because the payload has the shape the REST one does, direct_upstream_release_plan
and _apply_release_digests are untouched and digest enforcement stays
authoritative: an asset the release states no sha256 for is still dropped, and a
release with none is still refused rather than installed.

Scope: upstream only, REST first, source build still the final fallback, and
UNSLOTH_LLAMA_DISABLE_DOWNLOAD_HOST_RESOLVE opts out. The fork keeps its own
API-free download-host path. Real asset names also retire the Windows CUDA and
AMD carve-out the filename-guessing version needed, and a pinned tag now resolves
through the same path, which is what the macOS version floor pin b9415 needs.

Verified live with api.github.com blocked: macOS arm64, Linux x64 and Windows x64
NVIDIA each resolve b11071 and a digest that matches the REST payload exactly.

* Studio: route pinned upstream releases through the web path, and read prerelease status rather than assume it

Two review findings.

A pinned published_release_tag returned from iter_release_payloads_by_time before
reaching the fallback, so an explicitly pinned upstream release still dropped to a
source build under a rate limit even though its release page names it exactly. It
now takes the same web path, and the fork still re-raises.

The synthesized payload hardcoded prerelease False, which the REST listing filters
on, so the two paths could select differently. web_release_prerelease reads the
status from the release page label instead, and release_is_selectable is now the
one rule both paths apply.

That rule has one deliberate exception, which turns out to fix a live defect of its
own: ggml-org marks EVERY bNNNN build release prerelease, so the plain filter left
the upstream path selecting the newest release that is not one. Measured against
the live API today, main selects b10549 while the newest build is b11071, an install
522 builds behind, because the releases above it (v0.4.1 and older) publish no
prebuilt at all. An upstream bNNNN build is therefore selectable despite the flag;
a non-build prerelease is not, and the fork and every other repo keep the plain
rule unchanged.

* Studio: let a pinned upstream tag reach the release page on a retryable HTTP failure

HTTPError subclasses URLError, so the HTTPError clause shadowed the fallback added
alongside it: a pinned tag whose REST lookup exhausted its retries on a 500, 502,
503 or 504 re-raised instead of reading the release page, and the install dropped
to a source build with the page sitting there. The 404 case keeps scanning, since
a tag that does not exist has no page to read either, and the fork still re-raises.

* Studio: apply the same selectability rule to the update freshness check

_newest_release_tag_from_releases dropped every prerelease unconditionally while
the planner now installs an upstream bNNNN build, so the two answered differently
from the same payload, which its own docstring says must not happen. Reproduced
live against the API: the freshness check named v0.4.1 newest while the planner
installed b11071, so the marker for the freshly installed build read as stale and
every later update run would have repeated the whole download and install.

It now takes the repo and applies release_is_selectable, the rule the planner
uses. After the fix both answer b11071, and the fork is unchanged: it still drops
prereleases and still resolves b11030-mix-5ff778e.

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

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

* Studio: take the REST latest tag only when it names a build, and fix the whisper caller

Two things.

latest_upstream_release_tag returned whatever /releases/latest named, and upstream
points that at v0.4.1, a pointer release packaging no prebuilt. The source build
would then compile a different version from the one the prebuilt path installs,
which is the only reason that tag is resolved here. A non-build REST tag now
consults the release feed, as a missing one already did, and the REST answer is
still kept when the feed cannot name a build, since a released version beats no
source ref. Live, this moves the source ref from v0.4.1 to b11073.

install_whisper_prebuilt called _newest_release_tag_from_releases positionally and
the previous commit gave it a repo parameter, which broke three whisper tests. The
repo was already in scope; whisper is never ggml-org/llama.cpp, so it keeps the
plain drafts-and-prereleases-dropped rule it has always had.

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

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

* Reduce the comments added by this PR

* Studio: exclude upstream pointer releases, recover stalled reads, honour the opt-out everywhere

Four findings from a parallel review pass focused on install regressions, each
reproduced before it was fixed.

An upstream release that is not a bNNNN build is no longer selectable. It was only
the prerelease flag that excluded them, and the versioned pointer releases do not
carry one, so a v0.4.2 published after the newest build became the freshness
check's answer while the planner walked past it for want of an asset: the marker
read stale forever and every update run reinstalled the same build. For upstream
the rule is now simply whether the tag names a build, which closes that and the
prerelease case together. Every other repo keeps the plain rule.

A stalled or reset read no longer strands the install. TimeoutError and
ConnectionResetError are not URLError subclasses, so they escaped the four handlers
that route the web fallback and the recovery never ran. They now use
RELEASE_LISTING_TRANSPORT_ERRORS, which the module already applies to the same
listing call.

UNSLOTH_LLAMA_DISABLE_DOWNLOAD_HOST_RESOLVE now means the same thing on every path:
latest_upstream_release_tag consulted the release feed regardless, and keeps the
REST answer instead when the opt-out is set.

A release page that cannot be read no longer discards the release. The assets and
their digests have already loaded by then, and an upstream build tag answers the
prerelease question by itself, so only a tag that cannot fails closed.

192 fork selector cells unchanged, 240 enumerated predicate cells with no
violations, full tests/studio/install/ at 6950 passed and 0 failed.

* [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>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
unslothai#11402)

* Studio: require a published digest on upstream llama.cpp prebuilts too

install_llama_prebuilt applies two integrity policies depending on which repository it
resolved to, and the weaker one needs no override to reach.

For the fork, unslothai/llama.cpp, every candidate archive must carry a sha256 from the
release checksum index, and an attempt with none is dropped or the plan is refused. For
any other repository, direct_upstream_release_plan built every AssetChoice with
expected_sha256 left at its None default and paired them with an
ApprovedReleaseChecksums whose artifacts map is empty by construction.
download_file_verified treats a falsy digest as a pass: it downloads the bytes, logs one
line, and returns. install_from_archives then extracts, chmod 0o755's llama-server and
llama-quantize, and the backend runs them.

_route_to_vulkan_prebuilt rewrites the repository from the fork default to
ggml-org/llama.cpp for any Linux ARM64 host that routes to Vulkan, which covers the
documented UNSLOTH_LLAMA_CPP_BACKEND=vulkan and UNSLOTH_FORCE_VULKAN settings and the
automatic Intel GPU route, so this is not an override-only path.

The installer was not short of a digest either. The GitHub releases API returns a
per-asset digest, and this same file already reads it through _apply_release_digests for
the Windows ARM64 CUDA bundle. The upstream planner simply never consulted it.

direct_upstream_release_plan now runs its attempts through _apply_release_digests against
the digests on the release it was already handed, so no extra request, and raises
PrebuiltFallback when nothing survives. That is the same pair of rules the fork path
uses: an attempt with no digest is dropped, and a paired runtime archive with no digest
unpairs rather than riding along unchecked.

The existing selection fixtures built releases with no digest field, which the planner
now refuses, so they gained one. That is the fixtures catching up with the production
rule, not a test relaxation.

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

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

* Studio: keep the functional smoke test on digest-verified upstream prebuilts

Requiring a published digest on the upstream path had a side effect the change did
not intend: it turned off the functional smoke test for every upstream prebuilt
install.

validate_prebuilt_choice skipped the staged smoke test for any attempt carrying a
sha256, because until now a sha256 meant the approved checksum manifest covered the
bundle, and Unsloth's own release process builds and exercises those. Upstream
attempts reached that branch with expected_sha256 None, so they always validated.
Binding them to GitHub's per-asset digest silently moved them into the skip branch,
and staged_validation_enabled() is off by default, so llama-quantize and llama-server
were no longer exercised at all before activation.

The two checks are not interchangeable. A release digest proves the bytes are the
ones upstream uploaded; it says nothing about whether they run on this host, and the
upstream path is exactly where that mismatch lands, since it is what hosts the fork
does not cover fall to: Linux ARM64 Vulkan, Intel, the pinned macOS tag, and any
--published-repo. Losing the smoke test also loses the source-build fallback it
triggers, so a bundle that downloads intact but cannot load would now be activated
instead of rejected.

AssetChoice records whether its digest came from the release rather than the manifest,
and prebuilt_needs_functional_validation states the rule in one place: no digest
always validates, a release digest always validates, and only a manifest-approved
bundle keeps skipping behind staged_validation_enabled(). Selection is untouched,
over a 420-cell host-by-digest-coverage matrix no attempt changes.

The two probe pre-resolution gates read the same predicate now. They decide whether to
resolve the validation model up front, and their own comments say why that matters:
the per-candidate handler catches Exception, so a probe resolved lazily inside it
reads as a bad bundle and demotes a healthy GPU pick to CPU, re-downloading once per
attempt. Leaving them on the narrower test would have validated upstream attempts with
an unresolved probe and walked into precisely that.

Tests in TestUpstreamDigestKeepsTheFunctionalSmokeTest cover the marking, the
validation decision for all three bundle classes, and that the three gates agree; all
six fail without this change. tests/studio/install/ plus
studio/backend/tests/test_install_resolve_prebuilt.py is 7192 passed, 33 skipped.

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

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

* Studio: trim the commentary added by the upstream digest change

Comments only, no behaviour change. The rationale was stated at more length than it
earns and in several places twice, once in a docstring and again at the call site.

The stand-in digest helper carried the same five-line docstring in four test files; it
is one line now. The predicate docstring enumerated three cases the three lines of code
below it already enumerate, so it keeps only what the code cannot say: a release digest
proves the bytes, not that they load here. The call-site comments drop the parts that
restate _apply_release_digests and synthetic_checksums_for_release.

tests/studio/install/ plus studio/backend/tests/test_install_resolve_prebuilt.py is
7192 passed, 33 skipped, unchanged. ruff 0.15.18 clean.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
Backend CI and Frontend CI have been failing on main since this morning, so
every open PR inherits them. Four separate causes, none of which is a defect in
the behaviour being guarded.

tests/test_source_read_encoding.py, two offenders. unslothai#11398 added a read of
run.py in test_reset_password_command.py and unslothai#11402 added a read of the llama
prebuilt module in test_selection_logic.py, both with the platform default
encoding, which breaks on Windows the moment either file gains a non-ASCII
byte. The guard is right and the reads are wrong. Both now pass
encoding = "utf-8".

test_sidebar_exposes_queue_activity_for_each_thread pinned the literal
"{showWorkSpinner && (". unslothai#11408 moved the working row's spinner to the trailing
column and wrote the same gate as "{showWorkSpinner ? (", which mounts the same
element under the same condition, so a correct change failed. It now asks
gates_the_markup whether showWorkSpinner conditions mounted markup, which reads
both spellings and rejects the inverted ternary that only looks like a guard.
That is stricter than the old literal in the way that matters here:
showWorkSpinner also picks class strings in this file, so a plain substring
search would have gone on passing after the spinner stopped being rendered at
all.

The ANSI browser smoke failed with "element(s) not found". The real cause is
that unslothai#11425 gave the transcript code cell an icon button with a tooltip, and
CodeExecutionResultOutput renders it. Tooltip throws outside TooltipProvider,
which takes the whole React root down, so every pane on the page went missing.
The app mounts these components inside the provider tree in app/provider.tsx;
the smoke page mounts them bare and had no provider of its own. It does now.

The second half of that one is the reason it was hard to read. echo_browser_errors
printed the pageerror and nothing acted on it, so the run failed fifteen seconds
later on a locator timeout, with the real message sitting further up a log that
otherwise looked fine. It now returns the uncaught errors and the smoke fails
with them, which is what its own docstring says it exists to prevent. Returning
is additive; callers that ignore it are unchanged.

Verified by running the smoke both ways against a real browser: with the
provider all five panes render clean text, and without it the run now stops
immediately with "the smoke page threw before rendering, so no pane exists to
check: `Tooltip` must be used within `TooltipProvider`".

The four checks still red after this are the ones unslothai#11404 fixes.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…ut the GitHub API (unslothai#5886)

* Studio: fall back to a tokenless release redirect when the llama.cpp REST API is rate limited

unsloth studio update discovers the llama.cpp prebuilt through the GitHub REST
API, which is rate limited to 60 requests per hour per IP for anonymous callers.
Without GH_TOKEN or GITHUB_TOKEN, users on shared, NAT, or cloud IPs hit HTTP 403
and the installer falls back to a slow source build.

Keep the REST API as the primary path. When it is unavailable (for example a
tokenless 403), fall back to resolving the latest upstream release from the
unauthenticated github.com/<repo>/releases/latest redirect and build
deterministic asset download URLs, so the prebuilt path still works with no
token. The redirect is only a fallback and is always unauthenticated.

Scope is narrow: the fallback only applies to the upstream repo plus latest plus
the simple policy path, on platforms whose asset choice is a single deterministic
file. Pinned tags, the Linux CUDA manifest path, the token path, and Windows x64
NVIDIA or AMD asset selection are unchanged.

Add tests covering redirect parsing, REST first resolution, the redirect fallback
on a 403 and on a missing tag, the Windows CUDA opt out, and end to end macOS and
Linux latest resolution when the REST API 403s.

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

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

* Studio: fail closed on bad redirect tag and report both failures (PR unslothai#5886)

Harden the tokenless llama.cpp release-redirect fallback:

- Guard the redirect-resolved tag with is_release_tag_like so an unexpected
  redirect target fails closed to the REST/source path instead of building a
  404-bound download URL.
- When the REST listing and the redirect both fail, raise a chained error that
  names both causes instead of only the REST 403.
- Drop a no-op except branch in the specific-tag path and clarify the
  synthetic-release comment.

Add negative tests: both paths failing, a pinned tag never using the redirect,
a malformed redirect target being rejected, and a real REST asset URL taking
precedence over the synthetic one.

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

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

* Studio: harden tokenless release redirect fallback (PR unslothai#5886)

Implement the hardening the added tests cover:

- Guard the redirect-resolved tag with is_release_tag_like so an unexpected
  redirect target fails closed to the REST/source path instead of building a
  404-bound download URL.
- When the REST listing and the redirect both fail, raise a chained error that
  names both causes instead of only the REST 403.
- Drop a no-op except branch in the specific-tag path and clarify the
  synthetic-release comment.
- Unpack the (requested_tag, plans) return in the asset-precedence test.

* Studio: tidy redirect handler signature and align test import (PR unslothai#5886)

* Studio: resolve upstream llama.cpp releases, assets and digests without the GitHub API

The redirect-only fallback this branch opened with no longer resolves anything
installable, and could not install it if it did.

github.com/ggml-org/llama.cpp/releases/latest now redirects to v0.4.1, a pointer
release whose single asset is nightly-tag.txt, so the bNNNN guard rejected it and
the fallback never fired. Main has also since required a published per-asset
sha256 for upstream prebuilts (unslothai#11402), which a release payload synthesized from a
tag alone cannot supply, so even a bNNNN redirect would have been refused.

Resolve the whole release from the web host instead of guessing filenames:

- web_release_tags reads github.com/<repo>/releases.atom, which orders releases,
  so the newest build tag and the older-release walk-back both survive the API
  being unavailable.
- web_release_payload reads github.com/<repo>/releases/expanded_assets/<tag> and
  returns an ordinary release payload: real asset names, tag-pinned download URLs
  and the sha256 GitHub published for each one. Digests are read off the
  copy-to-clipboard control, which names its asset in the same element, so no
  asset can be handed another asset's hash.

Because the payload has the shape the REST one does, direct_upstream_release_plan
and _apply_release_digests are untouched and digest enforcement stays
authoritative: an asset the release states no sha256 for is still dropped, and a
release with none is still refused rather than installed.

Scope: upstream only, REST first, source build still the final fallback, and
UNSLOTH_LLAMA_DISABLE_DOWNLOAD_HOST_RESOLVE opts out. The fork keeps its own
API-free download-host path. Real asset names also retire the Windows CUDA and
AMD carve-out the filename-guessing version needed, and a pinned tag now resolves
through the same path, which is what the macOS version floor pin b9415 needs.

Verified live with api.github.com blocked: macOS arm64, Linux x64 and Windows x64
NVIDIA each resolve b11071 and a digest that matches the REST payload exactly.

* Studio: route pinned upstream releases through the web path, and read prerelease status rather than assume it

Two review findings.

A pinned published_release_tag returned from iter_release_payloads_by_time before
reaching the fallback, so an explicitly pinned upstream release still dropped to a
source build under a rate limit even though its release page names it exactly. It
now takes the same web path, and the fork still re-raises.

The synthesized payload hardcoded prerelease False, which the REST listing filters
on, so the two paths could select differently. web_release_prerelease reads the
status from the release page label instead, and release_is_selectable is now the
one rule both paths apply.

That rule has one deliberate exception, which turns out to fix a live defect of its
own: ggml-org marks EVERY bNNNN build release prerelease, so the plain filter left
the upstream path selecting the newest release that is not one. Measured against
the live API today, main selects b10549 while the newest build is b11071, an install
522 builds behind, because the releases above it (v0.4.1 and older) publish no
prebuilt at all. An upstream bNNNN build is therefore selectable despite the flag;
a non-build prerelease is not, and the fork and every other repo keep the plain
rule unchanged.

* Studio: let a pinned upstream tag reach the release page on a retryable HTTP failure

HTTPError subclasses URLError, so the HTTPError clause shadowed the fallback added
alongside it: a pinned tag whose REST lookup exhausted its retries on a 500, 502,
503 or 504 re-raised instead of reading the release page, and the install dropped
to a source build with the page sitting there. The 404 case keeps scanning, since
a tag that does not exist has no page to read either, and the fork still re-raises.

* Studio: apply the same selectability rule to the update freshness check

_newest_release_tag_from_releases dropped every prerelease unconditionally while
the planner now installs an upstream bNNNN build, so the two answered differently
from the same payload, which its own docstring says must not happen. Reproduced
live against the API: the freshness check named v0.4.1 newest while the planner
installed b11071, so the marker for the freshly installed build read as stale and
every later update run would have repeated the whole download and install.

It now takes the repo and applies release_is_selectable, the rule the planner
uses. After the fix both answer b11071, and the fork is unchanged: it still drops
prereleases and still resolves b11030-mix-5ff778e.

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

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

* Studio: take the REST latest tag only when it names a build, and fix the whisper caller

Two things.

latest_upstream_release_tag returned whatever /releases/latest named, and upstream
points that at v0.4.1, a pointer release packaging no prebuilt. The source build
would then compile a different version from the one the prebuilt path installs,
which is the only reason that tag is resolved here. A non-build REST tag now
consults the release feed, as a missing one already did, and the REST answer is
still kept when the feed cannot name a build, since a released version beats no
source ref. Live, this moves the source ref from v0.4.1 to b11073.

install_whisper_prebuilt called _newest_release_tag_from_releases positionally and
the previous commit gave it a repo parameter, which broke three whisper tests. The
repo was already in scope; whisper is never ggml-org/llama.cpp, so it keeps the
plain drafts-and-prereleases-dropped rule it has always had.

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

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

* Reduce the comments added by this PR

* Studio: exclude upstream pointer releases, recover stalled reads, honour the opt-out everywhere

Four findings from a parallel review pass focused on install regressions, each
reproduced before it was fixed.

An upstream release that is not a bNNNN build is no longer selectable. It was only
the prerelease flag that excluded them, and the versioned pointer releases do not
carry one, so a v0.4.2 published after the newest build became the freshness
check's answer while the planner walked past it for want of an asset: the marker
read stale forever and every update run reinstalled the same build. For upstream
the rule is now simply whether the tag names a build, which closes that and the
prerelease case together. Every other repo keeps the plain rule.

A stalled or reset read no longer strands the install. TimeoutError and
ConnectionResetError are not URLError subclasses, so they escaped the four handlers
that route the web fallback and the recovery never ran. They now use
RELEASE_LISTING_TRANSPORT_ERRORS, which the module already applies to the same
listing call.

UNSLOTH_LLAMA_DISABLE_DOWNLOAD_HOST_RESOLVE now means the same thing on every path:
latest_upstream_release_tag consulted the release feed regardless, and keeps the
REST answer instead when the opt-out is set.

A release page that cannot be read no longer discards the release. The assets and
their digests have already loaded by then, and an upstream build tag answers the
prerelease question by itself, so only a tag that cannot fails closed.

192 fork selector cells unchanged, 240 enumerated predicate cells with no
violations, full tests/studio/install/ at 6950 passed and 0 failed.

* [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>
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.

1 participant