fix(self-host): harvest non-weight siblings into slug_dir (cherry-pick #9610)#9652
Conversation
| let mut snapshot_dirs: std::collections::HashSet<PathBuf> = | ||
| hf_snapshots.values().cloned().collect(); | ||
| for (uri, _) in &entries { | ||
| if let Some(parent) = file_uri_parent(uri) { |
There was a problem hiding this comment.
file_uri_parent is applied to every file:// metadata entry, including custom chat-template files whose parent may be unrelated to the model, so a template in /tmp can import unrelated files into slug_dir and can nondeterministically overwrite valid harvested siblings from the HF snapshot. Fix: carry the is_custom flag through entries and only add file parents for non-custom model metadata or for an explicit local model directory.
| } | ||
| } | ||
| for snap in &snapshot_dirs { | ||
| harvest_siblings(snap, &slug_dir, &typed_filenames)?; |
There was a problem hiding this comment.
Reusing the same mdcsum directory and only relinking siblings that currently exist leaves previously harvested untyped files behind when a later snapshot with the same typed checksums removes them, causing from_pretrained(slug_dir) to see stale configuration. Fix: delete non-typed entries from slug_dir before harvesting or populate a fresh staged slug directory and atomically publish it.
Cherry-pick of #9610 (
94771a9) ontorelease/1.2.0.