* ggml-openvino: keep the rope angle in f32 under the f16 inference hint
* ggml-openvino: add a GGML_OP_ARGMAX translator
* ggml-openvino: keep the token dim dynamic for a 2-D activation graph input
* ggml-openvino: tolerate graph inputs and outputs with no backing storage
* ggml-openvino: invalidate a cached graph when its output set changes
* ggml-openvino: bound the compiled-model cache to N shapes instead of 1
* ggml-openvino: add GGML_OPENVINO_LOG_SUPPORTS_OP diagnostic
* ggml-openvino: honour a node's dynamic-dim classification on non-split graphs too
* ggml-openvino: fold consecutive SET_ROWS column writes into one scatter
* ggml-openvino: keep the speculative decoding feature buffers in device memory
* ggml-openvino: keep the fixed token count of static graph inputs for npu
GDN
In a static (NPU) graph that overwrites the fixed token count that
get_graph_input_shape set just before, for example of inp_tokens, so the NPU
graph got a dynamic token dimension. GATED_DELTA_NET models (Qwen3.5, Qwen3.6)
then fail to translate: "GATED_DELTA_NET pad masking requires a static token
dimension". Keep the change for dynamic graphs and the previous behaviour for
static ones.
* ggml-openvino: one output in the decode model of a static NPU pair
The decode model of a static prefill/decode pair copied the compute params of the
prefill graph, including output_len. With llama-perplexity the prefill graph has many
outputs (128 at -c 256), so the decode model gathered 128 rows from its one token in
the last layer. For a MoE model that layer then differs from the others and NPUW fails
to lower its experts ("could not lower the isolated expert partition"). A decode step
outputs one token; the model cache key already assumes it (decode_signature out=1).
* ggml-openvino: fix gated delta net when v is a view with padded heads
The GDN translator assumed v is a view of the fused qkv conv output with
the heads packed in each row, and sliced H_v * S_v elements off that row.
test-backend-ops now has padded_v cases, where v views a wider tensor and
each head row is padded (nb[1] > S_v * nb[0]). The slice then read the
padding, and the results were wrong on CPU and GPU.
Take the packed path only when nb[1] == S_v * nb[0]. Any other view goes
through the generic view resolution, which already returns
[B, T, H_v, S_v], so the reshape of the packed case is skipped too. Model
graphs build v with packed heads and keep the packed path.
* ggml-openvino: make the f32 rope angle opt-in
GGML_OPENVINO_ROPE_F32_ANGLE was on by default. It changes the RoPE of
every model on every device, and it was validated on one model on the
GPU only. On the CPU device, which computes in f32, its f16 round trip
rounds cos and sin, and ROPE cases of test-backend-ops fail against the
CPU backend.
Turn it off by default; GGML_OPENVINO_ROPE_F32_ANGLE=1 turns it on. Fix
the comment that called the round trip a no-op on f32 paths. Document
the variable, and the two diagnostics added with it
(GGML_OPENVINO_LOG_SUPPORTS_OP, GGML_OPENVINO_DIAG_GRAPH_IO), in the
dev_doc.
* docs : add the Muse-Glimmer-30B DFlash memory limit and env var samples
Muse-Glimmer-30B with a DFlash draft peaks at about 45 GB of RAM on an
integrated GPU. Add it to the GPU limitations as a runnable sample, and
add samples for GGML_OPENVINO_LOG_SUPPORTS_OP and
GGML_OPENVINO_DIAG_GRAPH_IO to the dev_doc.
* ggml-openvino: fix weight zero points, buffer extras and cache-key gaps
A code review of ggml/src/ggml-openvino found these bugs:
- Q4_1 weights: `extract_q4_1_data` packs two zero points per byte from a `parallel_for` over blocks, so two threads can write the same byte.
- Zero points out of the u4/u8 range wrap around instead of saturating. gemma-4-E2B has 6 Q4_K sub-blocks with a zero point of 16 or more; 16 wrapped to 0.
- `set_tensor` overwrote the extra that `init_tensor` created for a weight without deleting it.
- The two buffer constructors had separate id counters, and the buffer id is part of the shared graph key.
- A freed weight buffer stayed in the release registry, so a later release could madvise memory it no longer owned.
- `GGML_OPENVINO_ROPE_F32_ANGLE` changes the graph but was not in the compiled-model cache key.
- On NPU, group-128 requantization ignored the row width. A model whose rows are not a multiple of 128 failed to load its weights (SmolLM2-360M).
- The static Split cache held a strong reference to the Split on its own input (a reference cycle) and ignored the output port.
- `rms_norm` took op_case 3 for both a direct and a packed pre-scaled GDN output, so the packed one was not sliced.
- Smaller items: static decode read `out_ids` even when it is empty; the static path aborted where the dynamic path returns an error; a damaged weights `.meta` hash threw from `std::stoull`; `extract_layer_from_name` threw on a non-numeric suffix; `GGML_OP_FILL` was registered twice.
- ggml-quants.cpp: one `parallel_for` iteration per zero point byte for Q4_1; clamp zero points to [0, 15] (u4) and [0, 255] (u8).
- ggml-openvino.cpp: `ggml_openvino_set_extra` replaces and deletes the old extra at every site; one id counter; `ggml_openvino_unregister_weight_buffer` in the buffer destructor; a failed KV re-allocation returns `GGML_STATUS_ALLOC_FAILED`.
- model-cache.cpp: hash `GGML_OPENVINO_ROPE_F32_ANGLE`, cache version 9; `strtoull` for the `.meta` hash.
- npu_quant_policy.cpp: Q4_0_128 falls back to Q4_0_C when `ne[0] % 128 != 0`. ggml-openvino-extra.cpp: the group-64 requant targets fall back to Q8_0_C when `ne[0] % 64 != 0`.
- openvino/utils.cpp: the static Split cache uses a weak reference and the output port in its key, like the dynamic one.
- rms_norm.cpp, ggml-decoder.cpp: op_case 5 for a packed pre-scaled GDN output.
- utils.cpp: static decode writes 0 to `out_ids`; a compile after a weight release returns `GGML_STATUS_FAILED`.
- ggml-decoder.cpp: `extract_layer_from_name` returns nullopt for a non-numeric suffix.
- op_table.cpp/.h: remove the duplicate `GGML_OP_FILL`.
* ggml-openvino: copy the decoder once per graph conversion
`GgmlOvDecoder::visit_subgraph` made a full copy of the decoder for every node it visited. Translators only read the decoder, so one copy per walk is enough. Graph conversion time drops 12-24x (Qwen3.5-0.8B: 4.1 s to 0.17 s over the six graphs of a short run).
- ggml-decoder.cpp: make one decoder copy before the node loop.
- utils.cpp: `get_static_attention_size` takes the decoder by const reference and does not copy the compute params.
* ggml-openvino: remove dead code and fix stale comments
Code that nothing calls or registers, and comments that no longer match the code. No behavior change.
- Remove `translate_gated_delta_net_ref`, `translate_solve_tri` (not registered), the unused `FuseToSDPA` pass, `add_rope_sin_cos`, `checksum`, `save_ggml_tensor_data_to_txt`, `non_cont_dim`, the unused templates in openvino/utils.h and the undefined `getCurrentTime` declaration.
- ggml-decoder.cpp: drop the VIEW op_case tail that only ever set 0.
- utils.cpp: drop a duplicate `entry->ptr` store and the always-false `!model_leafs.empty() == false` term.
- `ggml_openvino_manual_gqa_enabled()` replaces two copies of the GGML_OPENVINO_MANUAL_GQA_ATTN default (flash_attn_ext.cpp and the cache key).
- ggml-openvino.cpp: remove the SSM_CONV case whose comment said it stays on CPU (it runs on OpenVINO); fix the gemma3n reason text (not GPU-only) and two typos.
* ggml-openvino: track dynamic dims through bailingmoe3's GDN views and conv state
bailingmoe3 uses GATED_DELTA_NET views to expose its attention and
state outputs. Preserve their dynamic dimensions in the decoder.
- Assign the dynamic dimensions of the translated attention and state
outputs to the corresponding GATED_DELTA_NET result VIEWs.
- Count the convolution state slots using the rows spanned by the
destination view. bailingmoe3 packs the q/k/v convolution states
into a single row.
- Preserve the tracked dynamic dimension in RESHAPE op case 0 when
the reshape only adds a trailing size-1 dimension.
* ggml-openvino: translate the per-key gate of GATED_DELTA_NET
Ling-3.0-tiny (bailingmoe3) uses a gate per key dimension (kda),
which the backend previously rejected, causing these layers to
fall back to the CPU.
- Use the fused GatedDeltaNet when the OpenVINO runtime and target
device support a rank-4 gate.
- Detect support once by compiling a one-node GatedDeltaNet with
a rank-4 gate and checking the target device with query_model.
Older runtimes reject this gate, and the CPU plugin does not
support it.
- Fall back to the reference loop when the fused path is unavailable.
- Support a dynamic token count in the reference loop by using
dynamic reshapes and deriving the trip count from the input shape.
- Reject unsupported cases with a reason: padded chunks, recurrent
caches, state snapshots, and the native state layout. The loop
currently handles one state in the ggml layout.
* ggml-openvino: Fix issue highlighted by tests
* ggml-openvino: reject a padded permuted v in gated delta net
supports_op rejected a permuted v only when src2 was the PERMUTE itself. With padded heads, v is a VIEW of the PERMUTE, so the check missed it and the per-key gate reference loop ran on a v layout it does not handle. Look through the VIEW so this case falls back like the other permuted v inputs.
* ggml-openvino: write back intermediate nodes of op-test graphs
The ADD_RMS_NORM_MUL op test checks the intermediate sum of its graph as
well as the final output. compute_model_outputs() made a node a model
output only when the graph does not consume all of it, so the sum was
never written back and the test read uninitialised memory (28 failures
on GPU and CPU). MUL_MAT_ID_SHARED, which checks its routed and shared
results, failed the same way on CPU.
Op-test graphs (the naive path) can read any node, so make every
non-in-place node a model output there. Model graphs are unchanged.
---------
Co-authored-by: Mustafa Cavus <mustafa.cavus@intel.com>
Co-authored-by: yzhou51 <yaowei.zhou@intel.com>
Co-authored-by: Sabnis, Omkar <omkar.sabnis@intel.com>
51 KiB
OpenVINO Backend for llama.cpp
Note
Performance and memory optimizations, accuracy validation, broader quantization coverage, broader operator and model support are work in progress.
OpenVINO is an open-source toolkit for optimizing and deploying high-performance AI inference, specifically designed for Intel hardware, including CPUs, GPUs (integrated and discrete), and NPUs, in the cloud, on-premises, and on the edge. The OpenVINO backend runs the same GGUF model files on Intel® CPUs, GPUs and NPUs, without changes to the model or the rest of llama.cpp.
When a ggml_cgraph is dispatched to the OpenVINO backend, it:
- Walks the GGML graph and identifies inputs, outputs, weights, and KV cache tensors.
- Translates the GGML operations into an
ov::Modelusing OpenVINO's frontend API. - Compiles and caches the model for the target device.
- Binds GGML tensor memory to OpenVINO inference tensors and runs inference.
For guidance on contributing to the OpenVINO backend, see the OpenVINO Backend Contributing Guide.
Contents
- Quick Start
- Supported Devices
- Supported Model Precisions
- Supported llama.cpp Tools
- Validated Models
- Build Instructions
- Runtime Configuration
- Known Limitations
- Work in Progress
Quick Start
On Ubuntu, with the prerequisites and the OpenVINO Runtime installed:
# 1. Build
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
source /opt/intel/openvino/setupvars.sh
cmake -B build/ReleaseOV -G Ninja -DCMAKE_BUILD_TYPE=Release -DGGML_OPENVINO=ON
cmake --build build/ReleaseOV --parallel
# 2. Download a model
mkdir -p ~/models/
wget https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_K_M.gguf \
-O ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf
# 3. Run on CPU, GPU or NPU
export GGML_OPENVINO_DEVICE=GPU
./build/ReleaseOV/bin/llama-cli -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -c 1024
The Ubuntu Build Script and the Windows Build Script do the setup in one step: they install the prerequisites and the OpenVINO Runtime, and build llama.cpp with the OpenVINO backend.
See Build Instructions for Windows and Docker, and Runtime Configuration for the environment variables.
Supported Devices
OpenVINO backend supports the following hardware:
- Intel CPUs
- Intel GPUs (integrated and discrete)
- Intel NPUs
Although OpenVINO supports a wide range of Intel hardware, the llama.cpp OpenVINO backend has been validated specifically on AI PCs such as the Intel® Core™ Ultra Series 2 (Lunar Lake) and Series 3 (Panther Lake).
Supported Model Precisions
FP16BF16(on Intel Xeon)Q8_0Q4_0Q4_1Q4_KQ5_0(converted at runtime, see the details below)Q5_1Q5_K(converted at runtime, see the details below)Q6_K(converted at runtime, see the details below)
Q4_K_M files mix Q4_K tensors with Q6_K tensors, and sometimes Q5_K tensors.
Quantization details for each device
All devices:
FP16andBF16tensors are used as they are.- A quantized token embedding (
token_embd.weight) and output weight (output.weight) are converted toQ8_0_C.
CPU and GPU:
Q4_0,Q4_1,Q4_K,Q5_1andQ8_0tensors keep their layout: weights, scales and zero points are extracted directly.Q5_KandQ6_Ktensors are converted toQ8_0_C.GGML_OPENVINO_REQUANT_KQUANTselects a 4-bit layout instead.Q5_0tensors are converted toQ4_0_64.
GPU:
Q4_K,Q5_KandQ6_KMoE expert tensors are converted toQ4_1_64. This lets the GPU plugin use its fused MoE op, which is much faster for prompt processing.GGML_OPENVINO_REQUANT_KQUANTdoes not change this.GGML_OPENVINO_MOE_OP=0turns the fused MoE op off.
NPU:
- All other quantized tensors are requantized to
Q4_0_128. - For a
Q6_Ktoken embedding,GGML_OPENVINO_NPU_TOKEN_EMBD_QUANTselects another layout. - The validated models use
Q4_K_Mfiles.
Layout names:
Q8_0_C: 8-bit, one scale per row.Q4_0_128andQ4_0_64: 4-bit, symmetric, one scale per 128 or 64 weights.
Additional Notes:
- Both
Q4_0andQ4_1models useQ6_Kfor the token embedding tensor and the final matmul weight tensor (often the same tensor) Q4_0models may produce someQ4_1tensors if an imatrix is provided during quantization usingllama-quantizeQ4_K_Mmodels may include bothQ6_KandQ5_Ktensors (observed in Phi-3)
Supported llama.cpp Tools
The OpenVINO backend works with the standard llama.cpp tools listed below. Tool coverage is not uniform across devices.
- llama-bench
- llama-cli
- llama-completion
- llama-embedding
- llama-perplexity
- llama-server
- llama-simple
Validated Models
The models below were tested with llama-cli and Q4_K_M files on an Intel® Core™ Ultra Series 2 (Lunar Lake). The OpenVINO backend is expected to work on a broader range of Intel hardware, model precisions, llama.cpp tools and model architectures.
Legend & Test Configuration:
- Status: ✓ = Passed | ~ = Accuracy issues | ✗ = Failed or Unsupported
- Execution mode: stateless (
GGML_OPENVINO_STATEFUL_EXECUTION=0) on every device. - Validation system: Intel® Core™ Ultra 7 258V (Lunar Lake) | 32 GB RAM | Ubuntu 26.04.1 | Intel Graphics Compiler 2.42.6 | Intel OpenCL GPU Driver 26.40.40196.8-0 | Intel NPU Driver 1.38.0.
- See Known Limitations for context on observed failures.
Validated models
The embedding models were tested with llama-embedding and Q8_0 files.
Build Instructions
0. Prerequisites
- Linux or Windows system with Intel hardware (CPU, GPU, or NPU)
- For Intel GPU or NPU Usage: Install the appropriate hardware drivers for your Intel GPU or NPU. For detailed instructions, see: Additional Configurations for Hardware Acceleration.
Linux
Build tools (Git, CMake, Ninja):
sudo apt-get update
sudo apt-get install -y build-essential libcurl4-openssl-dev libtbb12 cmake ninja-build python3-pip curl wget tar
OpenCL:
sudo apt install ocl-icd-opencl-dev opencl-headers opencl-clhpp-headers intel-opencl-icd
Windows
-
Download and install Microsoft Visual Studio 2022 Build Tools. During installation, select the "Desktop development with C++" workload.
-
Install the required tools:
# Windows PowerShell winget install Git.Git winget install GNU.Wget winget install Ninja-build.Ninja -
Install OpenCL using vcpkg:
# Windows PowerShell cd C:\ git clone https://github.com/microsoft/vcpkg cd vcpkg .\bootstrap-vcpkg.bat .\vcpkg install opencl # Optional but recommended: Integrate vcpkg with Visual Studio / CMake: .\vcpkg integrate install
1. Install OpenVINO Runtime
-
Follow the guide to install OpenVINO Runtime from an archive file: Linux | Windows
-
Verify OpenVINO is initialized properly:
echo $OpenVINO_DIR
2. Build llama.cpp with OpenVINO Backend
Clone the llama.cpp repository:
git clone https://github.com/ggml-org/llama.cpp
cd llama.cpp
Build on Linux:
source /opt/intel/openvino/setupvars.sh
cmake -B build/ReleaseOV -G Ninja -DCMAKE_BUILD_TYPE=Release -DGGML_OPENVINO=ON
cmake --build build/ReleaseOV --parallel
Build on Windows
Open x64 Native Tools Command Prompt for VS (so the MSVC toolchain is on PATH), then run:
C:\Intel\openvino\setupvars.bat
cmake -B build\ReleaseOV -G Ninja -DCMAKE_BUILD_TYPE=Release -DGGML_OPENVINO=ON -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake --build build\ReleaseOV --parallel
Note
The Windows install path is
C:\Intel\openvino(no spaces) to avoid quoting problems some CMake/Ninja toolchains have withC:\Program Files (x86)\.... Adjust to wherever you installed OpenVINO Runtime. Fromcmd, runC:\Intel\openvino\setupvars.bat; from PowerShell, run& "C:\Intel\openvino\setupvars.ps1"instead. Once the build is finished you can launch the binaries from anycmdorPowerShellwindow after sourcing the matchingsetupvarsscript for that shell.
Ubuntu Build Script
For Ubuntu users, the following shell script automates the prerequisite installs (build tools, OpenCL ICD), the OpenVINO Runtime download/extract/setup, and the Ninja-based llama.cpp build.
Save the following as build-llamacpp-ov.sh next to where you want the llama.cpp folder to land, then run it:
chmod +x build-llamacpp-ov.sh
./build-llamacpp-ov.sh
Click to expand build-llamacpp-ov.sh
#!/usr/bin/env bash
# ============================================
# llama.cpp OpenVINO Build Script (Ninja)
# ============================================
set -euo pipefail
OPENVINO_VERSION_MAJOR="2026.4.1"
OPENVINO_VERSION_FULL="2026.4.1.22982.07f9c262b05"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OPENVINO_INSTALL_DIR="/opt/intel/openvino_${OPENVINO_VERSION_MAJOR}"
OPENVINO_LINK_DIR="/opt/intel/openvino"
OPENVINO_TGZ="${SCRIPT_DIR}/openvino.tgz"
OPENVINO_URL="https://storage.openvinotoolkit.org/repositories/openvino/packages/${OPENVINO_VERSION_MAJOR}/linux/openvino_toolkit_ubuntu24_${OPENVINO_VERSION_FULL}_x86_64.tgz"
echo "============================================"
echo "Installing prerequisites (apt)..."
echo "============================================"
sudo apt-get update
sudo apt-get install -y \
build-essential libcurl4-openssl-dev libtbb12 \
cmake ninja-build python3-pip \
curl wget tar git
echo "============================================"
echo "Installing OpenCL runtime + headers..."
echo "============================================"
sudo apt-get install -y \
ocl-icd-opencl-dev opencl-headers opencl-clhpp-headers intel-opencl-icd
cd "${SCRIPT_DIR}"
# ============================================
# Clone llama.cpp if missing
# ============================================
if [[ ! -f "llama.cpp/CMakeLists.txt" ]]; then
echo "Cloning llama.cpp..."
git clone https://github.com/ggml-org/llama.cpp
fi
# ============================================
# Setup OpenVINO: download & extract to /opt/intel/openvino_${OPENVINO_VERSION_MAJOR},
# then point /opt/intel/openvino at it via symlink so the active version is swappable.
# ============================================
if [[ -f "${OPENVINO_INSTALL_DIR}/setupvars.sh" ]]; then
echo "OpenVINO ${OPENVINO_VERSION_MAJOR} already installed at ${OPENVINO_INSTALL_DIR}. Skipping download."
else
echo "OpenVINO not found at ${OPENVINO_INSTALL_DIR}. Starting download..."
curl -L -o "${OPENVINO_TGZ}" "${OPENVINO_URL}"
echo "Extracting OpenVINO to ${OPENVINO_INSTALL_DIR}..."
sudo mkdir -p "${OPENVINO_INSTALL_DIR}"
sudo tar -xzf "${OPENVINO_TGZ}" -C "${OPENVINO_INSTALL_DIR}" --strip-components=1
rm -f "${OPENVINO_TGZ}"
fi
# Refresh symlink: /opt/intel/openvino -> /opt/intel/openvino_${OPENVINO_VERSION_MAJOR}
sudo ln -sfn "${OPENVINO_INSTALL_DIR}" "${OPENVINO_LINK_DIR}"
OPENVINO_ROOT="${OPENVINO_LINK_DIR}"
echo "OpenVINO Ready: ${OPENVINO_ROOT} -> ${OPENVINO_INSTALL_DIR}"
# Install OpenVINO's own runtime dependencies (one-time per system).
if [[ -x "${OPENVINO_ROOT}/install_dependencies/install_openvino_dependencies.sh" ]]; then
echo "============================================"
echo "Installing OpenVINO runtime dependencies..."
echo "============================================"
echo "Y" | sudo -E "${OPENVINO_ROOT}/install_dependencies/install_openvino_dependencies.sh"
fi
# ============================================
# Clean old build cache
# ============================================
cd "${SCRIPT_DIR}/llama.cpp"
if [[ -d "build/ReleaseOV" ]]; then
echo "Removing old build directory..."
rm -rf "build/ReleaseOV"
fi
echo "============================================"
echo "Configuring with CMake..."
echo "============================================"
set +u
source "${OPENVINO_ROOT}/setupvars.sh"
set -u
cmake -B build/ReleaseOV -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DGGML_OPENVINO=ON
cmake --build build/ReleaseOV --parallel
echo "============================================"
echo "Build completed successfully!"
echo "============================================"
echo "Binaries: $(pwd)/build/ReleaseOV/bin"
echo
echo "NOTE: To run, source setupvars.sh and pick a device:"
echo " source /opt/intel/openvino/setupvars.sh"
echo " export GGML_OPENVINO_DEVICE=CPU # or GPU / NPU"
echo " ./build/ReleaseOV/bin/llama-cli -m model.gguf"
Note
The script pins OpenVINO
2026.4.1via theOPENVINO_VERSION_MAJOR/OPENVINO_VERSION_FULLvariables at the top — edit them to track a different release.
Windows Build Script
For Windows users, the following .bat script automates the prerequisite installs (Git, Ninja, CMake, Visual Studio 2022 Build Tools, vcpkg + OpenCL), the OpenVINO Runtime download/extract, and the Ninja-based llama.cpp build.
Save the following as build-llamacpp-ov.bat next to where you want the llama.cpp to land, then run it from either Command Prompt or PowerShell:
:: Command Prompt
build-llamacpp-ov.bat
# PowerShell
.\build-llamacpp-ov.bat
Click to expand build-llamacpp-ov.bat
@echo off
setlocal enabledelayedexpansion
REM ============================================
REM llama.cpp OpenVINO Build Script (Ninja)
REM ============================================
set "OPENVINO_VERSION_MAJOR=2026.4.1"
set "OPENVINO_VERSION_FULL=2026.4.1.22982.07f9c262b05"
set "SCRIPT_DIR=%~dp0"
set "VCPKG_DIR=C:\vcpkg"
set "OPENVINO_INSTALL_DIR=C:\Intel\openvino_%OPENVINO_VERSION_MAJOR%"
set "OPENVINO_LINK_DIR=C:\Intel\openvino"
set "OPENVINO_ZIP=%SCRIPT_DIR%openvino.zip"
set "OPENVINO_EXTRACT_TMP=%SCRIPT_DIR%openvino_extract_tmp"
set "OPENVINO_URL=https://storage.openvinotoolkit.org/repositories/openvino/packages/%OPENVINO_VERSION_MAJOR%/windows/openvino_toolkit_windows_%OPENVINO_VERSION_FULL%_x86_64.zip"
echo ============================================
echo Installing prerequisites...
echo ============================================
winget install --id Git.Git -e --accept-source-agreements --accept-package-agreements 2>nul
winget install --id Ninja-build.Ninja -e --accept-source-agreements --accept-package-agreements 2>nul
winget install --id Kitware.CMake -e --accept-source-agreements --accept-package-agreements 2>nul
REM Ensure Visual Studio Build Tools are installed.
echo Checking for Visual Studio Build Tools...
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
set "VS_INSTALLED="
if exist "%VSWHERE%" (
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath 2^>nul`) do (
set "VS_INSTALLED=%%i"
)
)
if defined VS_INSTALLED (
echo Visual Studio with VC++ x86/x64 tools already present at "!VS_INSTALLED!". Skipping winget install.
) else (
winget install --id Microsoft.VisualStudio.2022.BuildTools -e --override "--wait --passive --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended" --accept-source-agreements --accept-package-agreements
if errorlevel 1 (
echo WARNING: winget could not install Visual Studio Build Tools automatically.
echo Install manually from https://aka.ms/vs/17/release/vs_BuildTools.exe ^(select the "Desktop development with C++" workload^)
echo and re-run this script from a "Developer Command Prompt for VS 2022".
)
)
echo ============================================
echo Installing OpenCL via vcpkg...
echo ============================================
if not exist "%VCPKG_DIR%" (
git clone https://github.com/microsoft/vcpkg "%VCPKG_DIR%"
cd /d "%VCPKG_DIR%"
call bootstrap-vcpkg.bat
call vcpkg integrate install
)
cd /d "%VCPKG_DIR%"
call vcpkg install opencl
cd /d "%SCRIPT_DIR%"
REM ============================================
REM Clone llama.cpp if missing
REM ============================================
if not exist "llama.cpp\CMakeLists.txt" (
echo Cloning llama.cpp...
git clone https://github.com/ggml-org/llama.cpp
)
cd /d "llama.cpp"
set "SCRIPT_DIR=%CD%"
REM ============================================
REM Setup OpenVINO: download & extract to C:\Intel\openvino_%OPENVINO_VERSION_MAJOR%,
REM then point C:\Intel\openvino at it via a directory junction (mklink /J).
REM ============================================
if exist "%OPENVINO_INSTALL_DIR%\setupvars.bat" (
echo OpenVINO %OPENVINO_VERSION_MAJOR% already installed at "%OPENVINO_INSTALL_DIR%". Skipping download.
) else (
echo OpenVINO not found at "%OPENVINO_INSTALL_DIR%". Starting download...
curl -L -o "%OPENVINO_ZIP%" "%OPENVINO_URL%"
if errorlevel 1 (
echo ERROR: Download failed.
exit /b 1
)
echo Extracting OpenVINO...
if exist "%OPENVINO_EXTRACT_TMP%" rmdir /s /q "%OPENVINO_EXTRACT_TMP%"
mkdir "%OPENVINO_EXTRACT_TMP%"
tar -xf "%OPENVINO_ZIP%" -C "%OPENVINO_EXTRACT_TMP%"
if errorlevel 1 (
echo ERROR: Extraction failed.
exit /b 1
)
REM Move the single top-level folder contents into the versioned install dir.
set "OPENVINO_EXTRACTED="
for /d %%i in ("%OPENVINO_EXTRACT_TMP%\*") do set "OPENVINO_EXTRACTED=%%i"
if not defined OPENVINO_EXTRACTED (
echo ERROR: Could not locate extracted OpenVINO folder under "%OPENVINO_EXTRACT_TMP%".
exit /b 1
)
if not exist "%OPENVINO_INSTALL_DIR%" mkdir "%OPENVINO_INSTALL_DIR%"
xcopy /e /i /y /q "!OPENVINO_EXTRACTED!\*" "%OPENVINO_INSTALL_DIR%\" >nul
if errorlevel 1 (
echo ERROR: Failed to copy OpenVINO from "!OPENVINO_EXTRACTED!" to "%OPENVINO_INSTALL_DIR%".
echo Re-run this script from an elevated Command Prompt ^(Run as administrator^) if access is denied.
exit /b 1
)
rmdir /s /q "%OPENVINO_EXTRACT_TMP%"
del "%OPENVINO_ZIP%"
)
REM Refresh junction: C:\Intel\openvino -> C:\Intel\openvino_<version>.
REM `mklink /J` creates a directory junction (no admin / Developer Mode required).
if exist "%OPENVINO_LINK_DIR%" rmdir "%OPENVINO_LINK_DIR%"
mklink /J "%OPENVINO_LINK_DIR%" "%OPENVINO_INSTALL_DIR%" >nul
if errorlevel 1 (
echo ERROR: Failed to create junction "%OPENVINO_LINK_DIR%" -^> "%OPENVINO_INSTALL_DIR%".
echo If "%OPENVINO_LINK_DIR%" already exists as a regular non-empty folder, remove it manually and re-run.
exit /b 1
)
set "OPENVINO_ROOT=%OPENVINO_LINK_DIR%"
echo OpenVINO Ready: %OPENVINO_ROOT% -^> %OPENVINO_INSTALL_DIR%
echo ============================================
echo Setting up compiler environment...
echo ============================================
REM Locate Visual Studio Build Tools vcvars64.bat
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if exist "%VSWHERE%" (
for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products Microsoft.VisualStudio.Product.BuildTools -property installationPath`) do (
set "VS_PATH=%%i"
)
)
if defined VS_PATH (
call "%VS_PATH%\VC\Auxiliary\Build\vcvars64.bat" >nul
) else (
echo WARNING: Visual Studio Build Tools not found. Compiler may be missing.
)
REM ============================================
REM Clean old build cache
REM ============================================
if exist "build\ReleaseOV" (
echo Removing old build directory ...
rmdir /s /q "build\ReleaseOV"
)
echo ============================================
echo Configuring with CMake...
echo ============================================
call "%OPENVINO_ROOT%\setupvars.bat" >nul 2>nul
cmake -B build\ReleaseOV -G Ninja ^
-DCMAKE_BUILD_TYPE=Release ^
-DGGML_OPENVINO=ON ^
-DCMAKE_TOOLCHAIN_FILE="%VCPKG_DIR%\scripts\buildsystems\vcpkg.cmake"
if errorlevel 1 (
echo If you continue to face CMAKE errors, make sure to install:
echo winget install Microsoft.VisualStudio.2022.BuildTools
echo Then run the "Developer Command Prompt for VS 2022" and launch this script from there.
exit /b 1
)
cmake --build build\ReleaseOV --config Release
if errorlevel 1 exit /b 1
echo ============================================
echo Build completed successfully!
echo ============================================
echo Binaries: %CD%\build\ReleaseOV\bin
echo.
echo NOTE: To run, source setupvars.bat and pick a device:
echo call "C:\Intel\openvino\setupvars.bat"
echo set GGML_OPENVINO_DEVICE=CPU ^&^& REM or GPU / NPU
echo build\ReleaseOV\bin\llama-cli.exe -m model.gguf
echo.
endlocal
Note
The script pins OpenVINO
2026.4.1via theOPENVINO_VERSION_MAJOR/OPENVINO_VERSION_FULLvariables at the top — edit them to track a different release. From any new shell, source the matchingsetupvarsscript via the junction —call "C:\Intel\openvino\setupvars.bat"fromcmd, or& "C:\Intel\openvino\setupvars.ps1"from PowerShell. Ifwingetcannot register Visual Studio Build Tools on first run, install them once manually and re-run the script from an elevated Developer Command Prompt for VS 2022.
3. Download Sample Model
Download a sample model for testing.
mkdir -p ~/models/
wget https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_K_M.gguf \
-O ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf
Windows
# Windows PowerShell
mkdir C:\models
Invoke-WebRequest -Uri https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_K_M.gguf -OutFile C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf
REM Windows Command Prompt
mkdir C:\models
curl -L https://huggingface.co/bartowski/Llama-3.2-1B-Instruct-GGUF/resolve/main/Llama-3.2-1B-Instruct-Q4_K_M.gguf -o C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf
4. Run Inference with OpenVINO Backend
The first run of a model converts and compiles it for the device. This takes seconds on CPU and GPU, and can take minutes on the NPU for large models. Later tokens are faster, and the compiled model cache makes later runs start faster.
Note
Default context size is set to the model training context, which may be very large. For example, 131072 for Llama 3.2 1B, which may result in lower performance, especially on edge/laptop devices. Use
-cto limit context size in supported llama.cpp tools for better performance:
- CPU and GPU: for example
-c 1024.- NPU: keep the context small, for example
-c 512, or-c 256for larger models. Decode may slow down as the context grows.
# If the device is unset, the CPU is used.
export GGML_OPENVINO_DEVICE=GPU
# To run llama-simple:
./build/ReleaseOV/bin/llama-simple -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -n 50 "The story of AI is "
# To run in chat mode:
./build/ReleaseOV/bin/llama-cli -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -c 1024
# To run llama-bench:
GGML_OPENVINO_DEVICE=GPU ./build/ReleaseOV/bin/llama-bench -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf
# NPU: keep context small to avoid failures from very large model context windows.
export GGML_OPENVINO_DEVICE=NPU
./build/ReleaseOV/bin/llama-cli -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -c 512
Windows
REM Windows Command Prompt
set GGML_OPENVINO_DEVICE=GPU
REM To run llama-simple:
build\ReleaseOV\bin\llama-simple.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf" -n 50 "The story of AI is "
REM To run in chat mode:
build\ReleaseOV\bin\llama-cli.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf" -c 1024
REM To run llama-bench:
build\ReleaseOV\bin\llama-bench.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf"
REM NPU: keep the context small.
set GGML_OPENVINO_DEVICE=NPU
build\ReleaseOV\bin\llama-cli.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf" -c 512
# Windows PowerShell
$env:GGML_OPENVINO_DEVICE = "GPU"
build\ReleaseOV\bin\llama-cli.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf" -c 1024
# NPU: keep the context small.
$env:GGML_OPENVINO_DEVICE = "NPU"
build\ReleaseOV\bin\llama-cli.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf" -c 512
Note
- Select the OpenVINO device with
GGML_OPENVINO_DEVICE, not with-dev.- On systems with multiple GPUs, use
GPU.0orGPU.1to explicitly target specific GPU.- To split a model across several GPUs, set a comma-separated list, e.g.
GPU.0,GPU.1, and use-sm layer.- A device that is not available is an error (no fallback to CPU). The error message lists the available OpenVINO devices with their names.
- Run
llama-cli --list-devicesto see the valid values: each OpenVINO device shows theGGML_OPENVINO_DEVICE=<value>to set, and(selected)marks the active one.- See OpenVINO GPU Device for more details.
5. Docker Build
You can build and run llama.cpp with OpenVINO backend using Docker.
Build the images
# Build the base runtime image with compiled shared libraries and minimal dependencies.
docker build -t llama-openvino:base -f .devops/openvino.Dockerfile .
# Build the complete image with all binaries, Python tools, gguf-py library, and model conversion utilities.
docker build --target=full -t llama-openvino:full -f .devops/openvino.Dockerfile .
# Build a minimal CLI-only image containing just the llama-cli executable.
docker build --target=light -t llama-openvino:light -f .devops/openvino.Dockerfile .
# Builds a server-only image with llama-server executable, health check endpoint, and REST API support.
docker build --target=server -t llama-openvino:server -f .devops/openvino.Dockerfile .
# If you are behind a proxy:
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --target=server -t llama-openvino:server -f .devops/openvino.Dockerfile .
Run a container (CPU, GPU, NPU)
Run llama.cpp with OpenVINO backend Docker container. Save sample models in ~/models as shown above. It will be mounted to the container in the examples below.
# Run Docker container
docker run --rm -it -v ~/models:/models llama-openvino:light --no-warmup -c 1024 -m /models/Llama-3.2-1B-Instruct-Q4_K_M.gguf
# With Intel GPU access (iGPU or dGPU)
docker run --rm -it -v ~/models:/models \
--device=/dev/dri --group-add=$(stat -c "%g" /dev/dri/render* | head -n 1) -u $(id -u):$(id -g) \
--env=GGML_OPENVINO_DEVICE=GPU \
llama-openvino:light --no-warmup -c 1024 -m /models/Llama-3.2-1B-Instruct-Q4_K_M.gguf
# With Intel NPU access
docker run --rm -it -v ~/models:/models \
--device=/dev/accel --group-add=$(stat -c "%g" /dev/accel/accel* | head -n 1) -u $(id -u):$(id -g) \
--env=GGML_OPENVINO_DEVICE=NPU \
llama-openvino:light --no-warmup -c 512 -m /models/Llama-3.2-1B-Instruct-Q4_K_M.gguf
Run llama-server (container or local build) and test it
# Run the llama-openvino:server Docker container (CPU)
docker run --rm -it -p 8080:8080 -v ~/models:/models llama-openvino:server --no-warmup -m /models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -c 1024 --host 0.0.0.0
# Run the llama-openvino:server Docker container with Intel GPU access (iGPU or dGPU)
docker run --rm -it -v ~/models:/models \
--device=/dev/dri --group-add=$(stat -c "%g" /dev/dri/render* | head -n 1) -u $(id -u):$(id -g) \
-p 8080:8080 --env=GGML_OPENVINO_DEVICE=GPU \
llama-openvino:server --no-warmup -c 1024 -m /models/Llama-3.2-1B-Instruct-Q4_K_M.gguf --host 0.0.0.0
# Run the llama-openvino:server Docker container with Intel NPU access
docker run --rm -it -v ~/models:/models \
--device=/dev/accel --group-add=$(stat -c "%g" /dev/accel/accel* | head -n 1) -u $(id -u):$(id -g) \
-p 8080:8080 --env=GGML_OPENVINO_DEVICE=NPU \
llama-openvino:server --no-warmup -c 512 -m /models/Llama-3.2-1B-Instruct-Q4_K_M.gguf --host 0.0.0.0
# Or Using llama-server executable
./build/ReleaseOV/bin/llama-server -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf --port 8080 -c 1024
# Option 1: Open your browser to http://localhost:8080 to open Llama Chat, the built-in chat app of the llama.cpp server.
# Option 2: In a NEW terminal, test the server with curl
# If you are behind a proxy, make sure to set NO_PROXY to avoid proxy for localhost
export NO_PROXY=localhost,127.0.0.1
# Test health endpoint
curl -f http://localhost:8080/health
# Test with a simple prompt
curl -X POST "http://localhost:8080/v1/chat/completions" -H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Write a poem about OpenVINO"}],"max_tokens":100}' | jq .
Runtime Configuration
The backend needs no environment variable: it runs on the CPU with its defaults. Set GGML_OPENVINO_DEVICE to use the GPU or the NPU. All other variables are optional.
export GGML_OPENVINO_DEVICE=GPU # String
export GGML_OPENVINO_PROFILING=1 # Integer
export GGML_OPENVINO_EXACT_ZERO_POINT=1 # Boolean: 1 (on) or 0 (off)
# Show the variables in effect (log verbosity 4)
./build/ReleaseOV/bin/llama-cli -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -c 1024 -lv 4 2>&1 | grep "settings from the environment"
- The backend reads the variables once, at start. Unset or empty means the default.
- To lower the memory a model needs, see Tips for Memory Optimization.
- A value that is not valid stops the backend. A
GGML_OPENVINO_*name that the backend does not know gives a warning:
ggml-openvino: GGML_OPENVINO_EXACT_ZERO_POINT=yes is not valid, use 1 (on) or 0 (off)
ggml-openvino: unknown environment variable GGML_OPENVINO_DEVCE is ignored
Basic
| Variable | Device | Type | Default | Description |
|---|---|---|---|---|
GGML_OPENVINO_DEVICE |
all | String | CPU |
Target device: CPU, GPU or NPU. For several GPUs, see the device notes. Examples: GGML_OPENVINO_DEVICE=NPU, GGML_OPENVINO_DEVICE=GPU.0,GPU.1. |
GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR |
all | String | not set |
Directory for the backend's cache of compiled models. A later start with the same model and settings loads faster. See Compiled model cache. Example: GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR=/tmp/ov_cache. |
GGML_OPENVINO_NPU_CONFIG |
NPU | String | not set |
OpenVINO properties for the NPU plugin, as comma-separated KEY=VALUE pairs. See Plugin properties. Example: GGML_OPENVINO_NPU_CONFIG="NPU_COMPILER_TYPE=PLUGIN". |
GGML_OPENVINO_GPU_CONFIG |
GPU | String | not set |
OpenVINO properties for the GPU plugin, as comma-separated KEY=VALUE pairs. See Plugin properties. Example: GGML_OPENVINO_GPU_CONFIG="INFERENCE_PRECISION_HINT=f16". |
GGML_OPENVINO_CPU_CONFIG |
CPU | String | not set |
OpenVINO properties for the CPU plugin, as comma-separated KEY=VALUE pairs. See Plugin properties. Example: GGML_OPENVINO_CPU_CONFIG="INFERENCE_PRECISION_HINT=f16". |
GGML_OPENVINO_PROFILING |
all | Integer | 0 |
1 logs execution timing. 2 or higher also turns on OpenVINO and OpenCL profiling. Example: GGML_OPENVINO_PROFILING=1. |
Plugin properties
GGML_OPENVINO_NPU_CONFIG, GGML_OPENVINO_GPU_CONFIG and GGML_OPENVINO_CPU_CONFIG pass OpenVINO plugin properties to the device in their name.
# Format: comma-separated KEY=VALUE pairs. The backend uses the variable of the selected device only.
export GGML_OPENVINO_DEVICE=NPU
export GGML_OPENVINO_NPU_CONFIG="NPU_COMPILER_TYPE=PLUGIN,COMPILATION_NUM_THREADS=4"
# CPU: compute in FP16, as the GPU and the NPU do. This helps to debug the accuracy of a quantized model.
export GGML_OPENVINO_DEVICE=CPU
export GGML_OPENVINO_CPU_CONFIG="INFERENCE_PRECISION_HINT=f16"
- Property names and values are those of OpenVINO, for example
YESandNO. They are not the1and0of theGGML_OPENVINO_*variables. - The backend applies the variable last, so it overrides the properties that the backend sets.
- OpenVINO checks the properties when the model loads. If it rejects one, the load fails and the error names the variable.
- All properties and their values are in the OpenVINO documentation: NPU device, GPU device, CPU device.
- NPU: the backend sets several properties by default. They are listed in the developer documentation.
- GPU and CPU: the backend sets no property, except
CACHE_DIRandCACHE_MODE=OPTIMIZE_SIZEwhenGGML_OPENVINO_CACHE_DIRis set.
NPU_COMPILER_TYPE selects the NPU compiler. Both forms below work; use the first one. If both are set, GGML_OPENVINO_NPU_CONFIG takes precedence.
# Values: DRIVER (the compiler in the NPU driver; backend default), PLUGIN (the compiler in OpenVINO),
# PREFER_PLUGIN (OpenVINO default: PLUGIN when it is available, DRIVER if not).
export GGML_OPENVINO_NPU_CONFIG="NPU_COMPILER_TYPE=PLUGIN" # recommended form
export GGML_OPENVINO_NPU_COMPILER_TYPE=PLUGIN # older name, still works
Advanced tuning
The defaults fit most models. The variables below trade one property for another, for example speed for accuracy.
Advanced tuning variables
| Variable | Device | Type | Default | Description |
|---|---|---|---|---|
GGML_OPENVINO_PREFILL_CHUNK_SIZE |
NPU | Integer | 256 |
Number of tokens that the NPU processes in one prefill step. A larger value can make long prompts faster, and makes the first load longer. Zero or a negative value means the default. Example: GGML_OPENVINO_PREFILL_CHUNK_SIZE=512. |
GGML_OPENVINO_NPU_TOKEN_EMBD_QUANT |
NPU | String | q8_0_c |
How a Q6_K token_embd.weight is stored for the NPU: q8_0_c (8-bit, one scale per row), f16, q4_0_128 (4-bit, one scale per 128 weights) or q4_0_c (4-bit, one scale per row). The 4-bit layouts use less memory at some cost in accuracy; f16 uses more memory. Keep the default unless memory is tight. |
GGML_OPENVINO_GDN_DECOMPOSE |
all | Boolean | auto | Translate GATED_DELTA_NET (Qwen3.5) into MatMul operations instead of the OpenVINO GatedDeltaNet op. Unset: on for the Lunar Lake NPU, off elsewhere. 0 turns it off, 1 turns it on for any device. Try 1 for Qwen3.5 on the Panther Lake NPU. |
GGML_OPENVINO_MANUAL_GQA_ATTN |
CPU, GPU | Boolean | on for GPU | Build grouped-query attention from separate MatMul operations. Unset: on for GPU, off for CPU and NPU. 1 turns it on, 0 turns it off. Try 1 on the CPU for faster decode. |
GGML_OPENVINO_REQUANT_KQUANT |
CPU, GPU | String | not set |
Requantize Q6_K and Q5_K weights to a 4-bit layout instead of Q8_0_C: faster decode for lower accuracy. One of q4_asym64, q4_asym64_all (also Q4_K), q4_sym128, q4_sym128_all (also Q4_K) or native (no requantization). On GPU with Q4_K_M files use q4_asym64_all, because q4_asym64 does not compile there. |
GGML_OPENVINO_EXACT_ZERO_POINT |
CPU, GPU | Boolean | 0 |
Keep the exact zero point of asymmetric weights (Q4_1, Q4_K, Q5_1, Q5_K) instead of rounding it to an integer. This improves accuracy and lowers speed. Use it when accuracy matters more than speed. |
Compiled model cache
The cache keeps compiled models on disk, so later starts of the same model load faster. Use the same model and the same settings in every run.
# CPU or GPU: the first run compiles the model and writes the cache. Later runs read it.
export GGML_OPENVINO_DEVICE=GPU
export GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR=/tmp/ov_cache
./build/ReleaseOV/bin/llama-cli -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -c 1024
# CPU or GPU, later runs (optional): require the cached model and skip the weight upload and the compilation.
export GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY=1
# NPU: add the weightless bank.
export GGML_OPENVINO_DEVICE=NPU
export GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR=/tmp/ov_cache
export GGML_OPENVINO_NPU_WEIGHTLESS_BANK=1
./build/ReleaseOV/bin/llama-cli -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -c 512
# NPU, later runs (optional): use less memory. The run fails if a cached model is missing.
export GGML_OPENVINO_SELF_CONTAINED_MMAP=1
Cache variables
| Variable | Device | Type | Default | Description |
|---|---|---|---|---|
GGML_OPENVINO_COMPILED_MODEL_CACHE_ONLY |
CPU, GPU | Boolean | 0 |
Require an existing cached model and skip the weight upload and the compilation. Needs mmap model loading (the default on Linux and Windows) and a model that runs fully on OpenVINO. |
GGML_OPENVINO_NPU_WEIGHTLESS_BANK |
NPU | Boolean | 0 |
Requires GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR. Write the prefill and decode models without weights, plus one shared weights file. Later runs read the weights from that file and keep one copy in memory. |
GGML_OPENVINO_SELF_CONTAINED_MMAP |
NPU | Boolean | 0 |
Later runs only. Requires GGML_OPENVINO_NPU_WEIGHTLESS_BANK=1 and an existing cache. Use the memory-mapped GGUF file as the model buffer, which lowers the host memory peak. Fails if a cached model is missing; run once without it to build the cache. |
GGML_OPENVINO_CACHE_DIR |
all | String | not set |
Directory for the cache of the OpenVINO plugin itself. GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR is the recommended cache. |
- One directory can hold the cached models of different models and settings.
- NPU: each prefill length enters the cache in a run without
GGML_OPENVINO_SELF_CONTAINED_MMAP. - See Compiled model cache for the workflow and the restrictions.
Deprecated
| Variable | Device | Type | Default | Description |
|---|---|---|---|---|
GGML_OPENVINO_STATEFUL_EXECUTION |
CPU, GPU | Boolean | 0 |
Deprecated, to be removed. Keep the KV cache inside the OpenVINO model. Use the default, stateless execution (0). |
Limits of stateful execution
- CPU and GPU only; it has no effect on the NPU.
- One slot only (
-np 1). - State save and restore, sequence rewind, context shift and recurrent rollback are not supported.
- Qwen3.5 needs a graph that runs fully on OpenVINO, with model caching on.
- A prompt that starts at position 0 resets all states.
Debugging and development
Debug output, switches that turn a default optimization off, experimental options and older variable names are in the developer documentation.
Example Usage
GPU Inference with Profiling
export GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR=/tmp/ov_cache
export GGML_OPENVINO_PROFILING=1
export GGML_OPENVINO_DEVICE=GPU
./build/ReleaseOV/bin/llama-simple -m ~/models/Llama-3.2-1B-Instruct-Q4_K_M.gguf -n 50 "The story of AI is "
Windows
REM Windows Command Prompt
set GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR=C:\tmp\ov_cache
set GGML_OPENVINO_PROFILING=1
set GGML_OPENVINO_DEVICE=GPU
build\ReleaseOV\bin\llama-simple.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf" -n 50 "The story of AI is "
# Windows PowerShell
$env:GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR = "C:\tmp\ov_cache"
$env:GGML_OPENVINO_PROFILING = "1"
$env:GGML_OPENVINO_DEVICE = "GPU"
build\ReleaseOV\bin\llama-simple.exe -m "C:\models\Llama-3.2-1B-Instruct-Q4_K_M.gguf" -n 50 "The story of AI is "
Known Limitations
General (all devices)
- Llama.cpp OpenVINO backend currently supports a subset of GGML ops and text-only models. Unsupported ops or unsupported op shapes/cases fail during OpenVINO translation.
- Multimodal features (audio/image/video) are a work in progress.
- Embedding models: reranking models are not validated.
- Llama.cpp tool coverage across CPU/GPU/NPU is not uniform.
- Mamba-based models (e.g. Falcon-H1):
llama-perplexitywith several sequences per batch fails; set-bto the same value as-c. GPU accuracy is slightly lower than CPU.
GPU-specific
-
Muse-Glimmer-30B with a DFlash draft needs a 64 GB system (peak about 45 GB of RAM):
export GGML_OPENVINO_DEVICE=GPU export GGML_OPENVINO_SPILL_DIR=$HOME/ov_spill # local disk, not tmpfs export GGML_OPENVINO_ROPE_F32_ANGLE=1 # long prompts mkdir -p $GGML_OPENVINO_SPILL_DIR ./build/ReleaseOV/bin/llama-server -m Muse-Glimmer-30B-Q4_K_M.gguf -md <dflash-draft>.gguf \ --spec-type draft-dflash --spec-draft-n-max 4 -
Multiple GPUs (
GGML_OPENVINO_DEVICE=GPU.0,GPU.1with-sm layer):-sm tensoris not supported.- Copies between GPUs go through host memory. There is no asynchronous copy and no peer-to-peer copy.
- Only GPUs can be combined. A list with several NPUs, or with a GPU and the CPU or the NPU, is rejected.
-
MoE models use the GPU plugin's fused MoE op, which runs in f16 only:
- granitemoe models (e.g.
granite-3.1-1b-a400m) give wrong output.- Workaround:
GGML_OPENVINO_MOE_OP=0. Output is correct, but prompt processing is much slower.
- Workaround:
GGML_OPENVINO_GPU_CONFIG="INFERENCE_PRECISION_HINT=f32"fails to compile.
- granitemoe models (e.g.
-
llama-perplexitywith MoE models: set-bto the same value as-c, so that each batch holds one sequence.
NPU-specific
- Default context resolves to the model's training context (e.g. 131072 for Llama 3.2 1B), which can OOM or fail or degrade performance on NPU. Inspect the resolved value with
-lv 3.- Workaround: Pass an explicit
-c <N>, e.g.-c 512.
- Workaround: Pass an explicit
- NPU device uses a static graph with a fixed prefill chunk size (defaults to 256), configurable with
GGML_OPENVINO_PREFILL_CHUNK_SIZE. Large prefill/batch settings may need tuning. llama-server -np > 1(multiple parallel sequences) is not supported.llama-perplexity: requires-b 512or smaller.- Flash attention must stay on, which is the default (
-fa auto). With-fa off, the run fails on the NPU. llama-embeddingfails on the NPU.- Mamba-based models (e.g. Falcon-H1) fail on the NPU with
Failed to set tensor(element type mismatch). - Lunar Lake NPU: decode slows down sharply when the context is large. The context size at which this starts depends on the model.
- Workaround: Pass the smallest context that fits the use, e.g.
-c 512, or-c 256for larger models.
- Workaround: Pass the smallest context that fits the use, e.g.
- Panther Lake NPU: the load of a Qwen3.5 model can end with a segmentation fault in the NPU compiler of OpenVINO 2026.4.1.
- Workaround: Set
GGML_OPENVINO_NPU_CONFIG=COMPILATION_NUM_THREADS=1.
- Workaround: Set
- Panther Lake NPU:
GGML_OPENVINO_NPU_TOKEN_EMBD_QUANT=f16andq4_0_128can give wrong output. Keep the default. - Lunar Lake NPU:
granite-4.0-1bgives wrong output. The activations of the model exceed the FP16 range, and the NPU computes in FP16. The model runs correctly on CPU and GPU. - Lunar Lake NPU:
gemma-4-12Bdoes not run. The first inference fails withZE_RESULT_ERROR_UNINITIALIZEDfrom 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.
Note
The OpenVINO backend is actively under development. Fixes and improvements are underway, and this document will continue to be updated.
Work in Progress
- Performance and memory optimizations
- Accuracy validation
- Broader quantization coverage
- Support for additional model architectures