Repository navigation
Move LlamaLanguageModel to llama.cpp's extended batch API - #451
Open
james-333i wants to merge 1 commit into
Open
james-333i wants to merge 1 commit into
james-333i wants to merge 1 commit into
Conversation
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.
llama.cpp v1.x deprecates
llama_batch,llama_batch_init,llama_batch_free,llama_decodeandllama_encodein favor ofllama_batch_extandllama_process. With llama.swift 3.x,LlamaLanguageModel.swiftproduces 12 deprecation warnings.This moves the backend to the new API:
fillBatchhelper clears the batch, adds each token with its position, and requests logits for the last token when asked. It replaces the field writes that were repeated at each call site.llama_batch_init/llama_batch_freebecomellama_batch_ext_init/llama_batch_ext_free.llama_decodeandllama_encodebecomellama_processwith the matching process type.batch.n_tokens - 1now pass-1, the last output. The backend only ever requests logits for the last token, so the value is the same.One difference:
llama_batch_ext_inittakes its capacity from the context'sn_batchand has no size argument. The prompt loop now chunks by the smaller of the requested batch size andllama_n_batch(context).The reference decoder in
LlamaLanguageModelTestsused the same deprecated calls and is updated to match.The new functions are present in b12359, the build llama.swift 3.0.0 ships, so this does not need a newer llama.swift than the current requirement.