Repository navigation
Conversation
…ints Compressed fully connected layers with f16/bf16 decompression zero points fell back to OpenCL because oneDNN's default static_sazp mode requires integer zero points and computes w = scale * (q - zp). Use static_sbzp, which computes w = scale * q - zp'. Precomputing zp' = zp * scale preserves the exact dequantized weight while supporting non-integer zero points, as used by asymmetric formats such as GGUF Q4_K. In prepare_quantization, precompute the scaled zero points for eligible compressed FC layers with constant scales and zero points of the activations' type (f16/bf16), u4/i4/u8 weights, and at least two K-groups, and set the new decompression_zero_point_after_scale primitive flag. This is done only when oneDNN is used on the device. Update fully_connected_onednn to use static_sbzp when the flag is set, reject flagged primitives in the OpenCL implementations, and include the flag in primitive hashing, comparison, and serialization. Existing OpenCL behavior is preserved when oneDNN is disabled. Tests cover u4/u8 weights with group-32 f16 scales and non-integer f16 zero points across single-token and batched inference, static/dynamic shapes, 2D/3D inputs, cached networks, and the OpenCL fallback. They verify implementation selection, flag propagation, and exact dequantization accuracy, requiring at least 4x lower error than with a rounded zero point. Requires oneDNN with static_sbzp support (uxlfoundation/oneDNN#6218).
osabnis
force-pushed
the
gpu-fc-f16-zero-point
branch
from
October 14, 2026 18:44
2bad2f9 to
99e6e04
Compare
Write scaled zero points (`zp * scale`) directly in fbyx instead of the plain `[N, groups]` layout, avoiding a reorder and its extra copy during program build. This reduces peak GPU memory at decode depth 4096 on Intel Arc B390 by 52 MB for Llama-3.2 1B, 100 MB for Gemma-4 E2B, and 66 MB for Qwen3.5 4B with exact zero points. Values and KL divergence are unchanged. Add tests for shared scale/zero-point constants with and without oneDNN, verifying that oneDNN reads zero points directly from an fbyx constant without an intervening reorder.
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.
Details
Draft; depends on oneDNN: Requires
quantization_mode::static_sbzpfrom uxlfoundation/oneDNN#6218. This does not build with OpenVINO's current oneDNN version and can merge only after the upstream change is accepted and the submodule is updated. Related llama.cpp change: SDPA in f32 ravi9/llama.cpp#7.Problem: oneDNN's default
static_sazpmode requires integer zero points and computesw = scale * (q - zp). As a result, compressed FC layers with f16/bf16 zero points fall back to OpenCL. With exact zero points enabled (GGML_OPENVINO_EXACT_ZERO_POINT=1), 130 of 261 FC executions in a Gemma-4 decode usedfully_connected_gpu_gemvinstead of oneDNN.Motivation: GGUF Q4_K, Q4_1, Q5_1, and Q5_K use
w = d * q - m, corresponding to a generally non-integer zero pointm / d. Rounding this value introduces a systematic weight error and is a major contributor to the accuracy gap between the llama.cpp OpenVINO and CPU backends.Design: Use oneDNN's
static_sbzpmode, which computesw = scale * q - zp'. Settingzp' = zp * scalepreserves the exact dequantized weights.prepare_quantization: For eligible compressed FC layers with constant f16/bf16 scales and zero points, u4/i4/u8 weights, and at least two K-groups, precomputezp * scaleon the host and setdecompression_zero_point_after_scale. This is enabled only when oneDNN will be used on the device. Write the scaled zero points directly in the FC's fbyx layout to avoid an additional reorder and temporary copy during program build.fully_connected_onednn: Accept floating-point zero points when flagged and configurestatic_sbzp.Tests:
fully_connected_gpu_test.cpp,compressed_int{4,8}_f16_zp_*.Validation: Intel Arc B390 (Panther Lake), master
a54783c84ewith the rfcs: add a scales-before-zero-points quantization mode for matmul weights uxlfoundation/oneDNN#6218 prototype applied to the submodule. The branch is rebased onto405eb32bba; there are no GPU plugin changes between the two revisions.Tests:
*f16_zp*: 13/13 passed;*fully_connected*:*FullyConnected*: 1,195 passed, 31 skipped, 0 failed.Gemma-4: All 261 FC executions use oneDNN
jit:gemmwithGGML_OPENVINO_EXACT_ZERO_POINT=1.KL divergence vs. llama.cpp CPU backend (decode, context 1024):
Performance: llama.cpp
llama-bench, flash attention, median of 5 runs, tokens/s; all builds usea54783c84e. Each cell is rounded zero points (today's default) / exact zero points without this change / exact zero points with this change:This change brings exact zero points back to the speed of rounded ones: prefill 2.2–2.9x faster than without it, within 4% of rounded zero points, and decode at depth 4096 within 2%. Decode at depth 0 remains 1–4% slower than with rounded zero points, because f16 zero points add about 8% to the Q4_K weight bytes.
Peak GPU memory: At decode depth 4096, writing scaled zero points directly in their final layout reduces peak GPU memory by 52 MB for Llama-3.2 1B, 100 MB for Gemma-4 E2B, and 66 MB for Qwen3.5 4B. Exact zero points still require more memory than rounded zero points (1,292 vs. 1,242 MB for Llama-3.2 1B) because f16 zero points are larger than u4 zero points, and both the original and scaled values coexist while the program is built.
Tickets
AI Assistance