Skip to content

Safetensors load fix #233

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

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Safetensors load fix #233

merged 1 commit into from
Apr 29, 2024

Conversation

ring-c
Copy link
Contributor

@ring-c ring-c commented Apr 22, 2024

In GGML we have check for n_dims on tensor creation:
ggml/src/ggml.c:2745

assert(n_dims >= 1 && n_dims <= GGML_MAX_DIMS);

So, we cant use tensor_storage with n_dims not in range, so I added a skip for this.
Tested with lora Expressive_H.
Logs before fix:

model.cpp:1378 - loading tensors from [...]/Expressive_H.safetensors
[...]/ggml/src/ggml.c:2745: ggml_new_tensor_impl: Assertion `n_dims >= 1 && n_dims <= GGML_MAX_DIMS' failed.

Logs after fix:

model.cpp:1378 - loading tensors from [...]/Expressive_H.safetensors
lora.hpp:67   - finished loaded lora
lora.hpp:174  - (1972 / 1972) LoRA tensors applied successfully

@leejet
Copy link
Owner

leejet commented Apr 29, 2024

Thank you for your contribution.

@leejet leejet merged commit 760cfaa into leejet:master Apr 29, 2024
@@ -888,6 +888,11 @@ 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is kinda weird, since we check for
if (shape.size() > SD_MAX_DIMS) {
above.
(int n_dims = (int)shape.size();)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only checks for > SD_MAX_DIMS but problem in n_dims < 1

@ring-c ring-c deleted the lora branch April 30, 2024 09:37
@grauho grauho mentioned this pull request May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants