Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions mlx/backend/metal/quantized.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ inline array ensure_row_contiguous_matrix(
inline int get_qmv_batch_limit(int D, int O, metal::Device& d) {
auto arch_size = d.get_architecture().back();
auto arch_gen = d.get_architecture_gen();
// M5-generation GPUs run the qmv_wide kernels efficiently at larger row
// counts than the generic fallback assumes. Measured on M5 Max (g17s),
// 4-bit and 8-bit affine weights (group_size 64), D=8192 with
// O in {1024, 8192, 28672, 250112}: qmv_wide is ~18% faster than the qmm
// path at M=12 and still ahead at M=16. This mostly benefits speculative
// decoding verification (see #3553 for the small-M step it mitigates).
if (arch_gen >= 17 && arch_size != 'd') {
if (D <= 2048 && O <= 2048) {
return 18;
} else if (D <= 4096 && O <= 4096) {
return 12;
} else {
return 16;
}
}
if (arch_gen == 13 || arch_gen == 14) {
switch (arch_size) {
case 'd':
Expand Down