the component probe asked a cache that had no reason to hold the answer

The LTX-2.5 key reconciliation shipped, the retry failed identically, and the
repair had never run. It needs the component's config.json to know which names
the class expects, and _component_dir looked only in the local snapshot --
which, for a component whose weights come from a GGUF, is precisely the
subfolder nobody downloads. 20 GB of weights the file replaces are not worth
fetching; a few hundred bytes of config are.

Cache first, then one hf_hub_download of that component's config.json. Same
lesson as a cache-only existence check on a rented pod: an answer of "not
here" from a cache is not an answer about the repo.
Co-Authored-By: 's avatarClaude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014T3rZnLhydX9QqUcfBbqLu
parent b14e4ccd
...@@ -668,17 +668,38 @@ def _missing_tensor_hint(exc, name: str, path: str, cfg) -> str: ...@@ -668,17 +668,38 @@ def _missing_tensor_hint(exc, name: str, path: str, cfg) -> str:
def _component_dir(cfg, name: str): def _component_dir(cfg, name: str):
"""The local directory of one component of the base pipeline, or None.""" """The local directory of one component of the base pipeline, or None.
Cache-first, then the hub for the ONE file callers actually read here --
the component's ``config.json``, a few hundred bytes. A cache-only answer
is wrong in exactly the case that matters: when a component's weights come
from a GGUF, the base repo's copy of that subfolder is never downloaded, so
the directory does not exist locally and every caller silently gives up.
That is how the LTX-2.5 key reconciliation came to do nothing at all -- it
needs the config to know which names the class expects, and it was asking
a cache that had no reason to hold it.
"""
import os import os
base = (cfg or {}).get("path") or (cfg or {}).get("model") or "" base = (cfg or {}).get("path") or (cfg or {}).get("model") or ""
if not base:
return None
if os.path.isdir(base):
d = os.path.join(base, name)
return d if os.path.isdir(d) else None
try: try:
from huggingface_hub import snapshot_download from huggingface_hub import snapshot_download
root = (base if os.path.isdir(base) root = snapshot_download(base, local_files_only=True)
else snapshot_download(base, local_files_only=True)) d = os.path.join(root, name)
if os.path.isdir(d):
return d
except Exception:
pass
try:
from huggingface_hub import hf_hub_download
conf = hf_hub_download(base, f"{name}/config.json")
return os.path.dirname(conf)
except Exception: except Exception:
return None return None
d = os.path.join(root, name)
return d if os.path.isdir(d) else None
def build_gguf_pipeline_components(model_name: str, cfg: Optional[Dict[str, Any]], dtype): def build_gguf_pipeline_components(model_name: str, cfg: Optional[Dict[str, Any]], dtype):
......
"""The component probe must not answer from the cache alone.
When a component's weights come from a GGUF, the base repo's copy of that
subfolder is never downloaded — there is no reason to fetch 20 GB of weights
the file replaces. A cache-only lookup therefore returns None, and every
caller that needs the component's `config.json` silently does nothing.
That is exactly how the LTX-2.5 key reconciliation came to be a no-op: the
repair was shipped, the retry failed identically, and the only difference
between "fixed" and "did nothing" was a few hundred bytes of config that
nobody had downloaded.
"""
import os
from codai.models import hf_loading
def test_a_local_directory_is_used_as_is(tmp_path):
(tmp_path / "transformer").mkdir()
got = hf_loading._component_dir({"path": str(tmp_path)}, "transformer")
assert got == str(tmp_path / "transformer")
def test_a_component_missing_from_a_local_dir_is_none(tmp_path):
assert hf_loading._component_dir({"path": str(tmp_path)}, "transformer") is None
def test_the_cache_is_tried_first_then_the_hub(monkeypatch, tmp_path):
"""Cache hit: no network call at all."""
root = tmp_path / "snap"
(root / "transformer").mkdir(parents=True)
monkeypatch.setattr(hf_loading, "_norm", hf_loading._norm) # keep module import
import huggingface_hub
monkeypatch.setattr(huggingface_hub, "snapshot_download",
lambda repo, **kw: str(root))
def _boom(*a, **kw):
raise AssertionError("the hub must not be touched on a cache hit")
monkeypatch.setattr(huggingface_hub, "hf_hub_download", _boom)
got = hf_loading._component_dir({"path": "some/repo"}, "transformer")
assert got == str(root / "transformer")
def test_a_cache_miss_fetches_only_that_components_config(monkeypatch, tmp_path):
"""The fallback pulls one small file, never the component's weights."""
import huggingface_hub
asked = []
def _no_snapshot(repo, **kw):
raise OSError("not in the cache")
def _one_file(repo, filename, **kw):
asked.append(filename)
p = tmp_path / "transformer" / "config.json"
p.parent.mkdir(parents=True, exist_ok=True)
p.write_text("{}")
return str(p)
monkeypatch.setattr(huggingface_hub, "snapshot_download", _no_snapshot)
monkeypatch.setattr(huggingface_hub, "hf_hub_download", _one_file)
got = hf_loading._component_dir({"path": "some/repo"}, "transformer")
assert got == str(tmp_path / "transformer")
assert asked == ["transformer/config.json"]
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