Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
15dff06
ggml-openvino: fix SWA mask detection
osabnis Oct 2, 2026
3f023f5
ggml-openvino: fix SWA KV cache write indices
osabnis Oct 2, 2026
706a4d9
ggml-openvino: classify SWA layers only when the mask shows the window
osabnis Oct 4, 2026
e98f645
ggml-openvino: classify SWA layers from the first graph
osabnis Oct 5, 2026
8c174e4
ggml-openvino: skip unselected graph branches and support DUP
ravi9 Oct 5, 2026
130d8bd
ggml-openvino: make inp_scale_rows token dim dynamic
ravi9 Oct 5, 2026
0087a1b
ggml-openvino: skip GPU MUL_MAT op tests with unbound Q4_1/Q4_K weights
ravi9 Oct 5, 2026
672083f
ggml-openvino: create FILL in the output type
ravi9 Oct 5, 2026
5f2e77e
ggml-openvino: reject CONCAT with a quantized type
ravi9 Oct 5, 2026
627e811
ggml-openvino: handle the single recurrent state gather of build_rs
ravi9 Oct 5, 2026
5802ab8
openvino: align eltwise operand ranks to work around a GPU-plugin defect
cavusmustafa Oct 3, 2026
409ba45
openvino: match the MoE fusion on the rank-3 stateful graph
cavusmustafa Oct 2, 2026
39dacd4
ggml-openvino: do not unsqueeze an RMS norm output in AlignEltwiseOpe…
ravi9 Oct 6, 2026
a4493f9
docs : update OpenVINO validated models
ravi9 Oct 6, 2026
84232f4
ggml-openvino: derive attention sizes from the KQ mask shape
osabnis Oct 5, 2026
0aa29c7
ggml-openvino: only reuse Split outputs for exact chunk-aligned views
osabnis Oct 6, 2026
e127d6b
ggml-openvino: mark SWA fallback as a model-level heuristic
osabnis Oct 6, 2026
7906a48
Merge pull request #336 from osabnis/ov-gemma4-swa-fixes
cavusmustafa Oct 7, 2026
e706353
ggml-openvino: initialize ModelExtraInputInfo shape fields
osabnis Oct 9, 2026
dfb6ad9
ggml-openvino: remove GGML_OPENVINO_REQUANT_EMBD
osabnis Oct 9, 2026
ab759cf
Merge pull request #339 from osabnis/ov-dynamic-decode
cavusmustafa Oct 9, 2026
90a6103
openvino : support Qwen MTP decoding
wine99 Oct 14, 2026
4f92304
openvino: Optimize TopK
wine99 Oct 15, 2026
73f61e1
openvino: remove single-slot recurrent cache shortcuts
wine99 Oct 15, 2026
2a978aa
openvino: fuse generic recurrent caches and remove shape waits
wine99 Oct 16, 2026
b6a1c80
openvino: include dense Q8 weights in all INT4 requantization
wine99 Oct 19, 2026
01fa0b0
openvino: use two GDN outputs for snapshots
wine99 Oct 19, 2026
9630143
docs: explain native OpenVINO recurrent cache contracts
wine99 Oct 20, 2026
049f554
docs: clarify Qwen3.5 purpose of native OpenVINO cache ops
wine99 Oct 20, 2026
86c6480
llama: skip unallocated hybrid graph inputs
wine99 Oct 22, 2026
0364e7a
quantize: preserve Qwen hybrid layer metadata when pruning
wine99 Oct 22, 2026
490cbf3
openvino: emit fused recurrent computation and rotate device caches
wine99 Oct 22, 2026
4747851
openvino: limit KV slicing to attention caches and share compiled blobs
wine99 Oct 22, 2026
6cb21a7
tools: add natural-text server benchmark and OpenVINO profile summary
wine99 Oct 22, 2026
593af4d
docs: record fused-cache branch split and UD validation
wine99 Oct 22, 2026
2f43b5f
server-bench: preserve native token counts and save request timings
wine99 Oct 22, 2026
2474072
openvino: document MTP regression and host USM alias recovery
wine99 Oct 22, 2026
dd06588
openvino: record large-context allocation diagnosis and default-batch…
wine99 Oct 23, 2026
197304c
server-bench: count buffered native tokens and reject stream errors
wine99 Oct 23, 2026
a6a1612
openvino: document UD split and unified server benchmarks
wine99 Oct 23, 2026
7bcf06e
openvino: record Vulkan long-context baseline and GPU-fit controls
wine99 Oct 23, 2026
056e0a6
openvino: finalize UD benchmark report and MTP comparison
wine99 Oct 23, 2026
508e30b
ggml-openvino: honour the -1 skip id in MUL_MAT_ID
ravi9 Oct 26, 2026
3ea0e63
ggml-openvino: Gather rows before dequantizing a quantized embedding …
yzhou51 Oct 23, 2026
0974aef
ggml-openvino: select the NPU token_embd type with GGML_OPENVINO_NPU_…
ravi9 Oct 26, 2026
26870e7
openvino: merge latest dev_backend_openvino with generic recurrence
wine99 Oct 27, 2026
bdaf481
openvino: use stable in-place recurrent caches and optional separate …
wine99 Oct 27, 2026
9ca7965
openvino: accept matching empty axes in DIV repeat translation
wine99 Oct 27, 2026
2188bc2
openvino: remove the obsolete cache rotation environment setting
wine99 Oct 27, 2026
0368295
openvino: validate imported KV results in their four-dimensional layout
wine99 Oct 27, 2026
3d9b2fb
docs: record the bounded in-place KV and convolution benchmark rerun
wine99 Oct 27, 2026
626aae3
docs: complete default-batch OV unified-KV 32K benchmarks
wine99 Oct 27, 2026
da95d1b
openvino: remove the separate recurrent convolution path
wine99 Oct 28, 2026
c1ae620
openvino: handle zero-logits batches and changing sampler sequences
wine99 Oct 28, 2026
c2d9797
docs: compare default and large Qwen3.6 benchmark batches
wine99 Oct 28, 2026
2803132
docs: use the historical Vulkan default-batch reference consistently
wine99 Oct 28, 2026
f9b648a
server-bench: use an integer histogram bin count
wine99 Oct 28, 2026
88c46ee
benchmarks: summarize current OV unified MMLU timings
wine99 Oct 28, 2026
7a3c18b
docs: record cache-only unified KV MMLU results
wine99 Oct 28, 2026
8daa74c
openvino: preserve the TopK index port in GET_ROWS
wine99 Oct 28, 2026
71c0bbc
openvino: reuse the MTP sampling model across active slots
wine99 Oct 28, 2026
67ae1b8
openvino: expose selection flags and offsets in graph dumps
wine99 Oct 29, 2026
c805e2a
docs: consolidate Qwen OpenVINO defaults and performance evidence
wine99 Oct 29, 2026
9be7dba
docs: retain continuous-request MTP benchmark results
wine99 Oct 29, 2026
eb54746
docs: compare stable MTP with the non-MTP serving baseline
wine99 Oct 29, 2026
604e22e
openvino: isolate GDN snapshots and skip naive cache fusion
wine99 Oct 29, 2026
eeabd08
Merge origin/dev_backend_openvino into Qwen OpenVINO branch
wine99 Oct 30, 2026
b502f71
Merge origin/dev_backend_openvino into Qwen OpenVINO branch
wine99 Nov 3, 2026
9f294d0
ggml: document Qwen3.6 GenAI benchmarks
wine99 Nov 3, 2026
77b501c
ggml-openvino: keep PR changes inside the backend folder
wine99 Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions ggml/src/ggml-openvino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@ if (GGML_OPENVINO)
message(FATAL_ERROR "OpenVINO: OpenVINO toolkit supports x86-64 and arm64 but not ${CMAKE_SYSTEM_PROCESSOR}")
endif()
endif()

