Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
62a9108
ggml-openvino: translate recurrent cache replay graphs
wine99 Nov 25, 2026
f71e5a0
ggml-openvino: use host USM for 4-D KV on integrated GPUs
wine99 Nov 25, 2026
37f1086
Revert "ggml-openvino: use host USM for 4-D KV on integrated GPUs"
wine99 Nov 25, 2026
eff6adf
ggml-openvino: key compiled replay graphs by declared control shapes
wine99 Nov 25, 2026
8afbd7c
ggml-openvino: represent replay writes with Assign sinks
wine99 Nov 26, 2026
5129f9c
ggml-openvino: document writable replay graph contract
wine99 Nov 26, 2026
75ec84e
ggml-openvino: remove legacy native recurrent cache ops
wine99 Nov 26, 2026
0b2f83b
ggml-openvino: document replay graph selection during prefill
wine99 Nov 27, 2026
fba8f85
ggml-openvino: enable Qwen3.5 and Gemma4 image inputs
wine99 Nov 20, 2026
a3ad481
ggml-openvino: keep allocation IDs out of persistent cache signatures
wine99 Nov 20, 2026
1d172cb
ggml-openvino: preserve explicit F32 MatMul precision per node
wine99 Nov 24, 2026
0de408b
ggml-openvino: remove the node precision availability guard
wine99 Nov 26, 2026
b8b4254
ggml-openvino: document pending audio dynamics and preprocessing caching
wine99 Nov 26, 2026
993cdc3
ggml-openvino: declare the node precision helper in mulmat
wine99 Nov 26, 2026
a57b176
ggml-openvino: Enable MOE models on NPU for Qwen3.6-35B-A3B
yzhou51 Nov 20, 2026
665cadd
ggml-openvino: find the moe block once per decoder for the npu config
ravi9 Nov 21, 2026
35b8f3a
ggml-openvino: docs: OpenVINO version and Linux memory setting for Mo…
yzhou51 Nov 27, 2026
5e03562
ggml-openvino: back GPU host buffers with a file by default on Linux
suhas-somashekar-intel Nov 17, 2026
7f1dfe0
ggml-openvino: back GPU host buffers with a file by default on Linux-…
suhas-somashekar-intel Nov 17, 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
25 changes: 25 additions & 0 deletions docs/backend/OPENVINO.md
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,31 @@ build\ReleaseOV\bin\llama-simple.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.
- Lunar Lake NPU: `gemma-4-12B` does not run. The first inference fails with `ZE_RESULT_ERROR_UNINITIALIZED` from the NPU driver. The model runs on CPU and GPU.
- The first load of a model on the NPU compiles it for the device, which can take minutes for large models.
- **Workaround:** Use the [compiled model cache](#compiled-model-cache).
- MoE models with a softmax router and SwiGLU experts (for example Qwen3.6-35B-A3B) run on the NPU through the MoE support of NPUW: only the routed experts run for each token, with the router on the host. Tested with `Qwen3.6-35B-A3B-Q4_0` on Panther Lake (Windows) and Lunar Lake (Windows, Ubuntu) systems with 32 GB.
- Requires an OpenVINO build newer than 2026.4.1: a nightly build, or a build from the master branch after 2026-10-19. These models depend on two NPUW changes that 2026.4.1 does not have, [#38123](https://github.com/openvinotoolkit/openvino/pull/38123) (MoE mixing scores) and [#38124](https://github.com/openvinotoolkit/openvino/pull/38124) (batched MoE matching). With 2026.4.1 the model runs without an error, but the output is wrong: on `Qwen3.6-35B-A3B-Q4_0` the perplexity is 4.6 times that of the CPU, against 1.05 times with a master build.
- A 35B MoE model needs nearly all of a 32 GB system: the backend and NPUW each hold a copy of the weights (about 18 GB each), and the NPU can address 18 GB of the shared memory. Use a small context and these settings:

```bash
export GGML_OPENVINO_DEVICE=NPU
export GGML_OPENVINO_PREFILL_CHUNK_SIZE=128
export GGML_OPENVINO_NPU_CONFIG="NPUW_WEIGHTS_BANK_ALLOC=CPU,NPUW_FUNCALL_ASYNC=NO,COMPILATION_NUM_THREADS=1"
./llama-cli -m Qwen_Qwen3.6-35B-A3B-Q4_0.gguf -c 256
```

```bat
REM Windows
set GGML_OPENVINO_DEVICE=NPU
set GGML_OPENVINO_PREFILL_CHUNK_SIZE=128
set GGML_OPENVINO_NPU_CONFIG=NPUW_WEIGHTS_BANK_ALLOC=CPU,NPUW_FUNCALL_ASYNC=NO,COMPILATION_NUM_THREADS=1
llama-cli.exe -m Qwen_Qwen3.6-35B-A3B-Q4_0.gguf -c 256
```

- `NPUW_WEIGHTS_BANK_ALLOC=CPU` keeps the NPUW copy of the weights in host memory instead of the NPU-addressable memory, at some cost in speed.
- `NPUW_FUNCALL_ASYNC=NO` and `COMPILATION_NUM_THREADS=1` lower the memory peak. `GGML_OPENVINO_COMPILATION_NUM_THREADS=1` is an older name for the second one.
- The backend sets `NPUW_MOE_POOL_SIZE=0` and `NPUW_MOE_TOKEN_CHUNK_SIZE=16` itself for MoE models (see the [developer documentation](../../ggml/src/ggml-openvino/dev_doc/OpenVINO-ENV-VARS.md#npu-plugin-properties)). Without them the load can hang on a 32 GB system.
- The NPU compiler type can stay unset: models with `GATED_DELTA_NET` layers, such as Qwen3.6, then compile with the compiler in OpenVINO. `NPU_COMPILER_TYPE=PREFER_PLUGIN` gives the same result.
- Linux: the NPU reports almost all of the system memory, so `--fit` keeps every weight in the backend, and a 32 GB system swaps heavily. Pass `--fit-target 16384`: `--fit` then leaves part of the expert weights in the memory-mapped model file, as it does on Windows, where the NPU reports 16 GB. The graph still runs on the NPU alone.
- `llama-perplexity` with these models: use a `-c` of at most twice `GGML_OPENVINO_PREFILL_CHUNK_SIZE` (for example `-c 256` with a chunk size of 128). The output rows of the last layer must not exceed the chunk size.

> [!NOTE]
> The OpenVINO backend is actively under development. Fixes and improvements are underway, and this document will continue to be updated.
Expand Down
18 changes: 0 additions & 18 deletions ggml/src/ggml-openvino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,3 @@ endif()
if (WIN32)
target_link_libraries(ggml-openvino PRIVATE psapi)
endif()

# Released runtimes retain the ordinary cache translators.
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
unset(GGML_OPENVINO_HAS_CACHE_UPDATE CACHE)
cmake_push_check_state(RESET)
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)
cmake_pop_check_state()
if(GGML_OPENVINO_HAS_CACHE_UPDATE)
target_compile_definitions(ggml-openvino PRIVATE GGML_OPENVINO_HAS_CACHE_UPDATE=1)
endif()
30 changes: 15 additions & 15 deletions ggml/src/ggml-openvino/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
# 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 and update writable cache inputs in place, 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.
The OpenVINO backend translates Qwen recurrent replay for complete dynamic stateless GPU graphs and supports stable MTP sampling. 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.
Use `--spec-type draft-mtp --spec-draft-n-max 2` with a GGUF that contains MTP weights. Parallel execution uses `-np` and `--kv-unified`. OpenVINO replay requires dynamic stateless GPU execution.

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`. Each cache is a writable Parameter backed by one
stable caller-owned USM allocation. The ops return only convolution or attention;
there are no recurrent cache Results. Required source rows are staged before
writes, preserving resets, cyclic reorders and rollback. Cache readers must be
exclusive, including Reshape aliases.
`GGML_OPENVINO_DISABLE_FUSED_RECURRENCE=1` retains the ordinary cache decomposition.
Unmatched snapshot GDN uses ordinary GDN token prefixes with functional writeback.
Build both repos against the matching single-output op spec. Translation revision
15 requires regenerating compiled-model blobs once without cache-only mode.
The backend emits standard OpenVINO ops and `Assign` sinks for replay cache writeback. A GPU plugin with recurrent replay fusion replaces each matched group with an internal op that writes directly to the caller-owned GPU cache. If an `Assign` sink remains, the backend copies its state back to the GGML cache after inference. See the [replay graph contract](dev_doc/OPENVINO-RECURRENT-CACHE.md#replay-graph-contract).

Cache-only MTP serving still requires the separate OpenVINO dynamic output-binding fix (PR #39354). Removing recurrent cache Results does not eliminate that independent trigger in imported MTP graphs.

Expand All @@ -31,7 +20,7 @@ The recommended Qwen3.6-35B-A3B Q4_K_M setup uses GPU with `GGML_OPENVINO_REQUAN

`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.
See the [implementation guide](dev_doc/OPENVINO-RECURRENT-CACHE.md) for buffer ownership and replay.

# Compiled model cache

Expand Down Expand Up @@ -95,3 +84,14 @@ On the static path (NPU, or any device with `GGML_OPENVINO_FORCE_STATIC=1`), mod
# NPU host gather

`GGML_OPENVINO_NPU_HOST_GATHER=1` (NPU, opt-in) gathers the rows of large host-resident embedding tables (at least 64 MiB, raw GGUF data) on the host. The static graph gets the gathered rows through an `ggml_host_rows_<node>` input instead of an OpenVINO Gather over the table. NPUW otherwise lifts the table to a function input, and gathering from an input that large costs about as much as streaming the whole table every call (21.6 ms of Gemma 4 E2B decode). A table used only for such lookups (the Gemma 3n/4 per-layer embedding table) is not converted or bound to the NPU at all.

## Multimodal

Qwen3.5 and Gemma4 E2B image input work on OpenVINO CPU and GPU with their matching
projectors. Four-slot serving was validated with unified and split KV.
Qwen3.5 reuses its vision graph across image resolutions; Gemma4 uses
resolution-specific encoder graphs.

Gemma4 audio is not enabled: preprocessing and Conformer still need dynamic length/block handling, runtime padding and view/state offsets, and cross-length compiled-model reuse. The small weightless preprocessing graph currently runs uncached because of the naive path's node-count heuristic.

Static/NPU multimodal execution is untested.
Loading