Repository navigation
perf: use native Metal matrix multiplication by default - #81
Merged
Merged
Conversation
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.
Metal inference previously rewrote eligible matrix products into matrix-vector products even with model-default activation precision, preventing ggml from selecting its faster native MM/MMA kernels.
Let ggml choose the native matrix or vector kernel by default, following llama.cpp's approach. Keep the existing vector-product fallback when explicit or model-required F32 activations must be preserved.
Validation
test-clap-c-api-allocation,test-clap-graph-pipeline,test-clap-tensor-ops, andtest-clap-tensor-ops-cpu.larger_clap_general-q4_k_m.gguf, text querydog: a 32-file ESC-50 subset took 18.57 s → 5.84 s median over three runs per version (3.18× throughput).esc5directory completed in 338.65 s. The top-ten paths and order matched the original implementation.Precision
Native Metal matrix kernels can round operands to F16 despite F32 accumulation. The maximum observed cosine-score difference was approximately 0.000719; some close results changed order in the 32-file subset. Explicit/model-required F32 activation behavior retains the original fallback.
Full-directory timing is reported separately from the subset speedup; the original full-directory run was interrupted by measurement pauses and is not used for a full-directory speedup claim.