Skip to content

Commit 8625836

Browse files
committed
Update Submodule vendor/llama.cpp 81df3f7..82209ef
1 parent e3b7ad6 commit 8625836

4 files changed

Lines changed: 19 additions & 71 deletions

File tree

llama_cpp/_internals.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,6 @@ def reset_timings(self):
758758
def print_timings(self):
759759
llama_cpp.llama_perf_context_print(self.ctx)
760760

761-
def print_memory_breakdown(self):
762-
"""print a breakdown of per-device memory use via LLAMA_LOG"""
763-
llama_cpp.llama_memory_breakdown_print(self.ctx)
764-
765761
# LoRA / ALoRA Dynamic Routing Methods
766762

767763
def clear_loras(self):

llama_cpp/llama_cpp.py

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,53 +1519,6 @@ class llama_params_fit_status(enum.IntEnum):
15191519
LLAMA_PARAMS_FIT_STATUS_ERROR = 2
15201520

15211521

1522-
# // fits mparams and cparams to free device memory (assumes system memory is unlimited)
1523-
# // - returns true if the parameters could be successfully modified to fit device memory
1524-
# // - this function is NOT thread safe because it modifies the global llama logger state
1525-
# // - only parameters that have the same value as in llama_default_model_params are modified
1526-
# // with the exception of the context size which is modified if and only if equal to 0
1527-
# LLAMA_API enum llama_params_fit_status llama_params_fit(
1528-
# const char * path_model,
1529-
# struct llama_model_params * mparams,
1530-
# struct llama_context_params * cparams,
1531-
# float * tensor_split, // writable buffer for tensor split, needs at least llama_max_devices elements
1532-
# struct llama_model_tensor_buft_override * tensor_buft_overrides, // writable buffer for overrides, needs at least llama_max_tensor_buft_overrides elements
1533-
# size_t margin, // margin of memory to leave per device in bytes
1534-
# uint32_t n_ctx_min, // minimum context size to set when trying to reduce memory use
1535-
# enum ggml_log_level log_level); // minimum log level to print during fitting, lower levels go to debug log
1536-
@ctypes_function(
1537-
"llama_params_fit",
1538-
[
1539-
ctypes.c_char_p,
1540-
llama_model_params_p,
1541-
llama_context_params_p,
1542-
ctypes.POINTER(ctypes.c_float),
1543-
ctypes.POINTER(llama_model_tensor_buft_override),
1544-
ctypes.c_size_t,
1545-
ctypes.c_uint32,
1546-
ctypes.c_int,
1547-
],
1548-
ctypes.c_int,
1549-
)
1550-
def llama_params_fit(
1551-
path_model: ctypes.c_char_p,
1552-
mparams: CtypesPointer[llama_model_params],
1553-
cparams: CtypesPointer[llama_context_params],
1554-
tensor_split: CtypesPointer[ctypes.c_float],
1555-
tensor_buft_overrides: CtypesPointer[llama_model_tensor_buft_override],
1556-
margin: ctypes.c_size_t,
1557-
n_ctx_min: ctypes.c_uint32,
1558-
log_level: int,
1559-
/,
1560-
) -> int:
1561-
"""
1562-
fits mparams and cparams to free device memory (assumes system memory is unlimited)
1563-
returns true if the parameters could be successfully modified to fit device memory
1564-
this function is NOT thread safe because it modifies the global llama logger state
1565-
"""
1566-
...
1567-
1568-
15691522
# LLAMA_API int64_t llama_time_us(void);
15701523
@ctypes_function(
15711524
"llama_time_us",
@@ -4930,17 +4883,6 @@ def llama_perf_sampler_reset(chain: llama_sampler_p, /):
49304883
...
49314884

49324885

4933-
# // print a breakdown of per-device memory use via LLAMA_LOG:
4934-
# LLAMA_API void llama_memory_breakdown_print(const struct llama_context * ctx);
4935-
@ctypes_function(
4936-
"llama_memory_breakdown_print",
4937-
[llama_context_p_ctypes],
4938-
None,
4939-
)
4940-
def llama_memory_breakdown_print(ctx: llama_context_p, /):
4941-
...
4942-
4943-
49444886
# //
49454887
# // training
49464888
# //

llama_cpp/mtmd_cpp.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,19 @@ class mtmd_input_chunk_type(enum.IntEnum):
9494
mtmd_bitmap_p = NewType("mtmd_bitmap_p", int)
9595
mtmd_bitmap_p_ctypes = c_void_p
9696

97+
# // position indexing for decoder model
98+
# enum mtmd_pos_type {
99+
# MTMD_POS_TYPE_NORMAL, // number of positions equals to number of tokens
100+
# MTMD_POS_TYPE_MROPE, // qwen-vl mrope style, each image takes max(t,h,w) position indexes
101+
# };
102+
class mtmd_pos_type(enum.IntEnum):
103+
MTMD_POS_TYPE_NORMAL = 0 # number of positions equals to number of tokens
104+
MTMD_POS_TYPE_MROPE = 1 # qwen-vl mrope style, each image takes max(t,h,w) position indexes
105+
97106
# struct mtmd_image_tokens {
98107
# uint32_t nx; // number of tokens in x direction
99108
# uint32_t ny; // number of tokens in y direction
100-
# bool use_mrope_pos = false; // use M-RoPE position counting (the whole image is 1 temporal position)
109+
# mtmd_pos_type pos = MTMD_POS_TYPE_NORMAL;
101110
# uint32_t n_tokens() const { return nx * ny; }
102111
# clip_image_f32_batch batch_f32; // preprocessed image patches
103112
# std::string id; // optional user-defined ID, useful for KV cache tracking
@@ -269,36 +278,37 @@ def mtmd_free(ctx: mtmd_context_p):
269278
...
270279

271280
# // whether we need to set non-causal mask before llama_decode
272-
# MTMD_API bool mtmd_decode_use_non_causal(mtmd_context * ctx);
281+
# // if chunk is nullptr, we assume the default case where chunk is an image chunk
282+
# MTMD_API bool mtmd_decode_use_non_causal(const mtmd_context * ctx, const mtmd_input_chunk * chunk);
273283
@ctypes_function_mtmd(
274-
"mtmd_decode_use_non_causal", [mtmd_context_p_ctypes], c_bool)
275-
def mtmd_decode_use_non_causal(ctx: mtmd_context_p) -> c_bool:
284+
"mtmd_decode_use_non_causal", [mtmd_context_p_ctypes, mtmd_input_chunk_p_ctypes], c_bool)
285+
def mtmd_decode_use_non_causal(ctx: mtmd_context_p, chunk: mtmd_input_chunk_p) -> c_bool:
276286
...
277287

