whispercpp 1.3.7 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/ext/options.rb +1 -1
  4. data/ext/ruby_whisper.c +0 -1
  5. data/ext/ruby_whisper.h +7 -1
  6. data/ext/ruby_whisper_context.c +50 -1
  7. data/ext/ruby_whisper_log_settable.h +1 -2
  8. data/ext/ruby_whisper_params.c +9 -8
  9. data/ext/ruby_whisper_transcribe.cpp +0 -19
  10. data/ext/ruby_whisper_vad_context.c +30 -10
  11. data/ext/ruby_whisper_vad_context_detect.cpp +8 -9
  12. data/ext/ruby_whisper_vad_params.c +4 -4
  13. data/ext/ruby_whisper_vad_segment.c +2 -2
  14. data/ext/sources/CMakeLists.txt +2 -1
  15. data/ext/sources/cmake/parakeet.pc.in +2 -2
  16. data/ext/sources/cmake/whisper.pc.in +2 -2
  17. data/ext/sources/examples/cli/cli.cpp +9 -1
  18. data/ext/sources/examples/common-ggml.cpp +2 -0
  19. data/ext/sources/examples/vad-speech-segments/speech.cpp +3 -2
  20. data/ext/sources/ggml/CMakeLists.txt +3 -4
  21. data/ext/sources/ggml/include/ggml-cuda.h +0 -3
  22. data/ext/sources/ggml/include/ggml-sycl.h +8 -0
  23. data/ext/sources/ggml/include/ggml.h +3 -1
  24. data/ext/sources/ggml/src/CMakeLists.txt +8 -1
  25. data/ext/sources/ggml/src/ggml-backend-meta.cpp +7 -4
  26. data/ext/sources/ggml/src/ggml-common.h +13 -2
  27. data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +1 -1
  28. data/ext/sources/ggml/src/ggml-cpu/amx/mmq.cpp +5 -6
  29. data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +78 -4
  30. data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +142 -4
  31. data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +7 -2
  32. data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +14 -0
  33. data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +26 -19
  34. data/ext/sources/ggml/src/ggml-cpu/ops.cpp +129 -46
  35. data/ext/sources/ggml/src/ggml-cpu/quants.c +51 -0
  36. data/ext/sources/ggml/src/ggml-cpu/quants.h +3 -0
  37. data/ext/sources/ggml/src/ggml-cpu/simd-gemm.h +1 -1
  38. data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +11 -0
  39. data/ext/sources/ggml/src/ggml-cpu/vec.cpp +2 -2
  40. data/ext/sources/ggml/src/ggml-cuda/binbcast.cu +90 -46
  41. data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
  42. data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
  43. data/ext/sources/ggml/src/ggml-cuda/common.cuh +4 -0
  44. data/ext/sources/ggml/src/ggml-cuda/concat.cu +33 -21
  45. data/ext/sources/ggml/src/ggml-cuda/conv-transpose-1d.cu +14 -12
  46. data/ext/sources/ggml/src/ggml-cuda/convert.cu +86 -34
  47. data/ext/sources/ggml/src/ggml-cuda/cpy.cu +80 -29
  48. data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +9 -5
  49. data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +4 -0
  50. data/ext/sources/ggml/src/ggml-cuda/fattn-tile.cuh +9 -5
  51. data/ext/sources/ggml/src/ggml-cuda/fattn.cu +27 -21
  52. data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cu +40 -25
  53. data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cuh +10 -0
  54. data/ext/sources/ggml/src/ggml-cuda/getrows.cu +15 -12
  55. data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +718 -1248
  56. data/ext/sources/ggml/src/ggml-cuda/mmq.cu +7 -0
  57. data/ext/sources/ggml/src/ggml-cuda/mmvq.cu +77 -40
  58. data/ext/sources/ggml/src/ggml-cuda/out-prod.cu +55 -12
  59. data/ext/sources/ggml/src/ggml-cuda/set-rows.cu +64 -4
  60. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +1 -0
  61. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +1 -0
  62. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +1 -0
  63. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +1 -0
  64. data/ext/sources/ggml/src/ggml-cuda/topk-moe.cu +7 -1
  65. data/ext/sources/ggml/src/ggml-cuda/vendors/hip.h +1 -0
  66. data/ext/sources/ggml/src/ggml-cuda/vendors/musa.h +1 -0
  67. data/ext/sources/ggml/src/ggml-hexagon/CMakeLists.txt +0 -5
  68. data/ext/sources/ggml/src/ggml-hexagon/ggml-hexagon.cpp +1634 -1293
  69. data/ext/sources/ggml/src/ggml-hexagon/htp/CMakeLists.txt +11 -40
  70. data/ext/sources/ggml/src/ggml-hexagon/htp/cmake-toolchain.cmake +13 -15
  71. data/ext/sources/ggml/src/ggml-hexagon/htp/concat-ops.c +1 -1
  72. data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.c +1749 -399
  73. data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.h +303 -0
  74. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-common.h +80 -0
  75. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-dma.h +26 -23
  76. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-profile.h +64 -0
  77. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-utils.h +1 -83
  78. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-fa-kernels.h +555 -0
  79. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-mm-kernels-tiled.h +1303 -0
  80. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.c +9 -0
  81. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.h +27 -4
  82. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-utils.h +59 -37
  83. data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ctx.h +11 -3
  84. data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ops.h +52 -12
  85. data/ext/sources/ggml/src/ggml-hexagon/htp/htp-vtcm.h +19 -0
  86. data/ext/sources/ggml/src/ggml-hexagon/htp/htp_iface.idl +2 -1
  87. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-base.h +14 -30
  88. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-exp.h +39 -0
  89. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-fa-kernels.h +232 -0
  90. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-flat.h +1511 -0
  91. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-tiled.h +1200 -0
  92. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-sigmoid.h +39 -0
  93. data/ext/sources/ggml/src/ggml-hexagon/htp/main.c +127 -32
  94. data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.c +3023 -4425
  95. data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.h +650 -0
  96. data/ext/sources/ggml/src/ggml-hexagon/htp/rope-ops.c +48 -13
  97. data/ext/sources/ggml/src/ggml-hexagon/htp/ssm-conv.c +10 -9
  98. data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.c +15 -3
  99. data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.h +8 -0
  100. data/ext/sources/ggml/src/ggml-hexagon/htp-opnode.h +168 -50
  101. data/ext/sources/ggml/src/ggml-hexagon/libggml-htp.inf +0 -4
  102. data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +5 -0
  103. data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.cpp +69 -5
  104. data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.h +4 -1
  105. data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.m +27 -6
  106. data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +38 -0
  107. data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.cpp +132 -2
  108. data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.h +2 -0
  109. data/ext/sources/ggml/src/ggml-metal/ggml-metal.metal +345 -87
  110. data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +13 -0
  111. data/ext/sources/ggml/src/ggml-opencl/fa_tune.h +92 -0
  112. data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +4060 -357
  113. data/ext/sources/ggml/src/ggml-opencl/kernels/cvt.cl +198 -0
  114. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f16.cl +81 -41
  115. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32.cl +88 -39
  116. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_f16.cl +1995 -96
  117. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q4_0.cl +1615 -0
  118. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q8_0.cl +1486 -0
  119. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_pre_f16.cl +156 -0
  120. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32_ns.cl +74 -6
  121. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_f32_ns.cl +74 -6
  122. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_1_f32_ns.cl +74 -6
  123. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_f32_ns.cl +71 -6
  124. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_0_f32_ns.cl +74 -6
  125. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_1_f32_ns.cl +74 -6
  126. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_k_f32_ns.cl +74 -6
  127. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_f32_ns.cl +74 -6
  128. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q1_0_f32.cl +94 -0
  129. data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q1_0_f32.cl +121 -0
  130. data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q8_0_f32.cl +1 -1
  131. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mm_q1_0_f32_l4_lm.cl +156 -0
  132. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +1149 -0
  133. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32.cl +141 -0
  134. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32_flat.cl +190 -0
  135. data/ext/sources/ggml/src/ggml-opencl/kernels/norm.cl +5 -2
  136. data/ext/sources/ggml/src/ggml-opencl/kernels/set_rows.cl +500 -0
  137. data/ext/sources/ggml/src/ggml-opencl/libdl.h +79 -0
  138. data/ext/sources/ggml/src/ggml-openvino/.clang-format +0 -5
  139. data/ext/sources/ggml/src/ggml-openvino/CMakeLists.txt +2 -4
  140. data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.cpp +733 -130
  141. data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.h +76 -23
  142. data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.cpp +57 -3
  143. data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.h +29 -8
  144. data/ext/sources/ggml/src/ggml-openvino/ggml-openvino.cpp +307 -59
  145. data/ext/sources/ggml/src/ggml-openvino/ggml-quants.cpp +66 -0
  146. data/ext/sources/ggml/src/ggml-openvino/ggml-quants.h +10 -4
  147. data/ext/sources/ggml/src/ggml-openvino/openvino/decoder.h +56 -16
  148. data/ext/sources/ggml/src/ggml-openvino/openvino/frontend.h +1 -1
  149. data/ext/sources/ggml/src/ggml-openvino/openvino/input_model.h +4 -4
  150. data/ext/sources/ggml/src/ggml-openvino/openvino/node_context.h +94 -37
  151. data/ext/sources/ggml/src/ggml-openvino/openvino/op/add_id.cpp +76 -0
  152. data/ext/sources/ggml/src/ggml-openvino/openvino/op/argsort.cpp +47 -0
  153. data/ext/sources/ggml/src/ggml-openvino/openvino/op/clamp.cpp +33 -0
  154. data/ext/sources/ggml/src/ggml-openvino/openvino/op/concat.cpp +48 -0
  155. data/ext/sources/ggml/src/ggml-openvino/openvino/op/cont.cpp +8 -16
  156. data/ext/sources/ggml/src/ggml-openvino/openvino/op/cpy.cpp +14 -1
  157. data/ext/sources/ggml/src/ggml-openvino/openvino/op/div.cpp +146 -0
  158. data/ext/sources/ggml/src/ggml-openvino/openvino/op/flash_attn_ext.cpp +108 -21
  159. data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.cpp +282 -0
  160. data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.hpp +65 -0
  161. data/ext/sources/ggml/src/ggml-openvino/openvino/op/get_rows.cpp +2 -9
  162. data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_geglu.cpp +21 -7
  163. data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_swiglu.cpp +41 -8
  164. data/ext/sources/ggml/src/ggml-openvino/openvino/op/im2col.cpp +120 -0
  165. data/ext/sources/ggml/src/ggml-openvino/openvino/op/l2_norm.cpp +44 -0
  166. data/ext/sources/ggml/src/ggml-openvino/openvino/op/mul_mat_id.cpp +226 -0
  167. data/ext/sources/ggml/src/ggml-openvino/openvino/op/mulmat.cpp +19 -9
  168. data/ext/sources/ggml/src/ggml-openvino/openvino/op/norm.cpp +58 -0
  169. data/ext/sources/ggml/src/ggml-openvino/openvino/op/pad.cpp +95 -0
  170. data/ext/sources/ggml/src/ggml-openvino/openvino/op/permute.cpp +58 -13
  171. data/ext/sources/ggml/src/ggml-openvino/openvino/op/repeat.cpp +74 -0
  172. data/ext/sources/ggml/src/ggml-openvino/openvino/op/reshape.cpp +13 -6
  173. data/ext/sources/ggml/src/ggml-openvino/openvino/op/rms_norm.cpp +1 -1
  174. data/ext/sources/ggml/src/ggml-openvino/openvino/op/rope.cpp +134 -38
  175. data/ext/sources/ggml/src/ggml-openvino/openvino/op/set_rows.cpp +3 -3
  176. data/ext/sources/ggml/src/ggml-openvino/openvino/op/softmax.cpp +126 -49
  177. data/ext/sources/ggml/src/ggml-openvino/openvino/op/ssm_conv.cpp +59 -0
  178. data/ext/sources/ggml/src/ggml-openvino/openvino/op/sum_rows.cpp +27 -0
  179. data/ext/sources/ggml/src/ggml-openvino/openvino/op/transpose.cpp +32 -1
  180. data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_silu.cpp +1 -1
  181. data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_softplus.cpp +38 -0
  182. data/ext/sources/ggml/src/ggml-openvino/openvino/op/view.cpp +90 -25
  183. data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.cpp +41 -23
  184. data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.h +18 -5
  185. data/ext/sources/ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.h +1 -1
  186. data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.cpp +43 -40
  187. data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.h +5 -4
  188. data/ext/sources/ggml/src/ggml-openvino/openvino/utils.cpp +548 -3
  189. data/ext/sources/ggml/src/ggml-openvino/openvino/utils.h +28 -26
  190. data/ext/sources/ggml/src/ggml-openvino/utils.cpp +383 -94
  191. data/ext/sources/ggml/src/ggml-openvino/utils.h +11 -8
  192. data/ext/sources/ggml/src/ggml-quants.c +76 -0
  193. data/ext/sources/ggml/src/ggml-quants.h +3 -0
  194. data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +5 -5
  195. data/ext/sources/ggml/src/ggml-sycl/backend.hpp +2 -0
  196. data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +12 -0
  197. data/ext/sources/ggml/src/ggml-sycl/col2im-1d.cpp +102 -0
  198. data/ext/sources/ggml/src/ggml-sycl/col2im-1d.hpp +8 -0
  199. data/ext/sources/ggml/src/ggml-sycl/common.cpp +6 -8
  200. data/ext/sources/ggml/src/ggml-sycl/common.hpp +19 -2
  201. data/ext/sources/ggml/src/ggml-sycl/concat.cpp +21 -1
  202. data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.cpp +158 -0
  203. data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.hpp +10 -0
  204. data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.cpp +125 -0
  205. data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.hpp +10 -0
  206. data/ext/sources/ggml/src/ggml-sycl/conv2d.cpp +150 -0
  207. data/ext/sources/ggml/src/ggml-sycl/conv2d.hpp +10 -0
  208. data/ext/sources/ggml/src/ggml-sycl/conv3d.cpp +224 -0
  209. data/ext/sources/ggml/src/ggml-sycl/conv3d.hpp +8 -0
  210. data/ext/sources/ggml/src/ggml-sycl/convert.cpp +6 -0
  211. data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +706 -0
  212. data/ext/sources/ggml/src/ggml-sycl/cpy.hpp +281 -0
  213. data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.cpp +255 -0
  214. data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.hpp +7 -0
  215. data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +15 -0
  216. data/ext/sources/ggml/src/ggml-sycl/dmmv.cpp +492 -319
  217. data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +15 -7
  218. data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +215 -115
  219. data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +2 -0
  220. data/ext/sources/ggml/src/ggml-sycl/ggml-sycl.cpp +1006 -336
  221. data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +252 -67
  222. data/ext/sources/ggml/src/ggml-sycl/mmvq.hpp +17 -0
  223. data/ext/sources/ggml/src/ggml-sycl/norm.cpp +103 -49
  224. data/ext/sources/ggml/src/ggml-sycl/outprod.cpp +45 -9
  225. data/ext/sources/ggml/src/ggml-sycl/pool.cpp +185 -0
  226. data/ext/sources/ggml/src/ggml-sycl/pool.hpp +22 -0
  227. data/ext/sources/ggml/src/ggml-sycl/presets.hpp +3 -1
  228. data/ext/sources/ggml/src/ggml-sycl/set_rows.cpp +10 -2
  229. data/ext/sources/ggml/src/ggml-sycl/softmax.cpp +9 -10
  230. data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +35 -0
  231. data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +5 -0
  232. data/ext/sources/ggml/src/ggml-vulkan/ggml-vulkan.cpp +833 -215
  233. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/col2im_1d.comp +61 -0
  234. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_mm.comp +1 -1
  235. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv3d_mm.comp +431 -0
  236. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/diag.comp +3 -3
  237. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +1 -0
  238. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +1 -0
  239. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.glsl +21 -19
  240. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_back.comp +25 -0
  241. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl +23 -4
  242. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.glsl +14 -18
  243. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +4 -7
  244. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vecq.comp +21 -24
  245. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +31 -23
  246. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +6 -5
  247. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_funcs.glsl +84 -67
  248. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +10 -10
  249. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +3 -3
  250. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/roll.comp +3 -3
  251. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tri.comp +3 -3
  252. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/unary.comp +168 -0
  253. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +121 -74
  254. data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp +26 -19
  255. data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu.cpp +31 -36
  256. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/common_decls.tmpl +16 -2
  257. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_split.wgsl +7 -7
  258. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/get_rows.wgsl +21 -0
  259. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_decls.tmpl +439 -320
  260. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id_vec.wgsl +2 -2
  261. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec.wgsl +45 -39
  262. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_acc.tmpl +586 -465
  263. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_q_acc.tmpl +63 -69
  264. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/quantize_q8.wgsl +14 -9
  265. data/ext/sources/ggml/src/ggml.c +36 -14
  266. data/ext/sources/include/whisper.h +21 -0
  267. data/ext/sources/src/whisper.cpp +164 -14
  268. data/lib/whisper/log_settable.rb +5 -8
  269. data/lib/whisper/model/uri.rb +0 -7
  270. data/sig/whisper.rbs +6 -0
  271. data/test/test_vad.rb +9 -0
  272. data/test/test_vad_context.rb +2 -2
  273. data/whispercpp.gemspec +1 -1
  274. metadata +62 -37
  275. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-flash-attn-ops.c +0 -1878
  276. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-matmul-ops.c +0 -2066
  277. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.c +0 -6
  278. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.h +0 -88
  279. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-profile.h +0 -34
  280. data/ext/sources/ggml/src/ggml-hexagon/htp/vtcm-utils.h +0 -16
  281. data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_gelu.cpp +0 -25
  282. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/abs.comp +0 -21
  283. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/ceil.comp +0 -22
  284. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/clamp.comp +0 -17
  285. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/cos.comp +0 -17
  286. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/elu.comp +0 -27
  287. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/exp.comp +0 -20
  288. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/floor.comp +0 -22
  289. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp +0 -25
  290. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_erf.comp +0 -39
  291. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp +0 -23
  292. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardsigmoid.comp +0 -22
  293. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardswish.comp +0 -22
  294. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/leaky_relu.comp +0 -22
  295. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/neg.comp +0 -20
  296. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/relu.comp +0 -21
  297. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/round.comp +0 -29
  298. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sgn.comp +0 -21
  299. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp +0 -20
  300. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/silu.comp +0 -22
  301. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sin.comp +0 -17
  302. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/softplus.comp +0 -23
  303. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sqrt.comp +0 -17
  304. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/square.comp +0 -17
  305. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/step.comp +0 -22
  306. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp +0 -20
  307. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/trunc.comp +0 -22
  308. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/xielu.comp +0 -35
@@ -256,13 +256,6 @@ static void convert_mul_mat_vec_bf16_sycl(const void *vx, const dfloat *y,
256
256
  }
257
257
  #endif
258
258
 
259
- /*
260
- DPCT1110:4: The total declared local variable size in device function
261
- dequantize_mul_mat_vec_q2_k exceeds 128 bytes and may cause high register
262
- pressure. Consult with your hardware vendor to find the total register size
263
- available and adjust the code, or use smaller sub-group size to avoid high
264
- register pressure.
265
- */
266
259
  static void dequantize_mul_mat_vec_q2_k(const void *__restrict__ vx,
267
260
  const float *__restrict__ yy,
268
261
  float *__restrict__ dst,
@@ -284,19 +277,15 @@ static void dequantize_mul_mat_vec_q2_k(const void *__restrict__ vx,
284
277
 
285
278
  #if QK_K == 256
286
279
  const int tid =
287
- item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...31 or 0...15
280
+ item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...7 or 0...15
288
281
  const int ix =
289
282
  item_ct1.get_local_id(2) % K_QUANTS_PER_ITERATION; // 0 or 0,1
290
283
 
291
284
  const int step = 16/K_QUANTS_PER_ITERATION;
292
285
 
293
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
294
- const int in = tid - step*im; // 0...15 or 0...7
286
+ const int in = tid % step; // 0...15 or 0...7
295
287
 
296
288
  const int l0 = K_QUANTS_PER_ITERATION*in; // 0...15 or 0...14 in steps of 2
297
- const int q_offset = 32*im + l0;
298
- const int s_offset = 8*im;
299
- const int y_offset = 128*im + l0;
300
289
 
301
290
  uint32_t aux[4];
302
291
  const uint8_t * d = (const uint8_t *)aux;
@@ -304,33 +293,39 @@ static void dequantize_mul_mat_vec_q2_k(const void *__restrict__ vx,
304
293
 
305
294
  for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
306
295
 
307
- const float * y = yy + i * QK_K + y_offset;
308
- const uint8_t * q = x[i].qs + q_offset;
309
-
310
296
  const float dall = x[i].dm[0];
311
297
  const float dmin = x[i].dm[1];
312
298
 
313
- const uint32_t * a = (const uint32_t *)(x[i].scales + s_offset);
314
- aux[0] = a[0] & 0x0f0f0f0f;
315
- aux[1] = a[1] & 0x0f0f0f0f;
316
- aux[2] = (a[0] >> 4) & 0x0f0f0f0f;
317
- aux[3] = (a[1] >> 4) & 0x0f0f0f0f;
318
-
319
- float sum1 = 0, sum2 = 0;
320
- for (int l = 0; l < K_QUANTS_PER_ITERATION; ++l) {
321
- sum1 += y[l+ 0] * d[0] * ((q[l+ 0] >> 0) & 3)
322
- + y[l+32] * d[2] * ((q[l+ 0] >> 2) & 3)
323
- + y[l+64] * d[4] * ((q[l+ 0] >> 4) & 3)
324
- + y[l+96] * d[6] * ((q[l+ 0] >> 6) & 3)
325
- + y[l+16] * d[1] * ((q[l+16] >> 0) & 3)
326
- + y[l+48] * d[3] * ((q[l+16] >> 2) & 3)
327
- + y[l+80] * d[5] * ((q[l+16] >> 4) & 3)
328
- +y[l+112] * d[7] * ((q[l+16] >> 6) & 3);
329
- sum2 += y[l+ 0] * m[0] + y[l+32] * m[2] + y[l+64] * m[4] + y[ l+96] * m[6]
330
- + y[l+16] * m[1] + y[l+48] * m[3] + y[l+80] * m[5] + y[l+112] * m[7];
299
+ for (int im = 0; im < 2; ++im) {
300
+ const int q_offset = 32*im + l0;
301
+ const int s_offset = 8*im;
302
+ const int y_offset = 128*im + l0;
303
+
304
+ const float * y = yy + i * QK_K + y_offset;
305
+ const uint8_t * q = x[i].qs + q_offset;
306
+
307
+ const uint32_t * a = (const uint32_t *)(x[i].scales + s_offset);
308
+ aux[0] = a[0] & 0x0f0f0f0f;
309
+ aux[1] = a[1] & 0x0f0f0f0f;
310
+ aux[2] = (a[0] >> 4) & 0x0f0f0f0f;
311
+ aux[3] = (a[1] >> 4) & 0x0f0f0f0f;
312
+
313
+ float sum1 = 0, sum2 = 0;
314
+ for (int l = 0; l < K_QUANTS_PER_ITERATION; ++l) {
315
+ sum1 += y[l+ 0] * d[0] * ((q[l+ 0] >> 0) & 3)
316
+ + y[l+32] * d[2] * ((q[l+ 0] >> 2) & 3)
317
+ + y[l+64] * d[4] * ((q[l+ 0] >> 4) & 3)
318
+ + y[l+96] * d[6] * ((q[l+ 0] >> 6) & 3)
319
+ + y[l+16] * d[1] * ((q[l+16] >> 0) & 3)
320
+ + y[l+48] * d[3] * ((q[l+16] >> 2) & 3)
321
+ + y[l+80] * d[5] * ((q[l+16] >> 4) & 3)
322
+ +y[l+112] * d[7] * ((q[l+16] >> 6) & 3);
323
+ sum2 += y[l+ 0] * m[0] + y[l+32] * m[2] + y[l+64] * m[4] + y[ l+96] * m[6]
324
+ + y[l+16] * m[1] + y[l+48] * m[3] + y[l+80] * m[5] + y[l+112] * m[7];
331
325
 
326
+ }
327
+ tmp += dall * sum1 - dmin * sum2;
332
328
  }
333
- tmp += dall * sum1 - dmin * sum2;
334
329
 
335
330
  }
336
331
  #else
@@ -372,7 +367,7 @@ static void dequantize_mul_mat_vec_q2_k(const void *__restrict__ vx,
372
367
 
373
368
  // sum up partial sums and write back result
374
369
  #pragma unroll
375
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
370
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
376
371
  tmp +=
377
372
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
378
373
  }
@@ -382,13 +377,6 @@ static void dequantize_mul_mat_vec_q2_k(const void *__restrict__ vx,
382
377
  }
383
378
  }
384
379
 
385
- /*
386
- DPCT1110:5: The total declared local variable size in device function
387
- dequantize_mul_mat_vec_q3_k exceeds 128 bytes and may cause high register
388
- pressure. Consult with your hardware vendor to find the total register size
389
- available and adjust the code, or use smaller sub-group size to avoid high
390
- register pressure.
391
- */
392
380
  static void dequantize_mul_mat_vec_q3_k(const void *__restrict__ vx,
393
381
  const float *__restrict__ yy,
394
382
  float *__restrict__ dst,
@@ -412,52 +400,52 @@ static void dequantize_mul_mat_vec_q3_k(const void *__restrict__ vx,
412
400
  const uint16_t kmask2 = 0x0f0f;
413
401
 
414
402
  const int tid =
415
- item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...31 or 0...16
403
+ item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...7 or 0...15
416
404
  const int ix =
417
405
  item_ct1.get_local_id(2) % K_QUANTS_PER_ITERATION; // 0 or 0,1
418
406
 
419
407
  const int n = K_QUANTS_PER_ITERATION; // iterations in the inner loop
420
408
  const int step = 16/K_QUANTS_PER_ITERATION;
421
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
422
- const int in = tid - step*im; // 0....15 or 0...7
423
-
424
- const uint8_t m = 1 << (4*im);
409
+ const int in = tid % step; // 0...15 or 0...7
425
410
 
426
411
  const int l0 = n*in; // 0...15 or 0...14 in steps of 2
427
- const int q_offset = 32*im + l0;
428
- const int y_offset = 128*im + l0;
429
412
 
430
413
  uint16_t utmp[4];
431
414
  const int8_t * s = (const int8_t *)utmp;
432
415
 
433
- const uint16_t s_shift = 4*im;
434
-
435
416
  for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
436
417
 
437
- const float * y = yy + i * QK_K + y_offset;
438
- const uint8_t * q = x[i].qs + q_offset;
439
418
  const uint8_t * h = x[i].hmask + l0;
440
-
441
- const uint16_t * a = (const uint16_t *)x[i].scales;
442
- utmp[0] = ((a[0] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 0)) & kmask1) << 4);
443
- utmp[1] = ((a[1] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 0)) & kmask1) << 4);
444
- utmp[2] = ((a[2] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 2)) & kmask1) << 4);
445
- utmp[3] = ((a[3] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 2)) & kmask1) << 4);
446
-
447
419
  const float d = x[i].d;
