-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Check for llama_get_logits_ith() errors #7448
base: master
Are you sure you want to change the base?
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.
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>
Thanks for the detailed review! |
@compilade I'm reasonably certain it's passing and I've addressed your comments, if you want to take a look. |
@@ -457,7 +463,9 @@ int main(int argc, char ** argv) { | |||
continue; | |||
} | |||
|
|||
llama_sampling_sample(drafts[s].ctx_sampling, ctx_dft, NULL, drafts[s].i_batch_dft); | |||
if (llama_sampling_sample(drafts[s].ctx_sampling, ctx_dft, NULL, drafts[s].i_batch_dft) == -1) { | |||
return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's returning -1
here while it's returning 1
in other places for the same kind of check in the same file. Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It returns 1
from main()
functions to exit(1)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. But it's -1
(negative one) here, so the exit code will be 255
.
@@ -44,6 +44,7 @@ static const char * sample(struct llama_sampling_context * ctx_sampling, | |||
struct llama_context * ctx_llama, | |||
int * n_past) { | |||
const llama_token id = llama_sampling_sample(ctx_sampling, ctx_llama, NULL); | |||
GGML_ASSERT(id != -1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
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.