metal: Q2_0 backend - #25419
Merged
Merged
Conversation
khosravipasha
force-pushed
the
pr/q2_0-metal
branch
from
July 8, 2026 21:03
60dac7f to
a315e40
Compare
Contributor
Author
|
rebased to fix some merge conflicts, few things were moved (e.g. |
Merged
Member
|
@khosravipasha Could you rebase to latest |
khosravipasha
force-pushed
the
pr/q2_0-metal
branch
from
July 13, 2026 19:47
a315e40 to
3e17d9c
Compare
Contributor
Author
|
@ggerganov thanks, rebased with recent master. Running the CI on our fork as well PrismML-Eng#60 |
Contributor
Author
|
This time more tests passed, some failures in ubuntu (x64, ubuntu-22.04). From glacing at it does not seem relate to this PR. |
ggerganov
approved these changes
Jul 14, 2026
CowboyTim
pushed a commit
to aardbeiplantje/llama.cpp
that referenced
this pull request
Jul 21, 2026
RehanQasim-dev
pushed a commit
to aifoundry-org/llama.cpp
that referenced
this pull request
Jul 23, 2026
RehanQasim-dev
pushed a commit
to aifoundry-org/llama.cpp
that referenced
this pull request
Jul 23, 2026
ggerganov
added a commit
that referenced
this pull request
Jul 28, 2026
forforever73
pushed a commit
that referenced
this pull request
Aug 4, 2026
smalinin
pushed a commit
to smalinin/llama.cpp
that referenced
this pull request
Aug 4, 2026
satindergrewal
pushed a commit
to satindergrewal/llama.cpp
that referenced
this pull request
Aug 12, 2026
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
Follow up PR after merging of
Q2_0CPU PR[#24448].This PR adds the Metal backend support for
Q2_0.Supported Models
Supported Models: Ternary-Bonsai-{8B, 4B, 1.7B}-Q2_0_g64.gguf, more coming very soon.
Note: In our huggingface repos ggufs ending with
_Q2_0_64.ggufare packed for this PR,Q2_0.ggufones are older packing from our fork that have group 128, after all backends merge will rename and replace with the official Q2_0(group size 64)).# downloads to models/Ternary-Bonsai-<size>-Q2_0_g64.gguf hf download prism-ml/Ternary-Bonsai-1.7B-gguf Ternary-Bonsai-1.7B-Q2_0_g64.gguf --local-dir models hf download prism-ml/Ternary-Bonsai-4B-gguf Ternary-Bonsai-4B-Q2_0_g64.gguf --local-dir models hf download prism-ml/Ternary-Bonsai-8B-gguf Ternary-Bonsai-8B-Q2_0_g64.gguf --local-dir modelsCorrectness: Metal vs CPU logits KL
The ensure correctness we run the model twice: 1) Q2_0 CPU 2) Q2_0 Metal. We store the logits for both and compare the KL divergence. Using the standard llama-perplexity tool.
Metal Q2_0 matches the CPU reference (Mean KLD ~0, top-1 ≥99.9%).
Speeds:
llama-benchMetalRequirements
I have read and agree with the contributing guidelines: Yes
AI usage disclosure: Initial boilerplate code for Metal kernels were generated with AI for Q2_0 group size 64, manually reviewed all changes, and verified correctness using KL-test as above. Have been using the packed models and its working well as expected. Tested again after rebasing with new changes to make sure model is behaving as expected.