Skip to content

Commit

Permalink
Adjusted model loading such that LoRA alpha tensors are not skipped f…
Browse files Browse the repository at this point in the history
…or having an encoded dim of zero
  • Loading branch information
grauho committed May 12, 2024
1 parent ce1bcc7 commit c7ae9b7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,10 @@ ggml_type str_to_ggml_type(const std::string& dtype) {
return ttype;
}

static bool name_ends_with(const std::string name, const std::string suffix) {
return ((name.size() >= suffix.size()) && (name.compare(name.size() - suffix.size(), suffix.size(), suffix) == 0));
}

// https://huggingface.co/docs/safetensors/index
bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const std::string& prefix) {
LOG_DEBUG("init from '%s'", file_path.c_str());
Expand Down Expand Up @@ -889,7 +893,7 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
}

// ggml/src/ggml.c:2745
if (n_dims < 1 || n_dims > GGML_MAX_DIMS) {
if ((n_dims < 1 || n_dims > GGML_MAX_DIMS) && (name_ends_with(name, ".alpha") == false)) {
LOG_ERROR("skip tensor '%s' with n_dims %d", name.c_str(), n_dims);
continue;
}
Expand Down

0 comments on commit c7ae9b7

Please sign in to comment.