llama-server: fix gemma4 patch wiring (#16477)

This will fix the "clip.cpp:4399: Unknown projector type" crash.
This commit is contained in:
Daniel Hiltgen
2026-06-03 14:41:03 -07:00
committed by GitHub
parent ac3d0657a2
commit 229a1303fb
4 changed files with 41 additions and 1 deletions

View File

@@ -70,6 +70,18 @@ bool compat_disabled() {
return value && std::strcmp(value, "0") == 0;
}
bool clip_mmproj_embd_uses_projection_dim(const char * projector_type) {
static constexpr const char * kProjectorTypes[] = {
"gemma4a",
};
if (!projector_type) return false;
for (const char * compat_type : kProjectorTypes) {
if (std::strcmp(projector_type, compat_type) == 0) return true;
}
return false;
}
// Per-loader file path registry — set by translate_metadata, read by
// maybe_load_text_tensor so it can pass the path to load ops without a
// separate patch insertion in the model loader's load_all_data path.
@@ -3387,4 +3399,10 @@ bool maybe_load_text_tensor(const llama_model_loader * ml,
return load_tensor_with_op(cur, path.c_str(), buft, op);
}
int maybe_clip_mmproj_embd(const char * projector_type, int projection_dim) {
if (compat_disabled() || projection_dim <= 0) return 0;
if (!clip_mmproj_embd_uses_projection_dim(projector_type)) return 0;
return projection_dim;
}
} // namespace llama_ollama_compat