-
Notifications
You must be signed in to change notification settings - Fork 10k
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
llama : (proposal) return enum for llama_decode
and llama_encode
#9434
Conversation
Another option is to have a single |
I have just have a look on all public functions of the library to see which one can be benefit from having enum as returned status:
So for now I think having one single
What do you think about this? |
All functions that can fail should return an status. This would also include The status codes in this PR are too specific to be reused, but they don't need to be. A generic "failed memory allocation" and a "invalid parameter" status would cover most cases. IMO it's not good to be too specific in the error codes, applications do not need to know that, and it exposes implementation details that may change in the future. |
@slaren Yup, I agree that the error code introduced in this PR is a bit too specific (I'm just doing a 1-to-1 map from the old code though) For the proposal about other functions like |
It would be a breaking change for sure, most functions would need to be changed, but it should be done eventually. My preference would be to change all functions that can fail to return a status code. ggml also needs a similar refactor. |
I had the same idea and made a similar solution in my fork. But I solved this problem through a single But in these statuses it is also important not to forget that Therefore |
I would love to see this change. I introduced the ability to abort the Metal backend in |
@slaren I agree that changing all function to return status code is a good idea. This will be a big breaking change though, so I think we should do at later stage (given that currently there're some other on-going reworks in llama.cpp) @Xarbirus @conradev As discussed earlier, status returned from For now I will close this PR since the proposed approach is not what we want, but feel free to discuss if you have other ideas. |
Return value of
llama_encode
andllama_decode
is currently not very well-documented.This PR propose using an enum for it. I'm not sure if this is the good way to do, so feel free to discuss more on that.