ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / src / ggml-openvino / openvino / pass / kv_state_seq_axis.h
| 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<ov::Model> & model) override; |
| 19 | }; |
| 20 | |
| 21 | } // namespace pass |
| 22 | } // namespace ggml |
| 23 | } // namespace frontend |
| 24 | } // namespace ov |