@fugood/llama.node 0.6.2 → 1.0.0-beta.1

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 (378) hide show
  1. package/CMakeLists.txt +40 -30
  2. package/README.md +4 -1
  3. package/lib/binding.js +41 -29
  4. package/lib/binding.ts +26 -25
  5. package/package.json +45 -10
  6. package/scripts/build.js +47 -0
  7. package/scripts/llama.cpp.patch +109 -0
  8. package/src/anyascii.c +22223 -0
  9. package/src/anyascii.h +42 -0
  10. package/src/tts_utils.cpp +20 -7
  11. package/src/tts_utils.h +2 -0
  12. package/bin/darwin/arm64/llama-node.node +0 -0
  13. package/bin/darwin/x64/llama-node.node +0 -0
  14. package/bin/linux/arm64/llama-node.node +0 -0
  15. package/bin/linux/x64/llama-node.node +0 -0
  16. package/bin/linux-cuda/arm64/llama-node.node +0 -0
  17. package/bin/linux-cuda/x64/llama-node.node +0 -0
  18. package/bin/linux-vulkan/arm64/llama-node.node +0 -0
  19. package/bin/linux-vulkan/x64/llama-node.node +0 -0
  20. package/bin/win32/x64/llama-node.node +0 -0
  21. package/bin/win32/x64/node.lib +0 -0
  22. package/bin/win32-vulkan/arm64/llama-node.node +0 -0
  23. package/bin/win32-vulkan/arm64/node.lib +0 -0
  24. package/bin/win32-vulkan/x64/llama-node.node +0 -0
  25. package/bin/win32-vulkan/x64/node.lib +0 -0
  26. package/patches/node-api-headers+1.1.0.patch +0 -26
  27. package/src/llama.cpp/.github/workflows/build-linux-cross.yml +0 -233
  28. package/src/llama.cpp/.github/workflows/build.yml +0 -1078
  29. package/src/llama.cpp/.github/workflows/close-issue.yml +0 -28
  30. package/src/llama.cpp/.github/workflows/docker.yml +0 -178
  31. package/src/llama.cpp/.github/workflows/editorconfig.yml +0 -29
  32. package/src/llama.cpp/.github/workflows/gguf-publish.yml +0 -44
  33. package/src/llama.cpp/.github/workflows/labeler.yml +0 -17
  34. package/src/llama.cpp/.github/workflows/python-check-requirements.yml +0 -33
  35. package/src/llama.cpp/.github/workflows/python-lint.yml +0 -30
  36. package/src/llama.cpp/.github/workflows/python-type-check.yml +0 -40
  37. package/src/llama.cpp/.github/workflows/release.yml +0 -739
  38. package/src/llama.cpp/.github/workflows/server.yml +0 -237
  39. package/src/llama.cpp/.github/workflows/winget.yml +0 -42
  40. package/src/llama.cpp/cmake/arm64-apple-clang.cmake +0 -16
  41. package/src/llama.cpp/cmake/arm64-windows-llvm.cmake +0 -16
  42. package/src/llama.cpp/cmake/build-info.cmake +0 -64
  43. package/src/llama.cpp/cmake/common.cmake +0 -35
  44. package/src/llama.cpp/cmake/git-vars.cmake +0 -22
  45. package/src/llama.cpp/cmake/x64-windows-llvm.cmake +0 -5
  46. package/src/llama.cpp/common/build-info.cpp.in +0 -4
  47. package/src/llama.cpp/docs/build.md +0 -561
  48. package/src/llama.cpp/examples/CMakeLists.txt +0 -43
  49. package/src/llama.cpp/examples/batched/CMakeLists.txt +0 -5
  50. package/src/llama.cpp/examples/batched/batched.cpp +0 -246
  51. package/src/llama.cpp/examples/chat-13B.bat +0 -57
  52. package/src/llama.cpp/examples/convert-llama2c-to-ggml/CMakeLists.txt +0 -5
  53. package/src/llama.cpp/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp +0 -941
  54. package/src/llama.cpp/examples/deprecation-warning/deprecation-warning.cpp +0 -35
  55. package/src/llama.cpp/examples/embedding/CMakeLists.txt +0 -5
  56. package/src/llama.cpp/examples/embedding/embedding.cpp +0 -323
  57. package/src/llama.cpp/examples/eval-callback/CMakeLists.txt +0 -10
  58. package/src/llama.cpp/examples/eval-callback/eval-callback.cpp +0 -194
  59. package/src/llama.cpp/examples/gen-docs/CMakeLists.txt +0 -5
  60. package/src/llama.cpp/examples/gen-docs/gen-docs.cpp +0 -83
  61. package/src/llama.cpp/examples/gguf/CMakeLists.txt +0 -5
  62. package/src/llama.cpp/examples/gguf/gguf.cpp +0 -265
  63. package/src/llama.cpp/examples/gguf-hash/CMakeLists.txt +0 -22
  64. package/src/llama.cpp/examples/gguf-hash/deps/rotate-bits/rotate-bits.h +0 -46
  65. package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.c +0 -295
  66. package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.h +0 -52
  67. package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.c +0 -221
  68. package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.h +0 -24
  69. package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.c +0 -42
  70. package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.h +0 -7093
  71. package/src/llama.cpp/examples/gguf-hash/gguf-hash.cpp +0 -694
  72. package/src/llama.cpp/examples/gritlm/CMakeLists.txt +0 -5
  73. package/src/llama.cpp/examples/gritlm/gritlm.cpp +0 -229
  74. package/src/llama.cpp/examples/jeopardy/questions.txt +0 -100
  75. package/src/llama.cpp/examples/llama.android/app/build.gradle.kts +0 -65
  76. package/src/llama.cpp/examples/llama.android/build.gradle.kts +0 -6
  77. package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +0 -71
  78. package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/CMakeLists.txt +0 -53
  79. package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/llama-android.cpp +0 -452
  80. package/src/llama.cpp/examples/llama.android/settings.gradle.kts +0 -18
  81. package/src/llama.cpp/examples/lookahead/CMakeLists.txt +0 -5
  82. package/src/llama.cpp/examples/lookahead/lookahead.cpp +0 -472
  83. package/src/llama.cpp/examples/lookup/CMakeLists.txt +0 -23
  84. package/src/llama.cpp/examples/lookup/lookup-create.cpp +0 -40
  85. package/src/llama.cpp/examples/lookup/lookup-merge.cpp +0 -47
  86. package/src/llama.cpp/examples/lookup/lookup-stats.cpp +0 -157
  87. package/src/llama.cpp/examples/lookup/lookup.cpp +0 -242
  88. package/src/llama.cpp/examples/parallel/CMakeLists.txt +0 -5
  89. package/src/llama.cpp/examples/parallel/parallel.cpp +0 -492
  90. package/src/llama.cpp/examples/passkey/CMakeLists.txt +0 -5
  91. package/src/llama.cpp/examples/passkey/passkey.cpp +0 -277
  92. package/src/llama.cpp/examples/retrieval/CMakeLists.txt +0 -5
  93. package/src/llama.cpp/examples/retrieval/retrieval.cpp +0 -304
  94. package/src/llama.cpp/examples/save-load-state/CMakeLists.txt +0 -5
  95. package/src/llama.cpp/examples/save-load-state/save-load-state.cpp +0 -246
  96. package/src/llama.cpp/examples/simple/CMakeLists.txt +0 -5
  97. package/src/llama.cpp/examples/simple/simple.cpp +0 -206
  98. package/src/llama.cpp/examples/simple-chat/CMakeLists.txt +0 -5
  99. package/src/llama.cpp/examples/simple-chat/simple-chat.cpp +0 -206
  100. package/src/llama.cpp/examples/simple-cmake-pkg/CMakeLists.txt +0 -11
  101. package/src/llama.cpp/examples/speculative/CMakeLists.txt +0 -5
  102. package/src/llama.cpp/examples/speculative/speculative.cpp +0 -644
  103. package/src/llama.cpp/examples/speculative-simple/CMakeLists.txt +0 -5
  104. package/src/llama.cpp/examples/speculative-simple/speculative-simple.cpp +0 -261
  105. package/src/llama.cpp/examples/sycl/CMakeLists.txt +0 -9
  106. package/src/llama.cpp/examples/sycl/build.sh +0 -23
  107. package/src/llama.cpp/examples/sycl/ls-sycl-device.cpp +0 -13
  108. package/src/llama.cpp/examples/sycl/run-llama2.sh +0 -27
  109. package/src/llama.cpp/examples/sycl/run-llama3.sh +0 -28
  110. package/src/llama.cpp/examples/sycl/win-build-sycl.bat +0 -33
  111. package/src/llama.cpp/examples/sycl/win-run-llama2.bat +0 -9
  112. package/src/llama.cpp/examples/sycl/win-run-llama3.bat +0 -9
  113. package/src/llama.cpp/examples/training/CMakeLists.txt +0 -5
  114. package/src/llama.cpp/examples/training/finetune.cpp +0 -96
  115. package/src/llama.cpp/ggml/cmake/GitVars.cmake +0 -22
  116. package/src/llama.cpp/ggml/cmake/common.cmake +0 -26
  117. package/src/llama.cpp/ggml/src/ggml-alloc.c +0 -1042
  118. package/src/llama.cpp/ggml/src/ggml-backend-impl.h +0 -255
  119. package/src/llama.cpp/ggml/src/ggml-backend-reg.cpp +0 -586
  120. package/src/llama.cpp/ggml/src/ggml-backend.cpp +0 -2008
  121. package/src/llama.cpp/ggml/src/ggml-blas/CMakeLists.txt +0 -87
  122. package/src/llama.cpp/ggml/src/ggml-blas/ggml-blas.cpp +0 -517
  123. package/src/llama.cpp/ggml/src/ggml-cann/CMakeLists.txt +0 -74
  124. package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.cpp +0 -179
  125. package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.h +0 -258
  126. package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +0 -2863
  127. package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +0 -1110
  128. package/src/llama.cpp/ggml/src/ggml-cann/common.h +0 -420
  129. package/src/llama.cpp/ggml/src/ggml-cann/ggml-cann.cpp +0 -2570
  130. package/src/llama.cpp/ggml/src/ggml-common.h +0 -1857
  131. package/src/llama.cpp/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +0 -100
  132. package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +0 -184
  133. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/cuda.h +0 -15
  134. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +0 -243
  135. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/musa.h +0 -140
  136. package/src/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt +0 -131
  137. package/src/llama.cpp/ggml/src/ggml-impl.h +0 -601
  138. package/src/llama.cpp/ggml/src/ggml-kompute/CMakeLists.txt +0 -166
  139. package/src/llama.cpp/ggml/src/ggml-kompute/ggml-kompute.cpp +0 -2251
  140. package/src/llama.cpp/ggml/src/ggml-metal/CMakeLists.txt +0 -120
  141. package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +0 -622
  142. package/src/llama.cpp/ggml/src/ggml-musa/CMakeLists.txt +0 -113
  143. package/src/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +0 -96
  144. package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +0 -5124
  145. package/src/llama.cpp/ggml/src/ggml-opt.cpp +0 -1037
  146. package/src/llama.cpp/ggml/src/ggml-quants.c +0 -5232
  147. package/src/llama.cpp/ggml/src/ggml-quants.h +0 -100
  148. package/src/llama.cpp/ggml/src/ggml-rpc/CMakeLists.txt +0 -9
  149. package/src/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +0 -1813
  150. package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +0 -189
  151. package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +0 -37
  152. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +0 -239
  153. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.hpp +0 -39
  154. package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +0 -83
  155. package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +0 -493
  156. package/src/llama.cpp/ggml/src/ggml-sycl/concat.cpp +0 -197
  157. package/src/llama.cpp/ggml/src/ggml-sycl/concat.hpp +0 -20
  158. package/src/llama.cpp/ggml/src/ggml-sycl/conv.cpp +0 -100
  159. package/src/llama.cpp/ggml/src/ggml-sycl/conv.hpp +0 -20
  160. package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +0 -623
  161. package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +0 -34
  162. package/src/llama.cpp/ggml/src/ggml-sycl/cpy.cpp +0 -701
  163. package/src/llama.cpp/ggml/src/ggml-sycl/cpy.hpp +0 -11
  164. package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +0 -791
  165. package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +0 -1160
  166. package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.hpp +0 -27
  167. package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +0 -2957
  168. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +0 -1536
  169. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.hpp +0 -75
  170. package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +0 -99
  171. package/src/llama.cpp/ggml/src/ggml-sycl/getrows.cpp +0 -311
  172. package/src/llama.cpp/ggml/src/ggml-sycl/getrows.hpp +0 -20
  173. package/src/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +0 -4443
  174. package/src/llama.cpp/ggml/src/ggml-sycl/gla.cpp +0 -105
  175. package/src/llama.cpp/ggml/src/ggml-sycl/gla.hpp +0 -8
  176. package/src/llama.cpp/ggml/src/ggml-sycl/im2col.cpp +0 -136
  177. package/src/llama.cpp/ggml/src/ggml-sycl/im2col.hpp +0 -21
  178. package/src/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +0 -3030
  179. package/src/llama.cpp/ggml/src/ggml-sycl/mmq.hpp +0 -33
  180. package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +0 -1108
  181. package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.hpp +0 -27
  182. package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +0 -474
  183. package/src/llama.cpp/ggml/src/ggml-sycl/norm.hpp +0 -26
  184. package/src/llama.cpp/ggml/src/ggml-sycl/outprod.cpp +0 -46
  185. package/src/llama.cpp/ggml/src/ggml-sycl/outprod.hpp +0 -10
  186. package/src/llama.cpp/ggml/src/ggml-sycl/presets.hpp +0 -74
  187. package/src/llama.cpp/ggml/src/ggml-sycl/quants.hpp +0 -83
  188. package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +0 -362
  189. package/src/llama.cpp/ggml/src/ggml-sycl/rope.hpp +0 -20
  190. package/src/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +0 -264
  191. package/src/llama.cpp/ggml/src/ggml-sycl/softmax.hpp +0 -20
  192. package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.cpp +0 -13
  193. package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.hpp +0 -23
  194. package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.cpp +0 -73
  195. package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.hpp +0 -20
  196. package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +0 -1215
  197. package/src/llama.cpp/ggml/src/ggml-sycl/wkv.cpp +0 -305
  198. package/src/llama.cpp/ggml/src/ggml-sycl/wkv.hpp +0 -10
  199. package/src/llama.cpp/ggml/src/ggml-threading.cpp +0 -12
  200. package/src/llama.cpp/ggml/src/ggml-threading.h +0 -14
  201. package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +0 -196
  202. package/src/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +0 -10699
  203. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +0 -39
  204. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +0 -751
  205. package/src/llama.cpp/ggml/src/ggml.c +0 -6550
  206. package/src/llama.cpp/ggml/src/gguf.cpp +0 -1330
  207. package/src/llama.cpp/models/.editorconfig +0 -1
  208. package/src/llama.cpp/models/ggml-vocab-aquila.gguf +0 -0
  209. package/src/llama.cpp/models/ggml-vocab-baichuan.gguf +0 -0
  210. package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf +0 -0
  211. package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.inp +0 -112
  212. package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.out +0 -46
  213. package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.inp +0 -112
  214. package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.out +0 -46
  215. package/src/llama.cpp/models/ggml-vocab-command-r.gguf +0 -0
  216. package/src/llama.cpp/models/ggml-vocab-command-r.gguf.inp +0 -112
  217. package/src/llama.cpp/models/ggml-vocab-command-r.gguf.out +0 -46
  218. package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf +0 -0
  219. package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.inp +0 -112
  220. package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.out +0 -46
  221. package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf +0 -0
  222. package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.inp +0 -112
  223. package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.out +0 -46
  224. package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.inp +0 -112
  225. package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.out +0 -46
  226. package/src/llama.cpp/models/ggml-vocab-falcon.gguf +0 -0
  227. package/src/llama.cpp/models/ggml-vocab-falcon.gguf.inp +0 -112
  228. package/src/llama.cpp/models/ggml-vocab-falcon.gguf.out +0 -46
  229. package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf +0 -0
  230. package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.inp +0 -112
  231. package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.out +0 -46
  232. package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.inp +0 -112
  233. package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.out +0 -46
  234. package/src/llama.cpp/models/ggml-vocab-gpt-neox.gguf +0 -0
  235. package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf +0 -0
  236. package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.inp +0 -112
  237. package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.out +0 -46
  238. package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf +0 -0
  239. package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.inp +0 -112
  240. package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.out +0 -46
  241. package/src/llama.cpp/models/ggml-vocab-llama4.gguf.inp +0 -112
  242. package/src/llama.cpp/models/ggml-vocab-llama4.gguf.out +0 -46
  243. package/src/llama.cpp/models/ggml-vocab-mpt.gguf +0 -0
  244. package/src/llama.cpp/models/ggml-vocab-mpt.gguf.inp +0 -112
  245. package/src/llama.cpp/models/ggml-vocab-mpt.gguf.out +0 -46
  246. package/src/llama.cpp/models/ggml-vocab-phi-3.gguf +0 -0
  247. package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.inp +0 -112
  248. package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.out +0 -46
  249. package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.inp +0 -112
  250. package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.out +0 -46
  251. package/src/llama.cpp/models/ggml-vocab-qwen2.gguf +0 -0
  252. package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.inp +0 -112
  253. package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.out +0 -46
  254. package/src/llama.cpp/models/ggml-vocab-refact.gguf +0 -0
  255. package/src/llama.cpp/models/ggml-vocab-refact.gguf.inp +0 -112
  256. package/src/llama.cpp/models/ggml-vocab-refact.gguf.out +0 -46
  257. package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.inp +0 -112
  258. package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.out +0 -46
  259. package/src/llama.cpp/models/ggml-vocab-starcoder.gguf +0 -0
  260. package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.inp +0 -112
  261. package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.out +0 -46
  262. package/src/llama.cpp/pocs/CMakeLists.txt +0 -14
  263. package/src/llama.cpp/pocs/vdot/CMakeLists.txt +0 -9
  264. package/src/llama.cpp/pocs/vdot/q8dot.cpp +0 -173
  265. package/src/llama.cpp/pocs/vdot/vdot.cpp +0 -311
  266. package/src/llama.cpp/prompts/LLM-questions.txt +0 -49
  267. package/src/llama.cpp/prompts/alpaca.txt +0 -1
  268. package/src/llama.cpp/prompts/assistant.txt +0 -31
  269. package/src/llama.cpp/prompts/chat-with-baichuan.txt +0 -4
  270. package/src/llama.cpp/prompts/chat-with-bob.txt +0 -7
  271. package/src/llama.cpp/prompts/chat-with-qwen.txt +0 -1
  272. package/src/llama.cpp/prompts/chat-with-vicuna-v0.txt +0 -7
  273. package/src/llama.cpp/prompts/chat-with-vicuna-v1.txt +0 -7
  274. package/src/llama.cpp/prompts/chat.txt +0 -28
  275. package/src/llama.cpp/prompts/dan-modified.txt +0 -1
  276. package/src/llama.cpp/prompts/dan.txt +0 -1
  277. package/src/llama.cpp/prompts/mnemonics.txt +0 -93
  278. package/src/llama.cpp/prompts/parallel-questions.txt +0 -43
  279. package/src/llama.cpp/prompts/reason-act.txt +0 -18
  280. package/src/llama.cpp/requirements/requirements-all.txt +0 -15
  281. package/src/llama.cpp/requirements/requirements-compare-llama-bench.txt +0 -2
  282. package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf.txt +0 -7
  283. package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf_update.txt +0 -7
  284. package/src/llama.cpp/requirements/requirements-convert_legacy_llama.txt +0 -5
  285. package/src/llama.cpp/requirements/requirements-convert_llama_ggml_to_gguf.txt +0 -1
  286. package/src/llama.cpp/requirements/requirements-convert_lora_to_gguf.txt +0 -4
  287. package/src/llama.cpp/requirements/requirements-gguf_editor_gui.txt +0 -3
  288. package/src/llama.cpp/requirements/requirements-pydantic.txt +0 -3
  289. package/src/llama.cpp/requirements/requirements-test-tokenizer-random.txt +0 -1
  290. package/src/llama.cpp/requirements/requirements-tool_bench.txt +0 -12
  291. package/src/llama.cpp/requirements.txt +0 -13
  292. package/src/llama.cpp/scripts/build-info.sh +0 -30
  293. package/src/llama.cpp/scripts/install-oneapi.bat +0 -19
  294. package/src/llama.cpp/scripts/xxd.cmake +0 -16
  295. package/src/llama.cpp/tests/CMakeLists.txt +0 -177
  296. package/src/llama.cpp/tests/get-model.cpp +0 -21
  297. package/src/llama.cpp/tests/get-model.h +0 -2
  298. package/src/llama.cpp/tests/test-arg-parser.cpp +0 -178
  299. package/src/llama.cpp/tests/test-autorelease.cpp +0 -24
  300. package/src/llama.cpp/tests/test-backend-ops.cpp +0 -4793
  301. package/src/llama.cpp/tests/test-barrier.cpp +0 -94
  302. package/src/llama.cpp/tests/test-c.c +0 -7
  303. package/src/llama.cpp/tests/test-chat-template.cpp +0 -417
  304. package/src/llama.cpp/tests/test-chat.cpp +0 -985
  305. package/src/llama.cpp/tests/test-double-float.cpp +0 -57
  306. package/src/llama.cpp/tests/test-gbnf-validator.cpp +0 -109
  307. package/src/llama.cpp/tests/test-gguf.cpp +0 -1338
  308. package/src/llama.cpp/tests/test-grammar-integration.cpp +0 -1308
  309. package/src/llama.cpp/tests/test-grammar-llguidance.cpp +0 -1201
  310. package/src/llama.cpp/tests/test-grammar-parser.cpp +0 -519
  311. package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +0 -1304
  312. package/src/llama.cpp/tests/test-llama-grammar.cpp +0 -408
  313. package/src/llama.cpp/tests/test-log.cpp +0 -39
  314. package/src/llama.cpp/tests/test-model-load-cancel.cpp +0 -27
  315. package/src/llama.cpp/tests/test-mtmd-c-api.c +0 -63
  316. package/src/llama.cpp/tests/test-opt.cpp +0 -904
  317. package/src/llama.cpp/tests/test-quantize-fns.cpp +0 -186
  318. package/src/llama.cpp/tests/test-quantize-perf.cpp +0 -365
  319. package/src/llama.cpp/tests/test-quantize-stats.cpp +0 -424
  320. package/src/llama.cpp/tests/test-regex-partial.cpp +0 -288
  321. package/src/llama.cpp/tests/test-rope.cpp +0 -262
  322. package/src/llama.cpp/tests/test-sampling.cpp +0 -399
  323. package/src/llama.cpp/tests/test-tokenizer-0.cpp +0 -312
  324. package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +0 -155
  325. package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +0 -125
  326. package/src/llama.cpp/tools/CMakeLists.txt +0 -39
  327. package/src/llama.cpp/tools/batched-bench/CMakeLists.txt +0 -5
  328. package/src/llama.cpp/tools/batched-bench/batched-bench.cpp +0 -204
  329. package/src/llama.cpp/tools/cvector-generator/CMakeLists.txt +0 -5
  330. package/src/llama.cpp/tools/cvector-generator/completions.txt +0 -582
  331. package/src/llama.cpp/tools/cvector-generator/cvector-generator.cpp +0 -508
  332. package/src/llama.cpp/tools/cvector-generator/mean.hpp +0 -48
  333. package/src/llama.cpp/tools/cvector-generator/negative.txt +0 -4
  334. package/src/llama.cpp/tools/cvector-generator/pca.hpp +0 -315
  335. package/src/llama.cpp/tools/cvector-generator/positive.txt +0 -4
  336. package/src/llama.cpp/tools/export-lora/CMakeLists.txt +0 -5
  337. package/src/llama.cpp/tools/export-lora/export-lora.cpp +0 -434
  338. package/src/llama.cpp/tools/gguf-split/CMakeLists.txt +0 -5
  339. package/src/llama.cpp/tools/gguf-split/gguf-split.cpp +0 -583
  340. package/src/llama.cpp/tools/imatrix/CMakeLists.txt +0 -5
  341. package/src/llama.cpp/tools/imatrix/imatrix.cpp +0 -667
  342. package/src/llama.cpp/tools/llama-bench/CMakeLists.txt +0 -5
  343. package/src/llama.cpp/tools/llama-bench/llama-bench.cpp +0 -2024
  344. package/src/llama.cpp/tools/main/CMakeLists.txt +0 -5
  345. package/src/llama.cpp/tools/main/main.cpp +0 -977
  346. package/src/llama.cpp/tools/mtmd/CMakeLists.txt +0 -58
  347. package/src/llama.cpp/tools/mtmd/clip-impl.h +0 -462
  348. package/src/llama.cpp/tools/mtmd/clip.cpp +0 -4024
  349. package/src/llama.cpp/tools/mtmd/clip.h +0 -101
  350. package/src/llama.cpp/tools/mtmd/deprecation-warning.cpp +0 -22
  351. package/src/llama.cpp/tools/mtmd/miniaudio.h +0 -93468
  352. package/src/llama.cpp/tools/mtmd/mtmd-audio.cpp +0 -855
  353. package/src/llama.cpp/tools/mtmd/mtmd-audio.h +0 -62
  354. package/src/llama.cpp/tools/mtmd/mtmd-cli.cpp +0 -377
  355. package/src/llama.cpp/tools/mtmd/mtmd-helper.cpp +0 -297
  356. package/src/llama.cpp/tools/mtmd/mtmd.cpp +0 -942
  357. package/src/llama.cpp/tools/mtmd/mtmd.h +0 -362
  358. package/src/llama.cpp/tools/mtmd/requirements.txt +0 -5
  359. package/src/llama.cpp/tools/perplexity/CMakeLists.txt +0 -5
  360. package/src/llama.cpp/tools/perplexity/perplexity.cpp +0 -2063
  361. package/src/llama.cpp/tools/quantize/CMakeLists.txt +0 -6
  362. package/src/llama.cpp/tools/quantize/quantize.cpp +0 -519
  363. package/src/llama.cpp/tools/rpc/CMakeLists.txt +0 -4
  364. package/src/llama.cpp/tools/rpc/rpc-server.cpp +0 -322
  365. package/src/llama.cpp/tools/run/CMakeLists.txt +0 -16
  366. package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.cpp +0 -1995
  367. package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.h +0 -137
  368. package/src/llama.cpp/tools/run/run.cpp +0 -1261
  369. package/src/llama.cpp/tools/server/CMakeLists.txt +0 -51
  370. package/src/llama.cpp/tools/server/bench/requirements.txt +0 -2
  371. package/src/llama.cpp/tools/server/httplib.h +0 -10506
  372. package/src/llama.cpp/tools/server/server.cpp +0 -4966
  373. package/src/llama.cpp/tools/server/tests/requirements.txt +0 -8
  374. package/src/llama.cpp/tools/server/utils.hpp +0 -1337
  375. package/src/llama.cpp/tools/tokenize/CMakeLists.txt +0 -5
  376. package/src/llama.cpp/tools/tokenize/tokenize.cpp +0 -416
  377. package/src/llama.cpp/tools/tts/CMakeLists.txt +0 -5
  378. package/src/llama.cpp/tools/tts/tts.cpp +0 -1092