448
420
 
449
- float sum = 0;
450
- for (int l = 0; l < n; ++l) {
451
- sum += y[l+ 0] * (s[0] - 32) * (((q[l] >> 0) & 3) - (h[l] & (m << 0) ? 0 : 4))
452
- + y[l+32] * (s[2] - 32) * (((q[l] >> 2) & 3) - (h[l] & (m << 1) ? 0 : 4))
453
- + y[l+64] * (s[4] - 32) * (((q[l] >> 4) & 3) - (h[l] & (m << 2) ? 0 : 4))
454
- + y[l+96] * (s[6] - 32) * (((q[l] >> 6) & 3) - (h[l] & (m << 3) ? 0 : 4));
455
- sum += y[l+16] * (s[1] - 32) * (((q[l+16] >> 0) & 3) - (h[l+16] & (m << 0) ? 0 : 4))
456
- + y[l+48] * (s[3] - 32) * (((q[l+16] >> 2) & 3) - (h[l+16] & (m << 1) ? 0 : 4))
457
- + y[l+80] * (s[5] - 32) * (((q[l+16] >> 4) & 3) - (h[l+16] & (m << 2) ? 0 : 4))
458
- + y[l+112] * (s[7] - 32) * (((q[l+16] >> 6) & 3) - (h[l+16] & (m << 3) ? 0 : 4));
421
+ for (int im = 0; im < 2; ++im) {
422
+ const int q_offset = 32*im + l0;
423
+ const int y_offset = 128*im + l0;
424
+ const uint16_t s_shift = 4*im;
425
+ const uint8_t m = 1 << (4*im);
426
+
427
+ const float * y = yy + i * QK_K + y_offset;
428
+ const uint8_t * q = x[i].qs + q_offset;
429
+
430
+ const uint16_t * a = (const uint16_t *)x[i].scales;
431
+ utmp[0] = ((a[0] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 0)) & kmask1) << 4);
432
+ utmp[1] = ((a[1] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 0)) & kmask1) << 4);
433
+ utmp[2] = ((a[2] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 2)) & kmask1) << 4);
434
+ utmp[3] = ((a[3] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 2)) & kmask1) << 4);
435
+
436
+ float sum = 0;
437
+ for (int l = 0; l < n; ++l) {
438
+ sum += y[l+ 0] * (s[0] - 32) * (((q[l] >> 0) & 3) - (h[l] & (m << 0) ? 0 : 4))
439
+ + y[l+32] * (s[2] - 32) * (((q[l] >> 2) & 3) - (h[l] & (m << 1) ? 0 : 4))
440
+ + y[l+64] * (s[4] - 32) * (((q[l] >> 4) & 3) - (h[l] & (m << 2) ? 0 : 4))
441
+ + y[l+96] * (s[6] - 32) * (((q[l] >> 6) & 3) - (h[l] & (m << 3) ? 0 : 4));
442
+ sum += y[l+16] * (s[1] - 32) * (((q[l+16] >> 0) & 3) - (h[l+16] & (m << 0) ? 0 : 4))
443
+ + y[l+48] * (s[3] - 32) * (((q[l+16] >> 2) & 3) - (h[l+16] & (m << 1) ? 0 : 4))
444
+ + y[l+80] * (s[5] - 32) * (((q[l+16] >> 4) & 3) - (h[l+16] & (m << 2) ? 0 : 4))
445
+ + y[l+112] * (s[7] - 32) * (((q[l+16] >> 6) & 3) - (h[l+16] & (m << 3) ? 0 : 4));
446
+ }
447
+ tmp += d * sum;
459
448
  }
460
- tmp += d * sum;
461
449
 
462
450
  }
463
451
  #else
@@ -491,7 +479,7 @@ static void dequantize_mul_mat_vec_q3_k(const void *__restrict__ vx,
491
479
 
492
480
  // sum up partial sums and write back result
493
481
  #pragma unroll
494
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
482
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
495
483
  tmp +=
496
484
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
497
485
  }
@@ -530,53 +518,54 @@ static void dequantize_mul_mat_vec_q3_k_reorder(const void *__restrict__ vx,
530
518
  const uint16_t kmask2 = 0x0f0f;
531
519
 
532
520
  const int tid =
533
- item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...31 or 0...16
521
+ item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...7 or 0...15
534
522
  const int ix =
535
523
  item_ct1.get_local_id(2) % K_QUANTS_PER_ITERATION; // 0 or 0,1
536
524
 
537
525
  const int n = K_QUANTS_PER_ITERATION; // iterations in the inner loop
538
526
  const int step = 16/K_QUANTS_PER_ITERATION;
539
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
540
- const int in = tid - step*im; // 0....15 or 0...7
541
-
542
- const uint8_t m = 1 << (4*im);
527
+ const int in = tid % step; // 0...15 or 0...7
543
528
 
544
529
  const int l0 = n*in; // 0...15 or 0...14 in steps of 2
545
- const int q_offset = 32*im + l0;
546
- const int y_offset = 128*im + l0;
547
530
 
548
531
  uint16_t utmp[4];
549
532
  const int8_t * s = (const int8_t *)utmp;
550
533
 
551
- const uint16_t s_shift = 4*im;
552
-
553
534
  for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
554
535
  const int bi = ib0 + i;
555
536
 
556
- const float * y = yy + i * QK_K + y_offset;
557
- const uint8_t * q = qs_base + bi * (QK_K / 4) + q_offset;
558
537
  const uint8_t * h = hmask_base + bi * (QK_K / 8) + l0;
559
538
 
560
- const uint16_t * a = (const uint16_t *)(scales_base + bi * 12);
561
- utmp[0] = ((a[0] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 0)) & kmask1) << 4);
562
- utmp[1] = ((a[1] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 0)) & kmask1) << 4);
563
- utmp[2] = ((a[2] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 2)) & kmask1) << 4);
564
- utmp[3] = ((a[3] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 2)) & kmask1) << 4);
565
-
566
539
  const float d = d_base[bi];
567
540
 
568
- float sum = 0;
569
- for (int l = 0; l < n; ++l) {
570
- sum += y[l+ 0] * (s[0] - 32) * (((q[l] >> 0) & 3) - (h[l] & (m << 0) ? 0 : 4))
571
- + y[l+32] * (s[2] - 32) * (((q[l] >> 2) & 3) - (h[l] & (m << 1) ? 0 : 4))
572
- + y[l+64] * (s[4] - 32) * (((q[l] >> 4) & 3) - (h[l] & (m << 2) ? 0 : 4))
573
- + y[l+96] * (s[6] - 32) * (((q[l] >> 6) & 3) - (h[l] & (m << 3) ? 0 : 4));
574
- sum += y[l+16] * (s[1] - 32) * (((q[l+16] >> 0) & 3) - (h[l+16] & (m << 0) ? 0 : 4))
575
- + y[l+48] * (s[3] - 32) * (((q[l+16] >> 2) & 3) - (h[l+16] & (m << 1) ? 0 : 4))
576
- + y[l+80] * (s[5] - 32) * (((q[l+16] >> 4) & 3) - (h[l+16] & (m << 2) ? 0 : 4))
577
- + y[l+112] * (s[7] - 32) * (((q[l+16] >> 6) & 3) - (h[l+16] & (m << 3) ? 0 : 4));
541
+ for (int im = 0; im < 2; ++im) {
542
+ const int q_offset = 32*im + l0;
543
+ const int y_offset = 128*im + l0;
544
+ const uint16_t s_shift = 4*im;
545
+ const uint8_t m = 1 << (4*im);
546
+
547
+ const float * y = yy + i * QK_K + y_offset;
548
+ const uint8_t * q = qs_base + bi * (QK_K / 4) + q_offset;
549
+
550
+ const uint16_t * a = (const uint16_t *)(scales_base + bi * 12);
551
+ utmp[0] = ((a[0] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 0)) & kmask1) << 4);
552
+ utmp[1] = ((a[1] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 0)) & kmask1) << 4);
553
+ utmp[2] = ((a[2] >> s_shift) & kmask2) | (((a[4] >> (s_shift + 2)) & kmask1) << 4);
554
+ utmp[3] = ((a[3] >> s_shift) & kmask2) | (((a[5] >> (s_shift + 2)) & kmask1) << 4);
555
+
556
+ float sum = 0;
557
+ for (int l = 0; l < n; ++l) {
558
+ sum += y[l+ 0] * (s[0] - 32) * (((q[l] >> 0) & 3) - (h[l] & (m << 0) ? 0 : 4))
559
+ + y[l+32] * (s[2] - 32) * (((q[l] >> 2) & 3) - (h[l] & (m << 1) ? 0 : 4))
560
+ + y[l+64] * (s[4] - 32) * (((q[l] >> 4) & 3) - (h[l] & (m << 2) ? 0 : 4))
561
+ + y[l+96] * (s[6] - 32) * (((q[l] >> 6) & 3) - (h[l] & (m << 3) ? 0 : 4));
562
+ sum += y[l+16] * (s[1] - 32) * (((q[l+16] >> 0) & 3) - (h[l+16] & (m << 0) ? 0 : 4))
563
+ + y[l+48] * (s[3] - 32) * (((q[l+16] >> 2) & 3) - (h[l+16] & (m << 1) ? 0 : 4))
564
+ + y[l+80] * (s[5] - 32) * (((q[l+16] >> 4) & 3) - (h[l+16] & (m << 2) ? 0 : 4))
565
+ + y[l+112] * (s[7] - 32) * (((q[l+16] >> 6) & 3) - (h[l+16] & (m << 3) ? 0 : 4));
566
+ }
567
+ tmp += d * sum;
578
568
  }
