MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / get_n_kv

Method get_n_kv

subprojects/llama.cpp/src/llama-kv-cache.cpp:1000–1014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

998}
999
1000uint32_t llama_kv_cache::get_n_kv(const slot_info & sinfo) const {
1001 uint32_t result = 0;
1002
1003 // pad the n_kv value so that the graph remains constant across batches and can be reused
1004 // note: this also helps some backends with performance (f.ex https://github.com/ggml-org/llama.cpp/pull/16812#issuecomment-3455112220)
1005 const uint32_t n_pad_cur = std::max(n_pad, 256u);
1006
1007 for (uint32_t s = 0; s < sinfo.n_stream(); ++s) {
1008 const auto & cells = v_cells[sinfo.strm[s]];
1009
1010 result = std::max(std::min(cells.size(), std::max(n_pad_cur, GGML_PAD(cells.used_max_p1(), n_pad_cur))), result);
1011 }
1012
1013 return result;
1014}
1015
1016ggml_tensor * llama_kv_cache::get_k(ggml_context * ctx, int32_t il, uint32_t n_kv, const slot_info & sinfo) const {
1017 const int32_t ikv = map_layer_ids.at(il);

Callers 7

can_reuseMethod · 0.80
build_attn_inp_kv_implFunction · 0.80
build_attn_inp_k_implFunction · 0.80
applyMethod · 0.80

Calls 5

maxFunction · 0.85
minFunction · 0.85
n_streamMethod · 0.80
used_max_p1Method · 0.80
sizeMethod · 0.65

Tested by

no test coverage detected