Skip to content

Prevent LoRA alpha scalars from being skipped over during model loading #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
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
Loading