8000 Update llama.cpp · AB1Dev/llama-cpp-python@a7d17b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit a7d17b8

Browse files
committed
Update llama.cpp
1 parent 305482b commit a7d17b8

File tree

2 files changed

+60
-3
lines changed

2 files changed

+60
-3
lines changed

llama_cpp/llama_cpp.py

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ def _load_shared_library(lib_base_name: str):
102102

103103
# define LLAMA_SESSION_MAGIC LLAMA_FILE_MAGIC_GGSN
104104
LLAMA_SESSION_MAGIC = LLAMA_FILE_MAGIC_GGSN
105-
# define LLAMA_SESSION_VERSION 1
106-
LLAMA_SESSION_VERSION = 1
105+
# define LLAMA_SESSION_VERSION 2
106+
LLAMA_SESSION_VERSION = 2
107107

108108

109109
# struct llama_model;
@@ -624,6 +624,16 @@ def llama_n_embd(model: llama_model_p) -> int:
624624
_lib.llama_n_embd.restype = c_int
625625

626626

627+
# // Get the model's RoPE frequency scaling factor
628+
# LLAMA_API float llama_rope_freq_scale_train(const struct llama_model * model);
629+
def llama_rope_freq_scale_train(model: llama_model_p) -> float:
630+
return _lib.llama_rope_freq_scale_train(model)
631+
632+
633+
_lib.llama_rope_freq_scale_train.argtypes = [llama_model_p]
634+
_lib.llama_rope_freq_scale_train.restype = c_float
635+
636+
627637
# // Get a string describing the model type
628638
# LLAMA_API int llama_model_desc(const struct llama_model * model, char * buf, size_t buf_size);
629639
def llama_model_desc(
@@ -768,6 +778,8 @@ def llama_get_kv_cache_token_count(ctx: llama_context_p) -> int:
768778

769779

770780
# // Remove all tokens data of cells in [c0, c1)
781+
# // c0 < 0 : [0, c1]
782+
# // c1 < 0 : [c0, inf)
771783
# LLAMA_API void llama_kv_cache_tokens_rm(
772784
# struct llama_context * ctx,
773785
# int32_t c0,
@@ -783,6 +795,8 @@ def llama_kv_cache_tokens_rm(
783795

784796

785797
# // Removes all tokens that belong to the specified sequence and have positions in [p0, p1)
798+
# // p0 < 0 : [0, p1]
799+
# // p1 < 0 : [p0, inf)
786800
# LLAMA_API void llama_kv_cache_seq_rm(
787801
# struct llama_context * ctx,
788802
# llama_seq_id seq_id,
@@ -808,6 +822,8 @@ def llama_kv_cache_seq_rm(
808822

809823
# // Copy all tokens that belong to the specified sequence to another sequence
810824
# // Note that this does not allocate extra KV cache memory - it simply assigns the tokens to the new sequence
825+
# // p0 < 0 : [0, p1]
826+
# // p1 < 0 : [p0, inf)
811827
# LLAMA_API void llama_kv_cache_seq_cp(
812828
# struct llama_context * ctx,
813829
# llama_seq_id seq_id_src,
@@ -851,6 +867,8 @@ def llama_kv_cache_seq_keep(
851867

852868
# // Adds relative position "delta" to all tokens that belong to the specified sequence and have positions in [p0, p1)
853869
# // If the KV cache is RoPEd, the KV data is updated accordingly
870+
# // p0 < 0 : [0, p1]
871+
# // p1 < 0 : [p0, inf)
854872
# LLAMA_API void llama_kv_cache_seq_shift(
855873
# struct llama_context * ctx,
856874
# llama_seq_id seq_id,
@@ -1215,6 +1233,43 @@ def llama_token_nl(ctx: llama_context_p) -> int:
12151233
_lib.llama_token_nl.restype = llama_token
12161234

12171235

1236+
# // codellama infill tokens
1237+
# LLAMA_API llama_token llama_token_prefix(const struct llama_context * ctx); // Beginning of infill prefix
1238+
def llama_token_prefix(ctx: llama_context_p) -> int:
1239+
return _lib.llama_token_prefix(ctx)
1240+
1241+
1242+
_lib.llama_token_prefix.argtypes = [llama_context_p]
1243+
_lib.llama_token_prefix.restype = llama_token
1244+
1245+
1246+
# LLAMA_API llama_token llama_token_middle(const struct llama_context * ctx); // Beginning of infill middle
1247+
def llama_token_middle(ctx: llama_context_p) -> int:
1248+
return _lib.llama_token_middle(ctx)
1249+
1250+
1251+
_lib.llama_token_middle.argtypes = [llama_context_p]
1252+
_lib.llama_token_middle.restype = llama_token
1253+
1254+
1255+
# LLAMA_API llama_token llama_token_suffix(const struct llama_context * ctx); // Beginning of infill suffix
1256+
def llama_token_suffix(ctx: llama_context_p) -> int:
1257+
return _lib.llama_token_suffix(ctx)
1258+
1259+
1260+
_lib.llama_token_suffix.argtypes = [llama_context_p]
1261+
_lib.llama_token_suffix.restype = llama_token
1262+
1263+
1264+
# LLAMA_API llama_token llama_token_eot (const struct llama_context * ctx); // End of infill middle
1265+
def llama_token_eot(ctx: llama_context_p) -> int:
1266+
return _lib.llama_token_eot(ctx)
1267+
1268+
1269+
_lib.llama_token_eot.argtypes = [llama_context_p]
1270+
_lib.llama_token_eot.restype = llama_token
1271+
1272+
12181273
# //
12191274
# // Tokenization
12201275
# //
@@ -1728,6 +1783,7 @@ def llama_grammar_accept_token(
17281783
# struct llama_beam_view {
17291784
# const llama_token * tokens;
17301785

1786+
17311787
# size_t n_tokens;
17321788
# float p; // Cumulative beam probability (renormalized relative to all beams)
17331789
# bool eob; // Callback should set this to true when a beam is at end-of-beam.
@@ -1794,6 +1850,7 @@ def llama_beam_search(
17941850
ctx, callback, callback_data, n_beams, n_past, n_predict
17951851
)
17961852

1853+
17971854
_lib.llama_beam_search.argtypes = [
17981855
llama_context_p,
17991856
llama_beam_search_callback_fn_t,

vendor/llama.cpp

0 commit comments

Comments
 (0)
0