unsloth/tests/studio
DoubleMathew b39f4b282a
Pin Studio GGUF export to llama.cpp's local convert script (#5275)
* Pin Studio GGUF export to local llama.cpp convert script

setdefault UNSLOTH_LLAMA_CPP_SCRIPTS_DIR=LLAMA_CPP_DEFAULT_DIR before
save_pretrained_gguf so the convert_hf_to_gguf.py used at conversion
time matches the pinned llama-quantize binary and gguf-py installed
under ~/.unsloth/llama.cpp. Without this, the script is pulled from
upstream master and can drift past the binary's gguf API, causing
intermittent export failures.

setdefault preserves any explicit user override; validation of the
path lives in unsloth_zoo's _resolve_local_convert_script (warns and
falls back to network on a bad value).

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

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

* Scrub .github/workflows for staging push (matches staging base)

* Pin GGUF convert script for hub-only export path

Hoist the UNSLOTH_LLAMA_CPP_SCRIPTS_DIR setdefault and the
unsloth_zoo.llama_cpp import out of the if save_directory: block so
push_to_hub_gguf also runs with the pin. The worker passes
save_directory="" for hub-only exports, which previously skipped the
local branch and left the convert script fetched from master.

* Trim GGUF convert script pin rationale comment

Collapse 7 lines of rationale into 3 lines stating the load-bearing
facts: pin matches llama-quantize binary, set before both branches
because hub-only export has empty save_directory.

* Sync .github/workflows with upstream author branch

* Scrub .github/workflows for staging push (matches staging base)

* Warn when unsloth_zoo is too old to honor UNSLOTH_LLAMA_CPP_SCRIPTS_DIR

Studio's GGUF export sets UNSLOTH_LLAMA_CPP_SCRIPTS_DIR before
save_pretrained_gguf and push_to_hub_gguf so unsloth_zoo can prefer the
local pinned convert_hf_to_gguf.py. The resolver only exists in the
companion unsloth_zoo change; on older zoo builds permitted by the
current dependency floor, the env var is silently ignored and the
converter is still downloaded from llama.cpp master.

Probe for the resolver and emit a one-time warning so operators know the
pin is inactive and can upgrade unsloth_zoo.

* Combine the GGUF script-pin imports into one guarded block and warn once

Both LLAMA_CPP_DEFAULT_DIR and the resolver probe come from
unsloth_zoo.llama_cpp; older zoo wheels (e.g. 2026.1.4) lack
LLAMA_CPP_DEFAULT_DIR, so the previous unguarded import could crash the
GGUF export path on environments installed with --no-deps or a manually
pinned zoo. Move the constant import alongside the resolver probe inside
a single try/except ImportError so a missing symbol degrades to the
warning instead of a hard crash, matching the graceful-degradation
intent the probe was added for.

The compatibility warning previously fired on every export call because
'from X import Y' re-raises ImportError on every invocation when Y is
absent. Gate emission on a module-level flag so operators see it once
per process instead of once per export.

* Add Studio GGUF export script-pin test coverage

Consolidate tests for the UNSLOTH_LLAMA_CPP_SCRIPTS_DIR env-var pin in
ExportBackend.export_gguf into a single behavior-named module:

- AST-asserts the module-level _LLAMA_CPP_SCRIPTS_WARNING_EMITTED flag,
  the merged try-block importing both LLAMA_CPP_DEFAULT_DIR and
  _resolve_local_convert_script, and the warn-once gate inside the
  ImportError handler.
- Behaviorally verifies setdefault preserves explicit user overrides,
  assigns the default when unset, fires the compatibility warning at
  most once across multiple export calls, and degrades to a warning
  (without setting the env var) when LLAMA_CPP_DEFAULT_DIR itself is
  missing on an older unsloth_zoo.

* Sync .github/workflows with upstream author branch

* [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>
Co-authored-by: Daniel Han <danielhanchen@gmail.com>
Co-authored-by: Lee Jackson <130007945+Imagineer99@users.noreply.github.com>
2026-05-05 04:03:28 -07:00
..
install Fix/windowsprebuilt (#5241) 2026-05-02 09:42:19 +04:00
test_cancel_atomicity.py Studio: make stop button actually stop generation (#5069) 2026-04-24 10:09:25 -07:00
test_cancel_id_wiring.py Studio: make stop button actually stop generation (#5069) 2026-04-24 10:09:25 -07:00
test_chat_preset_builtin_invariants.py Studio: Refine chat preset and group built-in presets (#5159) 2026-04-28 02:40:15 -07:00
test_cli_repo_variant.py Studio: forward llama-server args from unsloth studio run , activate unsloth run , and allow passing model:quant to load models (#5271) 2026-05-04 17:08:04 +04:00
test_cli_run_alias.py Studio: forward llama-server args from unsloth studio run , activate unsloth run , and allow passing model:quant to load models (#5271) 2026-05-04 17:08:04 +04:00
test_cli_studio_defaults.py Default Studio host to 127.0.0.1 and prompt before auto-start (#5267) 2026-05-04 13:03:16 +04:00
test_llama_cpp_wall_clock_cap.py Studio: make stop button actually stop generation (#5069) 2026-04-24 10:09:25 -07:00
test_stream_cancel_registration_timing.py Studio: make stop button actually stop generation (#5069) 2026-04-24 10:09:25 -07:00
test_studio_gguf_export_script_pin.py Pin Studio GGUF export to llama.cpp's local convert script (#5275) 2026-05-05 04:03:28 -07:00
test_studio_text_descender_clipping.py Studio: Fix clipped model selector text descenders (#5210) 2026-04-29 02:51:25 -07:00