hf: a lone container does not outrank weights beside it

Give --model org/repo and the engine picks what to serve from the fetched
directory: one .rad on the top level won outright, whatever else was
there -- and .rad was not in the skip list a safetensors set imposes on
.bin/.pth/.gguf, so hfget fetched the rival too. A repository that ships
a real safetensors set beside one decoy .rad chose for the operator: the
container wins, the engine loads and serves it in place of the model the
operator named.

hf_served_path no longer resolves that tie by rank -- a container among
safetensors or gguf weights is refused by name and the operator passes the
file they mean -- and hfget skips .rad when a safetensors set is present,
as it skips every other rival. A repo holding only a container still
serves it: the fix is against the silent tie-break, not against .rad.
This commit is contained in:
fl0l0u committed 2026-11-15 20:38:10 +00:00
1 parent 4c9a79ca98
commit 965a7caa51
3 files changed
+40 -4

No files matched your search

+15 -3
View File
@@ -97,18 +97,30 @@ std::string hf_default_download_dir() {
std::string hf_served_path(const std::string& dir, std::string* why) {
std::vector<std::string> rad;
int64_t other_fmt = 0;
std::error_code ec;
for (const fs::directory_entry& e : fs::directory_iterator(dir, ec)) {
std::error_code fe;
if (e.is_regular_file(fe) && e.path().filename().string().ends_with(".rad"))
rad.push_back(e.path().filename().string());
if (!e.is_regular_file(fe)) continue;
const std::string name = e.path().filename().string();
if (name.ends_with(".rad")) rad.push_back(name);
/* A repo fetched with hfget holds its source weights beside anything the operator or a
* conversion added later; a container sitting among them is not self-appointing. */
else if (name.ends_with(".safetensors") || name.ends_with(".gguf")) ++other_fmt;
}
if (ec) {
*why = dir + ": " + ec.message();
return std::string();
}
if (rad.empty()) return dir;
if (rad.size() == 1) return dir + "/" + rad[0];
if (rad.size() == 1) {
if (other_fmt > 0) {
*why = dir + " holds the container " + rad[0] + " beside safetensors or gguf weights; " +
"pass the one to serve as --model " + dir + "/<file>";
return std::string();
}
return dir + "/" + rad[0];
}
std::string names;
for (size_t i = 0; i < rad.size(); ++i) names += (i ? ", " : "") + rad[i];
*why = dir + " holds " + std::to_string(rad.size()) + " containers (" + names +