# Released runtimes retain the ordinary cache translators.
include(CheckCXXSourceCompiles)
unset(GGML_OPENVINO_HAS_CACHE_UPDATE CACHE)
set(CMAKE_REQUIRED_LIBRARIES openvino::runtime)
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/openvino/op")
check_cxx_source_compiles("#include <recurrent_cache_update.hpp>
int main() {
auto conv = std::make_shared<ov::op::internal::RecurrentConvCacheUpdate>(ov::OutputVector{}, 3);
auto gdn = std::make_shared<ov::op::internal::RecurrentGatedDeltaNetUpdate>(ov::OutputVector{});
}"
GGML_OPENVINO_HAS_CACHE_UPDATE)
unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_INCLUDES)
if(GGML_OPENVINO_HAS_CACHE_UPDATE)
target_compile_definitions(ggml-openvino PRIVATE GGML_OPENVINO_HAS_CACHE_UPDATE=1)
endif()
53 changes: 50 additions & 3 deletions ggml/src/ggml-openvino/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# Qwen MTP

The default Qwen3.5/Qwen3.6 GPU path is dynamic stateless execution with in-place fused recurrent ops and stable MTP sampling. Build against the matching OpenVINO runtime/GPU plugin with independent `RecurrentConvCacheUpdate` and `RecurrentGatedDeltaNetUpdate` ops. The native Update ops return computation results plus the full updated cache, including rollback snapshots where required. No recurrent/sampling opt-in flag is needed on supported graphs. See the [development documentation index](dev_doc/README.md) for the implementation and the MTP sampling graph.

