Check for llama_get_logits_ith() errors#7448
Open
jart wants to merge 9 commits intoggml-org:masterfrom
Open
Conversation
Embeddings models like BERT don't have logits. This caused the llamafile software to crash for users who tried to inference mxbai-embed-large-v1. This change potentially helps prevent the server from crashing. Since it is possible for this function to fail having callers check the result is a good idea from a defensive coding standpoint. The older exception code has also been refactored, since it's no longer needed.
compilade
reviewed
May 21, 2024
Co-authored-by: compilade <git@compilade.net>
Co-authored-by: compilade <git@compilade.net>
Co-authored-by: compilade <git@compilade.net>
Co-authored-by: compilade <git@compilade.net>
Co-authored-by: compilade <git@compilade.net>
Co-authored-by: compilade <git@compilade.net>
Contributor
Author
|
Thanks for the detailed review! |
Contributor
Contributor
Author
|
@compilade I'm reasonably certain it's passing and I've addressed your comments, if you want to take a look. |
compilade
reviewed
May 22, 2024
Collaborator
There was a problem hiding this comment.
It's returning -1 here while it's returning 1 in other places for the same kind of check in the same file. Why?
Contributor
Author
There was a problem hiding this comment.
It returns 1 from main() functions to exit(1).
Collaborator
There was a problem hiding this comment.
Right. But it's -1 (negative one) here, so the exit code will be 255.
| struct llama_context * ctx_llama, | ||
| int * n_past) { | ||
| const llama_token id = llama_sampling_sample(ctx_sampling, ctx_llama, NULL); | ||
| GGML_ASSERT(id != -1); |
Collaborator
There was a problem hiding this comment.
Sometimes it's a return 1, other times it's an assertion, or an exception.
Which to use when? Should a single way be chosen?
Co-authored-by: compilade <git@compilade.net>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Embeddings models like BERT don't have logits. This caused the llamafile software to crash for users who tried to inference mxbai-embed-large-v1. This change potentially helps prevent the server from crashing. Since it is possible for this function to fail having callers check the result is a good idea from a defensive coding standpoint. The older exception code has also been refactored, since it's no longer needed.