Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/src/ggml-openvino/openvino/pass/kv_state_seq_axis.h # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / src / ggml-openvino / openvino / pass / kv_state_seq_axis.h` 24 lines ยท 1004 bytes Raw Blame History 1 #include "openvino/pass/pass.hpp" 2 3 namespace ov { 4 namespace frontend { 5 namespace ggml { 6 namespace pass { 7 8 // Moves the sequence axis of the stateful KV cache from dim 1 to dim 2, i.e. from 9 // [1, seq, n_heads_kv, head_size] to [1, n_heads_kv, seq, head_size], and updates the 10 // Concat that appends to it. Two wins: the GPU plugin only appends new tokens in place 11 // when the growing axis is a spatial axis, and the reader no longer has to transpose the 12 // whole accumulated state every token (that cost grows with context length, so it is the 13 // larger win at depth for a model with several KV heads). Only rewrites states that still 14 // match the frontend layout, so it no-ops if that layout ever changes. 15 class KVStateSeqAxis : public ov::pass::ModelPass { 16 public: 17 OPENVINO_MODEL_PASS_RTTI("ov::frontend::ggml::pass::KVStateSeqAxis") 18 bool run_on_model(const std::shared_ptr & model) override; 19 }; 20 21 } // namespace pass 22 } // namespace ggml 23 } // namespace frontend 24 } // namespace ov