mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2609] [CLOSED] Metal: faster decode GEMVs on M1 / M2 (wider K-quant and IQ4_XS loads, tuned tiles), bitwise the same output #4163
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4163
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/2609
Author: @PiMatyja
Created: 10/15/2026
Status: ❌ Closed
Base:
main← Head:metal-m1m2-gemv📝 Commits (1)
1c388bdMetal: faster decode GEMVs on M1 / M2 (wider K-quant and IQ4_XS loads, tuned tiles), bitwise the same output📊 Changes
5 files changed (+422 additions, -24 deletions)
View changed files
➕
metal/kernels/gemv_wide.metal(+124 -0)📝
metal/src/engine/window.cpp(+99 -19)📝
metal/src/mtl_rt.h(+2 -0)📝
metal/src/mtl_rt.mm(+5 -0)📝
metal/tests/gemv_parity.cpp(+192 -5)📄 Description
Summary
Wider loads for the Q4_K, Q5_K, Q6_K and IQ4_XS decoders and a tuned tile choice for the dense decode GEMVs, on M1 and M2 only (Apple GPU family 7 and 8). On an M2 Max with IQ3_XXS, decode is about 11% faster and the output is bitwise the same. M3 and newer build exactly what they build today.
What changed
metal/kernels/gemv_wide.metal(new): the wide decoders, reusinggemv.metal's templates under new kernel names.metal/src/engine/window.cpp: on M1 / M2, adds that file and picks a tuned tile for 1-3 token windows. The tile never changes the summation order. If a tuned kernel is missing, too big for threadgroup memory, or the tensor isn't 16-byte aligned, it falls back to today's tile.metal/src/mtl_rt.h/.mm:max_threadgroup_memory()andhas_function().metal/tests/gemv_parity.cpp: checks every new kernel bitwise against its stock twin; new--sweep.STRATA_METAL_GEMV=0turns it off.units.metal,quant.metalandgemv.metalare untouched, so no other kernel changes on any GPU.Extra Notes
M2 Max (30-core GPU), 64 GB, macOS 26.4.1, IQ3_XXS resident (with #2338), greedy, 3 rounds, decode tok/s:
Same text in both arms on all four prompts. Prompt speed unchanged.
gemv_parityandgemv_parity --sweeppass bitwise on the M2 and on an M4 Max, and the other parity tests match main. Not tested on an M1.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.