278288
# // whether the current model use M-RoPE for llama_decode
279-
# MTMD_API bool mtmd_decode_use_mrope(mtmd_context * ctx);
289+
# MTMD_API bool mtmd_decode_use_mrope(const mtmd_context * ctx);
280290
@ctypes_function_mtmd(
281291
"mtmd_decode_use_mrope", [mtmd_context_p_ctypes], c_bool)
282292
def mtmd_decode_use_mrope(ctx: mtmd_context_p) -> c_bool:
283293
...
284294

285295
# // whether the current model supports vision input
286-
# MTMD_API bool mtmd_support_vision(mtmd_context * ctx);
296+
# MTMD_API bool mtmd_support_vision(const mtmd_context * ctx);
287297
@ctypes_function_mtmd(
288298
"mtmd_support_vision", [mtmd_context_p_ctypes], c_bool)
289299
def mtmd_support_vision(ctx: mtmd_context_p) -> c_bool:
290300
...
291301

292302
# // whether the current model supports audio input
293-
# MTMD_API bool mtmd_support_audio(mtmd_context * ctx);
303+
# MTMD_API bool mtmd_support_audio(const mtmd_context * ctx);
294304
@ctypes_function_mtmd(
295305
"mtmd_support_audio", [mtmd_context_p_ctypes], c_bool)
296306
def mtmd_support_audio(ctx: mtmd_context_p) -> c_bool:
297307
...
298308

299309
# // get audio sample rate in Hz, for example 16000 for Whisper
300310
# // return -1 if audio is not supported
301-
# MTMD_API int mtmd_get_audio_sample_rate(mtmd_context * ctx);
311+
# MTMD_API int mtmd_get_audio_sample_rate(const mtmd_context * ctx);
302312
@ctypes_function_mtmd(
303313
"mtmd_get_audio_sample_rate", [mtmd_context_p_ctypes], c_int)
304314
def mtmd_get_audio_sample_rate(ctx: mtmd_context_p) -> c_int:

vendor/llama.cpp

0 commit comments

Comments
 (0)