Repository navigation
Conversation
Add Metal backend support for GGML_OP_GATED_LINEAR_ATTN (GLA). Supports head_size 64 and 128, f32 only. Tested with test-backend-ops (7/7 passed): - M5 Max 128GB (Apple10) - M2 Mac Mini (Apple8)
|
Hi @TheTom, thanks for your contribution! Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:
Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below. |
Author
|
Duplicate of #21452. Closing in favor of the original PR which has been updated with the clean commit and fresh benchmarks. |
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.
Add Metal backend support for
GGML_OP_GATED_LINEAR_ATTN(GLA). Supports head_size 64 and 128, f32 only.Overview
Metal is currently the only major GPU backend without GLA support. Without this, RWKV6Qwen2 models fall back to CPU for this op on every layer, causing GPU/CPU sync overhead that hurts performance significantly on lower-end Apple Silicon.
The kernel follows the existing RWKV WKV6 Metal structure: one thread per head element, threadgroup shared memory for k/q/gate, and a float4-vectorized inner loop.
supports_oprestricts execution to f32 with head sizes 64 or 128.Correctness
test-backend-ops (7/7 passed on both devices):
Before (master a6cc43c):
After:
Performance
Benchmarked with QRWKV6-7B-Instruct Q4_K_M, llama-bench, 3 runs each.
M2 Mac Mini 32GB (Apple8)
M5 Max 128GB (Apple10)
The M5 Max has enough GPU bandwidth that GLA is not the bottleneck at this model size. The M2 Mini shows the real impact of CPU fallback: 5.3x on single-token prefill and 22.5% on decode.
Perplexity
wikitext-2, 5 chunks, ctx=512:
Zero quality impact.
Notes
docs/ops.mdanddocs/ops/Metal.csvregenerated usingtest-backend-ops support --output csvand./scripts/create_ops_docs.py.Mentions #14909
Requirements