Skip to content

Commit c72739e

Browse files
committed
remove references to deprecated kv_self
1 parent 6e6b1f1 commit c72739e

File tree

1 file changed

+0
-264
lines changed

1 file changed

+0
-264
lines changed

llama_cpp/llama_cpp.py

Lines changed: 0 additions & 264 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,17 +1412,6 @@ def llama_pooling_type(ctx: llama_context_p, /) -> int:
14121412
...
14131413

14141414

1415-
# DEPRECATED(LLAMA_API struct llama_kv_cache * llama_get_kv_self(struct llama_context * ctx), "use llama_get_memory instead");
1416-
@ctypes_function(
1417-
"llama_get_kv_self",
1418-
[llama_context_p_ctypes],
1419-
llama_kv_cache_p_ctypes,
1420-
)
1421-
def llama_get_kv_self(ctx: llama_context_p, /) -> Optional[llama_kv_cache_p]:
1422-
"""Get the KV cache for self-attention (DEPRECATED)"""
1423-
...
1424-
1425-
14261415
# LLAMA_API const struct llama_vocab * llama_model_get_vocab(const struct llama_model * model);
14271416
@ctypes_function("llama_model_get_vocab", [llama_model_p_ctypes], llama_vocab_p_ctypes)
14281417
def llama_model_get_vocab(model: llama_model_p, /) -> Optional[llama_vocab_p]:
@@ -2048,259 +2037,6 @@ def llama_memory_can_shift(mem: llama_memory_t, /) -> bool:
20482037
"""Check if the memory supports shifting"""
20492038
...
20502039

