Repository navigation
Fetch the llama.cpp validation model only when the smoke test reads it - #8248
Conversation
An approved bundle proves integrity by sha256 and skips the staged smoke test, so the tiny GGUF probe goes unread on the default install path. It was still downloaded up front, which made huggingface.co a hard gate on every prebuilt install: a 429 there raised PrebuiltFallback and forced a multi-minute source build over a file nothing opens. Fetch it lazily instead, at the one branch that reads it, memoised so the two smoke steps share a single download. test_install_prebuilt_does_not_skip_unhealthy_existing_install tripped on the probe download as a proxy for reaching the normal install flow. That proxy is gone on the default path, so it now trips on validate_prebuilt_attempts, which is the behaviour it actually names.
The unit tests pin validate_prebuilt_choice's behaviour, but the bug was that a 429 short-circuited the whole install before the release loop. Assert that over install_prebuilt itself: with download_validation_model raising 429, the flow must still reach validate_prebuilt_attempts rather than exit EXIT_FALLBACK. Verified it fails against the pre-fix source.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b3d457a9d
ℹ️ 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".
| # kept intact; flip the flag / env to restore it (#5854). | ||
| if choice.expected_sha256 is None or staged_validation_enabled(): | ||
| # Only branch that reads the probe, so this is where a lazy one is fetched. | ||
| probe_path = resolve_validation_model(probe) |
There was a problem hiding this comment.
Keep probe-fetch failures outside candidate fallback
When validation is required and a plan has multiple attempts—for example, direct-upstream Windows GPU plus CPU assets—a PrebuiltFallback from the lazy model download now occurs here inside validate_prebuilt_attempts' per-candidate try. Its catch treats the network error as a failure of the preferred bundle and advances to a lower-priority candidate or older release; because the thunk does not memoize failures, every attempt may repeat the model retries after downloading and extracting another bundle, and a transient first failure followed by success can install CPU instead of the healthy GPU bundle. Materialize the probe once outside the per-candidate catch when the plan requires smoke validation, while retaining laziness for plans that skip it.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Correct catch, and it is mine. Reproduced it against the code at head.
validate_prebuilt_attempts wraps each candidate in except Exception, so once the probe moved inside validate_prebuilt_choice a failed download landed in that handler, got rewritten as candidate attempt failed before activation, and fell through to the next attempt rather than aborting. On a plan with a GPU asset ahead of a CPU one that installs the CPU bundle off a transient 429. The thunk memoised success only, so each further attempt re-ran the download after extracting another bundle, exactly as described.
Fixed in fb18afd by resolving the probe once before the candidate loop whenever any attempt will validate:
if staged_validation_enabled() or any(a.expected_sha256 is None for a in attempt_list):
probe = resolve_validation_model(probe)Hashless attempts are the reachable case, since they have no sha256 gate and are always validated. A failure there now raises outside the per-candidate handler and reaches the source-build fallback, which is the pre-change behaviour. Plans that skip validation never call the thunk, so the laziness this PR is about is unaffected.
Regression test added: two hashless attempts and a probe that raises 429 must leave the second candidate untouched and fetch exactly once. It fails against the pre-fix source.
validate_prebuilt_attempts catches Exception per candidate, so a probe download failing inside that try read as a failure of the bundle itself: a transient 429 demoted a healthy GPU pick to the CPU asset or an older release, and because the thunk memoises success but not failure, each further attempt re-downloaded after extracting another bundle. Hashless attempts always validate, so resolve the probe once before the loop whenever any attempt will need it. Plans that skip validation never call the thunk and stay lazy.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 64ce11b16a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| install_dir, | ||
| work_dir, | ||
| probe_path, | ||
| probe, |
There was a problem hiding this comment.
Keep probe failures out of release fallback
When UNSLOTH_LLAMA_STAGED_VALIDATION=1 (or a hashless direct-upstream plan) and latest resolves more than one release, a PrebuiltFallback from materializing this lazy probe is raised inside the per-release try; the except PrebuiltFallback below then treats a Hugging Face 429 as a bad release and continues to an older plan. Because the probe is independent of the release and failed thunks are retried, a transient first failure followed by success installs the older llama.cpp build instead of validating the selected release or falling back once. Resolve the probe once before entering the release loop when any plan will smoke-test, or otherwise keep probe failures out of the release fallback path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right again, and it is the same shape as the last one a level up. Confirmed against the code at head: the per-release handler in install_prebuilt is except PrebuiltFallback: ... continue, so a probe failure raised inside validate_prebuilt_attempts propagated out of the inner guard and demoted the selected release to an older plan. With the thunk memoising success but not failure, each plan re-ran the download.
Fixed in ab2ce98, same treatment as the inner loop, applied before the release loop:
if staged_validation_enabled() or any(
attempt.expected_sha256 is None
for release_plan in release_plans
for attempt in release_plan.attempts
):
probe = resolve_validation_model(probe)The guard inside validate_prebuilt_attempts stays, so that function is still correct when called on its own; with the outer resolve it just sees a Path and does nothing.
Regression test added: two hashless release plans with a probe that fails must exit EXIT_FALLBACK without validating either plan, so the run reaches the source build once instead of silently installing the older release. It fails against the pre-fix source.
The per-release handler in install_prebuilt swallows PrebuiltFallback and moves to an older plan, the same shape as the per-candidate handler one level down. A probe failure raised inside it installed an older llama.cpp build over a transient 429, and since the thunk memoises success but not failure, each plan retried the download. The probe does not depend on which release was picked, so resolve it once before the loop whenever any plan will smoke-test.
|
@codex review |
1 similar comment
|
@codex review |
|
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". |
An approved prebuilt bundle proves its integrity by sha256 and so skips the staged
smoke test, which leaves the tiny GGUF probe unread on the default install path.
It was still downloaded up front, before the release loop, which made
huggingface.co a hard gate on every prebuilt install: a 429 there raised
PrebuiltFallbackand forced a multi-minute source build over a file nothingwent on to open.
Seen on #8185, where
virgin win container / overlay=truefailed like this:Change
lazy_validation_model()returns a memoised thunk, andvalidate_prebuilt_choiceresolves it inside the one branch that reads the probe, so both
validate_quantizeand
validate_servershare a single fetch. The provider accepts aPathor acallable, so every existing caller and test keeps working unchanged.
The retry path itself was already sound (429 is in
RETRYABLE_HTTP_STATUS,Retry-Afteris honoured, exponential backoff with jitter), so this removes thedependency rather than widening the retry window. Hashless external prebuilts have
no sha256 gate and still validate, so they still fetch the probe, just at the point
of use.
Tests
lazy_validation_model: no download on construction, one download across repeat callsinstall_prebuilt: withdownload_validation_modelraising 429, theflow reaches
validate_prebuilt_attemptsinstead of exitingEXIT_FALLBACK. Verifiedthis one fails against the pre-fix source.
test_install_prebuilt_does_not_skip_unhealthy_existing_installhad been tripping onthe probe download as a proxy for reaching the normal install flow. That proxy no longer
exists on the default path, so it now trips on
validate_prebuilt_attempts, which is thebehaviour its name describes.
Validation
Full
tests/studio/install/green locally (1711 passed), ruff clean. Ran the matrix on astaging replica: Clean machine install, Mac Studio Install Matrix, MLX, Cross-platform
parity, Startup profile and every API/GGUF/Update/UI lane green. Backend CI is red there
and on unmodified main alike, on
test_python39_compatibility(the newly vendoredtruststore) and on
test_diffusion_backend/test_saved_image_metadata_precision_contract;all five reproduce on a clean checkout of main with none of these commits.