Skip to content

fix: preserve nested pretrained model paths in local directories - #2450

Open
original4422 wants to merge 2 commits into
abetlen:mainfrom
original4422:fix/pretrained-nested-local-dir
Open

original4422 wants to merge 2 commits into
abetlen:mainfrom
original4422:fix/pretrained-nested-local-dir

Conversation

@original4422

Copy link
Copy Markdown

Summary

Llama.from_pretrained(filename="nested/model.gguf", local_dir="models") matches and resolves the nested file, then drops its directory when constructing the model path.
Preserve the matched relative path for explicit local directories, including glob matches.

- models/model.gguf
+ models/nested/model.gguf

Add offline/online path-selection regressions, flat-directory and snapshot-cache controls, and an Unreleased changelog entry.

Evidence

  • Before: the eight new path tests give 4 failures and 4 passing controls on unmodified main 77fbb5d. Real offline nested literal/glob loads fail at the basename-only path even though Hugging Face Hub returns an existing nested file.
    After: all 8 path tests pass. Real offline nested literal/glob, flat-directory and snapshot literal/glob loads each generate 2 tokens with the cached stories15M Q4_0 GGUF, n_gpu_layers=0 and networking disabled.
  • make test: 34 passed, no skips, using existing cached model fixtures with HF_HUB_OFFLINE=1.
  • make lint: Ruff checks and formatting pass for all 30 Python files.

Validated on macOS arm64, Python 3.12.14, huggingface-hub 2.2.0 and bundled llama.cpp f5e6915c2, built with GGML_NATIVE=OFF and GGML_ACCELERATE=ON.
The full suite used the available native backends; the explicit loading probes used CPU layers only.
Online discovery is covered with bounded Hub stubs, not a live model download; cross-platform/GPU matrices remain for CI.

Implemented, reviewed and tested by an AI coding agent acting under the contributor's authorization.

Merge Danger

Door: two-way; reverting the path join restores the previous behavior.

Blast Radius: local-directory main-model loading; the matched relative path is retained without changing discovery, download calls or snapshot-cache resolution.

@original4422

Copy link
Copy Markdown
Author

Hi @abetlen, when convenient, could you review the nested local_dir model-path fix, or advise if changes are needed? This AI-assisted PR records 34 local test passes and five real CPU loading controls on d58b69e; the follow-up only adds the changelog PR reference. Cross-platform and GPU validation remain for CI. Thank you.

This branch has not been deployed

No deployments
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.

1 participant