2051-
2052-
# //
2053-
# // KV cache for self-attention (TODO: deprecate in favor of llama_memory)
2054-
# //
2055-
2056-
# // Returns the number of tokens in the KV cache (slow, use only for debug)
2057-
# // If a KV cell has multiple sequences assigned to it, it will be counted multiple times
2058-
# DEPRECATED(LLAMA_API int32_t llama_kv_self_n_tokens(const struct llama_context * ctx),
2059-
# "Use llama_kv_self_seq_pos_max() and llama_kv_self_seq_pos_min() instead (https://github.com/ggml-org/llama.cpp/issues/13793)");
2060-
@ctypes_function(
2061-
"llama_kv_self_n_tokens", [llama_context_p_ctypes], ctypes.c_int32
2062-
)
2063-
def llama_kv_self_n_tokens(ctx: llama_context_p, /) -> int:
2064-
"""Returns the number of tokens in the KV cache (slow, use only for debug) (DEPRECATED)"""
2065-
...
2066-
2067-
2068-
# // Returns the number of used KV cells (i.e. have at least one sequence assigned to them)
2069-
# DEPRECATED(LLAMA_API int32_t llama_kv_self_used_cells(const struct llama_context * ctx),
2070-
# "Use llama_kv_self_seq_pos_max() and llama_kv_self_seq_pos_min() instead (https://github.com/ggml-org/llama.cpp/issues/13793)");
2071-
@ctypes_function(
2072-
"llama_kv_self_used_cells", [llama_context_p_ctypes], ctypes.c_int32
2073-
)
2074-
def llama_kv_self_used_cells(ctx: llama_context_p, /) -> int:
2075-
"""Returns the number of used KV cells (DEPRECATED)"""
2076-
...
2077-
2078-
2079-
# // Clear the KV cache - both cell info is erased and KV data is zeroed
2080-
# DEPRECATED(LLAMA_API void llama_kv_self_clear(
2081-
# struct llama_context * ctx),
2082-
# "Use llama_memory_clear() instead");
2083-
@ctypes_function(
2084-
"llama_kv_self_clear", [llama_context_p_ctypes], None
2085-
)
2086-
def llama_kv_self_clear(ctx: llama_context_p, /):
2087-
"""Clear the KV cache (DEPRECATED)"""
2088-
...
2089-
2090-
2091-
# // Removes all tokens that belong to the specified sequence and have positions in [p0, p1)
2092-
# // Returns false if a partial sequence cannot be removed. Removing a whole sequence never fails
2093-
# // seq_id < 0 : match any sequence
2094-
# // p0 < 0 : [0, p1]
2095-
# // p1 < 0 : [p0, inf)
2096-
# DEPRECATED(LLAMA_API bool llama_kv_self_seq_rm(
2097-
# struct llama_context * ctx,
2098-
# llama_seq_id seq_id,
2099-
# llama_pos p0,
2100-
# llama_pos p1),
2101-
# "Use llama_memory_seq_rm() instead");
2102-
@ctypes_function(
2103-
"llama_kv_self_seq_rm",
2104-
[
2105-
llama_context_p_ctypes,
2106-
llama_seq_id,
2107-
llama_pos,
2108-
llama_pos,
2109-
],
2110-
ctypes.c_bool,
2111-
)
2112-
def llama_kv_self_seq_rm(
2113-
ctx: llama_context_p,
2114-
seq_id: Union[llama_seq_id, int],
2115-
p0: Union[llama_pos, int],
2116-
p1: Union[llama_pos, int],
2117-
/,
2118-
) -> bool:
2119-
"""Remove tokens from KV cache (DEPRECATED)"""
2120-
...
2121-
2122-
2123-
# // Copy all tokens that belong to the specified sequence to another sequence
2124-
# // Note that this does not allocate extra KV cache memory - it simply assigns the tokens to the new sequence
2125-
# // p0 < 0 : [0, p1]
2126-
# // p1 < 0 : [p0, inf)
2127-
# DEPRECATED(LLAMA_API void llama_kv_self_seq_cp(
2128-
# struct llama_context * ctx,
2129-
# llama_seq_id seq_id_src,
2130-
# llama_seq_id seq_id_dst,
2131-
# llama_pos p0,
2132-
# llama_pos p1),
2133-
# "Use llama_memory_seq_cp() instead");
2134-
@ctypes_function(
2135-
"llama_kv_self_seq_cp",
2136-
[
2137-
llama_context_p_ctypes,
2138-
llama_seq_id,
2139-
llama_seq_id,
2140-
llama_pos,
2141-
llama_pos,
2142-
],
2143-
None,
2144-
)
2145-
def llama_kv_self_seq_cp(
2146-
ctx: llama_context_p,
2147-
seq_id_src: Union[llama_seq_id, int],
2148-
seq_id_dst: Union[llama_seq_id, int],
2149-
p0: Union[llama_pos, int],
2150-
p1: Union[llama_pos, int],
2151-
/,
2152-
):
2153-
"""Copy tokens in KV cache (DEPRECATED)"""
2154-
...
2155-
2156-
2157-
# // Removes all tokens that do not belong to the specified sequence
2158-
# DEPRECATED(LLAMA_API void llama_kv_self_seq_keep(
2159-
# struct llama_context * ctx,
2160-
# llama_seq_id seq_id),
2161-
# "Use llama_memory_seq_keep() instead");
2162-
@ctypes_function(
2163-
"llama_kv_self_seq_keep", [llama_context_p_ctypes, llama_seq_id], None
2164-
)
2165-
def llama_kv_self_seq_keep(ctx: llama_context_p, seq_id: Union[llama_seq_id, int], /):
2166-
"""Keep only specified sequence in KV cache (DEPRECATED)"""
2167-
...
2168-
2169-
2170-
# // Adds relative position "delta" to all tokens that belong to the specified sequence and have positions in [p0, p1)
2171-
# // If the KV cache is RoPEd, the KV data is updated accordingly:
2172-
# // - lazily on next llama_decode()
2173-
# // p0 < 0 : [0, p1]
2174-
# // p1 < 0 : [p0, inf)
2175-
# DEPRECATED(LLAMA_API void llama_kv_self_seq_add(
2176-
# struct llama_context * ctx,
2177-
# llama_seq_id seq_id,
2178-
# llama_pos p0,
2179-
# llama_pos p1,
2180-
# llama_pos delta),
2181-
# "Use llama_memory_seq_add() instead");
2182-
@ctypes_function(
2183-
"llama_kv_self_seq_add",
2184-
[
2185-
llama_context_p_ctypes,
2186-
llama_seq_id,
2187-
llama_pos,
2188-
llama_pos,
2189-
llama_pos,
2190-
],
2191-
None,
2192-
)
2193-
def llama_kv_self_seq_add(
2194-
ctx: llama_context_p,
2195-
seq_id: Union[llama_seq_id, int],
2196-
p0: Union[llama_pos, int],
2197-
p1: Union[llama_pos, int],
2198-
delta: Union[llama_pos, int],
2199-
/,
2200-
):
2201-
"""Add delta to sequence positions in KV cache (DEPRECATED)"""
2202-
...
2203-
2204-
2205-
# // Integer division of the positions by factor of `d > 1`
2206-
# // If the KV cache is RoPEd, the KV data is updated accordingly:
2207-
# // - lazily on next llama_decode()
2208-
# // p0 < 0 : [0, p1]
2209-
# // p1 < 0 : [p0, inf)
2210-
# DEPRECATED(LLAMA_API void llama_kv_self_seq_div(
2211-
# struct llama_context * ctx,
2212-
# llama_seq_id seq_id,
2213-
# llama_pos p0,
2214-
# llama_pos p1,
2215-
# int d),
2216-
# "Use llama_memory_seq_div() instead");
2217-
@ctypes_function(
2218-
"llama_kv_self_seq_div",
2219-
[
2220-
llama_context_p_ctypes,
2221-
llama_seq_id,
2222-
llama_pos,
2223-
llama_pos,
2224-
ctypes.c_int,
2225-
],
2226-
None,
2227-
)
2228-
def llama_kv_self_seq_div(
2229-
ctx: llama_context_p,
2230-
seq_id: Union[llama_seq_id, int],
2231-
p0: Union[llama_pos, int],
2232-
p1: Union[llama_pos, int],
2233-
d: Union[ctypes.c_int, int],
2234-
/,
2235-
):
2236-
"""Divide sequence positions in KV cache (DEPRECATED)"""
2237-
...
2238-
2239-
2240-
# // Returns the smallest position present in the KV cache for the specified sequence
2241-
# // This is typically non-zero only for SWA caches
2242-
# // Note that all positions in the range [pos_min, pos_max] are guaranteed to be present in the KV cache
2243-
# // Return -1 if the sequence is empty
2244-
# DEPRECATED(LLAMA_API llama_pos llama_kv_self_seq_pos_min(
2245-
# struct llama_context * ctx,
2246-
# llama_seq_id seq_id),
2247-
# "Use llama_memory_seq_pos_min() instead");
2248-
@ctypes_function(
2249-
"llama_kv_self_seq_pos_min", [llama_context_p_ctypes, llama_seq_id], llama_pos
2250-
)
2251-
def llama_kv_self_seq_pos_min(
2252-
ctx: llama_context_p, seq_id: Union[llama_seq_id, int], /
2253-
) -> int:
2254-
"""Returns the smallest position in KV cache for sequence (DEPRECATED)"""
2255-
...
2256-
2257-
2258-
# // Returns the largest position present in the KV cache for the specified sequence
2259-
# // Note that all positions in the range [pos_min, pos_max] are guaranteed to be present in the KV cache
2260-
# // Return -1 if the sequence is empty
2261-
# DEPRECATED(LLAMA_API llama_pos llama_kv_self_seq_pos_max(
2262-
# struct llama_context * ctx,
2263-
# llama_seq_id seq_id),
2264-
# "Use llama_memory_seq_pos_max() instead");
2265-
@ctypes_function(
2266-
"llama_kv_self_seq_pos_max", [llama_context_p_ctypes, llama_seq_id], llama_pos
2267-
)
2268-
def llama_kv_self_seq_pos_max(
2269-
ctx: llama_context_p, seq_id: Union[llama_seq_id, int], /
2270-
) -> int:
2271-
"""Returns the largest position in KV cache for sequence (DEPRECATED)"""
2272-
...
2273-
2274-
2275-
# // Defragment the KV cache
2276-
# // This will be applied:
2277-
# // - lazily on next llama_decode()
2278-
# DEPRECATED(LLAMA_API void llama_kv_self_defrag(struct llama_context * ctx),
2279-
# "simply remove this call, the context will automatically decide when to do a defragmentation based on 'defrag_thold'");
2280-
@ctypes_function("llama_kv_self_defrag", [llama_context_p_ctypes], None)
2281-
def llama_kv_self_defrag(ctx: llama_context_p, /):
2282-
"""Defragment the KV cache (DEPRECATED)"""
2283-
...
2284-
2285-
2286-
# // Check if the context supports KV cache shifting
2287-
# DEPRECATED(LLAMA_API bool llama_kv_self_can_shift(const struct llama_context * ctx),
2288-
# "use llama_memory_can_shift() instead");
2289-
@ctypes_function("llama_kv_self_can_shift", [llama_context_p_ctypes], ctypes.c_bool)
2290-
def llama_kv_self_can_shift(ctx: llama_context_p, /) -> bool:
2291-
"""Check if the context supports KV cache shifting (DEPRECATED)"""
2292-
...
2293-
2294-
2295-
# // Apply the KV cache updates (such as K-shifts, defragmentation, etc.)
2296-
# DEPRECATED(LLAMA_API void llama_kv_self_update(struct llama_context * ctx),
2297-
# "simply remove this call, updates are applied lazily on the next llama_decode()");
2298-
@ctypes_function("llama_kv_self_update", [llama_context_p_ctypes], None)
2299-
def llama_kv_self_update(ctx: llama_context_p, /):
2300-
"""Apply the KV cache updates (DEPRECATED)"""
2301-
...
2302-
2303-
23042040
# //
23052041
# // State / sessions
23062042
# //

0 commit comments

Comments
 (0)