@@ -1,1215 +0,0 @@
1
- //
2
- // MIT license
3
- // Copyright (C) 2025 Intel Corporation
4
- // SPDX-License-Identifier: MIT
5
- //
6
-
7
- //
8
- // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9
- // See https://llvm.org/LICENSE.txt for license information.
10
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11
- //
12
-
13
- #ifndef GGML_SYCL_VECDOTQ_HPP
14
- #define GGML_SYCL_VECDOTQ_HPP
15
-
16
- #include "dpct/helper.hpp"
17
- #include "ggml.h"
18
- #include "quants.hpp"
19
-
20
- typedef float (*vec_dot_q_sycl_t)(const void * __restrict__ vbq, const block_q8_1 * __restrict__ bq8_1,
21
- const int & iqs);
22
-
23
- static __dpct_inline__ int get_int_from_int8(const int8_t* x8, const int& i32) {
24
- const uint16_t* x16 =
25
- (const uint16_t*)(x8 + sizeof(int) * i32); // assume at least 2 byte
26
- // alignment
27
-
28
- int x32 = 0;
29
- x32 |= x16[0] << 0;
30
- x32 |= x16[1] << 16;
31
-
32
- return x32;
33
- }
34
-
35
- static __dpct_inline__ int get_int_from_uint8(
36
- const uint8_t* x8,
37
- const int& i32) {
38
- const uint16_t* x16 =
39
- (const uint16_t*)(x8 + sizeof(int) * i32); // assume at least 2 byte
40
- // alignment
41
-
42
- int x32 = 0;
43
- x32 |= x16[0] << 0;
44
- x32 |= x16[1] << 16;
45
-
46
- return x32;
47
- }
48
-
49
- static __dpct_inline__ int get_int_from_int8_aligned(
50
- const int8_t* x8,
51
- const int& i32) {
52
- return *(
53
- (const int*)(x8 + sizeof(int) * i32)); // assume at least 4 byte alignment
54
- }
55
-
56
- static __dpct_inline__ int get_int_from_uint8_aligned(
57
- const uint8_t* x8,
58
- const int& i32) {
59
- return *(
60
- (const int*)(x8 + sizeof(int) * i32)); // assume at least 4 byte alignment
61
- }
62
-
63
- static __dpct_inline__ void get_int_from_table_16(const uint32_t &q4,
64
- const uint8_t *values,
65
- int &val1, int &val2) {
66
-
67
- uint32_t aux32; const uint8_t * q8 = (const uint8_t *)&aux32;
68
- aux32 = q4 & 0x0f0f0f0f;
69
- uint16_t v1 = values[q8[0]] | (values[q8[1]] << 8);
70
- uint16_t v2 = values[q8[2]] | (values[q8[3]] << 8);
71
- val1 = v1 | (v2 << 16);
72
- aux32 = (q4 >> 4) & 0x0f0f0f0f;
73
- v1 = values[q8[0]] | (values[q8[1]] << 8);
74
- v2 = values[q8[2]] | (values[q8[3]] << 8);
75
- val2 = v1 | (v2 << 16);
76
- }
77
-
78
- #define VDR_Q2_K_Q8_1_MMVQ 1
79
-
80
- // contiguous v/x values
81
- static __dpct_inline__ float vec_dot_q2_K_q8_1_impl_mmvq(
82
- const int &v, const int *__restrict__ u, const uint8_t *__restrict__ scales,
83
- const sycl::half2 &dm2, const float *__restrict__ d8) {
84
-
85
- float sumf_d = 0.0f;
86
- float sumf_m = 0.0f;
87
-
88
- #pragma unroll
89
- for (int i = 0; i < QR2_K; ++i) {
90
- const int sc = scales[2*i];
91
-
92
- const int vi = (v >> (2*i)) & 0x03030303;
93
-
94
- sumf_d +=
95
- d8[i] * (dpct::dp4a(vi, u[i], 0) * (sc & 0xF)); // SIMD dot product
96
-
97
- // fill int with 4x m
98
- int m = sc >> 4;
99
- m |= m << 8;
100
- m |= m << 16;
101
- sumf_m += d8[i] *
102
- dpct::dp4a(
103
- m, u[i],
104
- 0); // multiply constant q2_K part with sum of q8_1 values
105
- }
106
-
107
- const sycl::float2 dm2f =
108
- dm2.convert<float, sycl::rounding_mode::automatic>();
109
-
110
- return dm2f.x() * sumf_d - dm2f.y() * sumf_m;
111
- }
112
-
113
-
114
- #define VDR_Q3_K_Q8_1_MMVQ 1
115
-
116
- // contiguous v/x values
117
- static __dpct_inline__ float vec_dot_q3_K_q8_1_impl_mmvq(
118
- const int &vl, const int &vh, const int *__restrict__ u,
119
- const uint8_t *__restrict__ scales, const int &scale_offset,
120
- const float &d3, const float *__restrict__ d8) {
121
-
122
- float sumf = 0.0f;
123
-
124
- #pragma unroll
125
- for (int i = 0; i < QR3_K; ++i) {
126
- const int isc = scale_offset + 2*i;
127
-
128
- const int isc_low = isc % (QK_K/32);
129
- const int sc_shift_low = 4 * (isc / (QK_K/32));
130
- const int sc_low = (scales[isc_low] >> sc_shift_low) & 0xF;
131
-
132
- const int isc_high = isc % (QK_K/64);
133
- const int sc_shift_high = 2 * (isc / (QK_K/64));
134
- const int sc_high = ((scales[(QK_K/32) + isc_high] >> sc_shift_high) & 3) << 4;
135
-
136
- const int sc = (sc_low | sc_high) - 32;
137
-
138
- const int vil = (vl >> (2*i)) & 0x03030303;
139
-
140
- const int vih = ((vh >> i) << 2) & 0x04040404;
141
-
142
- const int vi =
143
- dpct::vectorized_binary<sycl::char4>(vil, vih, dpct::sub_sat());
144
-
145
- sumf += d8[i] * (dpct::dp4a(vi, u[i], 0) * sc); // SIMD dot product
146
- }
147
-
148
- return d3 * sumf;
149
- }
150
-
151
- #define VDR_Q4_K_Q8_1_MMVQ 2
152
-
153
- // contiguous v/x values
154
- static __dpct_inline__ float vec_dot_q4_K_q8_1_impl_vmmq(
155
- const int *__restrict__ v, const int *__restrict__ u,
156
- const uint8_t *__restrict__ sc, const uint8_t *__restrict__ m,
157
- const sycl::half2 &dm4, const float *__restrict__ d8) {
158
-
159
- float sumf_d = 0.0f;
160
- float sumf_m = 0.0f;
161
-
162
- #pragma unroll
163
- for (int i = 0; i < QR4_K; ++i) {
164
- const int v0i = (v[0] >> (4*i)) & 0x0F0F0F0F;
165
- const int v1i = (v[1] >> (4*i)) & 0x0F0F0F0F;
166
-
167
- const int dot1 =
168
- dpct::dp4a(v1i, u[2 * i + 1],
169
- dpct::dp4a(v0i, u[2 * i + 0], 0)); // SIMD dot product
170
- const int dot2 =
171
- dpct::dp4a(0x01010101, u[2 * i + 1],
172
- dpct::dp4a(0x01010101, u[2 * i + 0], 0)); // sum of u
173
-
174
- sumf_d += d8[i] * (dot1 * sc[i]);
175
- sumf_m += d8[i] * (dot2 * m[i]); // multiply constant part of q4_K with sum of q8_1 values
176
- }
177
-
178
- const sycl::float2 dm4f =
179
- dm4.convert<float, sycl::rounding_mode::automatic>();
180
-
181
- return dm4f.x() * sumf_d - dm4f.y() * sumf_m;
182
- }
183
-
184
-
185
- #define VDR_Q5_K_Q8_1_MMVQ 2
186
-
187
- // contiguous v/x values
188
- static __dpct_inline__ float vec_dot_q5_K_q8_1_impl_vmmq(
189
- const int *__restrict__ vl, const int *__restrict__ vh,
190
- const int *__restrict__ u, const uint8_t *__restrict__ sc,
191
- const uint8_t *__restrict__ m, const sycl::half2 &dm5,
192
- const float *__restrict__ d8) {
193
-
194
- float sumf_d = 0.0f;
195
- float sumf_m = 0.0f;
196
-
197
- #pragma unroll
198
- for (int i = 0; i < QR5_K; ++i) {
199
- const int vl0i = (vl[0] >> (4*i)) & 0x0F0F0F0F;
200
- const int vl1i = (vl[1] >> (4*i)) & 0x0F0F0F0F;
201
-
202
- const int vh0i = ((vh[0] >> i) << 4) & 0x10101010;
203
- const int vh1i = ((vh[1] >> i) << 4) & 0x10101010;
204
-
205
- const int v0i = vl0i | vh0i;
206
- const int v1i = vl1i | vh1i;
207
-
208
- const int dot1 =
209
- dpct::dp4a(v0i, u[2 * i + 0],
210
- dpct::dp4a(v1i, u[2 * i + 1], 0)); // SIMD dot product
211
- const int dot2 =
212
- dpct::dp4a(0x01010101, u[2 * i + 0],
213
- dpct::dp4a(0x01010101, u[2 * i + 1], 0)); // sum of u
214
-
215
- sumf_d += d8[i] * (dot1 * sc[i]);
216
- sumf_m += d8[i] * (dot2 * m[i]);
217
-
218
- }
219
-
220
- const sycl::float2 dm5f =
221
- dm5.convert<float, sycl::rounding_mode::automatic>();
222
-
223
- return dm5f.x() * sumf_d - dm5f.y() * sumf_m;
224
- }
225
-
226
-
227
- #define VDR_Q6_K_Q8_1_MMVQ 1
228
-
229
- // contiguous v/x values
230
- static __dpct_inline__ float
231
- vec_dot_q6_K_q8_1_impl_mmvq(const int &vl, const int &vh,
232
- const int *__restrict__ u,
233
- const int8_t *__restrict__ scales, const float &d,
234
- const float *__restrict__ d8) {
235
-
236
- float sumf = 0.0f;
237
-
238
- #pragma unroll
239
- for (int i = 0; i < QR6_K; ++i) {
240
- const int sc = scales[4*i];
241
-
242
- const int vil = (vl >> (4*i)) & 0x0F0F0F0F;
243
-
244
- const int vih = ((vh >> (4*i)) << 4) & 0x30303030;
245
-
246
- const int vi = dpct::vectorized_binary<sycl::char4>(
247
- (vil | vih), 0x20202020, dpct::sub_sat()); // vi = (vil | vih) - 32
248
-
249
- sumf += d8[i] * (dpct::dp4a(vi, u[i], 0) * sc); // SIMD dot product
250
- }
251
-
252
- return d*sumf;
253
- }
254
-
255
- // VDR = vec dot ratio, how many contiguous integers each thread processes when the vec dot kernel is called
256
- // MMVQ = mul_mat_vec_q, MMQ = mul_mat_q
257
-
258
- template <ggml_type T> struct reorder_vec_dot_q_sycl {
259
- static_assert(T != T, "ggml_type for reorder vecdot not implemented");
260
- };
261
-
262
- template <> struct reorder_vec_dot_q_sycl<GGML_TYPE_Q4_0> {
263
- static constexpr ggml_type gtype = GGML_TYPE_Q4_0;
264
-
265
- using q4_0_block = ggml_sycl_reordered::block_q_t<GGML_TYPE_Q4_0>;
266
- using q4_0_traits = typename q4_0_block::traits;
267
-
268
- __dpct_inline__ float vec_dot_q4_0_q8_1_impl(const int * v, const int * u, const float & d4, const sycl::half2 & ds8) {
269
- int sumi = 0;
270
-
271
- #pragma unroll
272
- for (size_t i = 0; i < q4_0_traits::vdr_mmvq; ++i) {
273
- const int vi0 = (v[i] >> 0) & 0x0F0F0F0F;
274
- const int vi1 = (v[i] >> 4) & 0x0F0F0F0F;
275
-
276
- // SIMD dot product of quantized values
277
- sumi = dpct::dp4a(vi0, u[2 * i + 0], sumi);
278
- sumi = dpct::dp4a(vi1, u[2 * i + 1], sumi);
279
- }
280
-
281
- const sycl::float2 ds8f = ds8.convert<float, sycl::rounding_mode::automatic>();
282
-
283
- // second part effectively subtracts 8 from each quant value
284
- return d4 * (sumi * ds8f.x() - (8 * q4_0_traits::vdr_mmvq / q4_0_traits::qi) * ds8f.y());
285
- }
286
-
287
- __dpct_inline__ float operator()(const void * __restrict__ vbq, const int ibx_offset, const int d_offset,
288
- const block_q8_1 * __restrict__ bq8_1, const int & iqs, int /* nblocks */) {
289
- const uint8_t * bq4_0 = static_cast<const uint8_t *>(vbq) + ibx_offset;
290
- const ggml_half d = *(reinterpret_cast<const ggml_half *>(static_cast<const uint8_t *>(vbq) + d_offset));
291
- int v[q4_0_traits::vdr_mmvq];
292
- int u[2 * q4_0_traits::vdr_mmvq];
293
-
294
- #pragma unroll
295
-
296
- for (size_t i = 0; i < q4_0_traits::vdr_mmvq; ++i) {
297
- v[i] = get_int_from_uint8(bq4_0, iqs + i);
298
- u[2 * i + 0] = get_int_from_int8_aligned(bq8_1->qs, iqs + i);
299
- u[2 * i + 1] = get_int_from_int8_aligned(bq8_1->qs, iqs + i + q4_0_traits::qi);
300
- }
301
-
302
- return vec_dot_q4_0_q8_1_impl(v, u, d, bq8_1->ds);
303
- };
304
- };
305
-
306
- static inline float vec_dot_q4_K_q8_1_common(const int * __restrict__ q4, const uint16_t * __restrict__ scales,
307
- const ggml_half2 & dm, const block_q8_1 * __restrict__ bq8_1,
308
- const int & iqs) {
309
- int v[2];
310
- int u[2 * QR4_K];
311
- float d8[QR4_K];
312
-
313
- v[0] = q4[0];
314
- v[1] = q4[4];
315
-
316
- uint16_t aux[2];
317
- const int j = (QR4_K * ((iqs / 2) / (QI8_1 / 2))) / 2;
318
- if (j < 2) {
319
- aux[0] = scales[j + 0] & 0x3f3f;
320
- aux[1] = scales[j + 2] & 0x3f3f;
321
- } else {
322
- aux[0] = ((scales[j + 2] >> 0) & 0x0f0f) | ((scales[j - 2] & 0xc0c0) >> 2);
323
- aux[1] = ((scales[j + 2] >> 4) & 0x0f0f) | ((scales[j - 0] & 0xc0c0) >> 2);
324
- }
325
-
326
- const uint8_t * sc = (const uint8_t *) aux;
327
- const uint8_t * m = sc + 2;
328
-
329
- const int bq8_offset = QR4_K * ((iqs / 2) / (QI8_1 / 2));
330
-
331
- for (int i = 0; i < QR4_K; ++i) {
332
- const block_q8_1 * bq8i = bq8_1 + bq8_offset + i;
333
- d8[i] = bq8i->ds[0];
334
-
335
- const int * q8 = (const int *) bq8i->qs + ((iqs / 2) % 4);
336
- u[2 * i + 0] = q8[0];
337
- u[2 * i + 1] = q8[4];
338
- }
339
-
340
- return vec_dot_q4_K_q8_1_impl_vmmq(v, u, sc, m, dm, d8);
341
- }
342
-
343
- template <> struct reorder_vec_dot_q_sycl<GGML_TYPE_Q4_K> {
344
- static constexpr ggml_type gtype = GGML_TYPE_Q4_K;
345
-
346
- using q4_k_block = ggml_sycl_reordered::block_q_t<GGML_TYPE_Q4_K>;
347
- using q4_k_traits = typename q4_k_block::traits;
348
-
349
- float operator()(const void * __restrict__ vbq, const int ibx_offset, const int d_offset,
350
- const block_q8_1 * __restrict__ bq8_1, const int & iqs, int nblocks) {
351
- const int ib = ibx_offset / (QK_K / 2);
352
-
353
- const uint8_t * base = static_cast<const uint8_t *>(vbq);
354
- const uint8_t * qs = base + ibx_offset;
355
- const int total_qs_bytes = nblocks * (QK_K / 2);
356
- const uint8_t * scs = base + total_qs_bytes + ib * K_SCALE_SIZE;
357
- const ggml_half2 * dms = reinterpret_cast<const ggml_half2 *>(base + d_offset);
358
-
359
- const int bq8_offset = QR4_K * ((iqs / 2) / (QI8_1 / 2));
360
- const int * q4 = (const int *) (qs + 16 * bq8_offset + 4 * ((iqs / 2) % 4));
361
- const uint16_t * scales = (const uint16_t *) scs;
362
-
363
- return vec_dot_q4_K_q8_1_common(q4, scales, *dms, bq8_1, iqs);
364
- }
365
- };
366
-
367
- #define VDR_Q4_0_Q8_1_MMVQ 2
368
- #define VDR_Q4_0_Q8_1_MMQ 4
369
-
370
- template <int vdr>
371
- static __dpct_inline__ float vec_dot_q4_0_q8_1_impl(const int * v, const int * u, const float & d4,
372
- const sycl::half2 & ds8) {
373
- int sumi = 0;
374
- #pragma unroll
375
- for (int i = 0; i < vdr; ++i) {
376
- const int vi0 = (v[i] >> 0) & 0x0F0F0F0F;
377
- const int vi1 = (v[i] >> 4) & 0x0F0F0F0F;
378
-
379
- // SIMD dot product of quantized values
380
- sumi = dpct::dp4a(vi0, u[2 * i + 0], sumi);
381
- sumi = dpct::dp4a(vi1, u[2 * i + 1], sumi);
382
- }
383
-
384
- const sycl::float2 ds8f = ds8.convert<float, sycl::rounding_mode::automatic>();
385
-
386
- // second part effectively subtracts 8 from each quant value
387
- return d4 * (sumi * ds8f.x() - (8 * vdr / QI4_0) * ds8f.y());
388
- }
389
-
390
- #define VDR_Q4_1_Q8_1_MMVQ 2
391
- #define VDR_Q4_1_Q8_1_MMQ 4
392
-
393
- template <int vdr>
394
- static __dpct_inline__ float vec_dot_q4_1_q8_1_impl(const int *v, const int *u,
395
- const sycl::half2 &dm4,
396
- const sycl::half2 &ds8) {
397
-
398
- int sumi = 0;
399
-
400
- #pragma unroll
401
- for (int i = 0; i < vdr; ++i) {
402
- const int vi0 = (v[i] >> 0) & 0x0F0F0F0F;
403
- const int vi1 = (v[i] >> 4) & 0x0F0F0F0F;
404
-
405
- // SIMD dot product of quantized values
406
- sumi = dpct::dp4a(vi0, u[2 * i + 0], sumi);
407
- sumi = dpct::dp4a(vi1, u[2 * i + 1], sumi);
408
- }
409
-
410
- #ifdef GGML_SYCL_F16
411
- const sycl::float2 tmp =
412
- (dm4 * ds8).convert<float, sycl::rounding_mode::automatic>();
413
- const float d4d8 = tmp.x();
414
- const float m4s8 = tmp.y();
415
- #else
416
- const sycl::float2 dm4f =
417
- dm4.convert<float, sycl::rounding_mode::automatic>();
418
- const sycl::float2 ds8f =
419
- ds8.convert<float, sycl::rounding_mode::automatic>();
420
- const float d4d8 = dm4f.x() * ds8f.x();
421
- const float m4s8 = dm4f.y() * ds8f.y();
422
- #endif // GGML_SYCL_F16
423
-
424
- // scale second part of sum by QI8_1/(vdr * QR4_1) to compensate for multiple threads adding it
425
- return sumi * d4d8 + m4s8 / (QI8_1 / (vdr * QR4_1));
426
- }
427
-
428
- #define VDR_Q5_0_Q8_1_MMVQ 2
429
- #define VDR_Q5_0_Q8_1_MMQ 4
430
-
431
- template <int vdr>
432
- static __dpct_inline__ float
433
- vec_dot_q5_0_q8_1_impl(const int *vl, const int *vh, const int *u,
434
- const float &d5, const sycl::half2 &ds8) {
435
- int sumi = 0;
436
-
437
- #pragma unroll
438
- for (int i = 0; i < vdr; ++i) {
439
- int vi0 = (vl[i] >> 0) & 0x0F0F0F0F; // lower 4 qs bits, still need qh as 5th bits
440
- vi0 |= (vh[i] << 4) & 0x00000010; // 0 -> 4
441
- vi0 |= (vh[i] << 11) & 0x00001000; // 1 -> 12
442
- vi0 |= (vh[i] << 18) & 0x00100000; // 2 -> 20
443
- vi0 |= (vh[i] << 25) & 0x10000000; // 3 -> 28
444
- sumi = dpct::dp4a(vi0, u[2 * i + 0],
445
- sumi); // SIMD dot product of quantized values
446
-
447
- int vi1 = (vl[i] >> 4) & 0x0F0F0F0F; // upper 4 qs bits, still need qh as 5th bits
448
- vi1 |= (vh[i] >> 12) & 0x00000010; // 16 -> 4
449
- vi1 |= (vh[i] >> 5) & 0x00001000; // 17 -> 12
450
- vi1 |= (vh[i] << 2) & 0x00100000; // 18 -> 20
451
- vi1 |= (vh[i] << 9) & 0x10000000; // 19 -> 28
452
- sumi = dpct::dp4a(vi1, u[2 * i + 1],
453
- sumi); // SIMD dot product of quantized values
454
- }
455
-
456
- const sycl::float2 ds8f =
457
- ds8.convert<float, sycl::rounding_mode::automatic>();
458
-
459
- // second part effectively subtracts 16 from each quant value
460
- return d5 * (sumi * ds8f.x() - (16 * vdr / QI5_0) * ds8f.y());
461
- }
462
-
463
- #define VDR_Q5_1_Q8_1_MMVQ 2
464
- #define VDR_Q5_1_Q8_1_MMQ 4
465
-
466
- template <int vdr>
467
- static __dpct_inline__ float
468
- vec_dot_q5_1_q8_1_impl(const int *vl, const int *vh, const int *u,
469
- const sycl::half2 &dm5, const sycl::half2 &ds8) {
470
-
471
- int sumi = 0;
472
-
473
- #pragma unroll
474
- for (int i = 0; i < vdr; ++i) {
475
- int vi0 = (vl[i] >> 0) & 0x0F0F0F0F; // lower 4 qs bits, still need qh as 5th bits
476
- vi0 |= (vh[i] << 4) & 0x00000010; // 0 -> 4
477
- vi0 |= (vh[i] << 11) & 0x00001000; // 1 -> 12
478
- vi0 |= (vh[i] << 18) & 0x00100000; // 2 -> 20
479
- vi0 |= (vh[i] << 25) & 0x10000000; // 3 -> 28
480
- sumi = dpct::dp4a(vi0, u[2 * i + 0],
481
- sumi); // SIMD dot product of quantized values
482
-
483
- int vi1 = (vl[i] >> 4) & 0x0F0F0F0F; // upper 4 qs bits, still need qh as 5th bits
484
- vi1 |= (vh[i] >> 12) & 0x00000010; // 16 -> 4
485
- vi1 |= (vh[i] >> 5) & 0x00001000; // 17 -> 12
486
- vi1 |= (vh[i] << 2) & 0x00100000; // 18 -> 20
487
- vi1 |= (vh[i] << 9) & 0x10000000; // 19 -> 28
488
- sumi = dpct::dp4a(vi1, u[2 * i + 1],
489
- sumi); // SIMD dot product of quantized values
490
- }
491
-
492
- #ifdef GGML_SYCL_F16
493
- const sycl::float2 tmp =
494
- (dm5 * ds8).convert<float, sycl::rounding_mode::automatic>();
495
- const float d5d8 = tmp.x();
496
- const float m5s8 = tmp.y();
497
-
498
-
499
- #else
500
- const sycl::float2 dm5f =
501
- dm5.convert<float, sycl::rounding_mode::automatic>();
502
- const sycl::float2 ds8f =
503
- ds8.convert<float, sycl::rounding_mode::automatic>();
504
- const float d5d8 = dm5f.x() * ds8f.x();
505
- const float m5s8 = dm5f.y() * ds8f.y();
506
- #endif // GGML_SYCL_F16
507
-
508
- // scale second part of sum by QI5_1 / vdr to compensate for multiple threads adding it
509
- return sumi*d5d8 + m5s8 / (QI5_1 / vdr);
510
- }
511
-
512
- #define VDR_Q8_0_Q8_1_MMVQ 2
513
- #define VDR_Q8_0_Q8_1_MMQ 8
514
-
515
- template <int vdr>
516
- static __dpct_inline__ float vec_dot_q8_0_q8_1_impl(const int *v, const int *u,
517
- const float &d8_0,
518
- const float &d8_1) {
519
-
520
- int sumi = 0;
521
-
522
- #pragma unroll
523
- for (int i = 0; i < vdr; ++i) {
524
- // SIMD dot product of quantized values
525
- sumi = dpct::dp4a(v[i], u[i], sumi);
526
- }
527
-
528
- return d8_0*d8_1 * sumi;
529
- }
530
-
531
- template <int vdr>
532
- static __dpct_inline__ float vec_dot_q8_1_q8_1_impl(const int *v, const int *u,
533
- const sycl::half2 &dm8,
534
- const sycl::half2 &ds8) {
535
-
536
- int sumi = 0;
537
-
538
- #pragma unroll
539
- for (int i = 0; i < vdr; ++i) {
540
- // SIMD dot product of quantized values
541
- sumi = dpct::dp4a(v[i], u[i], sumi);
542
- }
543
-
544
- #ifdef GGML_SYCL_F16
545
- const sycl::float2 tmp =
546
- (dm8 * ds8).convert<float, sycl::rounding_mode::automatic>();
547
- const float d8d8 = tmp.x();
548
- const float m8s8 = tmp.y();
549
- #else
550
- const sycl::float2 dm8f =
551
- dm8.convert<float, sycl::rounding_mode::automatic>();
552
- const sycl::float2 ds8f =
553
- ds8.convert<float, sycl::rounding_mode::automatic>();
554
- const float d8d8 = dm8f.x() * ds8f.x();
555
- const float m8s8 = dm8f.y() * ds8f.y();
556
- #endif // GGML_SYCL_F16
557
-
558
- // scale second part of sum by QI8_1/ vdr to compensate for multiple threads adding it
559
- return sumi*d8d8 + m8s8 / (QI8_1 / vdr);
560
- }
561
-
562
- static __dpct_inline__ float
563
- vec_dot_q4_0_q8_1(const void *__restrict__ vbq,
564
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
565
-
566
- const block_q4_0 * bq4_0 = (const block_q4_0 *) vbq;
567
-
568
- int v[VDR_Q4_0_Q8_1_MMVQ];
569
- int u[2 * VDR_Q4_0_Q8_1_MMVQ];
570
-
571
- #pragma unroll
572
- for (int i = 0; i < VDR_Q4_0_Q8_1_MMVQ; ++i) {
573
- v[i] = get_int_from_uint8(bq4_0->qs, iqs + i);
574
- u[2 * i + 0] = get_int_from_int8_aligned(bq8_1->qs, iqs + i);
575
- u[2 * i + 1] = get_int_from_int8_aligned(bq8_1->qs, iqs + i + QI4_0);
576
- }
577
-
578
- return vec_dot_q4_0_q8_1_impl<VDR_Q4_0_Q8_1_MMVQ>(v, u, bq4_0->d, bq8_1->ds);
579
- }
580
-
581
- static __dpct_inline__ float
582
- vec_dot_q4_1_q8_1(const void *__restrict__ vbq,
583
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
584
-
585
- const block_q4_1 * bq4_1 = (const block_q4_1 *) vbq;
586
-
587
- int v[VDR_Q4_1_Q8_1_MMVQ];
588
- int u[2*VDR_Q4_1_Q8_1_MMVQ];
589
-
590
- #pragma unroll
591
- for (int i = 0; i < VDR_Q4_1_Q8_1_MMVQ; ++i) {
592
- v[i] = get_int_from_uint8_aligned(bq4_1->qs, iqs + i);
593
- u[2*i+0] = get_int_from_int8_aligned(bq8_1->qs, iqs + i);
594
- u[2*i+1] = get_int_from_int8_aligned(bq8_1->qs, iqs + i + QI4_1);
595
- }
596
-
597
- return vec_dot_q4_1_q8_1_impl<VDR_Q4_1_Q8_1_MMVQ>(v, u, bq4_1->dm, bq8_1->ds);
598
- }
599
-
600
- static __dpct_inline__ float
601
- vec_dot_q5_0_q8_1(const void *__restrict__ vbq,
602
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
603
-
604
- const block_q5_0 * bq5_0 = (const block_q5_0 *) vbq;
605
-
606
- int vl[VDR_Q5_0_Q8_1_MMVQ];
607
- int vh[VDR_Q5_0_Q8_1_MMVQ];
608
- int u[2*VDR_Q5_0_Q8_1_MMVQ];
609
-
610
- #pragma unroll
611
- for (int i = 0; i < VDR_Q5_0_Q8_1_MMVQ; ++i) {
612
- vl[i] = get_int_from_uint8(bq5_0->qs, iqs + i);
613
- vh[i] = get_int_from_uint8(bq5_0->qh, 0) >> (4 * (iqs + i));
614
- u[2*i+0] = get_int_from_int8_aligned(bq8_1->qs, iqs + i);
615
- u[2*i+1] = get_int_from_int8_aligned(bq8_1->qs, iqs + i + QI5_0);
616
- }
617
-
618
- return vec_dot_q5_0_q8_1_impl<VDR_Q5_0_Q8_1_MMVQ>(vl, vh, u, bq5_0->d, bq8_1->ds);
619
- }
620
-
621
- static __dpct_inline__ float
622
- vec_dot_q5_1_q8_1(const void *__restrict__ vbq,
623
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
624
-
625
- const block_q5_1 * bq5_1 = (const block_q5_1 *) vbq;
626
-
627
- int vl[VDR_Q5_1_Q8_1_MMVQ];
628
- int vh[VDR_Q5_1_Q8_1_MMVQ];
629
- int u[2*VDR_Q5_1_Q8_1_MMVQ];
630
-
631
- #pragma unroll
632
- for (int i = 0; i < VDR_Q5_1_Q8_1_MMVQ; ++i) {
633
- vl[i] = get_int_from_uint8_aligned(bq5_1->qs, iqs + i);
634
- vh[i] = get_int_from_uint8_aligned(bq5_1->qh, 0) >> (4 * (iqs + i));
635
- u[2*i+0] = get_int_from_int8_aligned(bq8_1->qs, iqs + i);
636
- u[2*i+1] = get_int_from_int8_aligned(bq8_1->qs, iqs + i + QI5_1);
637
- }
638
-
639
- return vec_dot_q5_1_q8_1_impl<VDR_Q5_1_Q8_1_MMVQ>(vl, vh, u, bq5_1->dm, bq8_1->ds);
640
- }
641
-
642
- static __dpct_inline__ float
643
- vec_dot_q8_0_q8_1(const void *__restrict__ vbq,
644
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
645
-
646
- const block_q8_0 * bq8_0 = (const block_q8_0 *) vbq;
647
-
648
- int v[VDR_Q8_0_Q8_1_MMVQ];
649
- int u[VDR_Q8_0_Q8_1_MMVQ];
650
-
651
- #pragma unroll
652
- for (int i = 0; i < VDR_Q8_0_Q8_1_MMVQ; ++i) {
653
- v[i] = get_int_from_int8(bq8_0->qs, iqs + i);
654
- u[i] = get_int_from_int8_aligned(bq8_1->qs, iqs + i);
655
- }
656
-
657
- return vec_dot_q8_0_q8_1_impl<VDR_Q8_0_Q8_1_MMVQ>(v, u, bq8_0->d,
658
- bq8_1->ds[0]);
659
- }
660
-
661
- static __dpct_inline__ float
662
- vec_dot_q2_K_q8_1(const void *__restrict__ vbq,
663
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
664
-
665
- const block_q2_K * bq2_K = (const block_q2_K *) vbq;
666
-
667
- const int bq8_offset = QR2_K * (iqs / QI8_1);
668
- const int scale_offset = iqs - iqs % QI8_1 + (iqs % QI8_1) / (QI8_1/2);
669
-
670
- const uint8_t * scales = bq2_K->scales + scale_offset;
671
-
672
- const int v = get_int_from_uint8_aligned(bq2_K->qs, iqs);
673
- int u[QR2_K];
674
- float d8[QR2_K];
675
-
676
- #pragma unroll
677
- for (int i = 0; i < QR2_K; ++ i) {
678
- u[i] = get_int_from_int8_aligned(bq8_1[bq8_offset + i].qs, iqs % QI8_1);
679
- d8[i] = bq8_1[bq8_offset + i].ds[0];
680
- }
681
-
682
- return vec_dot_q2_K_q8_1_impl_mmvq(v, u, scales, bq2_K->dm, d8);
683
- }
684
-
685
- static __dpct_inline__ float
686
- vec_dot_q3_K_q8_1(const void *__restrict__ vbq,
687
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
688
-
689
- const block_q3_K * bq3_K = (const block_q3_K *) vbq;
690
-
691
- const int bq8_offset = QR3_K * (iqs / (QI3_K/2));
692
- const int scale_offset = iqs - iqs % QI8_1 + (iqs % QI8_1) / (QI8_1/2);
693
-
694
- const float d = bq3_K->d;
695
-
696
- const int vl = get_int_from_uint8(bq3_K->qs, iqs);
697
-
698
- // invert the mask with ~ so that a 0/1 results in 4/0 being subtracted
699
- const int vh = ~get_int_from_uint8(bq3_K->hmask, iqs % (QI3_K/2)) >> bq8_offset;
700
-
701
- int u[QR3_K];
702
- float d8[QR3_K];
703
-
704
- #pragma unroll
705
- for (int i = 0; i < QR3_K; ++i) {
706
- u[i] = get_int_from_int8_aligned(bq8_1[bq8_offset + i].qs, iqs % QI8_1);
707
- d8[i] = bq8_1[bq8_offset + i].ds[0];
708
- }
709
-
710
- return vec_dot_q3_K_q8_1_impl_mmvq(vl, vh, u, bq3_K->scales, scale_offset, d, d8);
711
- }
712
-
713
- static __dpct_inline__ float vec_dot_q4_K_q8_1(const void * __restrict__ vbq, const block_q8_1 * __restrict__ bq8_1,
714
- const int & iqs) {
715
- #ifndef GGML_QKK_64
716
-
717
- const block_q4_K * bq4_K = (const block_q4_K *) vbq;
718
-
719
- const int bq8_offset = QR4_K * ((iqs / 2) / (QI8_1 / 2));
720
- const int * q4 = (const int *) (bq4_K->qs + 16 * bq8_offset + 4 * ((iqs / 2) % 4));
721
- const uint16_t * scales = (const uint16_t *) bq4_K->scales;
722
-
723
- return vec_dot_q4_K_q8_1_common(q4, scales, bq4_K->dm, bq8_1, iqs);
724
-
725
- #else
726
-
727
- #if __SYCL_ARCH__ >= VER_4VEC // lowest compute capability for integer intrinsics
728
- const block_q4_K * bq4_K = (const block_q4_K *) vbq;
729
-
730
- float sumf_d = 0.0f;
731
- float sumf_m = 0.0f;
732
-
733
- uint16_t aux16[2];
734
- const uint8_t * s = (const uint8_t *)aux16;
735
-
736
- const uint16_t * a = (const uint16_t *)bq4_K->scales;
737
- aux16[0] = a[0] & 0x0f0f;
738
- aux16[1] = (a[0] >> 4) & 0x0f0f;
739
-
740
- const float dall = bq4_K->dm[0];
741
- const float dmin = bq4_K->dm[1];
742
-
743
- const float d8_1 = bq8_1[0].ds[0];
744
- const float d8_2 = bq8_1[1].ds[1];
745
-
746
- const int ui1 = *((const int *)bq8_1[0].qs + (iqs/2));
747
- const int ui2 = *((const int *)bq8_1[0].qs + (iqs/2) + 4);
748
- const int ui3 = *((const int *)bq8_1[1].qs + (iqs/2));
749
- const int ui4 = *((const int *)bq8_1[1].qs + (iqs/2) + 4);
750
-
751
- const int * q4 = (const int *)bq4_K->qs + (iqs/2);
752
- const int v1 = q4[0];
753
- const int v2 = q4[4];
754
-
755
- const int dot1 = dpct::dp4a(ui2, v2 & 0x0f0f0f0f, dpct::dp4a(ui1, v1 & 0x0f0f0f0f, 0));
756
- const int dot2 = dpct::dp4a(ui4, (v2 >> 4) & 0x0f0f0f0f, dpct::dp4a(ui3, (v1 >> 4) & 0x0f0f0f0f, 0));
757
- const int dot3 = dpct::dp4a(0x01010101, ui2, dpct::dp4a(0x01010101, ui1, 0));
758
- const int dot4 = dpct::dp4a(0x01010101, ui4, dpct::dp4a(0x01010101, ui3, 0));
759
-
760
- sumf_d += d8_1 * (dot1 * s[0]) + d8_2 * (dot2 * s[1]);
761
- sumf_m += d8_1 * (dot3 * s[2]) + d8_2 * (dot4 * s[3]);
762
-
763
- return dall * sumf_d - dmin * sumf_m;
764
-
765
- #else
766
- bad_arch();
767
- #endif // __SYCL_ARCH__ >= VER_4VEC
768
-
769
- #endif
770
- }
771
-
772
- static __dpct_inline__ float
773
- vec_dot_q5_K_q8_1(const void *__restrict__ vbq,
774
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
775
-
776
- #ifndef GGML_QKK_64
777
- const block_q5_K * bq5_K = (const block_q5_K *) vbq;
778
-
779
- int vl[2];
780
- int vh[2];
781
- int u[2*QR5_K];
782
- float d8[QR5_K];
783
-
784
- const int bq8_offset = QR5_K * ((iqs/2) / (QI8_1/2));
785
- const int * ql = (const int *)(bq5_K->qs + 16 * bq8_offset + 4 * ((iqs/2)%4));
786
- const int * qh = (const int *)(bq5_K->qh + 4 * ((iqs/2)%4));
787
-
788
- vl[0] = ql[0];
789
- vl[1] = ql[4];
790
-
791
- vh[0] = qh[0] >> bq8_offset;
792
- vh[1] = qh[4] >> bq8_offset;
793
-
794
- const uint16_t * scales = (const uint16_t *)bq5_K->scales;
795
- uint16_t aux[2];
796
- const int j = bq8_offset/2;
797
- if (j < 2) {
798
- aux[0] = scales[j+0] & 0x3f3f;
799
- aux[1] = scales[j+2] & 0x3f3f;
800
- } else {
801
- aux[0] = ((scales[j+2] >> 0) & 0x0f0f) | ((scales[j-2] & 0xc0c0) >> 2);
802
- aux[1] = ((scales[j+2] >> 4) & 0x0f0f) | ((scales[j-0] & 0xc0c0) >> 2);
803
- }
804
- const uint8_t * sc = (const uint8_t *)aux;
805
- const uint8_t * m = sc + 2;
806
-
807
- #pragma unroll
808
- for (int i = 0; i < QR5_K; ++i) {
809
- const block_q8_1 * bq8i = bq8_1 + bq8_offset + i;
810
- d8[i] = bq8i->ds[0];
811
-
812
- const int * q8 = (const int *)bq8i->qs + ((iqs/2)%4);
813
- u[2*i+0] = q8[0];
814
- u[2*i+1] = q8[4];
815
- }
816
-
817
- return vec_dot_q5_K_q8_1_impl_vmmq(vl, vh, u, sc, m, bq5_K->dm, d8);
818
-
819
- #else
820
-
821
- #if __SYCL_ARCH__ >= VER_4VEC // lowest compute capability for integer intrinsics
822
- const block_q5_K * bq5_K = (const block_q5_K *) vbq;
823
-
824
- const int8_t * s = bq5_K->scales;
825
-
826
- const float d = bq5_K->d;
827
-
828
- const float d8_1 = bq8_1[0].ds[0];
829
- const float d8_2 = bq8_1[1].ds[1];
830
-
831
- const int ui1 = *((const int *)bq8_1[0].qs + (iqs/2));
832
- const int ui2 = *((const int *)bq8_1[0].qs + (iqs/2) + 4);
833
- const int ui3 = *((const int *)bq8_1[1].qs + (iqs/2));
834
- const int ui4 = *((const int *)bq8_1[1].qs + (iqs/2) + 4);
835
-
836
- const int * ql = (const int *)bq5_K->qs + (iqs/2);
837
- const int vl1 = ql[0];
838
- const int vl2 = ql[4];
839
-
840
- const int step = 4 * (iqs/2); // 0, 4, 8, 12
841
- const int im = step/8; // = 0 for iqs = 0, 2, = 1 for iqs = 4, 6
842
- const int in = step%8; // 0, 4, 0, 4
843
- const int vh = (*((const int *)(bq5_K->qh + in))) >> im;
844
-
845
- const int v1 = (((vh << 4) & 0x10101010) ^ 0x10101010) | ((vl1 >> 0) & 0x0f0f0f0f);
846
- const int v2 = (((vh << 2) & 0x10101010) ^ 0x10101010) | ((vl2 >> 0) & 0x0f0f0f0f);
847
- const int v3 = (((vh >> 0) & 0x10101010) ^ 0x10101010) | ((vl1 >> 4) & 0x0f0f0f0f);
848
- const int v4 = (((vh >> 2) & 0x10101010) ^ 0x10101010) | ((vl2 >> 4) & 0x0f0f0f0f);
849
-
850
- const float sumf_d = d8_1 * (dpct::dp4a(ui1, v1, 0) * s[0] + dpct::dp4a(ui2, v2, 0) * s[1])
851
- + d8_2 * (dpct::dp4a(ui3, v3, 0) * s[2] + dpct::dp4a(ui4, v4, 0) * s[3]);
852
-
853
- return d * sumf_d;
854
-
855
- #else
856
- bad_arch();
857
- #endif // __SYCL_ARCH__ >= VER_4VEC
858
-
859
- #endif
860
- }
861
-
862
- static __dpct_inline__ float
863
- vec_dot_q6_K_q8_1(const void *__restrict__ vbq,
864
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
865
-
866
- const block_q6_K * bq6_K = (const block_q6_K *) vbq;
867
-
868
- const int bq8_offset = 2 * QR6_K * (iqs / (QI6_K/2)) + (iqs % (QI6_K/2)) / (QI6_K/4);
869
- const int scale_offset = (QI6_K/4) * (iqs / (QI6_K/2)) + (iqs % (QI6_K/2)) / (QI6_K/8);
870
- const int vh_shift = 2 * ((iqs % (QI6_K/2)) / (QI6_K/4));
871
-
872
- const int vl = get_int_from_uint8(bq6_K->ql, iqs);
873
- const int vh = get_int_from_uint8(bq6_K->qh, (QI6_K/4) * (iqs / (QI6_K/2)) + iqs % (QI6_K/4)) >> vh_shift;
874
-
875
- const int8_t * scales = bq6_K->scales + scale_offset;
876
-
877
- int u[QR6_K];
878
- float d8[QR6_K];
879
-
880
- #pragma unroll
881
- for (int i = 0; i < QR6_K; ++i) {
882
- u[i] = get_int_from_int8_aligned(bq8_1[bq8_offset + 2*i].qs, iqs % QI8_1);
883
- d8[i] = bq8_1[bq8_offset + 2 * i].ds[0];
884
- }
885
-
886
- return vec_dot_q6_K_q8_1_impl_mmvq(vl, vh, u, scales, bq6_K->d, d8);
887
- }
888
-
889
-
890
- static __dpct_inline__ float
891
- vec_dot_iq2_xxs_q8_1(const void *__restrict__ vbq,
892
- const block_q8_1 *__restrict__ bq8_1, const int &iqs,
893
- const uint64_t *iq2xxs_grid, const uint8_t *ksigns_iq2xs,
894
- const uint8_t *kmask_iq2xs) {
895
- #if QK_K == 256
896
- const block_iq2_xxs * bq2 = (const block_iq2_xxs *) vbq;
897
-
898
- const int ib32 = iqs;
899
- const uint16_t * q2 = bq2->qs + 4*ib32;
900
- const uint8_t * aux8 = (const uint8_t *)q2;
901
- const int8_t * q8 = bq8_1[ib32].qs;
902
- uint32_t aux32 = q2[2] | (q2[3] << 16);
903
- int sumi = 0;
904
- for (int l = 0; l < 4; ++l) {
905
- const uint8_t * grid = (const uint8_t *)(iq2xxs_grid + aux8[l]);
906
- const uint8_t signs = ksigns_iq2xs[aux32 & 127];
907
- for (int j = 0; j < 8; ++j) {
908
- sumi += q8[j] * grid[j] * (signs & kmask_iq2xs[j] ? -1 : 1);
909
- }
910
- q8 += 8;
911
- aux32 >>= 7;
912
- }
913
- const float d = (float)bq2->d * (0.5f + aux32) * bq8_1[ib32].ds[0] * 0.25f;
914
- return d * sumi;
915
- #else
916
- assert(false);
917
- return 0.f;
918
- #endif
919
- }
920
-
921
- static __dpct_inline__ float
922
- vec_dot_iq2_xs_q8_1(const void *__restrict__ vbq,
923
- const block_q8_1 *__restrict__ bq8_1, const int &iqs,
924
- const uint64_t *iq2xs_grid, const uint64_t *ksigns64) {
925
- #if DPCT_COMPATIBILITY_TEMP >= \
926
- MIN_CC_DP4A // lowest compute capability for integer intrinsics
927
- #if QK_K == 256
928
- const block_iq2_xs * bq2 = (const block_iq2_xs *) vbq;
929
-
930
- const int ib32 = iqs;
931
- const uint16_t * q2 = bq2->qs + 4*ib32;
932
- const int8_t * q8 = bq8_1[ib32].qs;
933
- const uint8_t ls1 = bq2->scales[ib32] & 0xf;
934
- const uint8_t ls2 = bq2->scales[ib32] >> 4;
935
- int sumi1 = 0;
936
- for (int l = 0; l < 2; ++l) {
937
- const uint32_t * grid = (const uint32_t *)(iq2xs_grid + (q2[l] & 511));
938
- const uint32_t * signs = (const uint32_t *)(ksigns64 + (q2[l] >> 9));
939
- const int grid_l = dpct::vectorized_binary<sycl::uchar4>(
940
- grid[0] ^ signs[0], signs[0], std::minus<>());
941
- const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
942
- grid[1] ^ signs[1], signs[1], std::minus<>());
943
- sumi1 = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi1);
944
- sumi1 = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi1);
945
- q8 += 8;
946
- }
947
- int sumi2 = 0;
948
- for (int l = 2; l < 4; ++l) {
949
- const uint32_t * grid = (const uint32_t *)(iq2xs_grid + (q2[l] & 511));
950
- const uint32_t * signs = (const uint32_t *)(ksigns64 + (q2[l] >> 9));
951
- const int grid_l = dpct::vectorized_binary<sycl::uchar4>(
952
- grid[0] ^ signs[0], signs[0], std::minus<>());
953
- const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
954
- grid[1] ^ signs[1], signs[1], std::minus<>());
955
- sumi2 = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi2);
956
- sumi2 = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi2);
957
- q8 += 8;
958
- }
959
- const float d = (float)bq2->d * bq8_1[ib32].ds[0] * 0.25f;
960
- return d * ((0.5f + ls1) * sumi1 + (0.5f + ls2) * sumi2);
961
- #else
962
- assert(false);
963
- return 0.f;
964
- #endif
965
- #else
966
- assert(false);
967
- return 0.f;
968
- #endif
969
- }
970
-
971
- static __dpct_inline__ float
972
- vec_dot_iq2_s_q8_1(const void *__restrict__ vbq,
973
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
974
- #if QK_K == 256
975
- const block_iq2_s * bq2 = (const block_iq2_s *) vbq;
976
-
977
- const int ib32 = iqs;
978
- const int8_t * q8 = bq8_1[ib32].qs;
979
- const uint8_t * signs = bq2->qs + QK_K/8 + 4*ib32;
980
- const uint8_t ls1 = bq2->scales[ib32] & 0xf;
981
- const uint8_t ls2 = bq2->scales[ib32] >> 4;
982
- int sumi1 = 0;
983
- for (int l = 0; l < 2; ++l) {
984
- const uint32_t * grid = (const uint32_t *)(iq2s_grid + (bq2->qs[4*ib32+l] | ((bq2->qh[ib32] << (8-2*l)) & 0x300)));
985
- const uint32_t signs0 = dpct::vectorized_binary<sycl::uchar4>(
986
- ((signs[l] & 0xf) * 0x01010101) & 0x08040201, 0x08040201,
987
- std::equal_to<>());
988
- const uint32_t signs1 = dpct::vectorized_binary<sycl::uchar4>(
989
- ((signs[l] >> 4) * 0x01010101) & 0x08040201, 0x08040201,
990
- std::equal_to<>());
991
- const int grid_l = dpct::vectorized_binary<sycl::uchar4>(
992
- grid[0] ^ signs0, signs0, std::minus<>());
993
- const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
994
- grid[1] ^ signs1, signs1, std::minus<>());
995
- sumi1 = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi1);
996
- sumi1 = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi1);
997
- q8 += 8;
998
- }
999
- int sumi2 = 0;
1000
- for (int l = 2; l < 4; ++l) {
1001
- const uint32_t * grid = (const uint32_t *)(iq2s_grid + (bq2->qs[4*ib32+l] | ((bq2->qh[ib32] << (8-2*l)) & 0x300)));
1002
- const uint32_t signs0 = dpct::vectorized_binary<sycl::uchar4>(
1003
- ((signs[l] & 0xf) * 0x01010101) & 0x08040201, 0x08040201,
1004
- std::equal_to<>());
1005
- const uint32_t signs1 = dpct::vectorized_binary<sycl::uchar4>(
1006
- ((signs[l] >> 4) * 0x01010101) & 0x08040201, 0x08040201,
1007
- std::equal_to<>());
1008
- const int grid_l = dpct::vectorized_binary<sycl::uchar4>(
1009
- grid[0] ^ signs0, signs0, std::minus<>());
1010
- const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
1011
- grid[1] ^ signs1, signs1, std::minus<>());
1012
- sumi2 = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi2);
1013
- sumi2 = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi2);
1014
- q8 += 8;
1015
- }
1016
- const float d = (float)bq2->d * bq8_1[ib32].ds[0] * 0.25f;
1017
- return d * ((0.5f + ls1) * sumi1 + (0.5f + ls2) * sumi2);
1018
- #else
1019
- assert(false);
1020
- #endif
1021
- }
1022
-
1023
- static __dpct_inline__ float
1024
- vec_dot_iq3_xxs_q8_1(const void *__restrict__ vbq,
1025
- const block_q8_1 *__restrict__ bq8_1, const int &iqs,
1026
- const uint32_t *iq3xxs_grid, const uint64_t *ksigns64) {
1027
- #if DPCT_COMPATIBILITY_TEMP >= \
1028
- MIN_CC_DP4A // lowest compute capability for integer intrinsics
1029
- #if QK_K == 256
1030
- const block_iq3_xxs * bq2 = (const block_iq3_xxs *) vbq;
1031
-
1032
- const int ib32 = iqs;
1033
- const uint8_t * q3 = bq2->qs + 8*ib32;
1034
- const uint16_t * gas = (const uint16_t *)(bq2->qs + QK_K/4) + 2*ib32;
1035
- const int8_t * q8 = bq8_1[ib32].qs;
1036
- uint32_t aux32 = gas[0] | (gas[1] << 16);
1037
- int sumi = 0;
1038
- for (int l = 0; l < 4; ++l) {
1039
- const uint32_t * grid1 = iq3xxs_grid + q3[2*l+0];
1040
- const uint32_t * grid2 = iq3xxs_grid + q3[2*l+1];
1041
- const uint32_t * signs = (const uint32_t *)(ksigns64 + (aux32 & 127));
1042
- const int grid_l = dpct::vectorized_binary<sycl::uchar4>(
1043
- grid1[0] ^ signs[0], signs[0], std::minus<>());
1044
- const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
1045
- grid2[0] ^ signs[1], signs[1], std::minus<>());
1046
- sumi = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi);
1047
- sumi = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi);
1048
- q8 += 8;
1049
- aux32 >>= 7;
1050
- }
1051
- const float d = (float)bq2->d * (0.5f + aux32) * bq8_1[ib32].ds[0] * 0.5f;
1052
- return d * sumi;
1053
- #else
1054
- assert(false);
1055
- return 0.f;
1056
- #endif
1057
- #else
1058
- assert(false);
1059
- return 0.f;
1060
- #endif
1061
- }
1062
-
1063
- static __dpct_inline__ float
1064
- vec_dot_iq3_s_q8_1(const void *__restrict__ vbq,
1065
- const block_q8_1 *__restrict__ bq8_1, const int &iqs,
1066
- const uint32_t *iq3s_grid) {
1067
- #if QK_K == 256
1068
- const block_iq3_s * bq2 = (const block_iq3_s *) vbq;
1069
-
1070
- const int ib32 = iqs;
1071
- const uint8_t * qs = bq2->qs + 8*ib32;
1072
- const int8_t * q8 = bq8_1[ib32].qs;
1073
- int sumi = 0;
1074
- for (int l = 0; l < 4; ++l) {
1075
- const uint32_t * grid1 = iq3s_grid + (qs[2*l+0] | ((bq2->qh[ib32] << (8 - 2*l)) & 256));
1076
- const uint32_t * grid2 = iq3s_grid + (qs[2*l+1] | ((bq2->qh[ib32] << (7 - 2*l)) & 256));
1077
- uint32_t signs0 = dpct::vectorized_binary<sycl::uchar4>(
1078
- ((bq2->signs[4 * ib32 + l] & 0xf) * 0x01010101) & 0x08040201,
1079
- 0x08040201, std::equal_to<>());
1080
- uint32_t signs1 = dpct::vectorized_binary<sycl::uchar4>(
1081
- ((bq2->signs[4 * ib32 + l] >> 4) * 0x01010101) & 0x08040201,
1082
- 0x08040201, std::equal_to<>());
1083
- const int grid_l = dpct::vectorized_binary<sycl::uchar4>(
1084
- grid1[0] ^ signs0, signs0, std::minus<>());
1085
- const int grid_h = dpct::vectorized_binary<sycl::uchar4>(
1086
- grid2[0] ^ signs1, signs1, std::minus<>());
1087
- sumi = dpct::dp4a(grid_l, *((const int *)q8 + 0), sumi);
1088
- sumi = dpct::dp4a(grid_h, *((const int *)q8 + 1), sumi);
1089
- q8 += 8;
1090
- }
1091
- const float d =
1092
- (float)bq2->d *
1093
- (1 + 2 * ((bq2->scales[ib32 / 2] >> 4 * (ib32 % 2)) & 0xf)) *
1094
- bq8_1[ib32].ds[0];
1095
- return d * sumi;
1096
- #else
1097
- assert(false);
1098
- #endif
1099
- }
1100
-
1101
- static __dpct_inline__ float
1102
- vec_dot_iq1_s_q8_1(const void *__restrict__ vbq,
1103
- const block_q8_1 *__restrict__ bq8_1, const int &iqs,
1104
- const uint32_t *iq1s_grid_gpu) {
1105
- #if QK_K == 256
1106
- const block_iq1_s * bq1 = (const block_iq1_s *) vbq;
1107
-
1108
- const int ib32 = iqs;
1109
- int sumi = 0;
1110
- const int * q8 = (const int *)bq8_1[ib32].qs;
1111
- for (int l = 0; l < 4; ++l) {
1112
- const int * grid = (const int *)(iq1s_grid_gpu + (bq1->qs[4*ib32+l] | (((bq1->qh[ib32] >> 3*l) & 7) << 8)));
1113
- int grid0 = grid[0] & 0x0f0f0f0f;
1114
- int grid1 = (grid[0] >> 4) & 0x0f0f0f0f;
1115
- sumi = dpct::dp4a(q8[2 * l + 1], grid1,
1116
- dpct::dp4a(q8[2 * l + 0], grid0, sumi));
1117
- }
1118
-
1119
- const float delta = bq1->qh[ib32] & 0x8000 ? -1-IQ1S_DELTA : -1+IQ1S_DELTA;
1120
- const float d1q = (float)bq1->d * (2*((bq1->qh[ib32] >> 12) & 7) + 1);
1121
- const float d = d1q * bq8_1[ib32].ds[0];
1122
- const float m = d1q * bq8_1[ib32].ds[1];
1123
- return d * sumi + m * delta;
1124
- #else
1125
- assert(false);
1126
- #endif
1127
- }
1128
-
1129
- static __dpct_inline__ float
1130
- vec_dot_iq1_m_q8_1(const void *__restrict__ vbq,
1131
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
1132
- #if QK_K == 256
1133
- const block_iq1_m * bq1 = (const block_iq1_m *) vbq;
1134
-
1135
- const int ib32 = iqs;
1136
- int sumi[2] = {0, 0};
1137
- float sumf[2] = {0.f, 0.f};
1138
-
1139
- const int * q8 = (const int *)bq8_1[ib32].qs;
1140
- for (int l = 0; l < 4; ++l) {
1141
- const int * grid = (const int *)(iq1s_grid_gpu + (bq1->qs[4*ib32+l] | (((bq1->qh[2*ib32+l/2] >> 4*(l%2)) & 7) << 8)));
1142
- int grid0 = grid[0] & 0x0f0f0f0f;
1143
- int grid1 = (grid[0] >> 4) & 0x0f0f0f0f;
1144
- sumi[l / 2] = dpct::dp4a(q8[2 * l + 1], grid1,
1145
- dpct::dp4a(q8[2 * l + 0], grid0, sumi[l / 2]));
1146
- const float delta = (bq1->qh[2*ib32+l/2] >> 4*(l%2)) & 0x08 ? -1-IQ1M_DELTA : -1+IQ1M_DELTA;
1147
- const int sumy = dpct::dp4a(q8[2 * l + 1], 0x01010101,
1148
- dpct::dp4a(q8[2 * l + 0], 0x01010101, 0));
1149
- sumf[l/2] += delta*sumy;
1150
- }
1151
-
1152
- iq1m_scale_t scale;
1153
- const uint16_t * sc = (const uint16_t *)bq1->scales;
1154
- scale.u16 = (sc[0] >> 12) | ((sc[1] >> 8) & 0x00f0) | ((sc[2] >> 4) & 0x0f00) | (sc[3] & 0xf000);
1155
- const float d = (float)scale.f16 * bq8_1[ib32].ds[0];
1156
- return d * ((sumi[0] + sumf[0]) * (2*((sc[ib32/2] >> 6*(ib32%2)) & 0x7) + 1) + (sumi[1] + sumf[1]) * (2*((sc[ib32/2] >> (6*(ib32%2)+3)) & 0x7) + 1));
1157
- #else
1158
- assert(false);
1159
- #endif
1160
- }
1161
-
1162
-
1163
- static __dpct_inline__ float
1164
- vec_dot_iq4_nl_q8_1(const void *__restrict__ vbq,
1165
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
1166
-
1167
- const block_iq4_nl * bq = (const block_iq4_nl *) vbq;
1168
-
1169
- const uint16_t * q4 = (const uint16_t *)bq->qs + 2*iqs;
1170
- const int32_t * q8 = (const int32_t *)bq8_1->qs + iqs;
1171
-
1172
- const uint8_t * values = (const uint8_t *)kvalues_iq4nl;
1173
-
1174
- int v1, v2;
1175
- int sumi1 = 0, sumi2 = 0;
1176
- for (int l = 0; l < VDR_Q4_0_Q8_1_MMVQ; ++l) {
1177
- const uint32_t aux = q4[2*l] | (q4[2*l+1] << 16);
1178
- get_int_from_table_16(aux, values, v1, v2);
1179
- sumi1 = dpct::dp4a(v1, q8[l + 0], sumi1);
1180
- sumi2 = dpct::dp4a(v2, q8[l + 4], sumi2);
1181
- }
1182
-
1183
- const float d = (float)bq->d * bq8_1->ds[0];
1184
- return d * (sumi1 + sumi2);
1185
- }
1186
-
1187
-
1188
- static __dpct_inline__ float
1189
- vec_dot_iq4_xs_q8_1(const void *__restrict__ vbq,
1190
- const block_q8_1 *__restrict__ bq8_1, const int &iqs) {
1191
-
1192
- #if QK_K == 256
1193
- const block_iq4_xs * bq4 = (const block_iq4_xs *) vbq;
1194
- const uint8_t * values = (const uint8_t *)kvalues_iq4nl;
1195
-
1196
- // iqs is 0...7
1197
- const int ib32 = iqs;
1198
- const int32_t * q8 = (const int *)bq8_1[ib32].qs;
1199
- const uint32_t * q4 = (const uint32_t *)bq4->qs + 4*ib32;
1200
- const int8_t ls = ((bq4->scales_l[ib32/2] >> 4*(ib32%2)) & 0xf) | (((bq4->scales_h >> 2*ib32) & 3) << 4);
1201
- const float d = (float)bq4->d * (ls - 32) * bq8_1[ib32].ds[0];
1202
- int v1, v2;
1203
- int sumi1 = 0, sumi2 = 0;
1204
- for (int j = 0; j < 4; ++j) {
1205
- get_int_from_table_16(q4[j], values, v1, v2);
1206
- sumi1 = dpct::dp4a(v1, q8[j + 0], sumi1);
1207
- sumi2 = dpct::dp4a(v2, q8[j + 4], sumi2);
1208
- }
1209
- return d * (sumi1 + sumi2);
1210
- #else
1211
- assert(false);
1212
- #endif
1213
- }
1214
-
1215
- #endif // GGML_SYCL_VECDOTQ_HPP