metal : PTQ1_0 multi-column mat-vec for 5-8 columns - #277
Open
jasontitus wants to merge 1 commit into
Open
jasontitus wants to merge 1 commit into
jasontitus wants to merge 1 commit into
Conversation
GGML_METAL_PTQ1_MULTICOL=1 (PrismML-Eng#262) runs the PTQ1_0 multi-column kernel for 2-4 columns; 5-8 still take the generic mul_mv_ext path. This splits 5-8 columns into two tiles of at most four (5 -> 3+2, 6 -> 3+3, 7 -> 4+3, 8 -> 4+4) on the existing c2/c3/c4 kernels, so batched decode, MTP verification and multi-request steps up to eight tokens stay on it. - a partial last tile clamps its column reads to the last valid column and skips the writes past it; a bool function constant (FC_MUL_MV + 5) removes those checks when every tile is complete, so 2-4 columns compile to exactly the PrismML-Eng#262 kernel (logits bitwise identical) - GGML_METAL_PTQ1_MULTICOL_MAX (clamped to 4..8, default 8) caps the widths the kernel takes; 4 restores PrismML-Eng#262 - test-backend-ops: 5-7 columns with row tails and broadcast, and 5/7 with a strided B Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHqq1nTe46u7euASncLsee
jasontitus
added a commit
to jasontitus/llama.cpp
that referenced
this pull request
Sep 26, 2026
…(PQ2_0 two columns) measured and ready 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
#262 added
GGML_METAL_PTQ1_MULTICOL=1, a PTQ1_0 mat-vec for 2-4 columns; 5-8 columns still takemul_mv_ext. Batched decode, MTP verification and multi-request steps often produce 5-8 columns (4 requests with MTP draft 1 are 8).This PR splits 5-8 columns into two tiles of at most four (5 -> 3+2, 6 -> 3+3, 7 -> 4+3, 8 -> 4+4) on the existing c2/c3/c4 kernels:
FC_MUL_MV + 5) removes those checks when every tile is complete, so 2-4 columns compile to exactly the metal : add PTQ1_0 mat-vec for two to four columns #262 kernelGGML_METAL_PTQ1_MULTICOL_MAX(clamped to 4..8, default 8) caps the widths the kernel takes; 4 gives the metal : add PTQ1_0 mat-vec for two to four columns #262 behaviorAdditional information
M5 Max, Ternary Bonsai 2 27B PTQ1_0, this branch,
GGML_METAL_PTQ1_MULTICOL=1in both arms, max 4 (#262) vs max 8, three A-B-B-A quartets with 8 s cooldowns (tok/s; MTP rows are llama-server with draft-mtp, draft 1, aggregate, 128 greedy tokens):Generated tokens identical in every pair.
Correctness:
-o MUL_MAT: 1493/1493 with the switch off, on with max 4, on with max 8 (the partial-tile pipelines compile and run), and with an out-of-range max. New cases: 5-7 columns with row tails and broadcast, and 5 and 7 with a strided B.mul_mv_ext), max relative difference 3.7e-5, same top token at every position.Requirements