579
- tmp += d * sum;
580
569
  }
581
570
  #else
582
571
  GGML_UNUSED(vx);
@@ -588,7 +577,7 @@ static void dequantize_mul_mat_vec_q3_k_reorder(const void *__restrict__ vx,
588
577
 
589
578
  // sum up partial sums and write back result
590
579
  #pragma unroll
591
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
580
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
592
581
  tmp +=
593
582
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
594
583
  }
@@ -598,13 +587,6 @@ static void dequantize_mul_mat_vec_q3_k_reorder(const void *__restrict__ vx,
598
587
  }
599
588
  }
600
589
 
601
- /*
602
- DPCT1110:6: The total declared local variable size in device function
603
- dequantize_mul_mat_vec_q4_k exceeds 128 bytes and may cause high register
604
- pressure. Consult with your hardware vendor to find the total register size
605
- available and adjust the code, or use smaller sub-group size to avoid high
606
- register pressure.
607
- */
608
590
  static void dequantize_mul_mat_vec_q4_k(const void *__restrict__ vx,
609
591
  const float *__restrict__ yy,
610
592
  float *__restrict__ dst,
@@ -625,22 +607,19 @@ static void dequantize_mul_mat_vec_q4_k(const void *__restrict__ vx,
625
607
  const uint16_t kmask3 = 0xc0c0;
626
608
 
627
609
  const int tid =
628
- item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...31 or 0...16
610
+ item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...7 or 0...15
629
611
  const int ix =
630
612
  item_ct1.get_local_id(2) % K_QUANTS_PER_ITERATION; // 0 or 0,1
631
613
 
632
614
  const int step = 8/K_QUANTS_PER_ITERATION; // 8 or 4
633
615
 
634
- const int il = tid/step; // 0...3
635
- const int ir = tid - step*il; // 0...7 or 0...3
616
+ const int il_base = tid/step; // 0 or 1 (was 0...3)
617
+ const int ir = tid - step*il_base; // 0...7 or 0...3
636
618
  const int n = 2 * K_QUANTS_PER_ITERATION; // 2 or 4
637
619
 
638
- const int im = il/2; // 0 or 1. 0 computes 0,32 + 128,160, 1 computes 64,96 + 192,224
639
- const int in = il%2;
620
+ const int in = il_base%2;
640
621
 
641
622
  const int l0 = n*(2*ir + in);
642
- const int q_offset = 32*im + l0;
643
- const int y_offset = 64*im + l0;
644
623
 
645
624
  uint16_t aux[4];
646
625
  const uint8_t * sc = (const uint8_t *)aux;
@@ -657,55 +636,60 @@ static void dequantize_mul_mat_vec_q4_k(const void *__restrict__ vx,
657
636
 
658
637
  for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
659
638
 
660
- const float * y1 = yy + i*QK_K + y_offset;
661
- const float * y2 = y1 + 128;
662
-
663
639
  const float dall = x[i].dm[0];
664
640
  const float dmin = x[i].dm[1];
665
641
 
666
- const uint16_t * a = (const uint16_t *)x[i].scales;
667
- aux[0] = a[im+0] & kmask1;
668
- aux[1] = a[im+2] & kmask1;
669
- aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
670
- aux[3] = ((a[im+4] >> 4) & kmask2) | ((a[im+2] & kmask3) >> 2);
642
+ for (int im = 0; im < 2; ++im) {
643
+ const int q_offset = 32*im + l0;
644
+ const int y_offset = 64*im + l0;
671
645
 
672
- #if K_QUANTS_PER_ITERATION == 2
673
- const uint32_t * q1 = (const uint32_t *)(x[i].qs + q_offset);
674
- const uint32_t * q2 = q1 + 16;
646
+ const float * y1 = yy + i*QK_K + y_offset;
647
+ const float * y2 = y1 + 128;
675
648
 
676
- q32[0] = q1[0] & 0x0f0f0f0f;
677
- q32[1] = q1[0] & 0xf0f0f0f0;
678
- q32[2] = q2[0] & 0x0f0f0f0f;
679
- q32[3] = q2[0] & 0xf0f0f0f0;
649
+ const uint16_t * a = (const uint16_t *)x[i].scales;
650
+ aux[0] = a[im+0] & kmask1;
651
+ aux[1] = a[im+2] & kmask1;
652
+ aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
653
+ aux[3] = ((a[im+4] >> 4) & kmask2) | ((a[im+2] & kmask3) >> 2);
680
654
 
681
- sycl::float4 s = {0.f, 0.f, 0.f, 0.f};
682
- float smin = 0;
683
- for (int l = 0; l < 4; ++l) {
684
- s.x() += y1[l] * q4[l + 0]; s.y() += y1[l + 32] * q4[l + 4];
685
- s.z() += y2[l] * q4[l + 8]; s.w() += y2[l + 32] * q4[l + 12];
686
- smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
687
- }
688
- tmp += dall * (s.x() * sc[0] + s.y() * sc[1] * 1.f / 16.f +
689
- s.z() * sc[4] + s.w() * sc[5] * 1.f / 16.f) -
690
- dmin * smin;
655
+ #if K_QUANTS_PER_ITERATION == 2
656
+ const uint32_t * q1 = (const uint32_t *)(x[i].qs + q_offset);
657
+ const uint32_t * q2 = q1 + 16;
658
+
659
+ q32[0] = q1[0] & 0x0f0f0f0f;
660
+ q32[1] = q1[0] & 0xf0f0f0f0;
661
+ q32[2] = q2[0] & 0x0f0f0f0f;
662
+ q32[3] = q2[0] & 0xf0f0f0f0;
663
+
664
+ sycl::float4 s = {0.f, 0.f, 0.f, 0.f};
665
+ float smin = 0;
666
+ for (int l = 0; l < 4; ++l) {
667
+ s.x() += y1[l] * q4[l + 0]; s.y() += y1[l + 32] * q4[l + 4];
668
+ s.z() += y2[l] * q4[l + 8]; s.w() += y2[l + 32] * q4[l + 12];
669
+ smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
670
+ }
671
+ tmp += dall * (s.x() * sc[0] + s.y() * sc[1] * 1.f / 16.f +
672
+ s.z() * sc[4] + s.w() * sc[5] * 1.f / 16.f) -
673
+ dmin * smin;
691
674
  #else
692
- const uint16_t * q1 = (const uint16_t *)(x[i].qs + q_offset);
693
- const uint16_t * q2 = q1 + 32;
694
-
695
- q16[0] = q1[0] & 0x0f0f;
696
- q16[1] = q1[0] & 0xf0f0;
697
- q16[2] = q2[0] & 0x0f0f;
698
- q16[3] = q2[0] & 0xf0f0;
699
-
700
- float4 s = {0.f, 0.f, 0.f, 0.f};
701
- float smin = 0;
702
- for (int l = 0; l < 2; ++l) {
703
- s.x += y1[l] * q4[l+0]; s.y += y1[l+32] * q4[l+2];
704
- s.z += y2[l] * q4[l+4]; s.w += y2[l+32] * q4[l+6];
705
- smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
706
- }
707
- tmp += dall * (s.x * sc[0] + s.y * sc[1] * 1.f/16.f + s.z * sc[4] + s.w * sc[5] * 1.f/16.f) - dmin * smin;
675
+ const uint16_t * q1 = (const uint16_t *)(x[i].qs + q_offset);
676
+ const uint16_t * q2 = q1 + 32;
677
+
678
+ q16[0] = q1[0] & 0x0f0f;
679
+ q16[1] = q1[0] & 0xf0f0;
680
+ q16[2] = q2[0] & 0x0f0f;
681
+ q16[3] = q2[0] & 0xf0f0;
682
+
683
+ sycl::float4 s = {0.f, 0.f, 0.f, 0.f};
684
+ float smin = 0;
685
+ for (int l = 0; l < 2; ++l) {
686
+ s.x() += y1[l] * q4[l+0]; s.y() += y1[l+32] * q4[l+2];
687
+ s.z() += y2[l] * q4[l+4]; s.w() += y2[l+32] * q4[l+6];
688
+ smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
689
+ }
690
+ tmp += dall * (s.x() * sc[0] + s.y() * sc[1] * 1.f/16.f + s.z() * sc[4] + s.w() * sc[5] * 1.f/16.f) - dmin * smin;
708
691
  #endif
692
+ }
709
693
 
710
694
  }
711
695
  #else
@@ -741,7 +725,7 @@ static void dequantize_mul_mat_vec_q4_k(const void *__restrict__ vx,
741
725
 
742
726
  // sum up partial sums and write back result
743
727
  #pragma unroll
744
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
728
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
745
729
  tmp +=
746
730
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
747
731
  }
@@ -776,22 +760,19 @@ static void dequantize_mul_mat_vec_q4_k_reorder(const void *__restrict__ vx,
776
760
  const uint16_t kmask3 = 0xc0c0;
777
761
 
778
762
  const int tid =
779
- item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...31 or 0...16
763
+ item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...7 or 0...15
780
764
  const int ix =
781
765
  item_ct1.get_local_id(2) % K_QUANTS_PER_ITERATION; // 0 or 0,1
782
766
 
783
767
  const int step = 8/K_QUANTS_PER_ITERATION; // 8 or 4
784
768
 
785
- const int il = tid/step; // 0...3
786
- const int ir = tid - step*il; // 0...7 or 0...3
769
+ const int il_base = tid/step; // 0 or 1 (was 0...3)
770
+ const int ir = tid - step*il_base; // 0...7 or 0...3
787
771
  const int n = 2 * K_QUANTS_PER_ITERATION; // 2 or 4
788
772
 
789
- const int im = il/2; // 0 or 1. 0 computes 0,32 + 128,160, 1 computes 64,96 + 192,224
790
- const int in = il%2;
773
+ const int in = il_base%2;
791
774
 
792
775
  const int l0 = n*(2*ir + in);
793
- const int q_offset = 32*im + l0;
794
- const int y_offset = 64*im + l0;
795
776
 
796
777
  uint16_t aux[4];
797
778
  const uint8_t * sc = (const uint8_t *)aux;
@@ -809,56 +790,61 @@ static void dequantize_mul_mat_vec_q4_k_reorder(const void *__restrict__ vx,
809
790
  for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
810
791
  const int bi = ib0 + i;
811
792
 
812
- const float * y1 = yy + i*QK_K + y_offset;
813
- const float * y2 = y1 + 128;
814
-
815
793
  const sycl::half2 dm_val = dm_base[bi];
816
794
  const float dall = dm_val[0];
817
795
  const float dmin = dm_val[1];
818
796
 
819
- const uint16_t * a = (const uint16_t *)(scales_base + bi * K_SCALE_SIZE);
820
- aux[0] = a[im+0] & kmask1;
821
- aux[1] = a[im+2] & kmask1;
822
- aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
823
- aux[3] = ((a[im+4] >> 4) & kmask2) | ((a[im+2] & kmask3) >> 2);
797
+ for (int im = 0; im < 2; ++im) {
798
+ const int q_offset = 32*im + l0;
799
+ const int y_offset = 64*im + l0;
824
800
 
825
- #if K_QUANTS_PER_ITERATION == 2
826
- const uint32_t * q1 = (const uint32_t *)(qs_base + bi * (QK_K / 2) + q_offset);
827
- const uint32_t * q2 = q1 + 16;
801
+ const float * y1 = yy + i*QK_K + y_offset;
802
+ const float * y2 = y1 + 128;
828
803
 
829
- q32[0] = q1[0] & 0x0f0f0f0f;
830
- q32[1] = q1[0] & 0xf0f0f0f0;
831
- q32[2] = q2[0] & 0x0f0f0f0f;
832
- q32[3] = q2[0] & 0xf0f0f0f0;
804
+ const uint16_t * a = (const uint16_t *)(scales_base + bi * K_SCALE_SIZE);
805
+ aux[0] = a[im+0] & kmask1;
806
+ aux[1] = a[im+2] & kmask1;
807
+ aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
808
+ aux[3] = ((a[im+4] >> 4) & kmask2) | ((a[im+2] & kmask3) >> 2);
833
809
 
834
- sycl::float4 s = {0.f, 0.f, 0.f, 0.f};
835
- float smin = 0;
836
- for (int l = 0; l < 4; ++l) {
837
- s.x() += y1[l] * q4[l + 0]; s.y() += y1[l + 32] * q4[l + 4];
838
- s.z() += y2[l] * q4[l + 8]; s.w() += y2[l + 32] * q4[l + 12];
839
- smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
840
- }
841
- tmp += dall * (s.x() * sc[0] + s.y() * sc[1] * 1.f / 16.f +
842
- s.z() * sc[4] + s.w() * sc[5] * 1.f / 16.f) -
843
- dmin * smin;
810
+ #if K_QUANTS_PER_ITERATION == 2
811
+ const uint32_t * q1 = (const uint32_t *)(qs_base + bi * (QK_K / 2) + q_offset);
812
+ const uint32_t * q2 = q1 + 16;
813
+
814
+ q32[0] = q1[0] & 0x0f0f0f0f;
815
+ q32[1] = q1[0] & 0xf0f0f0f0;
816
+ q32[2] = q2[0] & 0x0f0f0f0f;
817
+ q32[3] = q2[0] & 0xf0f0f0f0;
818
+
819
+ sycl::float4 s = {0.f, 0.f, 0.f, 0.f};
820
+ float smin = 0;
821
+ for (int l = 0; l < 4; ++l) {
822
+ s.x() += y1[l] * q4[l + 0]; s.y() += y1[l + 32] * q4[l + 4];
823
+ s.z() += y2[l] * q4[l + 8]; s.w() += y2[l + 32] * q4[l + 12];
824
+ smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
825
+ }
826
+ tmp += dall * (s.x() * sc[0] + s.y() * sc[1] * 1.f / 16.f +
827
+ s.z() * sc[4] + s.w() * sc[5] * 1.f / 16.f) -
828
+ dmin * smin;
844
829
  #else
845
- const uint16_t * q1 = (const uint16_t *)(qs_base + bi * (QK_K / 2) + q_offset);
846
- const uint16_t * q2 = q1 + 32;
847
-
848
- q16[0] = q1[0] & 0x0f0f;
849
- q16[1] = q1[0] & 0xf0f0;
850
- q16[2] = q2[0] & 0x0f0f;
851
- q16[3] = q2[0] & 0xf0f0;
852
-
853
- float4 s = {0.f, 0.f, 0.f, 0.f};
854
- float smin = 0;
855
- for (int l = 0; l < 2; ++l) {
856
- s.x += y1[l] * q4[l+0]; s.y += y1[l+32] * q4[l+2];
857
- s.z += y2[l] * q4[l+4]; s.w += y2[l+32] * q4[l+6];
858
- smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
859
- }
860
- tmp += dall * (s.x * sc[0] + s.y * sc[1] * 1.f/16.f + s.z * sc[4] + s.w * sc[5] * 1.f/16.f) - dmin * smin;
830
+ const uint16_t * q1 = (const uint16_t *)(qs_base + bi * (QK_K / 2) + q_offset);
831
+ const uint16_t * q2 = q1 + 32;
832
+
833
+ q16[0] = q1[0] & 0x0f0f;
834
+ q16[1] = q1[0] & 0xf0f0;
835
+ q16[2] = q2[0] & 0x0f0f;
836
+ q16[3] = q2[0] & 0xf0f0;
837
+
838
+ sycl::float4 s = {0.f, 0.f, 0.f, 0.f};
839
+ float smin = 0;
840
+ for (int l = 0; l < 2; ++l) {
841
+ s.x() += y1[l] * q4[l+0]; s.y() += y1[l+32] * q4[l+2];
842
+ s.z() += y2[l] * q4[l+4]; s.w() += y2[l+32] * q4[l+6];
843
+ smin += y1[l] * sc[2] + y1[l+32] * sc[3] + y2[l] * sc[6] + y2[l+32] * sc[7];
844
+ }
845
+ tmp += dall * (s.x() * sc[0] + s.y() * sc[1] * 1.f/16.f + s.z() * sc[4] + s.w() * sc[5] * 1.f/16.f) - dmin * smin;
861
846
  #endif
847
+ }
862
848
 
863
849
  }
864
850
  #else
@@ -897,7 +883,7 @@ static void dequantize_mul_mat_vec_q4_k_reorder(const void *__restrict__ vx,
897
883
 
898
884
  // sum up partial sums and write back result
899
885
  #pragma unroll
900
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
886
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
901
887
  tmp +=
902
888
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
903
889
  }
@@ -907,13 +893,6 @@ static void dequantize_mul_mat_vec_q4_k_reorder(const void *__restrict__ vx,
907
893
  }
908
894
  }
909
895
 
910
- /*
911
- DPCT1110:7: The total declared local variable size in device function
912
- dequantize_mul_mat_vec_q5_k exceeds 128 bytes and may cause high register
913
- pressure. Consult with your hardware vendor to find the total register size
914
- available and adjust the code, or use smaller sub-group size to avoid high
915
- register pressure.
916
- */
917
896
  static void dequantize_mul_mat_vec_q5_k(const void *__restrict__ vx,
918
897
  const float *__restrict__ yy,
919
898
  float *__restrict__ dst,
@@ -928,6 +907,141 @@ static void dequantize_mul_mat_vec_q5_k(const void *__restrict__ vx,
928
907
 
929
908
  float tmp = 0; // partial sum for thread in warp
930
909
 
910
+ #if QK_K == 256
911
+ const uint16_t kmask1 = 0x3f3f;
912
+ const uint16_t kmask2 = 0x0f0f;
913
+ const uint16_t kmask3 = 0xc0c0;
914
+
915
+ const int tid = item_ct1.get_local_id(2) / 2; // 0...7
916
+ const int ix = item_ct1.get_local_id(2) % 2;
917
+
918
+ const int il_base = tid/4; // 0 or 1 (was 0...3)
919
+ const int ir = tid - 4*il_base;// 0...3
920
+ const int n = 2;
921
+
922
+ const int in = il_base%2;
923
+
924
+ const int l0 = n*(2*ir + in);
925
+
926
+ uint16_t aux[4];
927
+ const uint8_t * sc = (const uint8_t *)aux;
928
+
929
+ uint16_t q16[8];
930
+ const uint8_t * q4 = (const uint8_t *)q16;
931
+
932
+ for (int i = ix; i < num_blocks_per_row; i += 2) {
933
+
934
+ const uint8_t * qh = x[i].qh + l0;
935
+ const float dall = x[i].dm[0];
936
+ const float dmin = x[i].dm[1];
937
+
938
+ for (int im = 0; im < 2; ++im) {
939
+ const int q_offset = 32*im + l0;
940
+ const int y_offset = 64*im + l0;
941
+
942
+ const uint8_t hm1 = 1 << (2*im);
943
+ const uint8_t hm2 = hm1 << 4;
944
+
945
+ const uint8_t * ql1 = x[i].qs + q_offset;
946
+ const float * y1 = yy + i*QK_K + y_offset;
947
+ const float * y2 = y1 + 128;
948
+
949
+ const uint16_t * a = (const uint16_t *)x[i].scales;
950
+ aux[0] = a[im+0] & kmask1;
951
+ aux[1] = a[im+2] & kmask1;
952
+ aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
953
+ aux[3] = ((a[im+4] >> 4) & kmask2) | ((a[im+2] & kmask3) >> 2);
954
+
955
+ sycl::float4 sum = {0.f, 0.f, 0.f, 0.f};
956
+ float smin = 0;
957
+ const uint16_t * q1 = (const uint16_t *)ql1;
958
+ const uint16_t * q2 = q1 + 32;
959
+ q16[0] = q1[0] & 0x0f0f;
960
+ q16[1] = q1[8] & 0x0f0f;
961
+ q16[2] = (q1[0] >> 4) & 0x0f0f;
962
+ q16[3] = (q1[8] >> 4) & 0x0f0f;
963
+ q16[4] = q2[0] & 0x0f0f;
964
+ q16[5] = q2[8] & 0x0f0f;
965
+ q16[6] = (q2[0] >> 4) & 0x0f0f;
966
+ q16[7] = (q2[8] >> 4) & 0x0f0f;
967
+ for (int l = 0; l < n; ++l) {
968
+ sum.x() +=
969
+ y1[l + 0] * (q4[l + 0] + (qh[l + 0] & (hm1 << 0) ? 16 : 0)) +
970
+ y1[l + 16] * (q4[l + 2] + (qh[l + 16] & (hm1 << 0) ? 16 : 0));
971
+ sum.y() +=
972
+ y1[l + 32] * (q4[l + 4] + (qh[l + 0] & (hm1 << 1) ? 16 : 0)) +
973
+ y1[l + 48] * (q4[l + 6] + (qh[l + 16] & (hm1 << 1) ? 16 : 0));
974
+ sum.z() +=
975
+ y2[l + 0] * (q4[l + 8] + (qh[l + 0] & (hm2 << 0) ? 16 : 0)) +
976
+ y2[l + 16] * (q4[l + 10] + (qh[l + 16] & (hm2 << 0) ? 16 : 0));
977
+ sum.w() +=
978
+ y2[l + 32] * (q4[l + 12] + (qh[l + 0] & (hm2 << 1) ? 16 : 0)) +
979
+ y2[l + 48] * (q4[l + 14] + (qh[l + 16] & (hm2 << 1) ? 16 : 0));
980
+ smin += (y1[l] + y1[l+16]) * sc[2] + (y1[l+32] + y1[l+48]) * sc[3]
981
+ + (y2[l] + y2[l+16]) * sc[6] + (y2[l+32] + y2[l+48]) * sc[7];
982
+ }
983
+ tmp += dall * (sum.x() * sc[0] + sum.y() * sc[1] + sum.z() * sc[4] +
984
+ sum.w() * sc[5]) -
985
+ dmin * smin;
986
+ }
987
+ }
988
+
989
+ #else
990
+ const int tid = item_ct1.get_local_id(2)/(2*K_QUANTS_PER_ITERATION); // 0...15
991
+ const int ix = item_ct1.get_local_id(2)%(2*K_QUANTS_PER_ITERATION);
992
+ const int step = tid * K_QUANTS_PER_ITERATION;
993
+ const int im = step/8;
994
+ const int in = step%8;
995
+
996
+ for (int i = ix; i < num_blocks_per_row; i += 2*K_QUANTS_PER_ITERATION) {
997
+ const uint8_t * q = x[i].qs + step;
998
+ const int8_t * s = x[i].scales;
999
+ const float * y = yy + i*QK_K + step;
1000
+ const float d = x[i].d;
1001
+ float sum = 0.f;
1002
+ for (int j = 0; j < K_QUANTS_PER_ITERATION; ++j) {
1003
+ const uint8_t h = x[i].qh[in+j] >> im;
1004
+ sum += y[j+ 0] * d * s[0] * ((q[j+ 0] & 0xF) - ((h >> 0) & 1 ? 0 : 16))
1005
+ + y[j+16] * d * s[1] * ((q[j+16] & 0xF) - ((h >> 2) & 1 ? 0 : 16))
1006
+ + y[j+32] * d * s[2] * ((q[j+ 0] >> 4) - ((h >> 4) & 1 ? 0 : 16))
1007
+ + y[j+48] * d * s[3] * ((q[j+16] >> 4) - ((h >> 6) & 1 ? 0 : 16));
1008
+ }
1009
+ tmp += sum;
1010
+ }
1011
+ #endif
1012
+
1013
+ // sum up partial sums and write back result
1014
+ #pragma unroll
1015
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
1016
+ tmp +=
1017
+ dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
1018
+ }
1019
+
1020
+ if (item_ct1.get_local_id(2) == 0) {
1021
+ dst[row] = tmp;
1022
+ }
1023
+ }
1024
+
1025
+ static void dequantize_mul_mat_vec_q5_k_reorder(const void *__restrict__ vx,
1026
+ const float *__restrict__ yy,
1027
+ float *__restrict__ dst,
1028
+ const int ncols, int nrows,
1029
+ const sycl::nd_item<3> &item_ct1) {
1030
+
1031
+ const int row = item_ct1.get_group(2);
1032
+ const int num_blocks_per_row = ncols / QK_K;
1033
+ const int ib0 = row*num_blocks_per_row;
1034
+
1035
+ // SOA base pointers for the reordered layout:
1036
+ // [qs: nb * QK_K/2] [qh: nb * QK_K/8] [scales: nb * K_SCALE_SIZE] [dm: nb * sizeof(half2)]
1037
+ const int nb = nrows * num_blocks_per_row;
1038
+ const uint8_t * qs_base = (const uint8_t *)vx;
1039
+ const uint8_t * qh_base = qs_base + (size_t)nb * (QK_K / 2);
1040
+ const uint8_t * scales_base = qh_base + (size_t)nb * (QK_K / 8);
1041
+ const sycl::half2 * dm_base = (const sycl::half2 *)(scales_base + (size_t)nb * K_SCALE_SIZE);
1042
+
1043
+ float tmp = 0; // partial sum for thread in warp
1044
+
931
1045
  #if QK_K == 256
932
1046
  const uint16_t kmask1 = 0x3f3f;
933
1047
  const uint16_t kmask2 = 0x0f0f;
@@ -957,16 +1071,18 @@ static void dequantize_mul_mat_vec_q5_k(const void *__restrict__ vx,
957
1071
  const uint8_t * q4 = (const uint8_t *)q16;
958
1072
 
959
1073
  for (int i = ix; i < num_blocks_per_row; i += 2) {
1074
+ const int bi = ib0 + i;
960
1075
 
961
- const uint8_t * ql1 = x[i].qs + q_offset;
962
- const uint8_t * qh = x[i].qh + l0;
1076
+ const uint8_t * ql1 = qs_base + bi * (QK_K / 2) + q_offset;
1077
+ const uint8_t * qh = qh_base + bi * (QK_K / 8) + l0;
963
1078
  const float * y1 = yy + i*QK_K + y_offset;
964
1079
  const float * y2 = y1 + 128;
965
1080
 
966
- const float dall = x[i].dm[0];
967
- const float dmin = x[i].dm[1];
1081
+ const sycl::half2 dm_val = dm_base[bi];
1082
+ const float dall = dm_val[0];
1083
+ const float dmin = dm_val[1];
968
1084
 
969
- const uint16_t * a = (const uint16_t *)x[i].scales;
1085
+ const uint16_t * a = (const uint16_t *)(scales_base + bi * K_SCALE_SIZE);
970
1086
  aux[0] = a[im+0] & kmask1;
971
1087
  aux[1] = a[im+2] & kmask1;
972
1088
  aux[2] = ((a[im+4] >> 0) & kmask2) | ((a[im+0] & kmask3) >> 2);
@@ -1004,34 +1120,13 @@ static void dequantize_mul_mat_vec_q5_k(const void *__restrict__ vx,
1004
1120
  sum.w() * sc[5]) -
1005
1121
  dmin * smin;
1006
1122
  }
1007
-
1008
1123
  #else
1009
- const int tid = item_ct1.get_local_id(2)/(2*K_QUANTS_PER_ITERATION); // 0...15
1010
- const int ix = item_ct1.get_local_id(2)%(2*K_QUANTS_PER_ITERATION);
1011
- const int step = tid * K_QUANTS_PER_ITERATION;
1012
- const int im = step/8;
1013
- const int in = step%8;
1014
-
1015
- for (int i = ix; i < num_blocks_per_row; i += 2*K_QUANTS_PER_ITERATION) {
1016
- const uint8_t * q = x[i].qs + step;
1017
- const int8_t * s = x[i].scales;
1018
- const float * y = yy + i*QK_K + step;
1019
- const float d = x[i].d;
1020
- float sum = 0.f;
1021
- for (int j = 0; j < K_QUANTS_PER_ITERATION; ++j) {
1022
- const uint8_t h = x[i].qh[in+j] >> im;
1023
- sum += y[j+ 0] * d * s[0] * ((q[j+ 0] & 0xF) - ((h >> 0) & 1 ? 0 : 16))
1024
- + y[j+16] * d * s[1] * ((q[j+16] & 0xF) - ((h >> 2) & 1 ? 0 : 16))
1025
- + y[j+32] * d * s[2] * ((q[j+ 0] >> 4) - ((h >> 4) & 1 ? 0 : 16))
1026
- + y[j+48] * d * s[3] * ((q[j+16] >> 4) - ((h >> 6) & 1 ? 0 : 16));
1027
- }
1028
- tmp += sum;
1029
- }
1124
+ // The reordered Q5_K layout is only produced for QK_K == 256.
1030
1125
  #endif
1031
1126
 
1032
1127
  // sum up partial sums and write back result
1033
1128
  #pragma unroll
1034
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
1129
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
1035
1130
  tmp +=
1036
1131
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
1037
1132
  }
@@ -1058,14 +1153,13 @@ static void dequantize_mul_mat_vec_q6_k(const void * __restrict__ vx, const floa
1058
1153
  #if QK_K == 256
1059
1154
 
1060
1155
  const int tid =
1061
- item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...31 or 0...16
1156
+ item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...7 or 0...15
1062
1157
  const int ix =
1063
1158
  item_ct1.get_local_id(2) % K_QUANTS_PER_ITERATION; // 0 or 0, 1
1064
1159
 
1065
1160
  const int step = 16/K_QUANTS_PER_ITERATION; // 16 or 8
1066
1161
 
1067
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
1068
- const int in = tid - step*im; // 0...15 or 0...7
1162
+ const int in = tid % step; // 0...15 or 0...7
1069
1163
 
1070
1164
  #if K_QUANTS_PER_ITERATION == 1
1071
1165
  const int l0 = K_QUANTS_PER_ITERATION*in; // 0...15
@@ -1074,42 +1168,45 @@ static void dequantize_mul_mat_vec_q6_k(const void * __restrict__ vx, const floa
1074
1168
  const int l0 = 4 * in; // 0, 4, 8, ..., 28
1075
1169
  const int is = in / 4;
1076
1170
  #endif
1077
- const int ql_offset = 64*im + l0;
1078
- const int qh_offset = 32*im + l0;
1079
- const int s_offset = 8*im + is;
1080
- const int y_offset = 128*im + l0;
1081
1171
 
1082
1172
  float tmp = 0; // partial sum for thread in warp
1083
1173
 
1084
1174
  for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
1085
1175
 
1086
- const float * y = yy + i * QK_K + y_offset;
1087
- const uint8_t * ql = x[i].ql + ql_offset;
1088
- const uint8_t * qh = x[i].qh + qh_offset;
1089
- const int8_t * s = x[i].scales + s_offset;
1090
-
1091
1176
  const float d = x[i].d;
1092
1177
 
1178
+ for (int im = 0; im < 2; ++im) {
1179
+ const int ql_offset = 64*im + l0;
1180
+ const int qh_offset = 32*im + l0;
1181
+ const int s_offset = 8*im + is;
1182
+ const int y_offset = 128*im + l0;
1183
+
1184
+ const float * y = yy + i * QK_K + y_offset;
1185
+ const uint8_t * ql = x[i].ql + ql_offset;
1186
+ const uint8_t * qh = x[i].qh + qh_offset;
1187
+ const int8_t * s = x[i].scales + s_offset;
1188
+
1093
1189
  #if K_QUANTS_PER_ITERATION == 1
1094
- float sum = y[ 0] * s[0] * d * ((int8_t)((ql[ 0] & 0xF) | ((qh[ 0] & 0x03) << 4)) - 32)
1095
- + y[16] * s[1] * d * ((int8_t)((ql[16] & 0xF) | ((qh[16] & 0x03) << 4)) - 32)
1096
- + y[32] * s[2] * d * ((int8_t)((ql[32] & 0xF) | ((qh[ 0] & 0x0c) << 2)) - 32)
1097
- + y[48] * s[3] * d * ((int8_t)((ql[48] & 0xF) | ((qh[16] & 0x0c) << 2)) - 32)
1098
- + y[64] * s[4] * d * ((int8_t)((ql[ 0] >> 4) | ((qh[ 0] & 0x30) >> 0)) - 32)
1099
- + y[80] * s[5] * d * ((int8_t)((ql[16] >> 4) | ((qh[16] & 0x30) >> 0)) - 32)
1100
- + y[96] * s[6] * d * ((int8_t)((ql[32] >> 4) | ((qh[ 0] & 0xc0) >> 2)) - 32)
1101
- +y[112] * s[7] * d * ((int8_t)((ql[48] >> 4) | ((qh[16] & 0xc0) >> 2)) - 32);
1102
- tmp += sum;
1190
+ float sum = y[ 0] * s[0] * d * ((int8_t)((ql[ 0] & 0xF) | ((qh[ 0] & 0x03) << 4)) - 32)
1191
+ + y[16] * s[1] * d * ((int8_t)((ql[16] & 0xF) | ((qh[16] & 0x03) << 4)) - 32)
1192
+ + y[32] * s[2] * d * ((int8_t)((ql[32] & 0xF) | ((qh[ 0] & 0x0c) << 2)) - 32)
1193
+ + y[48] * s[3] * d * ((int8_t)((ql[48] & 0xF) | ((qh[16] & 0x0c) << 2)) - 32)
1194
+ + y[64] * s[4] * d * ((int8_t)((ql[ 0] >> 4) | ((qh[ 0] & 0x30) >> 0)) - 32)
1195
+ + y[80] * s[5] * d * ((int8_t)((ql[16] >> 4) | ((qh[16] & 0x30) >> 0)) - 32)
1196
+ + y[96] * s[6] * d * ((int8_t)((ql[32] >> 4) | ((qh[ 0] & 0xc0) >> 2)) - 32)
1197
+ +y[112] * s[7] * d * ((int8_t)((ql[48] >> 4) | ((qh[16] & 0xc0) >> 2)) - 32);
1198
+ tmp += sum;
1103
1199
  #else
1104
- float sum = 0;
1105
- for (int l = 0; l < 4; ++l) {
1106
- sum += y[l+ 0] * s[0] * d * ((int8_t)((ql[l+ 0] & 0xF) | (((qh[l] >> 0) & 3) << 4)) - 32)
1107
- + y[l+32] * s[2] * d * ((int8_t)((ql[l+32] & 0xF) | (((qh[l] >> 2) & 3) << 4)) - 32)
1108
- + y[l+64] * s[4] * d * ((int8_t)((ql[l+ 0] >> 4) | (((qh[l] >> 4) & 3) << 4)) - 32)
1109
- + y[l+96] * s[6] * d * ((int8_t)((ql[l+32] >> 4) | (((qh[l] >> 6) & 3) << 4)) - 32);
1110
- }
1111
- tmp += sum;
1200
+ float sum = 0;
1201
+ for (int l = 0; l < 4; ++l) {
1202
+ sum += y[l+ 0] * s[0] * d * ((int8_t)((ql[l+ 0] & 0xF) | (((qh[l] >> 0) & 3) << 4)) - 32)
1203
+ + y[l+32] * s[2] * d * ((int8_t)((ql[l+32] & 0xF) | (((qh[l] >> 2) & 3) << 4)) - 32)
1204
+ + y[l+64] * s[4] * d * ((int8_t)((ql[l+ 0] >> 4) | (((qh[l] >> 4) & 3) << 4)) - 32)
1205
+ + y[l+96] * s[6] * d * ((int8_t)((ql[l+32] >> 4) | (((qh[l] >> 6) & 3) << 4)) - 32);
1206
+ }
1207
+ tmp += sum;
1112
1208
  #endif
1209
+ }
1113
1210
 
1114
1211
  }
1115
1212
 
@@ -1146,7 +1243,7 @@ static void dequantize_mul_mat_vec_q6_k(const void * __restrict__ vx, const floa
1146
1243
 
1147
1244
  // sum up partial sums and write back result
1148
1245
  #pragma unroll
1149
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
1246
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
1150
1247
  tmp +=
1151
1248
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
1152
1249
  }
@@ -1179,14 +1276,13 @@ static void dequantize_mul_mat_vec_q6_k_reorder(const void * __restrict__ vx, co
1179
1276
  #if QK_K == 256
1180
1277
 
1181
1278
  const int tid =
1182
- item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...31 or 0...16
1279
+ item_ct1.get_local_id(2) / K_QUANTS_PER_ITERATION; // 0...7 or 0...15
1183
1280
  const int ix =
1184
1281
  item_ct1.get_local_id(2) % K_QUANTS_PER_ITERATION; // 0 or 0, 1
1185
1282
 
1186
1283
  const int step = 16/K_QUANTS_PER_ITERATION; // 16 or 8
1187
1284
 
1188
- const int im = tid/step; // 0 or 1. 0 computes 0..., 1 computes 128...
1189
- const int in = tid - step*im; // 0...15 or 0...7
1285
+ const int in = tid % step; // 0...15 or 0...7
1190
1286
 
1191
1287
  #if K_QUANTS_PER_ITERATION == 1
1192
1288
  const int l0 = K_QUANTS_PER_ITERATION*in; // 0...15
@@ -1195,43 +1291,46 @@ static void dequantize_mul_mat_vec_q6_k_reorder(const void * __restrict__ vx, co
1195
1291
  const int l0 = 4 * in; // 0, 4, 8, ..., 28
1196
1292
  const int is = in / 4;
1197
1293
  #endif
1198
- const int ql_offset = 64*im + l0;
1199
- const int qh_offset = 32*im + l0;
1200
- const int s_offset = 8*im + is;
1201
- const int y_offset = 128*im + l0;
1202
1294
 
1203
1295
  float tmp = 0; // partial sum for thread in warp
1204
1296
 
1205
1297
  for (int i = ix; i < num_blocks_per_row; i += K_QUANTS_PER_ITERATION) {
1206
1298
  const int bi = ib0 + i;
1207
1299
 
1208
- const float * y = yy + i * QK_K + y_offset;
1209
- const uint8_t * ql = ql_base + bi * (QK_K / 2) + ql_offset;
1210
- const uint8_t * qh = qh_base + bi * (QK_K / 4) + qh_offset;
1211
- const int8_t * s = scales_base + bi * (QK_K / 16) + s_offset;
1212
-
1213
1300
  const float d = d_base[bi];
1214
1301
 
1302
+ for (int im = 0; im < 2; ++im) {
1303
+ const int ql_offset = 64*im + l0;
1304
+ const int qh_offset = 32*im + l0;
1305
+ const int s_offset = 8*im + is;
1306
+ const int y_offset = 128*im + l0;
1307
+
1308
+ const float * y = yy + i * QK_K + y_offset;
1309
+ const uint8_t * ql = ql_base + bi * (QK_K / 2) + ql_offset;
1310
+ const uint8_t * qh = qh_base + bi * (QK_K / 4) + qh_offset;
1311
+ const int8_t * s = scales_base + bi * (QK_K / 16) + s_offset;
1312
+
1215
1313
  #if K_QUANTS_PER_ITERATION == 1
1216
- float sum = y[ 0] * s[0] * d * ((int8_t)((ql[ 0] & 0xF) | ((qh[ 0] & 0x03) << 4)) - 32)
1217
- + y[16] * s[1] * d * ((int8_t)((ql[16] & 0xF) | ((qh[16] & 0x03) << 4)) - 32)
1218
- + y[32] * s[2] * d * ((int8_t)((ql[32] & 0xF) | ((qh[ 0] & 0x0c) << 2)) - 32)
1219
- + y[48] * s[3] * d * ((int8_t)((ql[48] & 0xF) | ((qh[16] & 0x0c) << 2)) - 32)
1220
- + y[64] * s[4] * d * ((int8_t)((ql[ 0] >> 4) | ((qh[ 0] & 0x30) >> 0)) - 32)
1221
- + y[80] * s[5] * d * ((int8_t)((ql[16] >> 4) | ((qh[16] & 0x30) >> 0)) - 32)
1222
- + y[96] * s[6] * d * ((int8_t)((ql[32] >> 4) | ((qh[ 0] & 0xc0) >> 2)) - 32)
1223
- +y[112] * s[7] * d * ((int8_t)((ql[48] >> 4) | ((qh[16] & 0xc0) >> 2)) - 32);
1224
- tmp += sum;
1314
+ float sum = y[ 0] * s[0] * d * ((int8_t)((ql[ 0] & 0xF) | ((qh[ 0] & 0x03) << 4)) - 32)
1315
+ + y[16] * s[1] * d * ((int8_t)((ql[16] & 0xF) | ((qh[16] & 0x03) << 4)) - 32)
1316
+ + y[32] * s[2] * d * ((int8_t)((ql[32] & 0xF) | ((qh[ 0] & 0x0c) << 2)) - 32)
1317
+ + y[48] * s[3] * d * ((int8_t)((ql[48] & 0xF) | ((qh[16] & 0x0c) << 2)) - 32)
1318
+ + y[64] * s[4] * d * ((int8_t)((ql[ 0] >> 4) | ((qh[ 0] & 0x30) >> 0)) - 32)
1319
+ + y[80] * s[5] * d * ((int8_t)((ql[16] >> 4) | ((qh[16] & 0x30) >> 0)) - 32)
1320
+ + y[96] * s[6] * d * ((int8_t)((ql[32] >> 4) | ((qh[ 0] & 0xc0) >> 2)) - 32)
1321
+ +y[112] * s[7] * d * ((int8_t)((ql[48] >> 4) | ((qh[16] & 0xc0) >> 2)) - 32);
1322
+ tmp += sum;
1225
1323
  #else
1226
- float sum = 0;
1227
- for (int l = 0; l < 4; ++l) {
1228
- sum += y[l+ 0] * s[0] * d * ((int8_t)((ql[l+ 0] & 0xF) | (((qh[l] >> 0) & 3) << 4)) - 32)
1229
- + y[l+32] * s[2] * d * ((int8_t)((ql[l+32] & 0xF) | (((qh[l] >> 2) & 3) << 4)) - 32)
1230
- + y[l+64] * s[4] * d * ((int8_t)((ql[l+ 0] >> 4) | (((qh[l] >> 4) & 3) << 4)) - 32)
1231
- + y[l+96] * s[6] * d * ((int8_t)((ql[l+32] >> 4) | (((qh[l] >> 6) & 3) << 4)) - 32);
1232
- }
1233
- tmp += sum;
1324
+ float sum = 0;
1325
+ for (int l = 0; l < 4; ++l) {
1326
+ sum += y[l+ 0] * s[0] * d * ((int8_t)((ql[l+ 0] & 0xF) | (((qh[l] >> 0) & 3) << 4)) - 32)
1327
+ + y[l+32] * s[2] * d * ((int8_t)((ql[l+32] & 0xF) | (((qh[l] >> 2) & 3) << 4)) - 32)
1328
+ + y[l+64] * s[4] * d * ((int8_t)((ql[l+ 0] >> 4) | (((qh[l] >> 4) & 3) << 4)) - 32)
1329
+ + y[l+96] * s[6] * d * ((int8_t)((ql[l+32] >> 4) | (((qh[l] >> 6) & 3) << 4)) - 32);
1330
+ }
1331
+ tmp += sum;
1234
1332
  #endif
1333
+ }
1235
1334
 
1236
1335
  }
1237
1336
 
@@ -1269,7 +1368,7 @@ static void dequantize_mul_mat_vec_q6_k_reorder(const void * __restrict__ vx, co
1269
1368
 
1270
1369
  // sum up partial sums and write back result
1271
1370
  #pragma unroll
1272
- for (int mask = QK_WARP_SIZE / 2; mask > 0; mask >>= 1) {
1371
+ for (int mask = WARP_SIZE / 2; mask > 0; mask >>= 1) {
1273
1372
  tmp +=
1274
1373
  dpct::permute_sub_group_by_xor(item_ct1.get_sub_group(), tmp, mask);
1275
1374
  }
@@ -1324,6 +1423,50 @@ static void dequantize_mul_mat_vec_q4_0_sycl(const void *vx, const dfloat *y,
1324
1423
  }
1325
1424
  }
1326
1425
 
1426
+ static void dequantize_mul_mat_vec_q1_0_sycl_reorder(const void *vx, const dfloat *y,
1427
+ float *dst, const int ncols,
1428
+ const int nrows,
1429
+ dpct::queue_ptr stream) {
1430
+ GGML_ASSERT(ncols % GGML_SYCL_DMMV_X == 0);
1431
+ const int block_num_y = (nrows + GGML_SYCL_MMV_Y - 1) / GGML_SYCL_MMV_Y;
1432
+ // the number of rows may exceed maximum grid size in the y or z dimensions, use the x dimension instead
1433
+ const sycl::range<3> block_nums(1, 1, block_num_y);
1434
+ const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, WARP_SIZE);
1435
+ {
1436
+ dpct::has_capability_or_fail(stream->get_device(),
1437
+ {sycl::aspect::fp16});
1438
+
1439
+ stream->parallel_for(
1440
+ sycl::nd_range<3>(block_nums * block_dims, block_dims),
1441
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1442
+ dequantize_mul_mat_vec_reorder<QK1_0, QR1_0, dequantize_q1_0_reorder>(
1443
+ vx, y, dst, ncols, nrows, item_ct1);
1444
+ });
1445
+ }
1446
+ }
1447
+
1448
+ static void dequantize_mul_mat_vec_q1_0_sycl(const void *vx, const dfloat *y,
1449
+ float *dst, const int ncols,
1450
+ const int nrows,
1451
+ dpct::queue_ptr stream) {
1452
+ GGML_ASSERT(ncols % GGML_SYCL_DMMV_X == 0);
1453
+ const int block_num_y = (nrows + GGML_SYCL_MMV_Y - 1) / GGML_SYCL_MMV_Y;
1454
+ // the number of rows may exceed maximum grid size in the y or z dimensions, use the x dimension instead
1455
+ const sycl::range<3> block_nums(1, 1, block_num_y);
1456
+ const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, WARP_SIZE);
1457
+ {
1458
+ dpct::has_capability_or_fail(stream->get_device(),
1459
+ {sycl::aspect::fp16});
1460
+
1461
+ stream->parallel_for(
1462
+ sycl::nd_range<3>(block_nums * block_dims, block_dims),
1463
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1464
+ dequantize_mul_mat_vec<QK1_0, QR1_0, dequantize_q1_0>(
1465
+ vx, y, dst, ncols, nrows, item_ct1);
1466
+ });
1467
+ }
1468
+ }
1469
+
1327
1470
  static void dequantize_mul_mat_vec_q4_1_sycl(const void *vx, const dfloat *y,
1328
1471
  float *dst, const int ncols,
1329
1472
  const int nrows,
@@ -1513,10 +1656,10 @@ static void dequantize_mul_mat_vec_q2_K_sycl(const void *vx, const float *y,
1513
1656
  const int ny = 2; // very slightly faster than 1 even when K_QUANTS_PER_ITERATION = 2
1514
1657
  const int block_num_y = (nrows + ny - 1) / ny;
1515
1658
  const sycl::range<3> block_nums(1, 1, block_num_y);
1516
- const sycl::range<3> block_dims(1, ny, QK_WARP_SIZE);
1659
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1517
1660
  stream->parallel_for(
1518
1661
  sycl::nd_range<3>(block_nums * block_dims, block_dims),
1519
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1662
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1520
1663
  dequantize_mul_mat_vec_q2_k(vx, y, dst, ncols, nrows, item_ct1);
1521
1664
  });
1522
1665
  }
@@ -1529,10 +1672,10 @@ static void dequantize_mul_mat_vec_q3_K_sycl(const void *vx, const float *y,
1529
1672
  const int ny = 2 / K_QUANTS_PER_ITERATION;
1530
1673
  const int block_num_y = (nrows + ny - 1) / ny;
1531
1674
  const sycl::range<3> block_nums(1, 1, block_num_y);
1532
- const sycl::range<3> block_dims(1, ny, QK_WARP_SIZE);
1675
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1533
1676
  stream->parallel_for(
1534
1677
  sycl::nd_range<3>(block_nums * block_dims, block_dims),
1535
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1678
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1536
1679
  dequantize_mul_mat_vec_q3_k(vx, y, dst, ncols, nrows, item_ct1);
1537
1680
  });
1538
1681
  }
@@ -1545,10 +1688,10 @@ static void dequantize_mul_mat_vec_q3_K_sycl_reorder(const void *vx, const float
1545
1688
  const int ny = 2 / K_QUANTS_PER_ITERATION;
1546
1689
  const int block_num_y = (nrows + ny - 1) / ny;
1547
1690
  const sycl::range<3> block_nums(1, 1, block_num_y);
1548
- const sycl::range<3> block_dims(1, ny, QK_WARP_SIZE);
1691
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1549
1692
  stream->parallel_for(
1550
1693
  sycl::nd_range<3>(block_nums * block_dims, block_dims),
1551
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1694
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1552
1695
  dequantize_mul_mat_vec_q3_k_reorder(vx, y, dst, ncols, nrows, item_ct1);
1553
1696
  });
1554
1697
  }
@@ -1561,10 +1704,10 @@ static void dequantize_mul_mat_vec_q4_K_sycl(const void *vx, const float *y,
1561
1704
  const int ny = 2 / K_QUANTS_PER_ITERATION;
1562
1705
  const int block_num_y = (nrows + ny - 1) / ny;
1563
1706
  const sycl::range<3> block_nums(1, 1, block_num_y);
1564
- const sycl::range<3> block_dims(1, ny, QK_WARP_SIZE);
1707
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1565
1708
  stream->parallel_for(
1566
1709
  sycl::nd_range<3>(block_nums * block_dims, block_dims),
1567
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1710
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1568
1711
  dequantize_mul_mat_vec_q4_k(vx, y, dst, ncols, nrows, item_ct1);
1569
1712
  });
1570
1713
  }