Use `--spec-type draft-mtp --spec-draft-n-max 2` with a GGUF that contains MTP weights. Parallel execution uses `-np` and `--kv-unified`. CPU snapshot execution, NPU execution, and forced static MTP are not supported.

Stateless recurrent execution uses the same reset, reorder, and partial cache-writeback paths at every slot capacity, including one slot without MTP.

The matched stateless GPU path uses `RecurrentConvCacheUpdate` and
`RecurrentGatedDeltaNetUpdate`. In-place cache mutation is the primary path:
Parameter and Result share a stable caller-owned USM allocation. Required source
rows are staged on device before writes, so resets, cyclic reorders and rollback
remain generic. Incompatible bindings use private output plus Result copy-back.
Rotation banks and the older three-op native path are removed.
The convolution Update op always takes depthwise weights and produces convolution
and the updated cache; the separate history/QKV mode is removed.
`GGML_OPENVINO_DISABLE_FUSED_RECURRENCE=1` retains the ordinary GGML cache decomposition.
Snapshot GDN still uses the independent Update op with a temporary cache bank.
Ordinary GDN is unchanged. Snapshot/rollback (speculative decoding) on OpenVINO
requires the patched package; unpatched packages support ordinary execution and
report snapshot GDN as unsupported, allowing fallback to another backend.
Rebuild both repos for these native ops. The current backend translation revision is 14; regenerate compiled-model blobs once without cache-only mode.

Set `GGML_OPENVINO_ENABLE_KV_4D=1` to enable the upstream stateless in-place
attention KV update pattern where eligible. It binds full-capacity cache tensors
and lets the GPU fusion expose the live prefix to attention. The current upstream
eligibility check supports one physical stream (including unified KV); explicit
split multi-slot KV retains the ordinary full-cache path. This option does not
change recurrent cache handling. Unified KV is recommended for multi-slot GPU
execution because it enables this in-place attention update.

