whispercpp 1.3.2 → 1.3.3

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 (244) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -3
  3. data/README.md +71 -14
  4. data/Rakefile +20 -7
  5. data/ext/.gitignore +4 -6
  6. data/ext/dependencies.rb +36 -24
  7. data/ext/extconf.rb +1 -1
  8. data/ext/options.rb +48 -184
  9. data/ext/ruby_whisper.c +18 -0
  10. data/ext/ruby_whisper_context.c +43 -12
  11. data/ext/ruby_whisper_model.c +1 -1
  12. data/ext/ruby_whisper_params.c +4 -2
  13. data/ext/ruby_whisper_segment.c +81 -4
  14. data/ext/ruby_whisper_transcribe.cpp +13 -7
  15. data/ext/ruby_whisper_vad_params.c +1 -1
  16. data/ext/sources/CMakeLists.txt +5 -1
  17. data/ext/sources/bindings/javascript/package.json +1 -1
  18. data/ext/sources/examples/addon.node/__test__/whisper.spec.js +120 -24
  19. data/ext/sources/examples/addon.node/addon.cpp +150 -31
  20. data/ext/sources/examples/addon.node/index.js +3 -0
  21. data/ext/sources/examples/addon.node/vad-example.js +132 -0
  22. data/ext/sources/examples/bench/bench.cpp +3 -2
  23. data/ext/sources/examples/cli/cli.cpp +3 -2
  24. data/ext/sources/examples/command/command.cpp +32 -8
  25. data/ext/sources/examples/common-whisper.cpp +14 -7
  26. data/ext/sources/examples/lsp/lsp.cpp +2 -0
  27. data/ext/sources/examples/quantize/quantize.cpp +3 -0
  28. data/ext/sources/examples/server/CMakeLists.txt +3 -0
  29. data/ext/sources/examples/server/server.cpp +169 -22
  30. data/ext/sources/examples/stream/stream.cpp +6 -0
  31. data/ext/sources/examples/talk-llama/CMakeLists.txt +4 -1
  32. data/ext/sources/examples/talk-llama/llama-arch.cpp +171 -3
  33. data/ext/sources/examples/talk-llama/llama-arch.h +28 -1
  34. data/ext/sources/examples/talk-llama/llama-batch.cpp +741 -272
  35. data/ext/sources/examples/talk-llama/llama-batch.h +112 -54
  36. data/ext/sources/examples/talk-llama/llama-chat.cpp +30 -8
  37. data/ext/sources/examples/talk-llama/llama-chat.h +1 -0
  38. data/ext/sources/examples/talk-llama/llama-context.cpp +520 -351
  39. data/ext/sources/examples/talk-llama/llama-context.h +38 -17
  40. data/ext/sources/examples/talk-llama/llama-cparams.cpp +1 -1
  41. data/ext/sources/examples/talk-llama/llama-cparams.h +1 -1
  42. data/ext/sources/examples/talk-llama/llama-graph.cpp +447 -372
  43. data/ext/sources/examples/talk-llama/llama-graph.h +128 -58
  44. data/ext/sources/examples/talk-llama/llama-hparams.cpp +10 -2
  45. data/ext/sources/examples/talk-llama/llama-hparams.h +19 -2
  46. data/ext/sources/examples/talk-llama/llama-kv-cache-unified-iswa.cpp +279 -0
  47. data/ext/sources/examples/talk-llama/llama-kv-cache-unified-iswa.h +128 -0
  48. data/ext/sources/examples/talk-llama/llama-kv-cache-unified.cpp +1841 -0
  49. data/ext/sources/examples/talk-llama/llama-kv-cache-unified.h +303 -0
  50. data/ext/sources/examples/talk-llama/llama-kv-cache.h +14 -472
  51. data/ext/sources/examples/talk-llama/llama-kv-cells.h +86 -26
  52. data/ext/sources/examples/talk-llama/llama-memory-hybrid.cpp +246 -0
  53. data/ext/sources/examples/talk-llama/llama-memory-hybrid.h +138 -0
  54. data/ext/sources/examples/talk-llama/llama-memory-recurrent.cpp +1125 -0
  55. data/ext/sources/examples/talk-llama/llama-memory-recurrent.h +183 -0
  56. data/ext/sources/examples/talk-llama/llama-memory.cpp +58 -0
  57. data/ext/sources/examples/talk-llama/llama-memory.h +88 -4
  58. data/ext/sources/examples/talk-llama/llama-mmap.cpp +1 -1
  59. data/ext/sources/examples/talk-llama/llama-model-loader.cpp +42 -17
  60. data/ext/sources/examples/talk-llama/llama-model-saver.cpp +1 -0
  61. data/ext/sources/examples/talk-llama/llama-model.cpp +1863 -563
  62. data/ext/sources/examples/talk-llama/llama-model.h +27 -0
  63. data/ext/sources/examples/talk-llama/llama-quant.cpp +89 -6
  64. data/ext/sources/examples/talk-llama/llama-vocab.cpp +65 -28
  65. data/ext/sources/examples/talk-llama/llama-vocab.h +1 -0
  66. data/ext/sources/examples/talk-llama/llama.cpp +11 -7
  67. data/ext/sources/examples/talk-llama/llama.h +147 -40
  68. data/ext/sources/examples/talk-llama/talk-llama.cpp +2 -0
  69. data/ext/sources/examples/talk-llama/unicode.cpp +5 -0
  70. data/ext/sources/examples/vad-speech-segments/speech.cpp +6 -0
  71. data/ext/sources/examples/wchess/wchess.cmd/wchess.cmd.cpp +2 -0
  72. data/ext/sources/ggml/CMakeLists.txt +48 -3
  73. data/ext/sources/ggml/cmake/common.cmake +24 -0
  74. data/ext/sources/ggml/include/ggml-backend.h +1 -1
  75. data/ext/sources/ggml/include/ggml-cpu.h +2 -0
  76. data/ext/sources/ggml/include/ggml.h +144 -5
  77. data/ext/sources/ggml/src/CMakeLists.txt +82 -24
  78. data/ext/sources/ggml/src/ggml-backend-reg.cpp +5 -0
  79. data/ext/sources/ggml/src/ggml-backend.cpp +46 -23
  80. data/ext/sources/ggml/src/ggml-blas/CMakeLists.txt +3 -3
  81. data/ext/sources/ggml/src/ggml-cann/CMakeLists.txt +1 -0
  82. data/ext/sources/ggml/src/ggml-cann/common.h +6 -1
  83. data/ext/sources/ggml/src/ggml-cann/ggml-cann.cpp +33 -9
  84. data/ext/sources/ggml/src/ggml-common.h +4 -0
  85. data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +133 -40
  86. data/ext/sources/ggml/src/ggml-cpu/amx/amx.cpp +1 -1
  87. data/ext/sources/ggml/src/ggml-cpu/amx/mmq.cpp +11 -10
  88. data/ext/sources/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
  89. data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +4114 -0
  90. data/ext/sources/ggml/src/ggml-cpu/arch/arm/repack.cpp +2163 -0
  91. data/ext/sources/ggml/src/ggml-cpu/arch/loongarch/quants.c +2639 -0
  92. data/ext/sources/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
  93. data/ext/sources/ggml/src/ggml-cpu/arch/powerpc/quants.c +2732 -0
  94. data/ext/sources/ggml/src/ggml-cpu/arch/riscv/quants.c +2069 -0
  95. data/ext/sources/ggml/src/ggml-cpu/arch/riscv/repack.cpp +397 -0
  96. data/ext/sources/ggml/src/ggml-cpu/arch/s390/quants.c +1300 -0
  97. data/ext/sources/ggml/src/ggml-cpu/arch/wasm/quants.c +1481 -0
  98. data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +4311 -0
  99. data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-aarch64.cpp → arch/x86/repack.cpp} +79 -3225
  100. data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +184 -0
  101. data/ext/sources/ggml/src/ggml-cpu/common.h +4 -3
  102. data/ext/sources/ggml/src/ggml-cpu/ggml-cpu-impl.h +16 -7
  103. data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +146 -105
  104. data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.cpp +12 -8
  105. data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-hbm.cpp → hbm.cpp} +1 -1
  106. data/ext/sources/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1 -1
  107. data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +58 -8
  108. data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.h +5 -0
  109. data/ext/sources/ggml/src/ggml-cpu/ops.cpp +1057 -174
  110. data/ext/sources/ggml/src/ggml-cpu/ops.h +8 -0
  111. data/ext/sources/ggml/src/ggml-cpu/quants.c +1158 -0
  112. data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-quants.h → quants.h} +26 -0
  113. data/ext/sources/ggml/src/ggml-cpu/repack.cpp +1571 -0
  114. data/ext/sources/ggml/src/ggml-cpu/repack.h +98 -0
  115. data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +330 -38
  116. data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-traits.cpp → traits.cpp} +1 -1
  117. data/ext/sources/ggml/src/ggml-cpu/vec.cpp +111 -18
  118. data/ext/sources/ggml/src/ggml-cpu/vec.h +303 -94
  119. data/ext/sources/ggml/src/ggml-cuda/common.cuh +60 -37
  120. data/ext/sources/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
  121. data/ext/sources/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
  122. data/ext/sources/ggml/src/ggml-cuda/conv2d-transpose.cu +91 -0
  123. data/ext/sources/ggml/src/ggml-cuda/conv2d-transpose.cuh +4 -0
  124. data/ext/sources/ggml/src/ggml-cuda/convert.cu +22 -0
  125. data/ext/sources/ggml/src/ggml-cuda/convert.cuh +5 -0
  126. data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +2 -2
  127. data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +5 -2
  128. data/ext/sources/ggml/src/ggml-cuda/fattn-wmma-f16.cu +4 -0
  129. data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +265 -123
  130. data/ext/sources/ggml/src/ggml-cuda/mean.cu +19 -0
  131. data/ext/sources/ggml/src/ggml-cuda/mean.cuh +3 -0
  132. data/ext/sources/ggml/src/ggml-cuda/mmv.cu +257 -87
  133. data/ext/sources/ggml/src/ggml-cuda/mmv.cuh +2 -3
  134. data/ext/sources/ggml/src/ggml-cuda/ssm-scan.cu +6 -4
  135. data/ext/sources/ggml/src/ggml-cuda/sumrows.cu +5 -18
  136. data/ext/sources/ggml/src/ggml-cuda/sumrows.cuh +0 -1
  137. data/ext/sources/ggml/src/ggml-cuda/unary.cu +89 -0
  138. data/ext/sources/ggml/src/ggml-cuda/unary.cuh +7 -0
  139. data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +4 -0
  140. data/ext/sources/ggml/src/ggml-impl.h +127 -183
  141. data/ext/sources/ggml/src/ggml-metal/CMakeLists.txt +11 -10
  142. data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +27 -0
  143. data/ext/sources/ggml/src/ggml-metal/ggml-metal.m +331 -49
  144. data/ext/sources/ggml/src/ggml-metal/ggml-metal.metal +564 -282
  145. data/ext/sources/ggml/src/ggml-musa/mudnn.cuh +2 -2
  146. data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +14 -0
  147. data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +1859 -489
  148. data/ext/sources/ggml/src/ggml-opencl/kernels/argsort.cl +86 -0
  149. data/ext/sources/ggml/src/ggml-opencl/kernels/concat.cl +109 -0
  150. data/ext/sources/ggml/src/ggml-opencl/kernels/div.cl +72 -0
  151. data/ext/sources/ggml/src/ggml-opencl/kernels/glu.cl +201 -0
  152. data/ext/sources/ggml/src/ggml-opencl/kernels/group_norm.cl +72 -0
  153. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_id_q4_0_f32_8x_flat.cl +283 -0
  154. data/ext/sources/ggml/src/ggml-opencl/kernels/pad.cl +30 -0
  155. data/ext/sources/ggml/src/ggml-opencl/kernels/repeat.cl +39 -0
  156. data/ext/sources/ggml/src/ggml-opencl/kernels/sigmoid.cl +29 -0
  157. data/ext/sources/ggml/src/ggml-opencl/kernels/sub.cl +72 -0
  158. data/ext/sources/ggml/src/ggml-opencl/kernels/sum_rows.cl +39 -0
  159. data/ext/sources/ggml/src/ggml-opencl/kernels/tanh.cl +63 -0
  160. data/ext/sources/ggml/src/ggml-opencl/kernels/tsembd.cl +48 -0
  161. data/ext/sources/ggml/src/ggml-opencl/kernels/upscale.cl +121 -0
  162. data/ext/sources/ggml/src/ggml-quants.c +6 -8
  163. data/ext/sources/ggml/src/ggml-rpc/ggml-rpc.cpp +18 -15
  164. data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +3 -3
  165. data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +5 -6
  166. data/ext/sources/ggml/src/ggml-sycl/common.hpp +20 -48
  167. data/ext/sources/ggml/src/ggml-sycl/concat.cpp +28 -41
  168. data/ext/sources/ggml/src/ggml-sycl/conv.cpp +4 -10
  169. data/ext/sources/ggml/src/ggml-sycl/convert.cpp +117 -165
  170. data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +192 -53
  171. data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +32 -0
  172. data/ext/sources/ggml/src/ggml-sycl/dmmv.cpp +49 -67
  173. data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +31 -1
  174. data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +648 -1039
  175. data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +18 -9
  176. data/ext/sources/ggml/src/ggml-sycl/gemm.hpp +3 -0
  177. data/ext/sources/ggml/src/ggml-sycl/getrows.cpp +8 -105
  178. data/ext/sources/ggml/src/ggml-sycl/ggml-sycl.cpp +238 -100
  179. data/ext/sources/ggml/src/ggml-sycl/gla.cpp +2 -2
  180. data/ext/sources/ggml/src/ggml-sycl/im2col.cpp +1 -1
  181. data/ext/sources/ggml/src/ggml-sycl/mmq.cpp +60 -80
  182. data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +158 -203
  183. data/ext/sources/ggml/src/ggml-sycl/norm.cpp +55 -74
  184. data/ext/sources/ggml/src/ggml-sycl/quants.hpp +38 -10
  185. data/ext/sources/ggml/src/ggml-sycl/rope.cpp +138 -27
  186. data/ext/sources/ggml/src/ggml-sycl/softmax.cpp +3 -3
  187. data/ext/sources/ggml/src/ggml-sycl/sycl_hw.cpp +3 -1
  188. data/ext/sources/ggml/src/ggml-sycl/sycl_hw.hpp +3 -0
  189. data/ext/sources/ggml/src/ggml-sycl/tsembd.cpp +3 -8
  190. data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +108 -16
  191. data/ext/sources/ggml/src/ggml-sycl/wkv.cpp +12 -16
  192. data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +36 -32
  193. data/ext/sources/ggml/src/ggml-vulkan/ggml-vulkan.cpp +726 -282
  194. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +4 -12
  195. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv_transpose_1d.comp +98 -0
  196. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/geglu.comp +13 -0
  197. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.comp +15 -0
  198. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.comp +29 -0
  199. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/reglu.comp +9 -0
  200. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp +12 -3
  201. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/swiglu.comp +9 -0
  202. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +10 -1
  203. data/ext/sources/ggml/src/ggml.c +328 -48
  204. data/ext/sources/ggml/src/ggml.cpp +26 -0
  205. data/ext/sources/ggml/src/gguf.cpp +24 -3
  206. data/ext/sources/include/whisper.h +2 -0
  207. data/ext/sources/src/CMakeLists.txt +2 -0
  208. data/ext/sources/src/coreml/whisper-compat.h +10 -0
  209. data/ext/sources/src/coreml/whisper-compat.m +35 -0
  210. data/ext/sources/src/coreml/whisper-decoder-impl.m +1 -0
  211. data/ext/sources/src/coreml/whisper-encoder-impl.m +1 -0
  212. data/ext/sources/src/whisper.cpp +218 -169
  213. data/extsources.rb +15 -9
  214. data/lib/whisper/context.rb +15 -0
  215. data/lib/whisper/model/uri.rb +56 -1
  216. data/lib/whisper/segment.rb +58 -0
  217. data/sig/whisper.rbs +68 -38
  218. data/{tests → test}/helper.rb +1 -12
  219. data/{tests → test}/test_model.rb +9 -0
  220. data/test/test_package.rb +51 -0
  221. data/test/test_segment.rb +146 -0
  222. data/{tests → test}/test_whisper.rb +70 -0
  223. data/whispercpp.gemspec +2 -3
  224. metadata +91 -43
  225. data/ext/sources/.dockerignore +0 -3
  226. data/ext/sources/.github/workflows/bindings-ruby.yml +0 -21
  227. data/ext/sources/ci/run.sh +0 -336
  228. data/ext/sources/close-issue.yml +0 -28
  229. data/ext/sources/examples/talk-llama/llama-kv-cache.cpp +0 -2739
  230. data/ext/sources/ggml/src/ggml-cpu/ggml-cpu-aarch64.h +0 -8
  231. data/ext/sources/ggml/src/ggml-cpu/ggml-cpu-quants.c +0 -13747
  232. data/tests/test_package.rb +0 -46
  233. data/tests/test_segment.rb +0 -74
  234. /data/ext/sources/ggml/src/ggml-cpu/{cpu-feats-x86.cpp → arch/x86/cpu-feats.cpp} +0 -0
  235. /data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-hbm.h → hbm.h} +0 -0
  236. /data/ext/sources/ggml/src/ggml-cpu/{ggml-cpu-traits.h → traits.h} +0 -0
  237. /data/{tests → test}/jfk_reader/.gitignore +0 -0
  238. /data/{tests → test}/jfk_reader/extconf.rb +0 -0
  239. /data/{tests → test}/jfk_reader/jfk_reader.c +0 -0
  240. /data/{tests → test}/test_callback.rb +0 -0
  241. /data/{tests → test}/test_error.rb +0 -0
  242. /data/{tests → test}/test_params.rb +0 -0
  243. /data/{tests → test}/test_vad.rb +0 -0
  244. /data/{tests → test}/test_vad_params.rb +0 -0
