You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1de2864
Browse filesBrowse the repository at this point in the historyBrowse files
ggml-openvino: one KV-slice switch for dynamic and static graphs
KV-cache slicing (bind the KV cache, and size the KQ masks, at the attended
length instead of the full context) existed twice: on by default for dynamic
graphs (GGML_OPENVINO_DISABLE_KV_SLICE to turn it off) and opt-in for static
prefill (GGML_OPENVINO_NPU_KV_SLICE). The static mode is not NPU-specific; it
applies to any static graph, including CPU/GPU with GGML_OPENVINO_FORCE_STATIC.
Describe it as one mechanism with two modes behind GGML_OPENVINO_KV_SLICE
(unset = each mode's default, 0 = off, 1 = on) and two predicates,
ggml_openvino_{dynamic,static}_kv_slice_enabled(), used by the KV binding,
the static graph shapes, the mask padding and the cache keys. The two old
variables remain as deprecated aliases.
Copy file name to clipboardExpand all lines: docs/backend/OPENVINO.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -728,10 +728,11 @@ Boolean flags follow a uniform convention: set to a **positive integer** (e.g. `
728
728
| `GGML_OPENVINO_NPU_REQUANT_POLICY`| String | `group-128` | NPU-only weight requantization layout. Use `group-128` for `Q4_0_128` or experimental `channel-wise` for `Q4_0_C`. Any other value fails during model loading. |
729
729
| `GGML_OPENVINO_NPU_FAST_MASK` | Boolean | `0` | NPU-only. Build the static prefill attention mask directly into the input tensor, skipping an intermediate host allocation + full-tensor copy per chunk. Numerically identical to the default path. |
730
730
| `GGML_OPENVINO_NPU_L0_HOST_TENSORS`| Boolean | `0` | NPU-only. Back the KV-cache / compute buffers with Level Zero host memory so the plugin imports them without an extra host-to-device copy each infer, cutting prefill KV I/O time. Falls back to plain host memory if the L0 allocation is unavailable. |
731
-
| `GGML_OPENVINO_NPU_KV_SLICE` | Boolean | `0` | NPU-only. Compile static prefill graphs and bind prefill KV-cache tensors at the active attention length instead of the full context capacity. Decode retains its fixed full-context graph. The prefill model is recompiled when the aligned attention length changes. |
731
+
| `GGML_OPENVINO_KV_SLICE` | Boolean | per mode | Bind the KV cache, and size the KQ masks, at the attended length instead of the full context. Dynamic graphs (CPU/GPU): a view over the cache, no recompilation; on by default. Static graphs (NPU, or `GGML_OPENVINO_FORCE_STATIC`): the prefill graph is compiled at the aligned attended length and recompiled when it changes, decode keeps its full-context graph; off by default. Unset = each mode's default, `0` = off in both, `1` = on in both. |
732
+
|`GGML_OPENVINO_NPU_KV_SLICE`| Boolean |`0`| Deprecated alias: `1` turns static KV slicing on (`GGML_OPENVINO_KV_SLICE` wins when set). Not NPU-specific; applies to any static graph. |
732
733
|`GGML_OPENVINO_STATEFUL_EXECUTION`| Boolean |`0`| Keep KV and supported recurrent caches inside the model. Single-slot CPU/GPU execution only. |
733
734
|`GGML_OPENVINO_DISABLE_CACHE`| Boolean |`0`| Disable the in-process compiled-model / decoder cache (cache is on by default). Set to `1` to disable. |
734
-
| `GGML_OPENVINO_DISABLE_KV_SLICE` | Boolean | `0` | Disable the KV-cache input-tensor slicing optimization (slicing is on by default on CPU/GPU). Set to `1` to disable. |
735
+
|`GGML_OPENVINO_DISABLE_KV_SLICE`| Boolean |`0`|Deprecated alias: `1` turns dynamic KV slicing off (`GGML_OPENVINO_KV_SLICE` wins when set). |
735
736
|`GGML_OPENVINO_ENABLE_KV_4D`| Boolean |`0`| GPU, stateless: bind the KV cache as `[1, ctx, n_heads_kv, head_size]` instead of `[1, 1, ctx, n_heads_kv * head_size]`, so the GPU plugin's `StatelessKVFusion` can update and read the cache in place. **Off by default**: it needs an OpenVINO build with openvino#37569 (2026.5 or a recent nightly) and is much slower on older releases (e.g. 2026.4.1). Set to a positive integer to enable. |
736
737
| `GGML_OPENVINO_KV_SCATTER_ELEMENTS` | Boolean | `0` | Use `ScatterElementsUpdate` instead of `ScatterUpdate` for non-stateful single-row KV writes. Intended for NPU decode paths where `ScatterUpdate` copies the full destination tensor to update one row. |
737
738
| `GGML_OPENVINO_DISABLE_KV_STATE_RELAYOUT` | Boolean | `0` | Disable the stateful KV-state sequence-axis relayout (relayout is on by default). It moves the KV state sequence axis from dim 1 to dim 2, so the GPU plugin can append new tokens in place instead of copying the whole state every token, and the reader side no longer transposes the whole accumulated state. Set to `1` to disable. |
0 commit comments