File tree Expand file tree Collapse file tree
backends/mlx/custom_kernel_ops/gguf/q4k Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,8 +91,6 @@ def _q4k_matvec_source(has_bias: bool) -> str:
9191
9292 for (short row = 0; row < N_R0; ++row) {{
9393 const int r = first_row + row;
94- if (r >= N) {{ break; }}
95-
9694 device const block_q4_K * blk = xrows + (uint)r * nb + ib;
9795 device const uint16_t * sc = (device const uint16_t *)blk->scales + iq;
9896 device const uint16_t * q1 = (device const uint16_t *)blk->qs + 16 * iq + 4 * ir;
@@ -285,7 +283,9 @@ def _q4k_matmul_source(has_bias: bool) -> str:
285283
286284
287285# Number of simdgroups per threadgroup for the mat-vec kernel.
288- _Q4K_MV_NSG = 4
286+ # Matches llama.cpp N_SG_Q4_K=2; nsg=4 launched half as many (fatter) threadgroups,
287+ # hurting occupancy / wave-quantization tail on the bandwidth-bound decode matvec.
288+ _Q4K_MV_NSG = 2
289289# Tile sizes for the mat-mat kernel (from llama.cpp kernel_mul_mm).
290290_Q4K_MM_NR0 = 64 # weight/output rows (N dim) per threadgroup
291291_Q4K_MM_NR1 = 32 # activation rows (M dim) per threadgroup
You can’t perform that action at this time.
0 commit comments