metal : static-K32 tensor mul_mm for full-tile Q1_0 products (GGML_METAL_Q1_MM_K32=1) - #280
Open
jasontitus wants to merge 1 commit into
Open
jasontitus wants to merge 1 commit into
jasontitus wants to merge 1 commit into
Conversation
…1_MM_K32=1) Assisted-by: Claude Opus 5.5
jasontitus
force-pushed
the
downstream/metal-q1-mm-k32
branch
from
September 26, 2026 04:51
32145a9 to
96c3886
Compare
jasontitus
added a commit
to jasontitus/llama.cpp
that referenced
this pull request
Sep 26, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHqq1nTe46u7euASncLsee
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
On devices with tensor units (M5, A19), Q1_0 prompt processing runs on the tensor
kernel_mul_mm, whose K extent is dynamic and whose loads and store are clamped for partial tiles. This adds an opt-in variant,GGML_METAL_Q1_MM_K32=1, for Q1_0 products made only of full tiles (M % 64, N % 128 and K % 32 all zero, all contiguous): a static K32 extent and no bounds handling. The same threads dequantize the same 16-weight chunks in the same K order with the samematmul2d; only the static extents and the whole-tile store differ. Any remainder keeps the whole product on the generic kernel. The kernel sits in theGGML_METAL_HAS_TENSORbranch ofmul_mm.metal. Off by default.Additional information
M5 Max, Bonsai 27B Q1_0, this branch, switch off vs on, three A-B-B-A quartets with 8 s cooldowns (tok/s, llama-bench):
Correctness:
-o MUL_MAT: all pass with the switch off and on; the K32 kernel runs for two new full-tile cases (plain, and batched with broadcast).Requirements