Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- feat: update llama.cpp to ggml-org/llama.cpp@46eb1742d
- fix(ci): remove unsupported macOS 14 release runners by @abetlen in #2416

## [0.3.37]
Expand Down
50 changes: 41 additions & 9 deletions llama_cpp/llama_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ class llama_token_data_array(ctypes.Structure):
# // - if not: only the last token is output
# // )
# //
# // [DEPRECATED] use llama_batch_ext instead
# typedef struct llama_batch {
# int32_t n_tokens;

Expand Down Expand Up @@ -1925,6 +1926,32 @@ def llama_model_meta_val_str_by_index(
...


# // GGUF metadata arrays of strings
# // currently, only these keys are support:
# // - tokenizer.tts_dicts
# // - tokenizer.tts_dict.*


# // Get the number of elements, or -1 if there is no such array
# LLAMA_API int32_t llama_model_meta_arr_n(const struct llama_model * model, const char * key);
@ctypes_function(
"llama_model_meta_arr_n", [llama_model_p_ctypes, ctypes.c_char_p], ctypes.c_int32
)
def llama_model_meta_arr_n(model: llama_model_p, key: bytes, /) -> int: ...


# // Get element i, owned by the model; None if not found
# LLAMA_API const char * llama_model_meta_arr_str(const struct llama_model * model, const char * key, int32_t i);
@ctypes_function(
"llama_model_meta_arr_str",
[llama_model_p_ctypes, ctypes.c_char_p, ctypes.c_int32],
ctypes.c_char_p,
)
def llama_model_meta_arr_str(
model: llama_model_p, key: bytes, i: int, /
) -> Optional[bytes]: ...


# // Get a string describing the model type
# LLAMA_API int32_t llama_model_desc(const struct llama_model * model, char * buf, size_t buf_size);
@ctypes_function(
Expand Down Expand Up @@ -2985,9 +3012,10 @@ def llama_state_seq_set_data_ext(
# //
# // NOTE: this is a helper function to facilitate transition to the new batch API - avoid using it
# //
# LLAMA_API struct llama_batch llama_batch_get_one(
# DEPRECATED(LLAMA_API struct llama_batch llama_batch_get_one(
# llama_token * tokens,
# int32_t n_tokens);
# int32_t n_tokens),
# "use llama_batch_ext_init and llama_batch_ext_add_token instead");
@ctypes_function(
"llama_batch_get_one",
[
Expand Down Expand Up @@ -3015,10 +3043,11 @@ def llama_batch_get_one(
# // Otherwise, llama_batch.token will be allocated to store n_tokens llama_token
# // The rest of the llama_batch members are allocated with size n_tokens
# // All members are left uninitialized
# LLAMA_API struct llama_batch llama_batch_init(
# DEPRECATED(LLAMA_API struct llama_batch llama_batch_init(
# int32_t n_tokens,
# int32_t embd,
# int32_t n_seq_max);
# int32_t n_seq_max),
# "use llama_batch_ext_init instead");
@ctypes_function(
"llama_batch_init", [ctypes.c_int32, ctypes.c_int32, ctypes.c_int32], llama_batch
)
Expand All @@ -3039,7 +3068,8 @@ def llama_batch_init(


# // Frees a batch of tokens allocated with llama_batch_init()
# LLAMA_API void llama_batch_free(struct llama_batch batch);
# DEPRECATED(LLAMA_API void llama_batch_free(struct llama_batch batch),
# "use llama_batch_ext_free instead");
@ctypes_function("llama_batch_free", [llama_batch], None)
def llama_batch_free(batch: llama_batch, /):
"""Frees a batch of tokens allocated with llama_batch_init()"""
Expand All @@ -3052,9 +3082,10 @@ def llama_batch_free(batch: llama_batch, /):
# // Can store the encoder output internally for later use by the decoder's cross-attention layers.
# // 0 - success
# // < 0 - error. the memory state is restored to the state before this call
# LLAMA_API int32_t llama_encode(
# DEPRECATED(LLAMA_API int32_t llama_encode(
# struct llama_context * ctx,
# struct llama_batch batch);
# struct llama_batch batch),
# "use llama_process with LLAMA_PROCESS_TYPE_ENCODE instead");
@ctypes_function("llama_encode", [llama_context_p_ctypes, llama_batch], ctypes.c_int32)
def llama_encode(ctx: llama_context_p, batch: llama_batch, /) -> int:
"""Process a batch of tokens.
Expand All @@ -3078,9 +3109,10 @@ def llama_encode(ctx: llama_context_p, batch: llama_batch, /) -> int:
# // 2 - aborted (processed ubatches will remain in the context's memory)
# // -1 - invalid input batch
# // < -1 - fatal error (processed ubatches will remain in the context's memory)
# LLAMA_API int32_t llama_decode(
# DEPRECATED(LLAMA_API int32_t llama_decode(
# struct llama_context * ctx,
# struct llama_batch batch);
# struct llama_batch batch),
# "use llama_process with LLAMA_PROCESS_TYPE_DECODE instead");
@ctypes_function("llama_decode", [llama_context_p_ctypes, llama_batch], ctypes.c_int32)
def llama_decode(ctx: llama_context_p, batch: llama_batch, /) -> int:
"""Process a batch of tokens.
Expand Down
Loading
Loading