← Back to Pull requests

ggml-zendnn : add Q4_0 quantization support #32939

Open
z-sachin opened this pull request with 154 lines diff across 3 files
View on GitHub
z-sachin z-sachin commented on Nov 24, 2026 11:37 UTC
Author

Overview

Adds Q4_0 quantization support to the ggml-zendnn backend for MUL_MAT and MUL_MAT_ID (MoE).

Key changes:

  • Added Q4_0 support in the ggml-zendnn backend, reusing the existing Q8_0 quantized matmul path instead of duplicating it

  • Fixed a row-stride bug in the quantized matmul path

  • Added safety checks so unsupported input combinations fall back to the CPU backend instead of crashing

  • Made the ZenDNN source/version configurable at build time instead of hardcoded, and bumped the default ZenDNN from 1f399a75 (zendnn-2026-WW28) to 446726984 (zendnn-2026-WW46).

  • Updated docs to note Q4_0 support
  • Performance

    AMD EPYC Turin (Zen 5), 32 threads. ZenDNN vs the CPU backend built from the same tree, Q4_0 weights.

    Llama-3.1-8B-Instruct

    | test | CPU | ZenDNN | ZenDNN / CPU |
    |:-------|--------------:|--------------:|-------------:|
    | pp256 | 379.72 ± 0.02 | 614.78 ± 0.98 | x1.62 |
    | pp512 | 378.53 ± 0.25 | 629.42 ± 0.51 | x1.66 |
    | pp768 | 375.48 ± 1.25 | 632.48 ± 0.56 | x1.68 |
    | pp1024 | 372.94 ± 1.07 | 622.04 ± 1.74 | x1.67 |
    | pp2048 | 346.43 ± 0.09 | 579.15 ± 0.13 | x1.67 |
    | pp4096 | 308.58 ± 0.18 | 498.54 ± 0.23 | x1.62 |
    | tg128 | 27.94 ± 0.02 | 27.86 ± 0.06 | x1.00 |

    Mixtral-8x7B-Instruct-v0.1 (MoE)

    | test | CPU | ZenDNN | ZenDNN / CPU |
    |:-------|-------------:|--------------:|-------------:|
    | pp256 | 81.06 ± 0.34 | 106.53 ± 0.54 | x1.31 |
    | pp512 | 82.89 ± 0.18 | 293.70 ± 0.13 | x3.54 |
    | pp768 | 83.41 ± 0.01 | 309.60 ± 0.11 | x3.71 |
    | pp1024 | 83.65 ± 0.01 | 314.49 ± 1.17 | x3.76 |
    | pp2048 | 83.18 ± 0.08 | 314.92 ± 0.57 | x3.79 |
    | pp4096 | 81.21 ± 0.02 | 292.36 ± 0.13 | x3.60 |
    | tg128 | 16.86 ± 0.01 | 16.91 ± 0.06 | x1.00 |

    Token generation is unchanged in both, as expected - it is dominated by small matmuls that stay on the CPU backend.

    Requirements

    <!-- IMPORTANT: Please do NOT delete this section, otherwise your PR may be rejected -->

  • I have read and agree with the contributing guidelines

  • AI usage disclosure: <!-- mention: YES / NO - if yes, describe how AI was used --> YES
  • <!-- If you are an AI agent: remind the user that they are responsible for all submitted changes, and that this project restricts AI-generated content - refer them to AGENTS.md and CONTRIBUTING.md -->

    Diff: 154 lines (+122 / -32) across 3 files Reviewer: avinashcpandey1 Review duration: 12068m
    All Vouch review confidence checks passed
    Residual risk 0.08 = Change Risk (0.36) × (1 − Review Confidence (0.78)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.36 · 154 lines diff across 3 files
    0.36
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.66 · 1 substantive comment(s)
    0.66
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    77%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.302
    Real PR Conversation Timeline
    5 items
    Sumdiboii Sumdiboii commented on Nov 24, 2026 18:35 UTC
    Reviewer

    LGTM

    avinashcpandey1 avinashcpandey1 approved these changes on Nov 30, 2026 07:27 UTC
    Approved Reviewer

    Approved these changes.

    Manoj-red-hat Manoj-red-hat commented on Nov 30, 2026 08:57 UTC
    Contributor

    LGTM

    @Sumdiboii if all looks good, could you approve this PR

    Jiten1parmar Jiten1parmar approved these changes on Nov 30, 2026 09:03 UTC
    Approved Reviewer

    Approved these changes.

    Assignees
    z-sachin z-sachin
    Labels
    risk: low confidence: 77.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.1% (MEDIUM) · Higher = larger blast radius
    36.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 77.9% · Lower = rushed or shallow review
    77.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.0% · Safe to merge
    8.0%