cohere-transcribe 0.1.0

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 (480) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +21 -0
  3. data/LICENSE.txt +201 -0
  4. data/NOTICE +5 -0
  5. data/README.md +265 -0
  6. data/THIRD_PARTY_NOTICES.md +67 -0
  7. data/exe/cohere-transcribe +8 -0
  8. data/exe/cohere-transcribe-doctor +8 -0
  9. data/ext/cohere_transcribe_native/CMakeLists.txt +262 -0
  10. data/ext/cohere_transcribe_native/README.md +26 -0
  11. data/ext/cohere_transcribe_native/audio_abi.cpp +1416 -0
  12. data/ext/cohere_transcribe_native/audio_exports.macos +5 -0
  13. data/ext/cohere_transcribe_native/audio_exports.map +10 -0
  14. data/ext/cohere_transcribe_native/cohere_abi.cpp +1209 -0
  15. data/ext/cohere_transcribe_native/exports.macos +40 -0
  16. data/ext/cohere_transcribe_native/exports.map +45 -0
  17. data/ext/cohere_transcribe_native/extconf.rb +89 -0
  18. data/ext/cohere_transcribe_native/test/abi_smoke.rb +232 -0
  19. data/ext/cohere_transcribe_native/test/audio_matrix_smoke.cpp +121 -0
  20. data/ext/cohere_transcribe_native/test/audio_reliability_smoke.cpp +198 -0
  21. data/ext/cohere_transcribe_native/test/native_abi_reliability_smoke.cpp +186 -0
  22. data/ext/cohere_transcribe_native/test/native_batch_projection_probe.rb +81 -0
  23. data/ext/cohere_transcribe_native/test/native_cancellation_smoke.cpp +194 -0
  24. data/lib/cohere/transcribe/alignment/ATTRIBUTION.md +23 -0
  25. data/lib/cohere/transcribe/alignment/LICENSE.ctc-forced-aligner +407 -0
  26. data/lib/cohere/transcribe/alignment/LICENSE.torchaudio +25 -0
  27. data/lib/cohere/transcribe/alignment/LICENSE.uroman +26 -0
  28. data/lib/cohere/transcribe/alignment/aligner.rb +476 -0
  29. data/lib/cohere/transcribe/alignment/ctc.rb +224 -0
  30. data/lib/cohere/transcribe/alignment/text.rb +237 -0
  31. data/lib/cohere/transcribe/alignment/uroman_data.rb +4950 -0
  32. data/lib/cohere/transcribe/api.rb +173 -0
  33. data/lib/cohere/transcribe/asr/batching.rb +472 -0
  34. data/lib/cohere/transcribe/asr/failure_policy.rb +112 -0
  35. data/lib/cohere/transcribe/asr/native.rb +676 -0
  36. data/lib/cohere/transcribe/audio/ATTRIBUTION.md +8 -0
  37. data/lib/cohere/transcribe/audio/LICENSE.auditok +21 -0
  38. data/lib/cohere/transcribe/audio/decoder.rb +315 -0
  39. data/lib/cohere/transcribe/audio/ffmpeg_native.rb +248 -0
  40. data/lib/cohere/transcribe/audio/segmentation.rb +260 -0
  41. data/lib/cohere/transcribe/cli.rb +727 -0
  42. data/lib/cohere/transcribe/configuration.rb +282 -0
  43. data/lib/cohere/transcribe/constants.rb +14 -0
  44. data/lib/cohere/transcribe/dense_converter.rb +548 -0
  45. data/lib/cohere/transcribe/doctor.rb +576 -0
  46. data/lib/cohere/transcribe/errors.rb +57 -0
  47. data/lib/cohere/transcribe/gguf_writer.rb +268 -0
  48. data/lib/cohere/transcribe/hub.rb +436 -0
  49. data/lib/cohere/transcribe/input.rb +110 -0
  50. data/lib/cohere/transcribe/licenses/crispasr.txt +21 -0
  51. data/lib/cohere/transcribe/loader.rb +128 -0
  52. data/lib/cohere/transcribe/model_identity.rb +440 -0
  53. data/lib/cohere/transcribe/output/publication.rb +1118 -0
  54. data/lib/cohere/transcribe/output/rendering.rb +105 -0
  55. data/lib/cohere/transcribe/output/timing.rb +86 -0
  56. data/lib/cohere/transcribe/python_text.rb +70 -0
  57. data/lib/cohere/transcribe/pytorch_checkpoint.rb +1180 -0
  58. data/lib/cohere/transcribe/runtime/engine.rb +1676 -0
  59. data/lib/cohere/transcribe/runtime/model_provider.rb +390 -0
  60. data/lib/cohere/transcribe/runtime/precision.rb +57 -0
  61. data/lib/cohere/transcribe/runtime/preparation.rb +215 -0
  62. data/lib/cohere/transcribe/runtime/resources.rb +165 -0
  63. data/lib/cohere/transcribe/runtime/word_pipeline.rb +364 -0
  64. data/lib/cohere/transcribe/safetensors.rb +579 -0
  65. data/lib/cohere/transcribe/state/checkpoint.rb +224 -0
  66. data/lib/cohere/transcribe/state/contracts.rb +141 -0
  67. data/lib/cohere/transcribe/state/io.rb +727 -0
  68. data/lib/cohere/transcribe/state/locking.rb +211 -0
  69. data/lib/cohere/transcribe/state/manifest.rb +155 -0
  70. data/lib/cohere/transcribe/state.rb +7 -0
  71. data/lib/cohere/transcribe/types.rb +535 -0
  72. data/lib/cohere/transcribe/vad/ATTRIBUTION.md +14 -0
  73. data/lib/cohere/transcribe/vad/LICENSE.faster-whisper +21 -0
  74. data/lib/cohere/transcribe/vad/LICENSE.silero-vad +21 -0
  75. data/lib/cohere/transcribe/vad/silero.rb +344 -0
  76. data/lib/cohere/transcribe/vad/silero_vad_v6.onnx +0 -0
  77. data/lib/cohere/transcribe/vad/timestamps.rb +219 -0
  78. data/lib/cohere/transcribe/version.rb +7 -0
  79. data/lib/cohere/transcribe.rb +26 -0
  80. data/sig/cohere/transcribe.rbs +250 -0
  81. data/vendor/crispasr/AUTHORS +510 -0
  82. data/vendor/crispasr/LICENSE +21 -0
  83. data/vendor/crispasr/UPSTREAM.md +9 -0
  84. data/vendor/crispasr/VERSION +1 -0
  85. data/vendor/crispasr/ggml/AUTHORS +335 -0
  86. data/vendor/crispasr/ggml/CMakeLists.txt +512 -0
  87. data/vendor/crispasr/ggml/LICENSE +21 -0
  88. data/vendor/crispasr/ggml/README.md +49 -0
  89. data/vendor/crispasr/ggml/cmake/FindNCCL.cmake +36 -0
  90. data/vendor/crispasr/ggml/cmake/GitVars.cmake +22 -0
  91. data/vendor/crispasr/ggml/cmake/common.cmake +50 -0
  92. data/vendor/crispasr/ggml/cmake/ggml-config.cmake.in +191 -0
  93. data/vendor/crispasr/ggml/ggml.pc.in +10 -0
  94. data/vendor/crispasr/ggml/include/ggml-alloc.h +85 -0
  95. data/vendor/crispasr/ggml/include/ggml-backend.h +431 -0
  96. data/vendor/crispasr/ggml/include/ggml-blas.h +25 -0
  97. data/vendor/crispasr/ggml/include/ggml-cann.h +123 -0
  98. data/vendor/crispasr/ggml/include/ggml-cpp.h +39 -0
  99. data/vendor/crispasr/ggml/include/ggml-cpu.h +151 -0
  100. data/vendor/crispasr/ggml/include/ggml-cuda.h +50 -0
  101. data/vendor/crispasr/ggml/include/ggml-hexagon.h +19 -0
  102. data/vendor/crispasr/ggml/include/ggml-metal.h +61 -0
  103. data/vendor/crispasr/ggml/include/ggml-opencl.h +26 -0
  104. data/vendor/crispasr/ggml/include/ggml-openvino.h +37 -0
  105. data/vendor/crispasr/ggml/include/ggml-opt.h +256 -0
  106. data/vendor/crispasr/ggml/include/ggml-rpc.h +35 -0
  107. data/vendor/crispasr/ggml/include/ggml-sycl.h +49 -0
  108. data/vendor/crispasr/ggml/include/ggml-virtgpu.h +14 -0
  109. data/vendor/crispasr/ggml/include/ggml-vulkan.h +29 -0
  110. data/vendor/crispasr/ggml/include/ggml-webgpu.h +19 -0
  111. data/vendor/crispasr/ggml/include/ggml-zdnn.h +17 -0
  112. data/vendor/crispasr/ggml/include/ggml-zendnn.h +22 -0
  113. data/vendor/crispasr/ggml/include/ggml.h +2887 -0
  114. data/vendor/crispasr/ggml/include/gguf.h +204 -0
  115. data/vendor/crispasr/ggml/src/CMakeLists.txt +493 -0
  116. data/vendor/crispasr/ggml/src/ggml-alloc.c +1323 -0
  117. data/vendor/crispasr/ggml/src/ggml-backend-dl.cpp +48 -0
  118. data/vendor/crispasr/ggml/src/ggml-backend-dl.h +44 -0
  119. data/vendor/crispasr/ggml/src/ggml-backend-impl.h +275 -0
  120. data/vendor/crispasr/ggml/src/ggml-backend-meta.cpp +2145 -0
  121. data/vendor/crispasr/ggml/src/ggml-backend-reg.cpp +586 -0
  122. data/vendor/crispasr/ggml/src/ggml-backend.cpp +2437 -0
  123. data/vendor/crispasr/ggml/src/ggml-common.h +1900 -0
  124. data/vendor/crispasr/ggml/src/ggml-cpu/CMakeLists.txt +718 -0
  125. data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.cpp +249 -0
  126. data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.h +8 -0
  127. data/vendor/crispasr/ggml/src/ggml-cpu/amx/common.h +115 -0
  128. data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.cpp +2512 -0
  129. data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.h +10 -0
  130. data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +98 -0
  131. data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/quants.c +4244 -0
  132. data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/repack.cpp +5156 -0
  133. data/vendor/crispasr/ggml/src/ggml-cpu/arch/loongarch/quants.c +2158 -0
  134. data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
  135. data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/quants.c +2304 -0
  136. data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/cpu-feats.cpp +38 -0
  137. data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/quants.c +4455 -0
  138. data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/repack.cpp +1703 -0
  139. data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/cpu-feats.cpp +50 -0
  140. data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/quants.c +1465 -0
  141. data/vendor/crispasr/ggml/src/ggml-cpu/arch/wasm/quants.c +1220 -0
  142. data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
  143. data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/quants.c +3970 -0
  144. data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/repack.cpp +6407 -0
  145. data/vendor/crispasr/ggml/src/ggml-cpu/arch-fallback.h +349 -0
  146. data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.cpp +154 -0
  147. data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.h +16 -0
  148. data/vendor/crispasr/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
  149. data/vendor/crispasr/ggml/src/ggml-cpu/common.h +95 -0
  150. data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu-impl.h +539 -0
  151. data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.c +3791 -0
  152. data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.cpp +703 -0
  153. data/vendor/crispasr/ggml/src/ggml-cpu/hbm.cpp +55 -0
  154. data/vendor/crispasr/ggml/src/ggml-cpu/hbm.h +8 -0
  155. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.cpp +939 -0
  156. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.h +90 -0
  157. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1513 -0
  158. data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
  159. data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.cpp +4051 -0
  160. data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.h +25 -0
  161. data/vendor/crispasr/ggml/src/ggml-cpu/ops.cpp +11662 -0
  162. data/vendor/crispasr/ggml/src/ggml-cpu/ops.h +121 -0
  163. data/vendor/crispasr/ggml/src/ggml-cpu/quants.c +1288 -0
  164. data/vendor/crispasr/ggml/src/ggml-cpu/quants.h +103 -0
  165. data/vendor/crispasr/ggml/src/ggml-cpu/repack.cpp +4836 -0
  166. data/vendor/crispasr/ggml/src/ggml-cpu/repack.h +245 -0
  167. data/vendor/crispasr/ggml/src/ggml-cpu/simd-gemm.h +226 -0
  168. data/vendor/crispasr/ggml/src/ggml-cpu/simd-mappings.h +1329 -0
  169. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.cpp +1025 -0
  170. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.h +13 -0
  171. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime1_kernels.cpp +3196 -0
  172. data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime_kernels.h +26 -0
  173. data/vendor/crispasr/ggml/src/ggml-cpu/traits.cpp +36 -0
  174. data/vendor/crispasr/ggml/src/ggml-cpu/traits.h +38 -0
  175. data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.cpp +336 -0
  176. data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.h +35 -0
  177. data/vendor/crispasr/ggml/src/ggml-cpu/vec.cpp +681 -0
  178. data/vendor/crispasr/ggml/src/ggml-cpu/vec.h +1606 -0
  179. data/vendor/crispasr/ggml/src/ggml-cuda/CMakeLists.txt +272 -0
  180. data/vendor/crispasr/ggml/src/ggml-cuda/acc.cu +61 -0
  181. data/vendor/crispasr/ggml/src/ggml-cuda/acc.cuh +5 -0
  182. data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cu +58 -0
  183. data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cuh +3 -0
  184. data/vendor/crispasr/ggml/src/ggml-cuda/arange.cu +34 -0
  185. data/vendor/crispasr/ggml/src/ggml-cuda/arange.cuh +5 -0
  186. data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cu +91 -0
  187. data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cuh +3 -0
  188. data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cu +265 -0
  189. data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cuh +19 -0
  190. data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cu +534 -0
  191. data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cuh +12 -0
  192. data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cu +45 -0
  193. data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cuh +5 -0
  194. data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
  195. data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
  196. data/vendor/crispasr/ggml/src/ggml-cuda/common.cuh +1489 -0
  197. data/vendor/crispasr/ggml/src/ggml-cuda/concat.cu +204 -0
  198. data/vendor/crispasr/ggml/src/ggml-cuda/concat.cuh +5 -0
  199. data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cu +97 -0
  200. data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
  201. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
  202. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
  203. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cu +115 -0
  204. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cuh +5 -0
  205. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cu +166 -0
  206. data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cuh +5 -0
  207. data/vendor/crispasr/ggml/src/ggml-cuda/convert.cu +892 -0
  208. data/vendor/crispasr/ggml/src/ggml-cuda/convert.cuh +66 -0
  209. data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cu +64 -0
  210. data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cuh +5 -0
  211. data/vendor/crispasr/ggml/src/ggml-cuda/cp-async.cuh +57 -0
  212. data/vendor/crispasr/ggml/src/ggml-cuda/cpy-utils.cuh +217 -0
  213. data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cu +581 -0
  214. data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cuh +7 -0
  215. data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cu +177 -0
  216. data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
  217. data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cu +307 -0
  218. data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cuh +5 -0
  219. data/vendor/crispasr/ggml/src/ggml-cuda/dequantize.cuh +99 -0
  220. data/vendor/crispasr/ggml/src/ggml-cuda/diag.cu +77 -0
  221. data/vendor/crispasr/ggml/src/ggml-cuda/diag.cuh +5 -0
  222. data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cu +40 -0
  223. data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cuh +5 -0
  224. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-common.cuh +1212 -0
  225. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-mma-f16.cuh +1860 -0
  226. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cu +57 -0
  227. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cuh +1309 -0
  228. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-vec.cuh +600 -0
  229. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cu +696 -0
  230. data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cuh +51 -0
  231. data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cu +620 -0
  232. data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cuh +5 -0
  233. data/vendor/crispasr/ggml/src/ggml-cuda/fill.cu +37 -0
  234. data/vendor/crispasr/ggml/src/ggml-cuda/fill.cuh +3 -0
  235. data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cu +273 -0
  236. data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cuh +4 -0
  237. data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cu +332 -0
  238. data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cuh +15 -0
  239. data/vendor/crispasr/ggml/src/ggml-cuda/ggml-cuda.cu +5580 -0
  240. data/vendor/crispasr/ggml/src/ggml-cuda/gla.cu +93 -0
  241. data/vendor/crispasr/ggml/src/ggml-cuda/gla.cuh +3 -0
  242. data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cu +274 -0
  243. data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cuh +6 -0
  244. data/vendor/crispasr/ggml/src/ggml-cuda/mean.cu +75 -0
  245. data/vendor/crispasr/ggml/src/ggml-cuda/mean.cuh +3 -0
  246. data/vendor/crispasr/ggml/src/ggml-cuda/mma.cuh +1333 -0
  247. data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cu +191 -0
  248. data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cuh +908 -0
  249. data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cu +164 -0
  250. data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cuh +5 -0
  251. data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cu +372 -0
  252. data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cuh +4175 -0
  253. data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cu +862 -0
  254. data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cuh +14 -0
  255. data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cu +1161 -0
  256. data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cuh +16 -0
  257. data/vendor/crispasr/ggml/src/ggml-cuda/norm.cu +756 -0
  258. data/vendor/crispasr/ggml/src/ggml-cuda/norm.cuh +20 -0
  259. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
  260. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
  261. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cu +49 -0
  262. data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cuh +5 -0
  263. data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cu +68 -0
  264. data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cuh +3 -0
  265. data/vendor/crispasr/ggml/src/ggml-cuda/pad.cu +106 -0
  266. data/vendor/crispasr/ggml/src/ggml-cuda/pad.cuh +5 -0
  267. data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cu +91 -0
  268. data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cuh +5 -0
  269. data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cu +94 -0
  270. data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cuh +5 -0
  271. data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cu +443 -0
  272. data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cuh +41 -0
  273. data/vendor/crispasr/ggml/src/ggml-cuda/reduce_rows.cuh +39 -0
  274. data/vendor/crispasr/ggml/src/ggml-cuda/roll.cu +67 -0
  275. data/vendor/crispasr/ggml/src/ggml-cuda/roll.cuh +5 -0
  276. data/vendor/crispasr/ggml/src/ggml-cuda/rope.cu +665 -0
  277. data/vendor/crispasr/ggml/src/ggml-cuda/rope.cuh +9 -0
  278. data/vendor/crispasr/ggml/src/ggml-cuda/scale.cu +34 -0
  279. data/vendor/crispasr/ggml/src/ggml-cuda/scale.cuh +5 -0
  280. data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cu +330 -0
  281. data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cuh +7 -0
  282. data/vendor/crispasr/ggml/src/ggml-cuda/set.cu +39 -0
  283. data/vendor/crispasr/ggml/src/ggml-cuda/set.cuh +7 -0
  284. data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cu +34 -0
  285. data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cuh +5 -0
  286. data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cu +472 -0
  287. data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cuh +7 -0
  288. data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cu +275 -0
  289. data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cuh +3 -0
  290. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cu +197 -0
  291. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
  292. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cu +342 -0
  293. data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
  294. data/vendor/crispasr/ggml/src/ggml-cuda/sum.cu +41 -0
  295. data/vendor/crispasr/ggml/src/ggml-cuda/sum.cuh +5 -0
  296. data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cu +43 -0
  297. data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cuh +4 -0
  298. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +5 -0
  299. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_32.cu +6 -0
  300. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +11 -0
  301. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
  302. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +10 -0
  303. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +12 -0
  304. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +5 -0
  305. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_32.cu +6 -0
  306. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +12 -0
  307. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +11 -0
  308. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
  309. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +10 -0
  310. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +5 -0
  311. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +10 -0
  312. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +12 -0
  313. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +11 -0
  314. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
  315. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
  316. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +10 -0
  317. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +12 -0
  318. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +11 -0
  319. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq112-dv112.cu +5 -0
  320. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq128-dv128.cu +5 -0
  321. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq256-dv256.cu +5 -0
  322. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq320-dv256.cu +5 -0
  323. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq40-dv40.cu +5 -0
  324. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq512-dv512.cu +5 -0
  325. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq576-dv512.cu +5 -0
  326. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq64-dv64.cu +5 -0
  327. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq72-dv72.cu +5 -0
  328. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq80-dv80.cu +5 -0
  329. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq96-dv96.cu +5 -0
  330. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-bf16.cu +7 -0
  331. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-f16.cu +7 -0
  332. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_0.cu +7 -0
  333. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_1.cu +7 -0
  334. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_0.cu +7 -0
  335. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_1.cu +7 -0
  336. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q8_0.cu +7 -0
  337. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-bf16.cu +7 -0
  338. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-f16.cu +7 -0
  339. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_0.cu +7 -0
  340. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_1.cu +7 -0
  341. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_0.cu +7 -0
  342. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_1.cu +7 -0
  343. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q8_0.cu +7 -0
  344. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-bf16.cu +7 -0
  345. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-f16.cu +7 -0
  346. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_0.cu +7 -0
  347. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_1.cu +7 -0
  348. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_0.cu +7 -0
  349. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_1.cu +7 -0
  350. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q8_0.cu +7 -0
  351. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-bf16.cu +7 -0
  352. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-f16.cu +7 -0
  353. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_0.cu +7 -0
  354. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_1.cu +7 -0
  355. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_0.cu +7 -0
  356. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_1.cu +7 -0
  357. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q8_0.cu +7 -0
  358. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-bf16.cu +7 -0
  359. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-f16.cu +7 -0
  360. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_0.cu +7 -0
  361. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_1.cu +7 -0
  362. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_0.cu +7 -0
  363. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_1.cu +7 -0
  364. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q8_0.cu +7 -0
  365. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-bf16.cu +7 -0
  366. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-f16.cu +7 -0
  367. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_0.cu +7 -0
  368. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_1.cu +7 -0
  369. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_0.cu +7 -0
  370. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_1.cu +7 -0
  371. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q8_0.cu +7 -0
  372. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-bf16.cu +7 -0
  373. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-f16.cu +7 -0
  374. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_0.cu +7 -0
  375. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_1.cu +7 -0
  376. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_0.cu +7 -0
  377. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_1.cu +7 -0
  378. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q8_0.cu +7 -0
  379. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_1.cu +5 -0
  380. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_10.cu +5 -0
  381. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_11.cu +5 -0
  382. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_12.cu +5 -0
  383. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_13.cu +5 -0
  384. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_14.cu +5 -0
  385. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_15.cu +5 -0
  386. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_16.cu +5 -0
  387. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_2.cu +5 -0
  388. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_3.cu +5 -0
  389. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_4.cu +5 -0
  390. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_5.cu +5 -0
  391. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_6.cu +5 -0
  392. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_7.cu +5 -0
  393. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_8.cu +5 -0
  394. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_9.cu +5 -0
  395. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
  396. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
  397. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
  398. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
  399. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
  400. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
  401. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
  402. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
  403. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-mxfp4.cu +5 -0
  404. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-nvfp4.cu +5 -0
  405. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q1_0.cu +5 -0
  406. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
  407. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
  408. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
  409. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
  410. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
  411. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
  412. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
  413. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
  414. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
  415. data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
  416. data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cu +95 -0
  417. data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cuh +3 -0
  418. data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cu +415 -0
  419. data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cuh +27 -0
  420. data/vendor/crispasr/ggml/src/ggml-cuda/tri.cu +136 -0
  421. data/vendor/crispasr/ggml/src/ggml-cuda/tri.cuh +5 -0
  422. data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cu +47 -0
  423. data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cuh +5 -0
  424. data/vendor/crispasr/ggml/src/ggml-cuda/unary.cu +644 -0
  425. data/vendor/crispasr/ggml/src/ggml-cuda/unary.cuh +116 -0
  426. data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cu +293 -0
  427. data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cuh +5 -0
  428. data/vendor/crispasr/ggml/src/ggml-cuda/vecdotq.cuh +1317 -0
  429. data/vendor/crispasr/ggml/src/ggml-cuda/vendors/cuda.h +28 -0
  430. data/vendor/crispasr/ggml/src/ggml-cuda/vendors/hip.h +306 -0
  431. data/vendor/crispasr/ggml/src/ggml-cuda/vendors/musa.h +148 -0
  432. data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cu +199 -0
  433. data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cuh +7 -0
  434. data/vendor/crispasr/ggml/src/ggml-impl.h +783 -0
  435. data/vendor/crispasr/ggml/src/ggml-metal/CMakeLists.txt +124 -0
  436. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.cpp +457 -0
  437. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.h +52 -0
  438. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.h +41 -0
  439. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.m +778 -0
  440. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.cpp +2117 -0
  441. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.h +299 -0
  442. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.m +2093 -0
  443. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-impl.h +1267 -0
  444. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.cpp +5023 -0
  445. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.h +111 -0
  446. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.cpp +954 -0
  447. data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.metal +11756 -0
  448. data/vendor/crispasr/ggml/src/ggml-opt.cpp +1094 -0
  449. data/vendor/crispasr/ggml/src/ggml-quants.c +5491 -0
  450. data/vendor/crispasr/ggml/src/ggml-quants.h +112 -0
  451. data/vendor/crispasr/ggml/src/ggml-threading.cpp +12 -0
  452. data/vendor/crispasr/ggml/src/ggml-threading.h +14 -0
  453. data/vendor/crispasr/ggml/src/ggml.c +7925 -0
  454. data/vendor/crispasr/ggml/src/ggml.cpp +26 -0
  455. data/vendor/crispasr/ggml/src/gguf.cpp +1556 -0
  456. data/vendor/crispasr/src/cohere-arch.h +137 -0
  457. data/vendor/crispasr/src/cohere.cpp +5642 -0
  458. data/vendor/crispasr/src/cohere.h +327 -0
  459. data/vendor/crispasr/src/cohere_batch_planner.h +82 -0
  460. data/vendor/crispasr/src/cohere_chunking.h +64 -0
  461. data/vendor/crispasr/src/cohere_decoder_batch_layout.h +60 -0
  462. data/vendor/crispasr/src/cohere_encoder_padded_layout.h +27 -0
  463. data/vendor/crispasr/src/cohere_frontend.cpp +189 -0
  464. data/vendor/crispasr/src/cohere_frontend.h +31 -0
  465. data/vendor/crispasr/src/cohere_ragged_controller.h +149 -0
  466. data/vendor/crispasr/src/cohere_token_renderer.h +181 -0
  467. data/vendor/crispasr/src/core/attention.h +924 -0
  468. data/vendor/crispasr/src/core/audio_chunking.h +97 -0
  469. data/vendor/crispasr/src/core/beam_decode.h +486 -0
  470. data/vendor/crispasr/src/core/cpu_ops.h +135 -0
  471. data/vendor/crispasr/src/core/gguf_loader.cpp +1021 -0
  472. data/vendor/crispasr/src/core/gguf_loader.h +216 -0
  473. data/vendor/crispasr/src/core/gpu_backend_pref.h +119 -0
  474. data/vendor/crispasr/src/core/mel.cpp +519 -0
  475. data/vendor/crispasr/src/core/mel.h +265 -0
  476. data/vendor/crispasr/src/core/ngram_loop_fix.h +173 -0
  477. data/vendor/crispasr/src/core/repetition_loop_guard.h +54 -0
  478. data/vendor/crispasr/src/crispasr_imatrix.cpp +255 -0
  479. data/vendor/crispasr/src/crispasr_imatrix.h +38 -0
  480. metadata +596 -0
