| 998 | } |
| 999 | |
| 1000 | uint32_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 | |
| 1016 | ggml_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); |
no test coverage detected