unsloth/studio/backend/utils/inference
Daniel Han 6c0826a9e4
Fix Windows local GGUF model loading crash (#4730)
* Fix Windows "Non-relative patterns are unsupported" when loading local GGUF models

When a user loads a GGUF model from a local Windows path (e.g.
C:\Users\danie\.lmstudio\models\unsloth\functiongemma-270m-it-GGUF),
the model identifier contains backslashes and a drive letter. Both
load_model_defaults() and _has_specific_yaml() constructed a YAML
filename from the full absolute path and passed it to Path.rglob(),
which rejects non-relative patterns on Windows.

Fixed by detecting Windows-style paths (drive letters, UNC paths,
backslashes) in addition to Unix-style paths, and using only the
directory basename for the YAML filename lookup when the identifier
is a local filesystem path.

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

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

* Refactor: reuse is_local_path helper, fix case-sensitive suffix lookup

- Replace inline local-path detection in model_config.py and
  inference_config.py with the existing is_local_path() from utils.paths,
  which already handles Unix, Windows drive-letter, UNC, and backslash paths
- Fix case-sensitive suffix lookup in load_model_defaults(): the
  _REVERSE_MODEL_MAPPING is lowercase-keyed, so suffix comparisons must use
  .lower() to match paths like /path/to/Spark-TTS-0.5B/LLM

* Fix WSL path parsing and _has_specific_yaml suffix lookup

- Use normalize_path() before Path() operations so backslash Windows
  paths (e.g. C:\Users\...\model) are correctly split on POSIX/WSL hosts
  where pathlib treats backslashes as literal characters
- Add suffix-based (2-component and 1-component) lookup to
  _has_specific_yaml() so it matches the same resolution rules as
  load_model_defaults(), fixing wrong inference params for local
  suffix-mapped models like Spark-TTS-0.5B/LLM

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-04-01 01:38:09 -07:00
..
__init__.py Final cleanup 2026-03-12 18:28:04 +00:00
inference_config.py Fix Windows local GGUF model loading crash (#4730) 2026-04-01 01:38:09 -07:00