@@ -1574,10 +1717,10 @@ static void dequantize_mul_mat_vec_q5_K_sycl(const void *vx, const float *y,
1574
1717
  const int nrows,
1575
1718
  dpct::queue_ptr stream) {
1576
1719
  GGML_ASSERT(ncols % QK_K == 0);
1577
- const sycl::range<3> block_dims(1, 1, QK_WARP_SIZE);
1720
+ const sycl::range<3> block_dims(1, 1, WARP_SIZE);
1578
1721
  stream->parallel_for(
1579
1722
  sycl::nd_range<3>(sycl::range<3>(1, 1, nrows) * block_dims, block_dims),
1580
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1723
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1581
1724
  dequantize_mul_mat_vec_q5_k(vx, y, dst, ncols, item_ct1);
1582
1725
  });
1583
1726
  }
@@ -1590,10 +1733,10 @@ static void dequantize_mul_mat_vec_q6_K_sycl(const void *vx, const float *y,
1590
1733
  const int ny = 2 / K_QUANTS_PER_ITERATION;
1591
1734
  const int block_num_y = (nrows + ny - 1) / ny;
1592
1735
  const sycl::range<3> block_nums(1, 1, block_num_y);
1593
- const sycl::range<3> block_dims(1, ny, QK_WARP_SIZE);
1736
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1594
1737
  stream->parallel_for(
1595
1738
  sycl::nd_range<3>(block_nums * block_dims, block_dims),
1596
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1739
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1597
1740
  dequantize_mul_mat_vec_q6_k(vx, y, dst, ncols, nrows, item_ct1);
1598
1741
  });
