MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / kv_self_update

Method kv_self_update

smallthinker/src/llama-context.cpp:434–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434bool llama_context::kv_self_update() {
435 if (!memory) {
436 return false;
437 }
438
439 llama_kv_cache * kv_self = static_cast<llama_kv_cache *>(memory.get());
440
441 if (!kv_self->update(*this)) {
442 // no updates have been performed
443 return false;
444 }
445
446 // if the KV cache did any computation, we have to reserve a new worst-case graph
447 const auto kv_state = kv_self->init_full();
448 if (!kv_state) {
449 throw std::runtime_error("failed to initialize KV cache");
450 }
451
452 const uint32_t n_seqs = cparams.n_seq_max;
453 const uint32_t n_tokens = std::min(cparams.n_ctx, cparams.n_ubatch);
454
455 auto * gf = graph_reserve(n_tokens, n_seqs, n_tokens, kv_state.get());
456 if (!gf) {
457 LLAMA_LOG_ERROR("%s: failed to reserve graph after the KV cache update\n", __func__);
458 }
459
460 return true;
461}
462
463enum llama_pooling_type llama_context::pooling_type() const {
464 return cparams.pooling_type;

Callers 1

llama_kv_self_updateFunction · 0.80

Calls 4

minFunction · 0.85
getMethod · 0.45
updateMethod · 0.45
init_fullMethod · 0.45

Tested by

no test coverage detected