Skip to content

kv-cache : rework kv_cell #13706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ extern "C" {
LLAMA_API int64_t llama_time_us(void);

LLAMA_API size_t llama_max_devices(void);
LLAMA_API size_t llama_max_parallel_sequences(void);

LLAMA_API bool llama_supports_mmap (void);
LLAMA_API bool llama_supports_mlock (void);
Expand Down
6 changes: 5 additions & 1 deletion src/llama-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ llama_context::llama_context(

const auto & hparams = model.hparams;

cparams.n_seq_max = std::max(1u, params.n_seq_max);
cparams.n_seq_max = std::max(1u, params.n_seq_max);
if (cparams.n_seq_max > LLAMA_MAX_PARALLEL_SEQUENCES) {
throw std::runtime_error("n_seq_max must be <= " + std::to_string(LLAMA_MAX_PARALLEL_SEQUENCES));
}

cparams.n_threads = params.n_threads;
cparams.n_threads_batch = params.n_threads_batch;
cparams.yarn_ext_factor = params.yarn_ext_factor;
Expand Down
4 changes: 4 additions & 0 deletions src/llama-cparams.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#include "llama-cparams.h"

size_t llama_max_parallel_sequences(void) {
return LLAMA_MAX_PARALLEL_SEQUENCES;
}
2 changes: 2 additions & 0 deletions src/llama-cparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include <cstdint>

#define LLAMA_MAX_PARALLEL_SEQUENCES 64

struct llama_cparams {
uint32_t n_ctx; // context size used during inference
uint32_t n_batch;
Expand Down
Loading
Loading