say "no such file" when a GGUF component is not on disk

diffusers reports a missing single-file checkpoint as

    Invalid `pretrained_model_name_or_path` provided. Please set it to a
    valid URL.

which sends you to check the repo id. The actual cause, measured on LTX-2.5,
was an entry pointing into ~/.cache/huggingface on the HOST -- a path the
container does not mount -- so the file existed everywhere except in the
process trying to open it. Every other part of that model was ready.

The path is probed before the load and named in the failure, with the reason
it is usually absent.
Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014T3rZnLhydX9QqUcfBbqLu
parent 920b3636
......@@ -714,6 +714,18 @@ def build_gguf_pipeline_components(model_name: str, cfg: Optional[Dict[str, Any]
problems.append(f"{name}: {cls_name or 'its class'} is not loadable "
f"from a single file in this diffusers")
continue
# A configured path that is simply not there is the commonest way this
# fails, and diffusers reports it as "Invalid `pretrained_model_name_
# _or_path` provided. Please set it to a valid URL." -- which reads
# like the repo id is wrong, not like a missing file. Measured: an
# entry pointing at ~/.cache on the HOST, which a container does not
# mount, cost a full round trip to diagnose.
_p = str(path).strip()
if not _p.startswith(("http://", "https://")) and not os.path.isfile(_p):
problems.append(
f"{name}: no such file: {_p} (a path this process cannot see "
f"-- in a container, check that it is under a mounted volume)")
continue
try:
print(f" Loading GGUF component '{name}' from {path}")
_undo = _patch_converter_key_aliases(cls_name, cls, cfg, name)
......
"""A configured GGUF component that is not on disk should say so.
diffusers reports a missing single-file checkpoint as
Invalid `pretrained_model_name_or_path` provided. Please set it to a
valid URL.
which reads as "your repo id is wrong" rather than "that file is not here".
Measured on LTX-2.5, whose entry pointed at ~/.cache/huggingface on the HOST
— a path the container does not mount. The model had every other thing it
needed.
"""
import pytest
from codai.models import hf_loading
def test_a_missing_file_is_named_as_a_missing_file(tmp_path, monkeypatch):
missing = str(tmp_path / "not-here" / "model-Q4_K_M.gguf")
cfg = {"path": "Lightricks/LTX-2.5-Diffusers",
"component_quantization": {"transformer": missing}}
monkeypatch.setattr(hf_loading, "_discover_components",
lambda name: {"transformer": ["diffusers",
"LTX2VideoTransformer3DModel"]})
with pytest.raises(RuntimeError) as err:
hf_loading.build_gguf_pipeline_components("LTX-2.5", cfg, "bfloat16")
msg = str(err.value)
assert "no such file" in msg and missing in msg
# And it points at the usual cause rather than leaving it a mystery.
assert "mounted volume" in msg
def test_an_http_url_is_not_checked_on_disk(monkeypatch):
"""Remote GGUFs are a supported form; only local paths are probed."""
import inspect
src = inspect.getsource(hf_loading.build_gguf_pipeline_components)
assert 'startswith(("http://", "https://"))' in src
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment