Skip to content

Commit 08c5ee8

Browse files
authored
llama : remove deprecated API (#5770)
ggml-ci
1 parent 78aacf3 commit 08c5ee8

File tree

2 files changed

+1
-132
lines changed

2 files changed

+1
-132
lines changed

llama.cpp

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -7894,9 +7894,9 @@ static int llama_decode_internal(
78947894
const auto n_batch = cparams.n_batch;
78957895

78967896
GGML_ASSERT(n_tokens <= n_batch);
7897+
GGML_ASSERT((!batch.token && batch.embd) || (batch.token && !batch.embd)); // NOLINT
78977898

78987899
int n_threads = n_tokens == 1 ? cparams.n_threads : cparams.n_threads_batch;
7899-
GGML_ASSERT((!batch.token && batch.embd) || (batch.token && !batch.embd)); // NOLINT
79007900

79017901
const int64_t t_start_us = ggml_time_us();
79027902

@@ -10062,10 +10062,6 @@ void llama_sample_temp(struct llama_context * ctx, llama_token_data_array * cand
1006210062
}
1006310063
}
1006410064

10065-
void llama_sample_temperature(struct llama_context * ctx, llama_token_data_array * candidates_p, float temp) {
10066-
llama_sample_temp(ctx, candidates_p, temp);
10067-
}
10068-
1006910065
void llama_sample_repetition_penalties(
1007010066
struct llama_context * ctx,
1007110067
llama_token_data_array * candidates,
@@ -10192,38 +10188,6 @@ void llama_sample_apply_guidance(
1019210188
ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
1019310189
}
1019410190

10195-
void llama_sample_classifier_free_guidance(
10196-
struct llama_context * ctx,
10197-
llama_token_data_array * candidates,
10198-
struct llama_context * guidance_ctx,
10199-
float scale) {
10200-
GGML_ASSERT(ctx);
10201-
int64_t t_start_sample_us;
10202-
10203-
t_start_sample_us = ggml_time_us();
10204-
const size_t n_vocab = llama_n_vocab(llama_get_model(ctx));
10205-
10206-
GGML_ASSERT(n_vocab == candidates->size);
10207-
GGML_ASSERT(!candidates->sorted);
10208-
10209-
std::vector<float> logits_base(n_vocab);
10210-
for (size_t i = 0; i < n_vocab; ++i) {
10211-
logits_base[i] = candidates->data[i].logit;
10212-
}
10213-
10214-
float * logits_guidance = llama_get_logits(guidance_ctx);
10215-
10216-
ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
10217-
llama_sample_apply_guidance(ctx, logits_base.data(), logits_guidance, scale);
10218-
t_start_sample_us = ggml_time_us();
10219-
10220-
for (size_t i = 0; i < n_vocab; ++i) {
10221-
candidates->data[i].logit = logits_base[i];
10222-
}
10223-
10224-
ctx->t_sample_us += ggml_time_us() - t_start_sample_us;
10225-
}
10226-
1022710191
llama_token llama_sample_token_mirostat(struct llama_context * ctx, llama_token_data_array * candidates, float tau, float eta, int32_t m, float * mu) {
1022810192
GGML_ASSERT(ctx);
1022910193

@@ -11724,15 +11688,6 @@ bool llama_supports_gpu_offload(void) {
1172411688
#endif
1172511689
}
1172611690

11727-
// deprecated:
11728-
bool llama_mmap_supported(void) {
11729-
return llama_supports_mmap();
11730-
}
11731-
11732-
bool llama_mlock_supported(void) {
11733-
return llama_supports_mlock();
11734-
}
11735-
1173611691
void llama_backend_init(void) {
1173711692
ggml_time_init();
1173811693

@@ -12244,15 +12199,6 @@ uint32_t llama_model_quantize(
1224412199
}
1224512200
}
1224612201

12247-
int32_t llama_apply_lora_from_file(struct llama_context * ctx, const char * path_lora, float scale, const char * path_base_model, int32_t n_threads) {
12248-
try {
12249-
return llama_apply_lora_from_file_internal(ctx->model, path_lora, scale, path_base_model, n_threads);
12250-
} catch (const std::exception & err) {
12251-
LLAMA_LOG_ERROR("%s: failed to apply lora adapter: %s\n", __func__, err.what());
12252-
return 1;
12253-
}
12254-
}
12255-
1225612202
int32_t llama_model_apply_lora_from_file(const struct llama_model * model, const char * path_lora, float scale, const char * path_base_model, int32_t n_threads) {
1225712203
try {
1225812204
return llama_apply_lora_from_file_internal(*model, path_lora, scale, path_base_model, n_threads);
@@ -12802,38 +12748,6 @@ bool llama_save_session_file(struct llama_context * ctx, const char * path_sessi
1280212748
return true;
1280312749
}
1280412750

12805-
int llama_eval(
12806-
struct llama_context * ctx,
12807-
llama_token * tokens,
12808-
int32_t n_tokens,
12809-
int32_t n_past) {
12810-
llama_kv_cache_seq_rm(ctx->kv_self, -1, n_past, -1);
12811-
12812-
const int ret = llama_decode_internal(*ctx, llama_batch_get_one(tokens, n_tokens, n_past, 0));
12813-
if (ret < 0) {
12814-
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
12815-
}
12816-
12817-
return ret;
12818-
}
12819-
12820-
int llama_eval_embd(
12821-
struct llama_context * ctx,
12822-
float * embd,
12823-
int32_t n_tokens,
12824-
int32_t n_past) {
12825-
llama_kv_cache_seq_rm(ctx->kv_self, -1, n_past, -1);
12826-
12827-
llama_batch batch = { n_tokens, nullptr, embd, nullptr, nullptr, nullptr, nullptr, n_past, 1, 0, };
12828-
12829-
const int ret = llama_decode_internal(*ctx, batch);
12830-
if (ret < 0) {
12831-
LLAMA_LOG_ERROR("%s: failed to decode, ret = %d\n", __func__, ret);
12832-
}
12833-
12834-
return ret;
12835-
}
12836-
1283712751
void llama_set_n_threads(struct llama_context * ctx, uint32_t n_threads, uint32_t n_threads_batch) {
1283812752
ctx->cparams.n_threads = n_threads;
1283912753
ctx->cparams.n_threads_batch = n_threads_batch;

llama.h

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,6 @@ extern "C" {
364364
LLAMA_API bool llama_supports_mlock (void);
365365
LLAMA_API bool llama_supports_gpu_offload(void);
366366

367-
LLAMA_API DEPRECATED(bool llama_mmap_supported (void), "use llama_supports_mmap() instead");
368-
LLAMA_API DEPRECATED(bool llama_mlock_supported(void), "use llama_supports_mlock() instead");
369-
370367
LLAMA_API const struct llama_model * llama_get_model(const struct llama_context * ctx);
371368

372369
LLAMA_API uint32_t llama_n_ctx (const struct llama_context * ctx);
@@ -423,14 +420,6 @@ extern "C" {
423420
// The model needs to be reloaded before applying a new adapter, otherwise the adapter
424421
// will be applied on top of the previous one
425422
// Returns 0 on success
426-
LLAMA_API DEPRECATED(int32_t llama_apply_lora_from_file(
427-
struct llama_context * ctx,
428-
const char * path_lora,
429-
float scale,
430-
const char * path_base_model,
431-
int32_t n_threads),
432-
"use llama_model_apply_lora_from_file instead");
433-
434423
LLAMA_API int32_t llama_model_apply_lora_from_file(
435424
const struct llama_model * model,
436425
const char * path_lora,
@@ -606,27 +595,6 @@ extern "C" {
606595
// Decoding
607596
//
608597

609-
// Run the llama inference to obtain the logits and probabilities for the next token(s).
610-
// tokens + n_tokens is the provided batch of new tokens to process
611-
// n_past is the number of tokens to use from previous eval calls
612-
// Returns 0 on success
613-
// DEPRECATED: use llama_decode() instead
614-
LLAMA_API DEPRECATED(int llama_eval(
615-
struct llama_context * ctx,
616-
llama_token * tokens,
617-
int32_t n_tokens,
618-
int32_t n_past),
619-
"use llama_decode() instead");
620-
621-
// Same as llama_eval, but use float matrix input directly.
622-
// DEPRECATED: use llama_decode() instead
623-
LLAMA_API DEPRECATED(int llama_eval_embd(
624-
struct llama_context * ctx,
625-
float * embd,
626-
int32_t n_tokens,
627-
int32_t n_past),
628-
"use llama_decode() instead");
629-
630598
// Return batch for single sequence of tokens starting at pos_0
631599
//
632600
// NOTE: this is a helper function to facilitate transition to the new batch API - avoid using it
@@ -800,13 +768,6 @@ extern "C" {
800768
float * logits_guidance,
801769
float scale);
802770

803-
LLAMA_API DEPRECATED(void llama_sample_classifier_free_guidance(
804-
struct llama_context * ctx,
805-
llama_token_data_array * candidates,
806-
struct llama_context * guidance_ctx,
807-
float scale),
808-
"use llama_sample_apply_guidance() instead");
809-
810771
/// @details Sorts candidate tokens by their logits in descending order and calculate probabilities based on logits.
811772
LLAMA_API void llama_sample_softmax(
812773
struct llama_context * ctx,
@@ -860,12 +821,6 @@ extern "C" {
860821
llama_token_data_array * candidates,
861822
float temp);
862823

863-
LLAMA_API DEPRECATED(void llama_sample_temperature(
864-
struct llama_context * ctx,
865-
llama_token_data_array * candidates,
866-
float temp),
867-
"use llama_sample_temp instead");
868-
869824
/// @details Apply constraints from grammar
870825
LLAMA_API void llama_sample_grammar(
871826
struct llama_context * ctx,

0 commit comments

Comments
 (0)