Repository navigation
Conversation
Asymmetric quantized weights (Q4_K, Q4_1, Q5_1, and non-requantized Q5_K) represent each group as `w = d * q - m`. The backend currently converts these to u4/u8 weights with an f16 scale and an integer zero point `round(m / d)`, which can shift all weights in a group by up to half a quantization step. Add `GGML_OPENVINO_EXACT_ZERO_POINT=1` to preserve the zero point in f16 instead, using the same path already used for MoE expert weights. This is disabled by default because, with current OpenVINO releases, an f16 zero point moves many GPU fully-connected layers off oneDNN, resulting in slower prompt processing.
Author
|
Note on merging: The switch is off by default, so the default behavior and output remain unchanged. This can therefore be merged as soon as it is approved. Enabling it by default should wait until an OpenVINO release includes both the oneDNN support for f16 zero points and the corresponding GPU plugin change. Without those changes, enabling the switch slows down prompt processing without providing a prompt-accuracy improvement (see the numbers in the description). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
The OpenVINO backend converts asymmetric quantized weights (Q4_K, Q4_1, Q5_1, and non-requantized Q5_K) to u4/u8 weights with an f16 scale and an integer zero point,
round(m / d). Rounding the zero point shifts every weight in a group in the same direction by up to half a quantization step. For Q4_K on Gemma-4 and Llama, this corresponds to about 8.3% relative weight error and is the primary source of the accuracy gap between the OpenVINO GPU backend and the CPU backend.This PR adds
GGML_OPENVINO_EXACT_ZERO_POINT. When enabled, asymmetric quantized weights retain the exact f16 zero point,m / d, matching the existing path used for MoE expert weights. The graph remains aSubtractfollowed by aMultiply, so the fully-connected weight compression pattern is unchanged.A new helper,
ggml_openvino_use_exact_zero_point(), replaces the expert-only check in the three places that must agree on the weight layout: the buffer layout (f16 zero-point slot),process_weight_tensor, andextract_quantized_weights. The setting is also registered in the environment registry, model-cache settings, anddocs/backend/OPENVINO.md.The option is off by default, so default behavior and output are unchanged.
Accuracy
KL divergence of the next-token distribution against the CPU backend at context 1024 using GGUF Q4_K_M on Arc B390. Decode uses one token per batch; prompt uses 1024-token batches. OpenVINO results use master with f16 zero points enabled on the oneDNN path (see Additional information). Vulkan results use ggml-org b11236 on the same system.
For decode, the percentage of cases where the OpenVINO backend selects the same top token as the CPU backend improves substantially with exact zero points:
Phi-4 mini still has a gap relative to Vulkan because its output layer is requantized to 8-bit; that path is outside the scope of this PR.
Why it is opt-in
With current OpenVINO releases, the GPU plugin does not accept an f16 zero point on its oneDNN fully-connected path, so many of these layers fall back to an OpenCL kernel (130 of 261 fully-connected operations in a Gemma-4 decode step).
On OpenVINO master without the oneDNN and GPU-plugin changes described below, enabling exact zero points results in:
With f16 zero-point support in oneDNN and the GPU plugin, all fully-connected layers remain on the oneDNN
jit:gemmpath. For example, all 261/261 fully-connected operations in a Gemma-4 decode step use oneDNN. With that support, exact zero points cost 1–2% of decode throughput at 1k context, prompt processing stays within measurement noise, and peak GPU memory grows by at most 0.23 GB.Testing
test-backend-ops teston GPU: 8024/8024 passed with the switch both disabled and enabled.Additional information
The GPU performance and prompt-accuracy results above require two changes outside llama.cpp:
Once an OpenVINO release contains both changes,
GGML_OPENVINO_EXACT_ZERO_POINTcan be considered for enabling by default.Requirements