Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/model/te/llm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ namespace LLM {
int num_heads = 16;
int64_t in_channels = 3;
int64_t out_hidden_size = 3584;
bool out_hidden_size_detected = false;
int temporal_patch_size = 2;
int patch_size = 14;
int spatial_merge_size = 2;
Expand Down Expand Up @@ -238,7 +239,8 @@ namespace LLM {
}
if (contains(name, "visual.merger.linear_fc2.weight") ||
contains(name, "visual.merger.mlp.2.weight")) {
config.vision.out_hidden_size = tensor_storage.ne[1];
config.vision.out_hidden_size = tensor_storage.ne[1];
config.vision.out_hidden_size_detected = true;
}
continue;
}
Expand Down Expand Up @@ -1768,6 +1770,15 @@ namespace LLM {
LOG_WARN("no vision weights detected, vision disabled");
enable_vision = false;
}
// The default would reject valid models, so only compare a detected dim.
if (enable_vision && config.vision.out_hidden_size_detected &&
config.vision.out_hidden_size != config.hidden_size) {
LOG_ERROR("vision projector output size (%" PRId64 ") does not match LLM hidden size (%" PRId64 "), "
"the vision weights (mmproj) likely belong to a different LLM variant, vision disabled",
config.vision.out_hidden_size,
config.hidden_size);
enable_vision = false;
}
if (enable_vision) {
LOG_DEBUG("enable llm vision");
if (config.llama_cpp_style) {
Expand Down
Loading