Skip to content

Commit

Permalink
whisper : add comment about the KV cache size
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Nov 14, 2023
1 parent ae1bd69 commit 6c8a003
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3040,8 +3040,9 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) {

state->backend = whisper_backend_init(ctx->params);

// TODO: determine how large the cache should be
const int factor = 2;
// at this point, we don't know yet how many decoders will be used, so we overallocate 3x ctx
// in theory, there can be a case where this is not enough, but in practice it should always be enough
const int factor = 3;

if (!kv_cache_init(ctx->model.hparams, state->kv_self, ctx->backend, ctx->itype, factor*ctx->model.hparams.n_text_ctx)) {
WHISPER_LOG_ERROR("%s: kv_cache_init() failed for self-attention cache\n", __func__);
Expand Down

0 comments on commit 6c8a003

Please sign in to comment.