@@ -0,0 +1,28 @@
1
+ #pragma once
2
+
3
+ #include <cuda_runtime.h>
4
+ #include <cuda.h>
5
+ #include <cublas_v2.h>
6
+ #include <cuda_bf16.h>
7
+ #include <cuda_fp16.h>
8
+
9
+ #ifdef GGML_USE_NCCL
10
+ #include <nccl.h>
11
+ #endif // GGML_USE_NCCL
12
+
13
+ #if CUDART_VERSION >= 11080
14
+ #include <cuda_fp8.h>
15
+ #define FP8_AVAILABLE
16
+ #endif // CUDART_VERSION >= 11080
17
+
18
+ #if CUDART_VERSION >= 12080
19
+ #include <cuda_fp4.h>
20
+ #endif // CUDART_VERSION >= 12080
21
+
22
+ #if CUDART_VERSION < 11020
23
+ #define CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED CU_DEVICE_ATTRIBUTE_VIRTUAL_ADDRESS_MANAGEMENT_SUPPORTED
24
+ #define CUBLAS_TF32_TENSOR_OP_MATH CUBLAS_TENSOR_OP_MATH
25
+ #define CUBLAS_COMPUTE_16F CUDA_R_16F
26
+ #define CUBLAS_COMPUTE_32F CUDA_R_32F
27
+ #define cublasComputeType_t cudaDataType_t
28
+ #endif // CUDART_VERSION < 11020
@@ -0,0 +1,306 @@
1
+ #pragma once
2
+
3
+ #define HIP_DISABLE_WARP_SYNC_BUILTINS 1
4
+ #include <hip/hip_runtime.h>
5
+ #include <hipblas/hipblas.h>
6
+ #include <hip/hip_fp16.h>
7
+ #include <hip/hip_bf16.h>
8
+
9
+ #if defined(GGML_HIP_ROCWMMA_FATTN)
10
+ #include <rocwmma/rocwmma-version.hpp>
11
+ #endif // defined(GGML_HIP_ROCWMMA_FATTN)
12
+
13
+ #ifdef GGML_USE_NCCL
14
+ #include <rccl/rccl.h>
15
+ #endif // GGML_USE_NCCL
16
+
17
+
18
+ #define CUBLAS_GEMM_DEFAULT HIPBLAS_GEMM_DEFAULT
19
+ #define CUBLAS_GEMM_DEFAULT_TENSOR_OP HIPBLAS_GEMM_DEFAULT
20
+ #define CUBLAS_OP_N HIPBLAS_OP_N
21
+ #define CUBLAS_OP_T HIPBLAS_OP_T
22
+ #define CUBLAS_STATUS_SUCCESS HIPBLAS_STATUS_SUCCESS
23
+ #define CUBLAS_TF32_TENSOR_OP_MATH 0
24
+ #define CUDA_R_16F HIPBLAS_R_16F
25
+ #define CUDA_R_16BF HIPBLAS_R_16B
26
+ #define CUDA_R_32F HIPBLAS_R_32F
27
+ #define CUBLAS_SIDE_RIGHT HIPBLAS_SIDE_RIGHT
28
+ #define CUBLAS_FILL_MODE_UPPER HIPBLAS_FILL_MODE_UPPER
29
+ #define CUBLAS_DIAG_NON_UNIT HIPBLAS_DIAG_NON_UNIT
30
+ #define CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED hipDeviceAttributeVirtualMemoryManagementSupported
31
+ #define CU_MEM_ALLOC_GRANULARITY_RECOMMENDED hipMemAllocationGranularityRecommended
32
+ #define CU_MEM_ALLOCATION_TYPE_PINNED hipMemAllocationTypePinned
33
+ #define CU_MEM_LOCATION_TYPE_DEVICE hipMemLocationTypeDevice
34
+ #define CU_MEM_ACCESS_FLAGS_PROT_READWRITE hipMemAccessFlagsProtReadWrite
35
+ #define CU_CHECK(fn) {hipError_t err = fn; if(err != hipSuccess) { GGML_ABORT("HipVMM Failure: %s\n", hipGetErrorString(err)); }}
36
+ #define __shfl_sync(mask, var, laneMask, width) __shfl(var, laneMask, width)
37
+ #define __shfl_up_sync(mask, var, laneMask, width) __shfl_up(var, laneMask, width)
38
+ #define __shfl_xor_sync(mask, var, laneMask, width) __shfl_xor(var, laneMask, width)
39
+ #define __all_sync(mask, var) __all(var)
40
+ #define __any_sync(mask, var) __any(var)
41
+ #define cublasStrsmBatched hipblasStrsmBatched
42
+ #define cublasCreate hipblasCreate
43
+ #define cublasDestroy hipblasDestroy
44
+ #define cublasGemmEx hipblasGemmEx
45
+ #define cublasGemmBatchedEx hipblasGemmBatchedEx
46
+ #define cublasGemmStridedBatchedEx hipblasGemmStridedBatchedEx
47
+ #define cublasHandle_t hipblasHandle_t
48
+ #define cublasSetMathMode(handle, mode) CUBLAS_STATUS_SUCCESS
49
+ #define cublasSetStream hipblasSetStream
50
+ #define cublasSgemm hipblasSgemm
51
+ #define cublasStatus_t hipblasStatus_t
52
+ #define cublasOperation_t hipblasOperation_t
53
+ #define cudaDevAttrCooperativeLaunch hipDeviceAttributeCooperativeLaunch
54
+ #define cudaDeviceCanAccessPeer hipDeviceCanAccessPeer
55
+ #define cudaDeviceDisablePeerAccess hipDeviceDisablePeerAccess
56
+ #define cudaDeviceEnablePeerAccess hipDeviceEnablePeerAccess
57
+ #define cudaDeviceGetAttribute hipDeviceGetAttribute
58
+ #define cudaDeviceProp hipDeviceProp_t
59
+ #define cudaDeviceSynchronize hipDeviceSynchronize
60
+ #define cudaError_t hipError_t
61
+ #define cudaErrorMemoryAllocation hipErrorOutOfMemory
62
+ #define cudaErrorPeerAccessAlreadyEnabled hipErrorPeerAccessAlreadyEnabled
63
+ #define cudaErrorPeerAccessNotEnabled hipErrorPeerAccessNotEnabled
64
+ #define cudaEventCreateWithFlags hipEventCreateWithFlags
65
+ #define cudaEventDisableTiming hipEventDisableTiming
66
+ #define cudaEventRecord hipEventRecord
67
+ #define cudaEventSynchronize hipEventSynchronize
68
+ #define cudaEvent_t hipEvent_t
69
+ #define cudaEventDestroy hipEventDestroy
70
+ #define cudaFree hipFree
71
+ #define cudaFreeHost hipHostFree
72
+ #define cudaGetDevice hipGetDevice
73
+ #define cudaGetDeviceCount hipGetDeviceCount
74
+ #define cudaGetDeviceProperties hipGetDeviceProperties
75
+ #define cudaGetErrorString hipGetErrorString
76
+ #define cudaGetLastError hipGetLastError
77
+ #define cudaHostRegister hipHostRegister
78
+ #define cudaHostRegisterPortable hipHostRegisterPortable
79
+ #define cudaHostRegisterReadOnly hipHostRegisterReadOnly
80
+ #define cudaHostUnregister hipHostUnregister
81
+ #define cudaLaunchCooperativeKernel hipLaunchCooperativeKernel
82
+ #define cudaLaunchHostFunc hipLaunchHostFunc
83
+ #define cudaMalloc hipMalloc
84
+ #define cudaMallocHost(ptr, size) hipHostMalloc(ptr, size, hipHostMallocDefault)
85
+ #define cudaMallocManaged hipMallocManaged
86
+ #define cudaMemAdvise hipMemAdvise
87
+ #define cudaMemcpy hipMemcpy
88
+ #define cudaMemcpyAsync hipMemcpyAsync
89
+ #define cudaMemcpyPeerAsync hipMemcpyPeerAsync
90
+ #define cudaMemcpy2DAsync hipMemcpy2DAsync
91
+ #define cudaMemcpyDeviceToDevice hipMemcpyDeviceToDevice
92
+ #define cudaMemcpyDeviceToHost hipMemcpyDeviceToHost
93
+ #define cudaMemcpyHostToDevice hipMemcpyHostToDevice
94
+ #define cudaMemcpyKind hipMemcpyKind
95
+ #define cudaMemset hipMemset
96
+ #define cudaMemsetAsync hipMemsetAsync
97
+ #define cudaMemGetInfo hipMemGetInfo
98
+ #define cudaOccupancyMaxPotentialBlockSize hipOccupancyMaxPotentialBlockSize
99
+ #define cudaSetDevice hipSetDevice
100
+ #define cuDeviceGet hipDeviceGet
101
+ #define CUdevice hipDevice_t
102
+ #define CUdeviceptr hipDeviceptr_t
103
+ #define cuMemUnmap hipMemUnmap
104
+ #define CUmemAccessDesc hipMemAccessDesc
105
+ #define cuMemAddressFree hipMemAddressFree
106
+ #define cuMemRelease hipMemRelease
107
+ #define CUmemGenericAllocationHandle hipMemGenericAllocationHandle_t
108
+ #define cuMemCreate hipMemCreate
109
+ #define cuMemAddressReserve hipMemAddressReserve
110
+ #define cuMemMap hipMemMap
111
+ #define cuMemSetAccess hipMemSetAccess
112
+ #define cuMemGetAllocationGranularity hipMemGetAllocationGranularity
113
+ #define CUmemAllocationProp hipMemAllocationProp
114
+ #define cuDeviceGetAttribute hipDeviceGetAttribute
115
+ #define cudaStreamCreateWithFlags hipStreamCreateWithFlags
116
+ #define cudaStreamDestroy hipStreamDestroy
117
+ #define cudaStreamFireAndForget hipStreamFireAndForget
118
+ #define cudaStreamNonBlocking hipStreamNonBlocking
119
+ #define cudaStreamPerThread hipStreamPerThread
120
+ #define cudaStreamSynchronize hipStreamSynchronize
121
+ #define cudaStreamWaitEvent hipStreamWaitEvent
122
+ #define cudaGraphExec_t hipGraphExec_t
123
+ #define cudaGraphNode_t hipGraphNode_t
124
+ #define cudaKernelNodeParams hipKernelNodeParams
125
+ #define cudaKernelNodeParams hipKernelNodeParams
126
+ #define cudaGraphExecDestroy hipGraphExecDestroy
127
+ #define cudaGraphLaunch hipGraphLaunch
128
+ #define cudaErrorGraphExecUpdateFailure hipErrorGraphExecUpdateFailure
129
+ #define cudaGraphExecUpdateResult hipGraphExecUpdateResult
130
+ #define cudaGraphNodeType hipGraphNodeType
131
+ #define cudaGraphNodeTypeKernel hipGraphNodeTypeKernel
132
+ #define cudaGraphInstantiate hipGraphInstantiate
133
+ #define cudaStreamEndCapture hipStreamEndCapture
134
+ #define cudaGraphDestroy hipGraphDestroy
135
+ #define cudaGraphKernelNodeSetParams hipGraphKernelNodeSetParams
136
+ #define cudaErrorInvalidDeviceFunction hipErrorInvalidDeviceFunction
137
+ #define cudaGraphKernelNodeGetParams hipGraphKernelNodeGetParams
138
+ #define cudaGraphNodeGetType hipGraphNodeGetType
139
+ #define cudaGraphGetNodes hipGraphGetNodes
140
+ #define cudaGraphExecUpdate hipGraphExecUpdate
141
+ #define cudaStreamCaptureModeRelaxed hipStreamCaptureModeRelaxed
142
+ #define cudaStreamBeginCapture hipStreamBeginCapture
143
+ #define cudaGraph_t hipGraph_t
144
+ #define cudaStream_t hipStream_t
145
+ #define cudaSuccess hipSuccess
146
+ #define cudaOccupancyMaxActiveBlocksPerMultiprocessor hipOccupancyMaxActiveBlocksPerMultiprocessor
147
+ #define cudaFuncSetAttribute hipFuncSetAttribute
148
+ #define cudaFuncAttributeMaxDynamicSharedMemorySize hipFuncAttributeMaxDynamicSharedMemorySize
149
+ #define __trap() do { abort(); __builtin_unreachable(); } while(0)
150
+ #define CUBLAS_STATUS_SUCCESS HIPBLAS_STATUS_SUCCESS
151
+ #define CUBLAS_STATUS_NOT_INITIALIZED HIPBLAS_STATUS_NOT_INITIALIZED
152
+ #define CUBLAS_STATUS_ALLOC_FAILED HIPBLAS_STATUS_ALLOC_FAILED
153
+ #define CUBLAS_STATUS_INVALID_VALUE HIPBLAS_STATUS_INVALID_VALUE
154
+ #define CUBLAS_STATUS_ARCH_MISMATCH HIPBLAS_STATUS_ARCH_MISMATCH
155
+ #define CUBLAS_STATUS_MAPPING_ERROR HIPBLAS_STATUS_MAPPING_ERROR
156
+ #define CUBLAS_STATUS_EXECUTION_FAILED HIPBLAS_STATUS_EXECUTION_FAILED
157
+ #define CUBLAS_STATUS_INTERNAL_ERROR HIPBLAS_STATUS_INTERNAL_ERROR
158
+ #define CUBLAS_STATUS_NOT_SUPPORTED HIPBLAS_STATUS_NOT_SUPPORTED
159
+
160
+ #if HIP_VERSION >= 60500000
161
+ #define CUBLAS_COMPUTE_16F HIPBLAS_COMPUTE_16F
162
+ #define CUBLAS_COMPUTE_32F HIPBLAS_COMPUTE_32F
163
+ #define CUBLAS_COMPUTE_32F_FAST_16F HIPBLAS_COMPUTE_32F_FAST_16F
164
+ #define cublasComputeType_t hipblasComputeType_t
165
+ #define cudaDataType_t hipDataType
166
+ #else
167
+ #define CUBLAS_COMPUTE_16F HIPBLAS_R_16F
168
+ #define CUBLAS_COMPUTE_32F HIPBLAS_R_32F
169
+ #define CUBLAS_COMPUTE_32F_FAST_16F HIPBLAS_R_32F
170
+ #define cublasComputeType_t hipblasDatatype_t
171
+ #define cudaDataType_t hipblasDatatype_t
172
+ #endif // HIP_VERSION >= 6050000
173
+
174
+ #if !defined(__HIP_PLATFORM_AMD__)
175
+ #error "The HIP backend supports only AMD targets"
176
+ #endif // !defined(__HIP_PLATFORM_AMD__)
177
+
178
+ #define __CUDA_ARCH__ 1300
179
+
180
+ #if defined(__gfx900__) || defined(__gfx906__)
181
+ #define GCN5
182
+ #endif // defined(__gfx900__) || defined(__gfx906__)
183
+
184
+ #if defined(__gfx803__)
185
+ #define GCN4
186
+ #endif // defined(__gfx803__)
187
+
188
+ #if defined(GCN5) || defined(GCN4)
189
+ #define GCN
190
+ #endif // defined(GCN5) || defined(GCN4)
191
+
192
+ #if defined(__gfx950__)
193
+ #define CDNA4
194
+ #endif // defined(__gfx950__)
195
+
196
+ #if defined(__gfx942__)
197
+ #define CDNA3
198
+ #endif // defined(__gfx942__)
199
+
200
+ #if defined(__gfx90a__)
201
+ #define CDNA2
202
+ #endif // defined(__gfx90a__)
203
+
204
+ #if defined(__gfx908__)
205
+ #define CDNA1
206
+ #endif // defined(__gfx908__)
207
+
208
+ #if defined(CDNA4) || defined(CDNA3) || defined(CDNA2) || defined(CDNA1)
209
+ #define CDNA // For the entire family
210
+ #endif // defined(CDNA4) || defined(CDNA3) || defined(CDNA2) || defined(CDNA1)
211
+
212
+ #if defined(__GFX12__)
213
+ #define RDNA4
214
+ #endif // defined(__GFX12__)
215
+
216
+ #if defined(__GFX11__)
217
+ #define RDNA3
218
+ #endif // defined(__GFX11__)
219
+
220
+ #if defined(__gfx1150__) || defined(__gfx1151__)
221
+ #define RDNA3_5
222
+ #endif // defined(__gfx1150__) || defined(__gfx1151__)
223
+
224
+ #if defined(RDNA3) && !defined(RDNA3_5)
225
+ #define RDNA3_0
226
+ #endif // defined(RDNA3) && !defined(RDNA3_5)
227
+
228
+ #if defined(__gfx1030__) || defined(__gfx1031__) || defined(__gfx1032__) || defined(__gfx1033__) || \
229
+ defined(__gfx1034__) || defined(__gfx1035__) || defined(__gfx1036__) || defined(__gfx1037__)
230
+ #define RDNA2
231
+ #endif
232
+
233
+ #if defined(__gfx1010__) || defined(__gfx1012__)
234
+ #define RDNA1
235
+ #endif // defined(__gfx1010__) || defined(__gfx1012__)
236
+
237
+ #if defined(RDNA4) || defined(RDNA3) || defined(RDNA2) || defined(RDNA1)
238
+ #define RDNA // For the entire family
239
+ #endif // defined(RDNA4) || defined(RDNA3) || defined(RDNA2) || defined(RDNA1)
240
+
241
+ #ifndef __has_builtin
242
+ #define __has_builtin(x) 0
243
+ #endif
244
+
245
+ typedef __hip_bfloat16 nv_bfloat16;
246
+ typedef __hip_bfloat162 nv_bfloat162;
247
+
248
+ #if HIP_VERSION >= 60200000
249
+ #include <hip/hip_fp8.h>
250
+ #ifdef _WIN32
251
+ typedef __hip_fp8_e4m3_fnuz __nv_fp8_e4m3; // Windows ROCm hip_fp8.h missing e4m3
252
+ #else
253
+ typedef __hip_fp8_e4m3 __nv_fp8_e4m3;
254
+ #endif
255
+ #define FP8_AVAILABLE
256
+ #endif // HIP_VERSION >= 60200000
257
+
258
+ typedef int8_t int8x4_t __attribute__((ext_vector_type(4)));
259
+ typedef uint8_t uint8x4_t __attribute__((ext_vector_type(4)));
260
+ static __device__ __forceinline__ int __vsubss4(const int a, const int b) {
261
+ const int8x4_t va = reinterpret_cast<const int8x4_t&>(a);
262
+ const int8x4_t vb = reinterpret_cast<const int8x4_t&>(b);
263
+ #if __has_builtin(__builtin_elementwise_sub_sat)
264
+ const int8x4_t c = __builtin_elementwise_sub_sat(va, vb);
265
+ return reinterpret_cast<const int &>(c);
266
+ #else
267
+ int8x4_t c;
268
+ int16_t tmp;
269
+ #pragma unroll
270
+ for (int i = 0; i < 4; i++) {
271
+ tmp = va[i] - vb[i];
272
+ if(tmp > std::numeric_limits<int8_t>::max()) tmp = std::numeric_limits<int8_t>::max();
273
+ if(tmp < std::numeric_limits<int8_t>::min()) tmp = std::numeric_limits<int8_t>::min();
274
+ c[i] = tmp;
275
+ }
276
+ return reinterpret_cast<int &>(c);
277
+ #endif // __has_builtin(__builtin_elementwise_sub_sat)
278
+ }
279
+
280
+ static __device__ __forceinline__ int __vsub4(const int a, const int b) {
281
+ return __vsubss4(a, b);
282
+ }
283
+
284
+ static __device__ __forceinline__ unsigned int __vcmpeq4(unsigned int a, unsigned int b) {
285
+ const uint8x4_t& va = reinterpret_cast<const uint8x4_t&>(a);
286
+ const uint8x4_t& vb = reinterpret_cast<const uint8x4_t&>(b);
287
+ unsigned int c;
288
+ uint8x4_t& vc = reinterpret_cast<uint8x4_t&>(c);
289
+ #pragma unroll
290
+ for (int i = 0; i < 4; ++i) {
291
+ vc[i] = va[i] == vb[i] ? 0xff : 0x00;
292
+ }
293
+ return c;
294
+ }
295
+
296
+ static __device__ __forceinline__ unsigned int __vcmpne4(unsigned int a, unsigned int b) {
297
+ const uint8x4_t& va = reinterpret_cast<const uint8x4_t&>(a);
298
+ const uint8x4_t& vb = reinterpret_cast<const uint8x4_t&>(b);
299
+ unsigned int c;
300
+ uint8x4_t& vc = reinterpret_cast<uint8x4_t&>(c);
301
+ #pragma unroll
302
+ for (int i = 0; i < 4; ++i) {
303
+ vc[i] = va[i] == vb[i] ? 0x00 : 0xff;
304
+ }
305
+ return c;
306
+ }
@@ -0,0 +1,148 @@
1
+ #pragma once
2
+
3
+ #include <musa_runtime.h>
4
+ #include <musa.h>
5
+ #include <mublas.h>
6
+ #include <musa_bf16.h>
7
+ #include <musa_fp16.h>
8
+ #define CUBLAS_COMPUTE_16F CUDA_R_16F
9
+ #define CUBLAS_COMPUTE_32F CUDA_R_32F
10
+ #define CUBLAS_COMPUTE_32F_FAST_16F MUBLAS_COMPUTE_32F_FAST_16F
11
+ #define CUBLAS_GEMM_DEFAULT MUBLAS_GEMM_DEFAULT
12
+ #define CUBLAS_GEMM_DEFAULT_TENSOR_OP MUBLAS_GEMM_DEFAULT
13
+ #define CUBLAS_OP_N MUBLAS_OP_N
14
+ #define CUBLAS_OP_T MUBLAS_OP_T
15
+ #define CUBLAS_DEFAULT_MATH MUBLAS_DEFAULT_MATH
16
+ #define CUBLAS_SIDE_RIGHT MUBLAS_SIDE_RIGHT
17
+ #define CUBLAS_FILL_MODE_UPPER MUBLAS_FILL_MODE_UPPER
18
+ #define CUBLAS_DIAG_NON_UNIT MUBLAS_DIAG_NON_UNIT
19
+ #define CUBLAS_STATUS_SUCCESS MUBLAS_STATUS_SUCCESS
20
+ #define CUBLAS_TF32_TENSOR_OP_MATH MUBLAS_TENSOR_OP_MATH
21
+ #define CUDA_R_16F MUSA_R_16F
22
+ #define CUDA_R_16BF MUSA_R_16BF
23
+ #define CUDA_R_32F MUSA_R_32F
24
+ #define cublasStrsmBatched mublasStrsmBatched
25
+ #define cublasComputeType_t cudaDataType_t
26
+ #define cublasCreate mublasCreate
27
+ #define cublasDestroy mublasDestroy
28
+ #define cublasGemmEx mublasGemmEx
29
+ #define cublasGemmBatchedEx mublasGemmBatchedEx
30
+ #define cublasGemmStridedBatchedEx mublasGemmStridedBatchedEx
31
+ #define cublasHandle_t mublasHandle_t
32
+ #define cublasSetMathMode mublasSetMathMode
33
+ #define cublasSetStream mublasSetStream
34
+ #define cublasSgemm mublasSgemm
35
+ #define cublasStatus_t mublasStatus_t
36
+ #define cublasOperation_t mublasOperation_t
37
+ #define cublasGetStatusString mublasGetStatusString
38
+ #define cudaDataType_t musaDataType_t
39
+ #define cudaDeviceCanAccessPeer musaDeviceCanAccessPeer
40
+ #define cudaDeviceDisablePeerAccess musaDeviceDisablePeerAccess
41
+ #define cudaDeviceEnablePeerAccess musaDeviceEnablePeerAccess
42
+ #define cudaDeviceProp musaDeviceProp
43
+ #define cudaDeviceSynchronize musaDeviceSynchronize
44
+ #define cudaError_t musaError_t
45
+ #define cudaErrorMemoryAllocation musaErrorMemoryAllocation
46
+ #define cudaErrorPeerAccessAlreadyEnabled musaErrorPeerAccessAlreadyEnabled
47
+ #define cudaErrorPeerAccessNotEnabled musaErrorPeerAccessNotEnabled
48
+ #define cudaEventCreateWithFlags musaEventCreateWithFlags
49
+ #define cudaEventDisableTiming musaEventDisableTiming
50
+ #define cudaEventRecord musaEventRecord
51
+ #define cudaEventSynchronize musaEventSynchronize
52
+ #define cudaEvent_t musaEvent_t
53
+ #define cudaEventDestroy musaEventDestroy
54
+ #define cudaFree musaFree
55
+ #define cudaFreeHost musaFreeHost
56
+ #define cudaGetDevice musaGetDevice
57
+ #define cudaGetDeviceCount musaGetDeviceCount
58
+ #define cudaGetDeviceProperties musaGetDeviceProperties
59
+ #define cudaGetErrorString musaGetErrorString
60
+ #define cudaGetLastError musaGetLastError
61
+ #define cudaHostRegister musaHostRegister
62
+ #define cudaHostRegisterPortable musaHostRegisterPortable
63
+ #define cudaHostRegisterReadOnly musaHostRegisterReadOnly
64
+ #define cudaHostUnregister musaHostUnregister
65
+ #define cudaLaunchCooperativeKernel musaLaunchCooperativeKernel
66
+ #define cudaLaunchHostFunc musaLaunchHostFunc
67
+ #define cudaMalloc musaMalloc
68
+ #define cudaMallocHost musaMallocHost
69
+ #define cudaMallocManaged musaMallocManaged
70
+ #define cudaMemcpy musaMemcpy
71
+ #define cudaMemcpyAsync musaMemcpyAsync
72
+ #define cudaMemcpyPeerAsync musaMemcpyPeerAsync
73
+ #define cudaMemcpy2DAsync musaMemcpy2DAsync
74
+ #define cudaMemcpyDeviceToDevice musaMemcpyDeviceToDevice
75
+ #define cudaMemcpyDeviceToHost musaMemcpyDeviceToHost
76
+ #define cudaMemcpyHostToDevice musaMemcpyHostToDevice
77
+ #define cudaMemcpyKind musaMemcpyKind
78
+ #define cudaMemset musaMemset
79
+ #define cudaMemsetAsync musaMemsetAsync
80
+ #define cudaMemGetInfo musaMemGetInfo
81
+ #define cudaOccupancyMaxPotentialBlockSize musaOccupancyMaxPotentialBlockSize
82
+ #define cudaSetDevice musaSetDevice
83
+ #define cudaStreamCreateWithFlags musaStreamCreateWithFlags
84
+ #define cudaStreamDestroy musaStreamDestroy
85
+ #define cudaStreamFireAndForget musaStreamFireAndForget
86
+ #define cudaStreamNonBlocking musaStreamNonBlocking
87
+ #define cudaStreamPerThread musaStreamPerThread
88
+ #define cudaStreamSynchronize musaStreamSynchronize
89
+ #define cudaStreamWaitEvent musaStreamWaitEvent
90
+ #define cudaStream_t musaStream_t
91
+ #define cudaSuccess musaSuccess
92
+
93
+ // Additional mappings for MUSA virtual memory pool
94
+ #define CU_DEVICE_ATTRIBUTE_VIRTUAL_MEMORY_MANAGEMENT_SUPPORTED MU_DEVICE_ATTRIBUTE_VIRTUAL_ADDRESS_MANAGEMENT_SUPPORTED
95
+ #define CU_MEM_ACCESS_FLAGS_PROT_READWRITE MU_MEM_ACCESS_FLAGS_PROT_READWRITE
96
+ #define CU_MEM_ALLOC_GRANULARITY_RECOMMENDED MU_MEM_ALLOC_GRANULARITY_RECOMMENDED
97
+ #define CU_MEM_ALLOCATION_TYPE_PINNED MU_MEM_ALLOCATION_TYPE_PINNED
98
+ #define CU_MEM_LOCATION_TYPE_DEVICE MU_MEM_LOCATION_TYPE_DEVICE
99
+ #define CUdevice MUdevice
100
+ #define CUdeviceptr MUdeviceptr
101
+ #define CUmemAccessDesc MUmemAccessDesc
102
+ #define CUmemAllocationProp MUmemAllocationProp
103
+ #define CUmemGenericAllocationHandle MUmemGenericAllocationHandle
104
+ #define cuDeviceGet muDeviceGet
105
+ #define cuDeviceGetAttribute muDeviceGetAttribute
106
+ #define cuMemAddressFree muMemAddressFree
107
+ #define cuMemAddressReserve muMemAddressReserve
108
+ #define cuMemCreate muMemCreate
109
+ #define cuMemGetAllocationGranularity muMemGetAllocationGranularity
110
+ #define cuMemMap muMemMap
111
+ #define cuMemRelease muMemRelease
112
+ #define cuMemSetAccess muMemSetAccess
113
+ #define cuMemUnmap muMemUnmap
114
+ #define cudaFuncAttributeMaxDynamicSharedMemorySize musaFuncAttributeMaxDynamicSharedMemorySize
115
+ #define cudaFuncSetAttribute musaFuncSetAttribute
116
+ #define cudaMemcpy3DPeerParms musaMemcpy3DPeerParms
117
+ #define make_cudaExtent make_musaExtent
118
+ #define make_cudaPitchedPtr make_musaPitchedPtr
119
+
120
+ // Additional mappings for MUSA graphs
121
+ #define CUDA_SUCCESS MUSA_SUCCESS
122
+ #define CUresult MUresult
123
+ #define cuGetErrorString muGetErrorString
124
+ #define cudaErrorGraphExecUpdateFailure musaErrorGraphExecUpdateFailure
125
+ #define cudaErrorInvalidDeviceFunction musaErrorInvalidDeviceFunction
126
+ #define cudaGraphDestroy musaGraphDestroy
127
+ #define cudaGraphExecDestroy musaGraphExecDestroy
128
+ #define cudaGraphExec_t musaGraphExec_t
129
+ #define cudaGraphExecUpdate musaGraphExecUpdate
130
+ #define cudaGraphExecUpdateResult musaGraphExecUpdateResult
131
+ #define cudaGraphGetNodes musaGraphGetNodes
132
+ #define cudaGraphInstantiate musaGraphInstantiate
133
+ #define cudaGraphKernelNodeGetParams musaGraphKernelNodeGetParams
134
+ #define cudaGraphKernelNodeSetParams musaGraphKernelNodeSetParams
135
+ #define cudaGraphLaunch musaGraphLaunch
136
+ #define cudaGraphNodeGetType musaGraphNodeGetType
137
+ #define cudaGraphNode_t musaGraphNode_t
138
+ #define cudaGraphNodeType musaGraphNodeType
139
+ #define cudaGraphNodeTypeKernel musaGraphNodeTypeKernel
140
+ #define cudaGraph_t musaGraph_t
141
+ #define cudaKernelNodeParams musaKernelNodeParams
142
+ #define cudaStreamCaptureModeRelaxed musaStreamCaptureModeRelaxed
143
+ #define cudaStreamBeginCapture musaStreamBeginCapture
144
+ #define cudaStreamEndCapture musaStreamEndCapture
145
+ #define cudaOccupancyMaxActiveBlocksPerMultiprocessor musaOccupancyMaxActiveBlocksPerMultiprocessor
146
+
147
+ typedef __mt_bfloat16 nv_bfloat16;
148
+ typedef __mt_bfloat162 nv_bfloat162;
@@ -0,0 +1,199 @@
1
+ #include "common.cuh"
2
+ #include "wkv.cuh"
3
+
4
+ template <int block_size>
5
+ static __global__ void rwkv_wkv_f32(const int B, const int T, const int C, const int H, const float * k, const float * v, const float * r, const float * tf, const float * td, const float * s, float * dst) {
6
+ const int tid = threadIdx.x;
7
+ const int bid = blockIdx.x;
8
+
9
+ const int head_size = block_size;
10
+ const int batch_i = bid / H;
11
+ const int head_i = bid % H;
12
+ const int state_size = C * head_size;
13
+ const int n_seq_tokens = T / B;
14
+
15
+ float state[head_size];
16
+ __shared__ float _k[head_size], _r[head_size], _tf[head_size], _td[head_size];
17
+
18
+ #pragma unroll
19
+ for (int i = 0; i < head_size; i++) {
20
+ state[i] = s[batch_i * state_size + head_i * head_size * head_size + i * head_size + tid];
21
+ }
22
+
23
+ __syncthreads();
24
+ _tf[tid] = tf[head_i * head_size + tid];
25
+ __syncthreads();
26
+
27
+ for (int t = batch_i * n_seq_tokens * C + head_i * head_size + tid; t < (batch_i + 1) * n_seq_tokens * C + head_i * head_size + tid; t += C) {
28
+ __syncthreads();
29
+ _k[tid] = k[t];
30
+ _r[tid] = r[t];
31
+ _td[tid] = td[t];
32
+ __syncthreads();
33
+
34
+ const float _v = v[t];
35
+ float y = 0;
36
+ for (int j = 0; j < head_size; j += 4) {
37
+ const float4& k = (float4&)(_k[j]);
38
+ const float4& r = (float4&)(_r[j]);
39
+ const float4& tf = (float4&)(_tf[j]);
40
+ const float4& td = (float4&)(_td[j]);
41
+ float4& s = (float4&)(state[j]);
42
+ float4 kv;
43
+
44
+ kv.x = k.x * _v;
45
+ kv.y = k.y * _v;
46
+ kv.z = k.z * _v;
47
+ kv.w = k.w * _v;
48
+
49
+ y += r.x * (tf.x * kv.x + s.x);
50
+ y += r.y * (tf.y * kv.y + s.y);
51
+ y += r.z * (tf.z * kv.z + s.z);
52
+ y += r.w * (tf.w * kv.w + s.w);
53
+
54
+ s.x = s.x * td.x + kv.x;
55
+ s.y = s.y * td.y + kv.y;
56
+ s.z = s.z * td.z + kv.z;
57
+ s.w = s.w * td.w + kv.w;
58
+ }
59
+ dst[t] = y;
60
+ }
61
+
62
+ #pragma unroll
63
+ for (int i = 0; i < head_size; i++) {
64
+ dst[T * C + batch_i * state_size + head_i * head_size * head_size + i * head_size + tid] = state[i];
65
+ }
66
+ }
67
+
68
+ template <int block_size>
69
+ static __global__ void rwkv_wkv7_f32(const int B, const int T, const int C, const int H, const float * r, const float * w, const float * k, const float * v, const float * a, const float * b, const float * s, float * dst) {
70
+ const int tid = threadIdx.x;
71
+ const int bid = blockIdx.x;
72
+
73
+ const int head_size = block_size;
74
+ const int batch_i = bid / H;
75
+ const int head_i = bid % H;
76
+ const int state_size = C * head_size;
77
+ const int n_seq_tokens = T / B;
78
+
79
+ float state[head_size];
80
+ __shared__ float _r[head_size], _w[head_size], _k[head_size], _a[head_size], _b[head_size];
81
+
82
+ #ifndef GGML_USE_MUSA
83
+ #pragma unroll
84
+ #endif
85
+ for (int i = 0; i < head_size; i++) {
86
+ state[i] = s[batch_i * state_size + head_i * head_size * head_size + tid * head_size + i];
87
+ }
88
+
89
+ for (int t = batch_i * n_seq_tokens * C + head_i * head_size + tid; t < (batch_i + 1) * n_seq_tokens * C + head_i * head_size + tid; t += C) {
90
+ __syncthreads();
91
+ _r[tid] = r[t];
92
+ _w[tid] = w[t];
93
+ _k[tid] = k[t];
94
+ _a[tid] = a[t];
95
+ _b[tid] = b[t];
96
+ __syncthreads();
97
+
98
+ float sa = 0;
99
+ #pragma unroll
100
+ for (int j = 0; j < head_size; j += 4)
101
+ {
102
+ const float4& a = (float4&)(_a[j]);
103
+ const float4& s = (float4&)(state[j]);
104
+ sa += a.x * s.x;
105
+ sa += a.y * s.y;
106
+ sa += a.z * s.z;
107
+ sa += a.w * s.w;
108
+ }
109
+
110
+ const float _v = v[t];
111
+ float y = 0;
112
+ for (int j = 0; j < head_size; j += 4) {
113
+ const float4& r = (float4&)(_r[j]);
114
+ const float4& w = (float4&)(_w[j]);
115
+ const float4& k = (float4&)(_k[j]);
116
+ const float4& b = (float4&)(_b[j]);
117
+ float4& s = (float4&)(state[j]);
118
+ float4 kv;
119
+
120
+ kv.x = k.x * _v;
121
+ kv.y = k.y * _v;
122
+ kv.z = k.z * _v;
123
+ kv.w = k.w * _v;
124
+
125
+ s.x = s.x * w.x + kv.x + sa * b.x;
126
+ s.y = s.y * w.y + kv.y + sa * b.y;
127
+ s.z = s.z * w.z + kv.z + sa * b.z;
128
+ s.w = s.w * w.w + kv.w + sa * b.w;
129
+
130
+ y += s.x * r.x;
131
+ y += s.y * r.y;
132
+ y += s.z * r.z;
133
+ y += s.w * r.w;
134
+ }
135
+ dst[t] = y;
136
+ }
137
+
138
+ #pragma unroll
139
+ for (int i = 0; i < head_size; i++) {
140
+ dst[T * C + batch_i * state_size + head_i * head_size * head_size + tid * head_size + i] = state[i];
141
+ }
142
+ }
143
+
144
+ void ggml_cuda_op_rwkv_wkv6(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
145
+ const float * k_d = (const float *)dst->src[0]->data;
146
+ const float * v_d = (const float *)dst->src[1]->data;
147
+ const float * r_d = (const float *)dst->src[2]->data;
148
+ const float * tf_d = (const float *)dst->src[3]->data;
149
+ const float * td_d = (const float *)dst->src[4]->data;
150
+ const float * s_d = (const float *)dst->src[5]->data;
151
+
152
+ const int64_t B = dst->src[5]->ne[1];
153
+ const int64_t T = dst->src[0]->ne[2];
154
+ const int64_t C = dst->ne[0];
155
+ const int64_t H = dst->src[0]->ne[1];
156
+
157
+ float * dst_d = (float *)dst->data;
158
+
159
+ cudaStream_t stream = ctx.stream();
160
+
161
+ GGML_ASSERT(dst->src[5]->type == GGML_TYPE_F32);
162
+ GGML_ASSERT(C % H == 0);
163
+ GGML_ASSERT(C / H == CUDA_WKV_BLOCK_SIZE || C / H == CUDA_WKV_BLOCK_SIZE * 2);
164
+
165
+ if (C / H == CUDA_WKV_BLOCK_SIZE) {
166
+ rwkv_wkv_f32<CUDA_WKV_BLOCK_SIZE><<<B * H, C / H, 0, stream>>>(B, T, C, H, k_d, v_d, r_d, tf_d, td_d, s_d, dst_d);
167
+ } else {
168
+ rwkv_wkv_f32<CUDA_WKV_BLOCK_SIZE * 2><<<B * H, C / H, 0, stream>>>(B, T, C, H, k_d, v_d, r_d, tf_d, td_d, s_d, dst_d);
169
+ }
170
+ }
171
+
172
+ void ggml_cuda_op_rwkv_wkv7(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
173
+ const float * r_d = (const float *)dst->src[0]->data;
174
+ const float * w_d = (const float *)dst->src[1]->data;
175
+ const float * k_d = (const float *)dst->src[2]->data;
176
+ const float * v_d = (const float *)dst->src[3]->data;
177
+ const float * a_d = (const float *)dst->src[4]->data;
178
+ const float * b_d = (const float *)dst->src[5]->data;
179
+ const float * s_d = (const float *)dst->src[6]->data;
180
+
181
+ const int64_t B = dst->src[6]->ne[1];
182
+ const int64_t T = dst->src[0]->ne[2];
183
+ const int64_t C = dst->ne[0];
184
+ const int64_t H = dst->src[0]->ne[1];
185
+
186
+ float * dst_d = (float *)dst->data;
187
+
188
+ cudaStream_t stream = ctx.stream();
189
+
190
+ GGML_ASSERT(dst->src[6]->type == GGML_TYPE_F32);
191
+ GGML_ASSERT(C % H == 0);
192
+ GGML_ASSERT(C / H == CUDA_WKV_BLOCK_SIZE || C / H == CUDA_WKV_BLOCK_SIZE * 2);
193
+
194
+ if (C / H == CUDA_WKV_BLOCK_SIZE) {
195
+ rwkv_wkv7_f32<CUDA_WKV_BLOCK_SIZE><<<B * H, C / H, 0, stream>>>(B, T, C, H, r_d, w_d, k_d, v_d, a_d, b_d, s_d, dst_d);
196
+ } else {
197
+ rwkv_wkv7_f32<CUDA_WKV_BLOCK_SIZE * 2><<<B * H, C / H, 0, stream>>>(B, T, C, H, r_d, w_d, k_d, v_d, a_d, b_d, s_d, dst_d);
198
+ }
199
+ }
@@ -0,0 +1,7 @@
1
+ #include "common.cuh"
2
+
3
+ #define CUDA_WKV_BLOCK_SIZE 64
4
+
5
+ void ggml_cuda_op_rwkv_wkv6(ggml_backend_cuda_context & ctx, ggml_tensor * dst);
6
+
7
+ void ggml_cuda_op_rwkv_wkv7(ggml_backend_cuda_context & ctx, ggml_tensor * dst);