The recommended Qwen3.6-35B-A3B Q4_K_M setup uses GPU with `GGML_OPENVINO_REQUANT_KQUANT=q4_asym64_all` and `GGML_OPENVINO_NATIVE_SOFTPLUS=1`. Leave `GGML_OPENVINO_KV_SLICE` at its default (`1`). See [attention KV layout](dev_doc/OPENVINO-RECURRENT-CACHE.md#attention-kv-layout) for eligibility.

`q4_asym64_all` converts Q4_K/Q5_K/Q6_K/Q8_0/Q5_1 weights, including dense Q8_0 projections, to asymmetric INT4 with group size 64. `token_embd.weight` and `output.weight` retain symmetric channel-wise INT8. Q8_0/Q5_1 rows whose width is not divisible by 64 also use channel-wise INT8. This follows the primary/backup precision scheme of NNCF `INT4_ASYM`, `ratio=1.0`, `group_size=64`, `backup_mode=INT8_SYM` for these supported source types; it requantizes GGUF values rather than the original floating-point model and leaves floating-point weights unchanged. Earlier versions kept dense Q8_0 at INT8/group-32. Repopulate compiled-model caches without cache-only mode after this change; the cache fingerprint invalidates the old precision policy.

See the [implementation guide](dev_doc/OPENVINO-RECURRENT-CACHE.md) for buffer ownership and rollback.

# Compiled model cache

`GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR` exports compiled CPU/GPU graphs with their weights. It bypasses the plugin-level `GGML_OPENVINO_CACHE_DIR` and uses `OPTIMIZE_SPEED`, so weightless caching is disabled.
Expand All @@ -7,7 +44,6 @@ One directory can hold blobs for different models and compilation settings. Run
```sh
GGML_OPENVINO_DEVICE=GPU \
GGML_OPENVINO_NATIVE_SOFTPLUS=1 \
GGML_OPENVINO_KV_SLICE=0 \
GGML_OPENVINO_REQUANT_KQUANT=q4_asym64_all \
GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR=/path/to/qwen-cache \
./build/ReleaseOV/bin/llama-bench -m /path/to/model.gguf -r 1
Expand All @@ -20,7 +56,6 @@ On later runs, supply the same compilation settings and enable `GGML_OPENVINO_CO
```sh
GGML_OPENVINO_DEVICE=GPU \
GGML_OPENVINO_NATIVE_SOFTPLUS=1 \
GGML_OPENVINO_KV_SLICE=0 \
GGML_OPENVINO_REQUANT_KQUANT=q4_asym64_all \
GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR=/path/to/qwen-cache \
GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY=1 \
Expand All @@ -29,10 +64,22 @@ GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY=1 \

Cache-only mode allocates backend address space without filling weight pages. On Windows, this also uses system commit capacity. The model-buffer size in the loader log is this virtual size. Weight uploads only record source identity; they do not read or requantize the weights. Graph conversion and compilation are skipped. Runtime buffers are still allocated and populated normally.

Cache-only mode uses the settings provided by the current process. Keep these values exactly the same, including set versus unset: `GGML_OPENVINO_REQUANT_KQUANT`, `GGML_OPENVINO_EXACT_ZERO_POINT`, `GGML_OPENVINO_NATIVE_SOFTPLUS`, `GGML_OPENVINO_KV_SLICE`, `GGML_OPENVINO_MANUAL_GQA_ATTN`, `GGML_OPENVINO_STATEFUL_EXECUTION`, `GGML_OPENVINO_DISABLE_KV_STATE_RELAYOUT`, `GGML_OPENVINO_DISABLE_REMOTE_OUTPUTS`, `GGML_OPENVINO_REDUCE_COMPILE_MEM`, `GGML_OPENVINO_MEMORY_OPTIMIZE`, `GGML_OPENVINO_PROFILING`, `GGML_OPENVINO_DISABLE_SHAPE_FROM_MASK`, and `GGML_OPENVINO_DEBUG_NODE`. On GPU, also repeat `GGML_OPENVINO_MOE_OP=0` if used. `GGML_OPENVINO_SPILL_DIR` is optional on the first run and ignored in cache-only mode; host-weight release is disabled in cache-only mode.
Cache-only mode uses the settings provided by the current process. Keep these values exactly the same, including set versus unset: `GGML_OPENVINO_REQUANT_KQUANT`, `GGML_OPENVINO_EXACT_ZERO_POINT`, `GGML_OPENVINO_NATIVE_SOFTPLUS`, `GGML_OPENVINO_MANUAL_GQA_ATTN`, `GGML_OPENVINO_STATEFUL_EXECUTION`, `GGML_OPENVINO_DISABLE_KV_STATE_RELAYOUT`, `GGML_OPENVINO_DISABLE_REMOTE_OUTPUTS`, `GGML_OPENVINO_REDUCE_COMPILE_MEM`, `GGML_OPENVINO_MEMORY_OPTIMIZE`, `GGML_OPENVINO_PROFILING`, `GGML_OPENVINO_DISABLE_SHAPE_FROM_MASK`, and `GGML_OPENVINO_DEBUG_NODE`, `GGML_OPENVINO_ENABLE_KV_4D`, and `GGML_OPENVINO_DISABLE_FUSED_RECURRENCE`. On GPU, also repeat `GGML_OPENVINO_MOE_OP=0` if used. `GGML_OPENVINO_SPILL_DIR` is optional on the first run and ignored in cache-only mode; host-weight release is disabled in cache-only mode.

`GGML_OPENVINO_KV_SLICE` is a runtime binding option for dynamic graphs and can differ between cache population and cache-only runs. The same dynamic compiled graph accepts full-capacity and live-prefix attention K/V tensors. Slicing is enabled by default for contiguous ordinary K/V roots with one allocated stream, one active sequence at offset zero, and no sliding-window attention. Recurrent convolution/GDN caches and their rollback snapshots always retain their full stored row bank. Other layouts use full bindings. Repopulate caches made before this option was removed from the fingerprint once without cache-only mode.

A missing or incompatible graph fails with an error instead of compiling with absent weights. The fingerprint uses the dynamic graph's topology, ports, model parameters, weights, settings, and OpenVINO version; changing only dynamic token or KV sizes does not require a new entry. A different workload can still require another graph; populate it first without cache-only mode.

## MTP sampling and active slots

Qwen3.5/Qwen3.6 MTP uses a pure top-k backend sampler. Dynamic stateless execution retains its sampling branches for every configured slot and output row, including inactive branches. One packed `sampling_rows` input selects logits rows at runtime. Graph node names and candidate-output ports stay fixed, so changing the active subset of four slots reuses the same compiled draft model instead of creating up to 15 variants.

Active candidate IDs and scores are written to the normal GGML outputs. Inactive branches read row 0 (the padding row when there are no logits) and write to private scratch tensors (device USM on GPU), without changing sampler state or touching inactive GGML buffers. The top-k computations remain separate per branch; this trades some extra sampling work for a stable graph interface. Other sampler chains retain their existing branch-selection behavior.

This is one draft model per compatible graph configuration, not one compiled blob for the whole server. The trunk and other graph stages still have their own entries. Different sampler configurations, recurrent capacities, rollback modes or incompatible KV layouts can require additional models. Cache-only mode still requires initial preparation; changing just the active subset no longer requires exhaustive subset priming.

The generic recurrent-cache translation invalidates blobs made with the former single-slot shortcuts. Run once without `GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY` to populate compatible entries before enabling cache-only mode again.

## Restrictions

- Cache-only mode requires Linux or Windows and mmap loading (`--load-mode mmap`, or the default when all selected devices support mmap). Do not use tensor validation or mlock when trying to avoid weight reads.
Expand Down
45 changes: 45 additions & 0 deletions ggml/src/ggml-openvino/dev_doc/MTP-SAMPLING-GRAPH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Stable multislot MTP graph

The captured UD draft graph contains 107 nodes regardless of which of four slots are active. It is the single MTP attention/MoE layer, not the recurrent trunk. Two speculative tokens require two consecutive draft calls, batched over active sequences.

```text
MTP token IDs + input hidden state
|
0-84: MTP layer and normalization, N active sequences
|
85: logits [248320, N]
86: PAD adds one safe row
|
+-- 87-91: slot 0 sampling
+-- 92-96: slot 1 sampling
+-- 97-101: slot 2 sampling
+-- 102-106: slot 3 sampling
```

Each branch contains VIEW, two Reshapes, TopK (ten candidate IDs), and GET_ROWS (their scores). Ten is the candidate count, not the speculative-token count.

| Active slots | Sampling COMPUTE flags, slots 0-3 | Raw/current nodes | Old filtered nodes | Packed sampling_rows |
|---|---|---:|---:|---|
| 3 | `[0,0,0,1]` | 107 | 92 | `[0,0,0,0]` |
| 0,2 | `[1,0,1,0]` | 107 | 97 | `[0,0,1,0]` |
| All four | `[1,1,1,1]` | 107 | 107 | `[0,1,2,3]` |

Old counts apply the old COMPUTE filter to the captures. Unselected nodes remain in the raw cgraph. Previously, removing them changed translated topology, slot-specific row Parameter names and output ports; even equal-sized subsets such as `{0,1}` and `{0,2}` differed. This could trigger up to 15 draft variants, with compilation/import on first use or a missing-cache error in cache-only mode.

Now all pure top-k branches remain. Their names include stable graph ordinals even when inactive. One int64 `sampling_rows` Parameter supplies row indices at runtime. For `{0,2}`, the two logits rows belong to slots 0 and 2:

```text
sampling_rows = [0, 0, 1, 0]
slot 0 -> row 0 -> normal candidate buffers
slot 1 -> row 0 -> private scratch, ignored
slot 2 -> row 1 -> normal candidate buffers
slot 3 -> row 0 -> private scratch, ignored
```

The vector is not an active mask. Host-side COMPUTE flags select normal versus scratch output destinations. PAD provides a valid row when there are no logits. Inactive outputs use device USM on GPU and do not affect sampler state or acceptance. Other sampler chains retain their selected-branch semantics.

Only small sampling work executes for inactive slots. The MTP layer and output projection still process N active rows. Top-k is separate per branch, not yet one batched TopK. The observed draft interface has 10 inputs and 12 outputs: eight candidate ID/score outputs, hidden state, full logits and two KV Results.

Dump shapes use GGML order `[width, rows, dim2, dim3]`; OV reverses it. `view_offs` is in bytes: one logits row occupies `248320 * 4 = 993280` bytes. Buffer labels describe GGML storage, not the device executing imported GPU operations.

The captures used cache-only mode, four slots, context 8192 and the default two-token MTP settings.
54 changes: 54 additions & 0 deletions ggml/src/ggml-openvino/dev_doc/OPENVINO-RECURRENT-CACHE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Current Qwen GPU implementation

As of 2026-10-29, the default Qwen3.5/Qwen3.6 path is dynamic stateless execution with `RecurrentConvCacheUpdate`, `RecurrentGatedDeltaNetUpdate`, and stable pure-top-k MTP translation. It supports one or multiple slots and rollback. The implementation applies to `qwen35` and `qwen35moe`; the reference model is the UD Qwen3.6-35B-A3B MTP GGUF.

Build against the matching OpenVINO runtime/GPU plugin with the independent Update ops. The tested runtime is `qwen-mtp-inplace-primary`, commit `9299cc3d78`; llama.cpp stable sampling is `71c0bbc4d`. Configure `GGML_OPENVINO_DEVICE=GPU`, native softplus, and the documented requantization policy. The current cache translation revision is 14.

## Buffer ownership and operation boundaries

| State | Storage and lifetime | Update path |
|---|---|---|
| Attention K/V | Full caller-owned USM allocation, sized by context and KV layout | Native stateless KV fusion when eligible; SDPA consumes the live prefix |
| Convolution `cache_r` | Full caller-owned USM row bank, sized by slot/snapshot capacity | Fused reset, original-row gather/reorder, convolution and ordered history/snapshot writes |
| GDN `cache_s` | Full caller-owned USM row bank, sized by slot/snapshot capacity | Fused reset, original-row gather/reorder, GDN and ordered final/snapshot writes |
| Runtime controls | Reused USM host storage on GPU | Row maps, offsets and write controls remain runtime inputs |
| Protected source rows | Private device scratch | Staged before writes to protect cycles, duplicate sources and overlaps |
| Inactive sampling results | Private device-USM scratch | Discarded without touching inactive GGML output buffers |

Attention context capacity does not set recurrent-cache size. Cache input Parameter and cache Result bind the same stable allocation on the primary path. There are no rotation banks or pointer swaps.

The GPU plugin uses two stages: first preserve required original rows in scratch while applying logical reset and precision rounding; then compute and perform ordered writes. This avoids overwriting a source before another destination has read it. Identity reorder sources need no scratch writes. In-place execution removes the spare full output bank, not every cache read or internal memory transaction.

`RecurrentConvCacheUpdate` has nine required inputs, including depthwise weights. Output 0 is convolution `[1,B,T,C]`; output 1 is the full updated cache. It does not expose an intermediate history/QKV tensor. `RecurrentGatedDeltaNetUpdate` emits attention and the full updated state cache; the cache retains the newest `min(T,snapshot_count)` states for MTP, newest first.

## Generic fallback and restrictions

Exact compatible layouts/storage and exclusive cache readers permit mutation, including eligible optimized Reshape aliases. Shared original-cache readers, incompatible layouts, unrelated overlaps or unsupported execution paths retain immutable-input semantics using a private output and required Result copy-back. Restore or clear state after a failed aliased inference before retrying. GPU replay is disabled for these ops because stage selection depends on bindings.

`GGML_OPENVINO_DISABLE_FUSED_RECURRENCE=1` retains the ordinary cache decomposition for diagnosis. Naive graphs skip full-model recurrence fusion setup. Unmatched/naive snapshot GDN uses the independent Update op with a temporary cache bank; ordinary GDN remains unchanged. Snapshot/rollback (speculative decoding) on OpenVINO requires a patched runtime/GPU plugin. Unpatched packages reject snapshot GDN with a warning and allow scheduler fallback to another backend. Rotation, the former three-op cache solution, the history-only/separate-convolution mode and single-slot no-rollback shortcuts are removed. Stateful and NPU MTP are not the supported default; this validation does not claim those paths.

## Attention KV layout

`GGML_OPENVINO_ENABLE_KV_4D=1` enables eligible native stateless in-place attention updates. The current eligibility covers one physical stream, including unified KV. Explicit split multi-slot KV retains the full-cache path and can be much slower even with only one active slot. Use `--kv-unified` for multi-slot OV GPU serving.

Leave `GGML_OPENVINO_KV_SLICE` at its default (`1`). Live-prefix slicing applies to eligible ordinary attention K/V roots, not recurrent caches. In-place KV fusion can bind the full allocation while exposing a live prefix internally. KV-slice on/off is a runtime binding choice and does not require different compiled blobs; incompatible graph layouts/capacities can still do so.

## Stable MTP sampling

The [graph walkthrough](MTP-SAMPLING-GRAPH.md) describes the fixed sampling interface. The backend keeps pure top-k branches for all configured slots, packs runtime row indices, and uses scratch for inactive outputs. It does not change the original cgraph or execute inactive stateful sampler chains. Only the small sampling branches stay at configured capacity; the expensive draft layer processes active rows.

One compatible draft graph is shared across active subsets. Trunk and genuinely different graph stages/configurations remain separate. Prepare a compatible revision-14 cache once, then use cache-only mode. Exhaustive active-subset priming is no longer required, though first-use model import and runtime preparation still have a cost.

## Validation

Native OV tests cover shape/attribute serialization, reset, cycles, duplicates, overlapping writes, mixed precision, changing shapes, aliased/distinct buffers, exclusive Reshapes, shared readers, host/device USM and export/import. Convolution is checked against a host reference; GDN uses an independent cache mapping around ordinary GDN. See `docs/dev/qwen35-llamacpp-recurrent-cache.md` and `recurrent_cache_update.cpp` in the OV checkout for contracts and tests.

## Debugging and source map

- `ggml-decoder.cpp`: dynamic dimensions, control inputs, output names and `cgraph_ov.txt` dump.
- `utils.cpp`: compute-branch filtering, compiled reuse and input/output binding.
- `openvino/recurrent_cache_fusion.cpp`: structural pattern matching and native Update op translation.
- `openvino/translate_session.cpp`: runtime sampling aliases and model construction.
- OV `recurrent_cache_update` implementation: mutation eligibility, source staging and GPU computation.

`GGML_OPENVINO_DUMP_CGRAPH=1` dumps the raw graph before filtering. It includes COMPUTE/OUTPUT flags and byte offsets and overwrites `cgraph_ov.txt` on each call. Enable dumps only for diagnosis; use the captured examples for a static view. GPU profiles and OpenCL copy traces add overhead, and lack of an explicit copy call does not prove zero traffic inside a kernel.
Loading