Skip to content

Fix llama.cpp update banner offering a downgrade when GitHub /releases/latest lags - #6214

Closed
shimmyshimmer wants to merge 2 commits into
mainfrom
fix/llama-update-banner-downgrade
Closed

shimmyshimmer wants to merge 2 commits into
mainfrom
fix/llama-update-banner-downgrade

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

Summary

Fixes the "New llama.cpp prebuilt" banner offering what looks like a downgrade (for example b9596 -> b9594) and reappearing forever after a successful update.

Reported on Reddit: https://www.reddit.com/r/unsloth/comments/1u34fa3/new_llamacpp_prebuilt_b9596_b9594/

Root cause

Detection and apply use two different definitions of "latest":

  • Detection (studio/backend/utils/llama_cpp_freshness.py) calls GitHub's /repos/unslothai/llama.cpp/releases/latest. GitHub sorts that endpoint by the created_at of the commit the release targets, not by publish time or build number. Our fork's automated releases share or jumble created_at timestamps (several current releases have the identical commit date), so when builds are published out of order or rebuilt, the endpoint can return a lower build (b9594) even though b9596 is already released.
  • Apply (the Update button) runs install_llama_prebuilt.py --llama-tag latest, which resolves against upstream ggml-org/llama.cpp/releases/latest and scans fork releases by publish time, correctly installing the newest build (b9596).

The banner then decided update_available with a plain inequality in get_update_status:

update_available = bool(has_marker and installed and latest and installed != latest)

So after a legitimate update to b9596, the marker (b9596) never equals the lagging detection tag (b9594), and the banner reappears rendered as a downgrade arrow. The source-build path already compared build numbers (installed_build < latest_build); the prebuilt marker path did not.

Fix

  • Add parse_build_number() to llama_cpp_freshness.py (strict bNNNN match).
  • get_update_status now compares build numbers on the marker path and only reports update_available for real upgrades. Tag inequality is kept as the fallback when either tag is not bNNNN shaped.
  • check_prebuilt_freshness applies the same guard so the stale flag (and the CLI stale warning) cannot report a downgrade either.

Clicking Update in the affected state was already harmless (the installer re-resolves latest itself and reinstalls the newest build), so this is purely a detection and UI fix.

Tests

New regression tests:

  • test_status_installed_newer_than_latest_release_not_offered (installed b9596, latest b9594, no banner)
  • test_status_non_numeric_tags_fall_back_to_inequality
  • test_check_prebuilt_freshness_not_stale_when_installed_newer
  • test_parse_build_number
tests/test_llama_cpp_update.py     37 passed
tests/test_llama_cpp_freshness.py  22 passed

Note: test_start_update_installer_failure_reports_error and test_update_clears_maintenance_flag_on_installer_failure fail on main when the two files run in the same pytest invocation (pre-existing cross-file pollution, unrelated to this change); each file passes cleanly on its own.

…t lags

The update banner decided update_available with a plain tag inequality
(installed != latest). GitHub's /releases/latest endpoint sorts by the
commit date of the release target, not by build number, so when fork
releases land out of order it can return an older build than the one the
installer just resolved from upstream. Users then saw a persistent banner
like b9596 -> b9594 right after updating, which looks like a downgrade
prompt and never goes away.

Compare bNNNN build numbers on the prebuilt marker path (mirroring what
the source-build path already did) and only offer real upgrades, with tag
inequality kept as the fallback for non-bNNNN tags. Apply the same guard
to the freshness stale flag so the CLI warning cannot report a downgrade
either.

Reported in https://www.reddit.com/r/unsloth/comments/1u34fa3/

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces logic to compare numeric build numbers (e.g., bNNNN) for llama.cpp releases instead of relying solely on tag inequality. This prevents newer installed builds from being flagged as stale or offered as downgrades when GitHub's /releases/latest lags behind due to out-of-order releases. Unit tests have been added to verify this behavior. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0dff621b6

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

installed_build = parse_build_number(installed)
latest_build = parse_build_number(latest)
if installed_build is not None and latest_build is not None:
behind = installed_build < latest_build

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid suppressing updates based on the lagging release tag

When /releases/latest is behind the actual newest release (the condition this change is handling), this comparison can hide real updates for users whose installed build is between the lagging tag and the true latest tag. For example, if GitHub returns b9594 while b9596 is already published and the user has b9595, behind becomes false, so get_update_status shows no banner even though the update path re-resolves --llama-tag latest and would install b9596.

Useful? React with 👍 / 👎.

@danielhanchen

Copy link
Copy Markdown
Member

Superseded by #6219. One heads-up: the re.fullmatch(r"b(\d+)") parse returns nothing for the current b9596-mix-<sha> release tags (the live /releases/latest is b9596-mix-e6f2453), so on mix releases this falls back to the old string inequality and still offers the downgrade and keeps sticking. #6219 reads the base build from the start of the tag so mix tags parse, and resolves latest by publish time. Suggest closing in favor of that one.

@danielhanchen

Copy link
Copy Markdown
Member

Closing in favor of #6219, which is merged.

This now conflicts with main since #6219 reworked the same two files, and the approach here does not cover the current release format: re.fullmatch(r"b(\d+)") returns None on the live b9596-mix-<sha> tags (the test here asserts parse_build_number("b9596-custom") is None), so on a mix release it falls back to the old string inequality and still offers the downgrade. #6219 reads the base build from the start of the tag so mix tags parse, and resolves latest by publish time rather than the lagging /releases/latest pointer, so those cases are handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants