Fix llama.cpp prebuilt: skip already-installed same-release fallback (#6285)
* Fix llama.cpp prebuilt: skip the already-installed same-release fallback install_prebuilt computes diffusion_visual_server_backfill_needed from the newest candidate (plan.attempts[0]); when that is True it passed existing_install_dir=None to validate_prebuilt_attempts, which disabled the "existing install already matches this candidate" skip for the WHOLE plan. So when the newest bundle failed validation the installer re-downloaded and re-extracted an older fallback bundle that was already correctly installed. Pass the real install dir always and gate the skip per-attempt: a matching candidate is skipped unless that specific candidate still needs the DiffusionGemma backfill re-extract. Also make test_llama_cpp_search_roots_handles_studio_root_oserror read the full _find_llama_server_binary / _kill_orphaned_servers method bodies instead of a fixed 4000-char window. The except handler it asserts already exists, but the function grew past the window so the guard silently failed; slicing to the next sibling def keeps the check correct as the file grows. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Daniel Han <michaelhan2050@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
502d4ade1c
commit
a8af0a1a4f
2 changed files with 28 additions and 18 deletions
|
|
@ -6436,13 +6436,19 @@ def validate_prebuilt_attempts(
|
|||
f"runtime_line={attempt.runtime_line} coverage_class={attempt.coverage_class}"
|
||||
)
|
||||
|
||||
if existing_install_dir is not None and existing_install_matches_choice(
|
||||
existing_install_dir,
|
||||
host,
|
||||
llama_tag = llama_tag,
|
||||
release_tag = release_tag,
|
||||
choice = attempt,
|
||||
approved_checksums = approved_checksums,
|
||||
if (
|
||||
existing_install_dir is not None
|
||||
and existing_install_matches_choice(
|
||||
existing_install_dir,
|
||||
host,
|
||||
llama_tag = llama_tag,
|
||||
release_tag = release_tag,
|
||||
choice = attempt,
|
||||
approved_checksums = approved_checksums,
|
||||
)
|
||||
# Skip a matching candidate unless it still needs the DiffusionGemma
|
||||
# backfill re-extract (gated per-attempt, not per-plan).
|
||||
and not diffusion_visual_server_backfill_needed(existing_install_dir, host, attempt)
|
||||
):
|
||||
log(
|
||||
"existing llama.cpp install already matches fallback candidate "
|
||||
|
|
@ -6601,9 +6607,8 @@ def install_prebuilt(
|
|||
release_tag = plan.release_tag,
|
||||
approved_checksums = plan.approved_checksums,
|
||||
initial_fallback_used = release_index > 0,
|
||||
# a backfill must reinstall, so do not let the inner
|
||||
# existing-install match short-circuit the re-extract
|
||||
existing_install_dir = None if backfill else install_dir,
|
||||
# Skip is gated per-attempt inside, so pass the dir always.
|
||||
existing_install_dir = install_dir,
|
||||
)
|
||||
except ExistingInstallSatisfied:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -873,15 +873,20 @@ def test_llama_cpp_search_roots_handles_studio_root_oserror():
|
|||
llama_cpp = (
|
||||
REPO_ROOT / "studio" / "backend" / "core" / "inference" / "llama_cpp.py"
|
||||
).read_text()
|
||||
find_block_start = llama_cpp.index("_find_llama_server_binary")
|
||||
find_block = llama_cpp[find_block_start : find_block_start + 4000]
|
||||
assert (
|
||||
"except (ImportError, OSError, ValueError):" in find_block
|
||||
|
||||
def _method_body(name: str) -> str:
|
||||
# Whole method body (def to next sibling def), so the check survives the
|
||||
# function growing past any fixed-size window.
|
||||
start = llama_cpp.index(f"def {name}")
|
||||
indent = " " * (start - llama_cpp.rfind("\n", 0, start) - 1)
|
||||
nxt = llama_cpp.find(f"\n{indent}def ", start + 1)
|
||||
return llama_cpp[start : nxt if nxt != -1 else len(llama_cpp)]
|
||||
|
||||
assert "except (ImportError, OSError, ValueError):" in _method_body(
|
||||
"_find_llama_server_binary"
|
||||
), "_find_llama_server_binary must catch (ImportError, OSError, ValueError) from studio_root()"
|
||||
kill_def_idx = llama_cpp.index("def _kill_orphaned_servers")
|
||||
kill_block = llama_cpp[kill_def_idx : kill_def_idx + 4000]
|
||||
assert (
|
||||
"except (ImportError, OSError, ValueError):" in kill_block
|
||||
assert "except (ImportError, OSError, ValueError):" in _method_body(
|
||||
"_kill_orphaned_servers"
|
||||
), "sibling _kill_orphaned_servers must keep its (ImportError, OSError, ValueError) handler"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue