Commit a06044b93 for llama.cpp
commit a06044b934db085e373286444e0c15b93635a20c
Author: Niklas Wenzel <dev@nikwen.de>
Date: Mon Nov 16 15:16:13 2026 +0100
llama : deprecate old batch API (#32306)
diff --git a/include/llama.h b/include/llama.h
index 01d8fb88a..3b2baa3bc 100644
--- a/include/llama.h
+++ b/include/llama.h
@@ -271,6 +271,7 @@ extern "C" {
// - if not: only the last token is output
// )
//
+ // [DEPRECATED] use llama_batch_ext instead
typedef struct llama_batch {
int32_t n_tokens;
@@ -945,9 +946,10 @@ extern "C" {
//
// 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");
// Allocates a batch of tokens on the heap that can hold a maximum of n_tokens
// Each token can be assigned up to n_seq_max sequence ids
@@ -956,13 +958,15 @@ extern "C" {
// 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");
// 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");
// Process a batch of tokens.
// In contrast to llama_decode() - this call does not use KV cache.
@@ -970,9 +974,10 @@ extern "C" {
// 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");
// Process a batch of tokens.
// Requires the context to have a memory.
@@ -986,9 +991,10 @@ extern "C" {
// 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");
//
// Extended batch API