@@ -663,111 +663,6 @@ extern "C" {
663663 // Check if the memory supports shifting
664664 LLAMA_API bool llama_memory_can_shift (llama_memory_t mem);
665665
666- //
667- // KV cache for self-attention (TODO: deprecate in favor of llama_memory)
668- //
669-
670- // Returns the number of tokens in the KV cache (slow, use only for debug)
671- // If a KV cell has multiple sequences assigned to it, it will be counted multiple times
672- DEPRECATED (LLAMA_API int32_t llama_kv_self_n_tokens (const struct llama_context * ctx),
673- "Use llama_kv_self_seq_pos_max() and llama_kv_self_seq_pos_min() instead (https:// github.com/ggml-org/llama.cpp/issues/13793)");
674-
675- // Returns the number of used KV cells (i.e. have at least one sequence assigned to them)
676- DEPRECATED (LLAMA_API int32_t llama_kv_self_used_cells (const struct llama_context * ctx),
677- "Use llama_kv_self_seq_pos_max() and llama_kv_self_seq_pos_min() instead (https:// github.com/ggml-org/llama.cpp/issues/13793)");
678-
679- // Clear the KV cache - both cell info is erased and KV data is zeroed
680- DEPRECATED (LLAMA_API void llama_kv_self_clear (
681- struct llama_context * ctx),
682- "Use llama_memory_clear() instead");
683-
684- // Removes all tokens that belong to the specified sequence and have positions in [p0, p1)
685- // Returns false if a partial sequence cannot be removed. Removing a whole sequence never fails
686- // seq_id < 0 : match any sequence
687- // p0 < 0 : [0, p1]
688- // p1 < 0 : [p0, inf)
689- DEPRECATED (LLAMA_API bool llama_kv_self_seq_rm (
690- struct llama_context * ctx,
691- llama_seq_id seq_id,
692- llama_pos p0,
693- llama_pos p1),
694- "Use llama_memory_seq_rm() instead");
695-
696- // Copy all tokens that belong to the specified sequence to another sequence
697- // Note that this does not allocate extra KV cache memory - it simply assigns the tokens to the new sequence
698- // p0 < 0 : [0, p1]
699- // p1 < 0 : [p0, inf)
700- DEPRECATED (LLAMA_API void llama_kv_self_seq_cp (
701- struct llama_context * ctx,
702- llama_seq_id seq_id_src,
703- llama_seq_id seq_id_dst,
704- llama_pos p0,
705- llama_pos p1),
706- "Use llama_memory_seq_cp() instead");
707-
708- // Removes all tokens that do not belong to the specified sequence
709- DEPRECATED (LLAMA_API void llama_kv_self_seq_keep (
710- struct llama_context * ctx,
711- llama_seq_id seq_id),
712- "Use llama_memory_seq_keep() instead");
713-
714- // Adds relative position "delta" to all tokens that belong to the specified sequence and have positions in [p0, p1)
715- // If the KV cache is RoPEd, the KV data is updated accordingly:
716- // - lazily on next llama_decode()
717- // p0 < 0 : [0, p1]
718- // p1 < 0 : [p0, inf)
719- DEPRECATED (LLAMA_API void llama_kv_self_seq_add (
720- struct llama_context * ctx,
721- llama_seq_id seq_id,
722- llama_pos p0,
723- llama_pos p1,
724- llama_pos delta),
725- "Use llama_memory_seq_add() instead");
726-
727- // Integer division of the positions by factor of `d > 1`
728- // If the KV cache is RoPEd, the KV data is updated accordingly:
729- // - lazily on next llama_decode()
730- // p0 < 0 : [0, p1]
731- // p1 < 0 : [p0, inf)
732- DEPRECATED (LLAMA_API void llama_kv_self_seq_div (
733- struct llama_context * ctx,
734- llama_seq_id seq_id,
735- llama_pos p0,
736- llama_pos p1,
737- int d),
738- "Use llama_memory_seq_div() instead");
739-
740- // Returns the smallest position present in the KV cache for the specified sequence
741- // This is typically non-zero only for SWA caches
742- // Note that all positions in the range [pos_min, pos_max] are guaranteed to be present in the KV cache
743- // Return -1 if the sequence is empty
744- DEPRECATED (LLAMA_API llama_pos llama_kv_self_seq_pos_min (
745- struct llama_context * ctx,
746- llama_seq_id seq_id),
747- "Use llama_memory_seq_pos_min() instead");
748-
749- // Returns the largest position present in the KV cache for the specified sequence
750- // Note that all positions in the range [pos_min, pos_max] are guaranteed to be present in the KV cache
751- // Return -1 if the sequence is empty
752- DEPRECATED (LLAMA_API llama_pos llama_kv_self_seq_pos_max (
753- struct llama_context * ctx,
754- llama_seq_id seq_id),
755- "Use llama_memory_seq_pos_max() instead");
756-
757- // Defragment the KV cache
758- // This will be applied:
759- // - lazily on next llama_decode()
760- DEPRECATED (LLAMA_API void llama_kv_self_defrag (struct llama_context * ctx),
761- "simply remove this call, the context will automatically decide when to do a defragmentation based on 'defrag_thold'");
762-
763- // Check if the context supports KV cache shifting
764- DEPRECATED (LLAMA_API bool llama_kv_self_can_shift (const struct llama_context * ctx),
765- "use llama_memory_can_shift() instead");
766-
767- // Apply the KV cache updates (such as K-shifts, defragmentation, etc.)
768- DEPRECATED (LLAMA_API void llama_kv_self_update (struct llama_context * ctx),
769- "simply remove this call, updates are applied lazily on the next llama_decode()");
770-
771666 //
772667 // State / sessions
773668 //
0 commit comments