1599
1742
  }
@@ -1606,14 +1749,30 @@ static void dequantize_mul_mat_vec_q4_K_sycl_reorder(const void *vx, const float
1606
1749
  const int ny = 2 / K_QUANTS_PER_ITERATION;
1607
1750
  const int block_num_y = (nrows + ny - 1) / ny;
1608
1751
  const sycl::range<3> block_nums(1, 1, block_num_y);
1609
- const sycl::range<3> block_dims(1, ny, QK_WARP_SIZE);
1752
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1610
1753
  stream->parallel_for(
1611
1754
  sycl::nd_range<3>(block_nums * block_dims, block_dims),
1612
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1755
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1613
1756
  dequantize_mul_mat_vec_q4_k_reorder(vx, y, dst, ncols, nrows, item_ct1);
1614
1757
  });
1615
1758
  }
1616
1759
 
1760
+ static void dequantize_mul_mat_vec_q5_K_sycl_reorder(const void *vx, const float *y,
1761
+ float *dst, const int ncols,
1762
+ const int nrows,
1763
+ dpct::queue_ptr stream) {
1764
+ GGML_ASSERT(ncols % QK_K == 0);
1765
+ const int ny = 2 / K_QUANTS_PER_ITERATION;
1766
+ const int block_num_y = (nrows + ny - 1) / ny;
1767
+ const sycl::range<3> block_nums(1, 1, block_num_y);
1768
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1769
+ stream->parallel_for(
1770
+ sycl::nd_range<3>(block_nums * block_dims, block_dims),
1771
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1772
+ dequantize_mul_mat_vec_q5_k_reorder(vx, y, dst, ncols, nrows, item_ct1);
1773
+ });
1774
+ }
1775
+
1617
1776
  static void dequantize_mul_mat_vec_q6_K_sycl_reorder(const void *vx, const float *y,
1618
1777
  float *dst, const int ncols,
1619
1778
  const int nrows,
@@ -1622,10 +1781,10 @@ static void dequantize_mul_mat_vec_q6_K_sycl_reorder(const void *vx, const float
1622
1781
  const int ny = 2 / K_QUANTS_PER_ITERATION;
1623
1782
  const int block_num_y = (nrows + ny - 1) / ny;
1624
1783
  const sycl::range<3> block_nums(1, 1, block_num_y);
1625
- const sycl::range<3> block_dims(1, ny, QK_WARP_SIZE);
1784
+ const sycl::range<3> block_dims(1, ny, WARP_SIZE);
1626
1785
  stream->parallel_for(
1627
1786
  sycl::nd_range<3>(block_nums * block_dims, block_dims),
1628
- [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(QK_WARP_SIZE)]] {
1787
+ [=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
1629
1788
  dequantize_mul_mat_vec_q6_k_reorder(vx, y, dst, ncols, nrows, item_ct1);
1630
1789
  });
1631
1790
  }
@@ -1647,6 +1806,7 @@ void ggml_sycl_op_dequantize_mul_mat_vec(
1647
1806
  sycl::half *src1_dfloat = nullptr; // dfloat == half
1648
1807
 
1649
1808
  bool src1_convert_f16 =
1809
+ src0->type == GGML_TYPE_Q1_0 ||
1650
1810
  src0->type == GGML_TYPE_Q4_0 || src0->type == GGML_TYPE_Q4_1 ||
1651
1811
  src0->type == GGML_TYPE_Q5_0 || src0->type == GGML_TYPE_Q5_1 ||
1652
1812
  src0->type == GGML_TYPE_Q8_0 || src0->type == GGML_TYPE_F16 ||
@@ -1665,6 +1825,14 @@ void ggml_sycl_op_dequantize_mul_mat_vec(
1665
1825
  #endif // GGML_SYCL_F16
1666
1826
 
1667
1827
  switch (src0->type) {
1828
+ case GGML_TYPE_Q1_0:
1829
+ if ((ggml_tensor_extra_gpu*)dst->src[0]->extra &&
1830
+ ((ggml_tensor_extra_gpu*)dst->src[0]->extra)->optimized_feature.reorder) {
1831
+ dequantize_mul_mat_vec_q1_0_sycl_reorder(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
1832
+ } else {
1833
+ dequantize_mul_mat_vec_q1_0_sycl(src0_dd_i, src1_dfloat, dst_dd_i, ne00, row_diff, stream);
1834
+ }
1835
+ break;
1668
1836
  case GGML_TYPE_Q4_0:
1669
1837
  if ((ggml_tensor_extra_gpu*)dst->src[0]->extra &&
1670
1838
  ((ggml_tensor_extra_gpu*)dst->src[0]->extra)->optimized_feature.reorder) {
@@ -1710,7 +1878,12 @@ void ggml_sycl_op_dequantize_mul_mat_vec(
1710
1878
  }
1711
1879
  break;
1712
1880
  case GGML_TYPE_Q5_K:
1713
- dequantize_mul_mat_vec_q5_K_sycl(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
1881
+ if ((ggml_tensor_extra_gpu *) dst->src[0]->extra &&
1882
+ ((ggml_tensor_extra_gpu *) dst->src[0]->extra)->optimized_feature.reorder) {
1883
+ dequantize_mul_mat_vec_q5_K_sycl_reorder(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
1884
+ } else {
1885
+ dequantize_mul_mat_vec_q5_K_sycl(src0_dd_i, src1_ddf_i, dst_dd_i, ne00, row_diff, stream);
1886
+ }
1714
1887
  break;
1715
1888
  case GGML_TYPE_Q6_K:
1716
1889
  if ((ggml_tensor_extra_gpu *) dst->src[0]->extra &&