@@ -1,336 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # sample usage:
4
- #
5
- # mkdir tmp
6
- #
7
- # # CPU-only build
8
- # bash ./ci/run.sh ./tmp/results ./tmp/mnt
9
- #
10
- # # with CUDA support
11
- # GG_BUILD_CUDA=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt
12
- #
13
- # # with SYCL support
14
- # GG_BUILD_SYCL=1 bash ./ci/run.sh ./tmp/results ./tmp/mnt
15
-
16
- if [ -z "$2" ]; then
17
- echo "usage: $0 <output-dir> <mnt-dir>"
18
- exit 1
19
- fi
20
-
21
- mkdir -p "$1"
22
- mkdir -p "$2"
23
-
24
- OUT=$(realpath "$1")
25
- MNT=$(realpath "$2")
26
-
27
- rm -f "$OUT/*.log"
28
- rm -f "$OUT/*.exit"
29
- rm -f "$OUT/*.md"
30
-
31
- sd=`dirname $0`
32
- cd $sd/../
33
- SRC=`pwd`
34
-
35
- ALL_MODELS=( "tiny.en" "tiny" "base.en" "base" "small.en" "small" "medium.en" "medium" "large-v1" "large-v2" "large-v3" "large-v3-turbo" )
36
- BENCH_N_THREADS=4
37
- BENCH_ENCODER_ONLY=0
38
- BENCH_FLASH_ATTN=0
39
-
40
- # check for user-specified models first. if not specified, use fast models
41
- if [ ! -z ${GG_BUILD_TEST_MODELS} ]; then
42
- IFS=',' read -r -a MODELS <<< "${GG_BUILD_TEST_MODELS}"
43
- else
44
- if [ ! -z ${GG_BUILD_LOW_PERF} ]; then
45
- MODELS=( "tiny" "base" "small" )
46
- else
47
- MODELS=("${ALL_MODELS[@]}")
48
- fi
49
- fi
50
-
51
- CMAKE_EXTRA="-DWHISPER_FATAL_WARNINGS=ON"
52
-
53
- if [ ! -z ${GG_BUILD_CUDA} ]; then
54
- CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=native"
55
- fi
56
-
57
- if [ ! -z ${GG_BUILD_SYCL} ]; then
58
- if [ -z ${ONEAPI_ROOT} ]; then
59
- echo "Not detected ONEAPI_ROOT, please install oneAPI base toolkit and enable it by:"
60
- echo "source /opt/intel/oneapi/setvars.sh"
61
- exit 1
62
- fi
63
-
64
- CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON"
65
- fi
66
-
67
- if [ ! -z ${GG_BUILD_OPENVINO} ]; then
68
- CMAKE_EXTRA="${CMAKE_EXTRA} -DWHISPER_OPENVINO=ON"
69
- fi
70
-
71
- if [ ! -z ${GG_BUILD_METAL} ]; then
72
- CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_METAL=ON"
73
- fi
74
-
75
- if [ ! -z ${GG_BUILD_VULKAN} ]; then
76
- CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_VULKAN=ON"
77
- fi
78
-
79
- if [ ! -z ${GG_BUILD_BLAS} ]; then
80
- CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_BLAS=ON"
81
- fi
82
-
83
- if [ ! -z ${GG_BUILD_COREML} ]; then
84
- CMAKE_EXTRA="${CMAKE_EXTRA} -DWHISPER_COREML=ON"
85
- fi
86
-
87
- ## helpers
88
-
89
- # download a file if it does not exist or if it is outdated
90
- function gg_wget {
91
- local out=$1
92
- local url=$2
93
-
94
- local cwd=`pwd`
95
-
96
- mkdir -p $out
97
- cd $out
98
-
99
- # should not re-download if file is the same
100
- wget -nv -N $url
101
-
102
- cd $cwd
103
- }
104
-
105
- function gg_download_model {
106
- local model_name=$1
107
- local model_file="$MNT/models/ggml-${model_name}.bin"
108
-
109
- if [ ! -f ${model_file} ]; then
110
- local cwd=`pwd`
111
- mkdir -p "$MNT/models"
112
- cd "$MNT/models"
113
- bash "$cwd/models/download-ggml-model.sh" ${model_name} .
114
- cd "$cwd"
115
- fi
116
- }
117
-
118
- function gg_printf {
119
- printf -- "$@" >> $OUT/README.md
120
- }
121
-
122
- # Helper function to check command exit status
123
- function gg_check_last_command_status {
124
- local exit_file=$1
125
- local command_name=$2
126
-
127
- local exit_status=$?
128
- echo "$exit_status" > "$exit_file"
129
-
130
- if [ $exit_status -ne 0 ]; then
131
- echo "Error: Command $command_name failed with exit status $exit_status"
132
- return 1
133
- fi
134
-
135
- return 0
136
- }
137
-
138
- # Usage: gg_run <test_name> [additional_args...]
139
- #
140
- # Parameters:
141
- # test_name - Name of the test to run (calls gg_run_<test_name>)
142
- # additional_args - Any additional arguments to pass to the test function (first argument is appended to the log filename)
143
- function gg_run {
144
- ci=$1
145
-
146
- if [ $# -gt 1 ]; then
147
- ci="${ci}_${2}"
148
- fi
149
-
150
- set -o pipefail
151
- set -x
152
-
153
- gg_run_$1 "$@" | tee $OUT/$ci.log
154
- cur=$?
155
- echo "$cur" > $OUT/$ci.exit
156
-
157
- set +x
158
- set +o pipefail
159
-
160
- gg_sum_$1 "$@"
161
-
162
- ret=$((ret | cur))
163
- }
164
-
165
- function gg_check_build_requirements {
166
- if ! command -v cmake &> /dev/null; then
167
- gg_printf 'cmake not found, please install'
168
- fi
169
-
170
- if ! command -v make &> /dev/null; then
171
- gg_printf 'make not found, please install'
172
- fi
173
- }
174
-
175
- ## ci
176
-
177
- function gg_run_ctest {
178
- mode=$2
179
-
180
- cd ${SRC}
181
-
182
- rm -rf build-ci-${mode} && mkdir build-ci-${mode} && cd build-ci-${mode}
183
-
184
- set -e
185
-
186
- gg_check_build_requirements
187
-
188
- (time cmake -DCMAKE_BUILD_TYPE=${mode} ${CMAKE_EXTRA} .. ) 2>&1 | tee -a $OUT/${ci}-cmake.log
189
- (time make -j$(nproc) ) 2>&1 | tee -a $OUT/${ci}-make.log
190
-
191
- (time ctest --output-on-failure -L main -E test-opt ) 2>&1 | tee -a $OUT/${ci}-ctest.log
192
-
193
- set +e
194
- }
195
-
196
- function gg_sum_ctest {
197
- mode=$2
198
-
199
- gg_printf '### %s\n\n' "${ci}"
200
-
201
- gg_printf 'Runs ctest in '${mode}' mode\n'
202
- gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
203
- gg_printf '```\n'
204
- gg_printf '%s\n' "$(cat $OUT/${ci}-ctest.log)"
205
- gg_printf '```\n'
206
- }
207
-
208
- function gg_run_bench {
209
- cd ${SRC}
210
-
211
- # set flash attention flag if enabled
212
- fattn=""
213
- if [ "$BENCH_FLASH_ATTN" -eq 1 ]; then
214
- fattn="-fa"
215
- fi
216
-
217
- # run memcpy benchmark if not encoder-only mode
218
- if [ "$BENCH_ENCODER_ONLY" -eq 0 ]; then
219
- echo "Running memcpy benchmark"
220
- (time ./build-ci-release/bin/whisper-bench -w 1 -t $BENCH_N_THREADS 2>&1) | tee -a $OUT/${ci}-memcpy.log
221
- gg_check_last_command_status "$OUT/${ci}-memcpy.exit" "memcpy benchmark"
222
-
223
- echo "Running ggml_mul_mat benchmark with $BENCH_N_THREADS threads"
224
- (time ./build-ci-release/bin/whisper-bench -w 2 -t $BENCH_N_THREADS 2>&1) | tee -a $OUT/${ci}-mul_mat.log
225
- gg_check_last_command_status "$OUT/${ci}-mul_mat.exit" "ggml_mul_mat benchmark"
226
- fi
227
-
228
- echo "Running benchmark for all models"
229
-
230
- # generate header for the benchmark table
231
- {
232
- printf "| %16s | %13s | %3s | %3s | %7s | %7s | %7s | %7s | %7s |\n" "Config" "Model" "Th" "FA" "Enc." "Dec." "Bch5" "PP" "Commit"
233
- printf "| %16s | %13s | %3s | %3s | %7s | %7s | %7s | %7s | %7s |\n" "---" "---" "---" "---" "---" "---" "---" "---" "---"
234
- } | tee -a $OUT/${ci}-models-table.log
235
-
236
- # run benchmark for each model
237
- for model in "${MODELS[@]}"; do
238
- echo "Benchmarking model: $model"
239
-
240
- # run the benchmark and capture output
241
- output=$(./build-ci-release/bin/whisper-bench -m $MNT/models/ggml-$model.bin -t $BENCH_N_THREADS $fattn 2>&1)
242
- ret=$?
243
-
244
- # save the raw output
245
- echo "$output" > $OUT/${ci}-bench-$model.log
246
-
247
- if [ $ret -eq 0 ]; then
248
- # parse the benchmark results
249
- encode_time=$(echo "$output" | grep "encode time" | awk '{print $11}')
250
- decode_time=$(echo "$output" | grep "decode time" | awk '{print $11}')
251
- batchd_time=$(echo "$output" | grep "batchd time" | awk '{print $11}')
252
- prompt_time=$(echo "$output" | grep "prompt time" | awk '{print $11}')
253
- system_info=$(echo "$output" | grep "system_info")
254
- actual_threads=$(echo "$output" | grep "system_info" | awk '{print $4}')
255
-
256
- # determine configuration
257
- config=""
258
- if [[ $system_info == *"AVX2 = 1"* ]]; then
259
- config="$config AVX2"
260
- fi
261
- if [[ $system_info == *"NEON = 1"* ]]; then
262
- config="$config NEON"
263
- fi
264
- if [[ $system_info == *"BLAS = 1"* ]]; then
265
- config="$config BLAS"
266
- fi
267
- if [[ $system_info == *"COREML = 1"* ]]; then
268
- config="$config COREML"
269
- fi
270
- if [[ $system_info == *"CUDA = 1"* ]]; then
271
- config="$config CUDA"
272
- fi
273
- if [[ $system_info == *"METAL = 1"* ]]; then
274
- config="$config METAL"
275
- fi
276
-
277
- # get commit hash
278
- commit=$(git rev-parse --short HEAD)
279
-
280
- # add row to benchmark table
281
- printf "| %16s | %13s | %3s | %3s | %7s | %7s | %7s | %7s | %7s |\n" \
282
- "$config" "$model" "$actual_threads" "$BENCH_FLASH_ATTN" "$encode_time" "$decode_time" "$batchd_time" "$prompt_time" "$commit" \
283
- | tee -a $OUT/${ci}-models-table.log
284
- else
285
- echo "Benchmark failed for model: $model" | tee -a $OUT/${ci}-bench-errors.log
286
- fi
287
- done
288
- }
289
-
290
- function gg_sum_bench {
291
- gg_printf '### %s\n\n' "${ci}"
292
-
293
- gg_printf 'Whisper Benchmark Results\n'
294
- gg_printf '- status: %s\n' "$(cat $OUT/${ci}.exit)"
295
-
296
- # show memcpy and ggml_mul_mat benchmark results if available
297
- if [ "$BENCH_ENCODER_ONLY" -eq 0 ]; then
298
- if [ -f "$OUT/${ci}-memcpy.log" ]; then
299
- gg_printf '#### memcpy Benchmark\n\n'
300
- gg_printf '```\n%s\n```\n\n' "$(cat $OUT/${ci}-memcpy.log)"
301
- fi
302
-
303
- if [ -f "$OUT/${ci}-mul_mat.log" ]; then
304
- gg_printf '#### ggml_mul_mat Benchmark\n\n'
305
- gg_printf '```\n%s\n```\n\n' "$(cat $OUT/${ci}-mul_mat.log)"
306
- fi
307
- fi
308
-
309
- # show model benchmark results
310
- gg_printf '#### Model Benchmarks\n\n'
311
- if [ -f "$OUT/${ci}-models-table.log" ]; then
312
- gg_printf '%s\n\n' "$(cat $OUT/${ci}-models-table.log)"
313
- else
314
- gg_printf 'No model benchmark results available.\n\n'
315
- fi
316
-
317
- # show any errors that occurred
318
- if [ -f "$OUT/${ci}-bench-errors.log" ]; then
319
- gg_printf '#### Benchmark Errors\n\n'
320
- gg_printf '```\n%s\n```\n\n' "$(cat $OUT/${ci}-bench-errors.log)"
321
- fi
322
- }
323
-
324
- ret=0
325
-
326
- for model in "${MODELS[@]}"; do
327
- test $ret -eq 0 && gg_download_model ${model}
328
- done
329
- if [ -z ${GG_BUILD_SYCL}]; then
330
- test $ret -eq 0 && gg_run ctest debug
331
- fi
332
- test $ret -eq 0 && gg_run ctest release
333
-
334
- test $ret -eq 0 && gg_run bench
335
-
336
- exit $ret
@@ -1,28 +0,0 @@
1
- name: Close inactive issues
2
- on:
3
- schedule:
4
- - cron: "42 0 * * *"
5
-
6
- # Fine-grant permission
7
- # https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
8
- permissions:
9
- issues: write
10
-
11
- jobs:
12
- close-issues:
13
- runs-on: ubuntu-latest
14
- permissions:
15
- issues: write
16
- pull-requests: write
17
- steps:
18
- - uses: actions/stale@v5
19
- with:
20
- exempt-issue-labels: "refactor,help wanted,good first issue,research,bug,roadmap"
21
- days-before-issue-stale: 30
22
- days-before-issue-close: 14
23
- stale-issue-label: "stale"
24
- close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
25
- days-before-pr-stale: -1
26
- days-before-pr-close: -1
27
- operations-per-run: 10000
28
- repo-token: ${{ secrets.GITHUB_TOKEN }}