whispercpp 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/ext/options.rb +1 -1
- data/ext/ruby_whisper.c +0 -1
- data/ext/ruby_whisper.h +7 -1
- data/ext/ruby_whisper_context.c +50 -1
- data/ext/ruby_whisper_log_settable.h +1 -2
- data/ext/ruby_whisper_params.c +9 -8
- data/ext/ruby_whisper_transcribe.cpp +0 -19
- data/ext/ruby_whisper_vad_context.c +30 -10
- data/ext/ruby_whisper_vad_context_detect.cpp +8 -9
- data/ext/ruby_whisper_vad_params.c +4 -4
- data/ext/ruby_whisper_vad_segment.c +2 -2
- data/ext/sources/CMakeLists.txt +2 -1
- data/ext/sources/cmake/parakeet.pc.in +2 -2
- data/ext/sources/cmake/whisper.pc.in +2 -2
- data/ext/sources/examples/cli/cli.cpp +9 -1
- data/ext/sources/examples/common-ggml.cpp +2 -0
- data/ext/sources/examples/vad-speech-segments/speech.cpp +3 -2
- data/ext/sources/ggml/CMakeLists.txt +3 -4
- data/ext/sources/ggml/include/ggml-cuda.h +0 -3
- data/ext/sources/ggml/include/ggml-sycl.h +8 -0
- data/ext/sources/ggml/include/ggml.h +3 -1
- data/ext/sources/ggml/src/CMakeLists.txt +8 -1
- data/ext/sources/ggml/src/ggml-backend-meta.cpp +7 -4
- data/ext/sources/ggml/src/ggml-common.h +13 -2
- data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +1 -1
- data/ext/sources/ggml/src/ggml-cpu/amx/mmq.cpp +5 -6
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +78 -4
- data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +142 -4
- data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +7 -2
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +14 -0
- data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +26 -19
- data/ext/sources/ggml/src/ggml-cpu/ops.cpp +129 -46
- data/ext/sources/ggml/src/ggml-cpu/quants.c +51 -0
- data/ext/sources/ggml/src/ggml-cpu/quants.h +3 -0
- data/ext/sources/ggml/src/ggml-cpu/simd-gemm.h +1 -1
- data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +11 -0
- data/ext/sources/ggml/src/ggml-cpu/vec.cpp +2 -2
- data/ext/sources/ggml/src/ggml-cuda/binbcast.cu +90 -46
- data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
- data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/common.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/concat.cu +33 -21
- data/ext/sources/ggml/src/ggml-cuda/conv-transpose-1d.cu +14 -12
- data/ext/sources/ggml/src/ggml-cuda/convert.cu +86 -34
- data/ext/sources/ggml/src/ggml-cuda/cpy.cu +80 -29
- data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +9 -5
- data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-tile.cuh +9 -5
- data/ext/sources/ggml/src/ggml-cuda/fattn.cu +27 -21
- data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cu +40 -25
- data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cuh +10 -0
- data/ext/sources/ggml/src/ggml-cuda/getrows.cu +15 -12
- data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +718 -1248
- data/ext/sources/ggml/src/ggml-cuda/mmq.cu +7 -0
- data/ext/sources/ggml/src/ggml-cuda/mmvq.cu +77 -40
- data/ext/sources/ggml/src/ggml-cuda/out-prod.cu +55 -12
- data/ext/sources/ggml/src/ggml-cuda/set-rows.cu +64 -4
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/topk-moe.cu +7 -1
- data/ext/sources/ggml/src/ggml-cuda/vendors/hip.h +1 -0
- data/ext/sources/ggml/src/ggml-cuda/vendors/musa.h +1 -0
- data/ext/sources/ggml/src/ggml-hexagon/CMakeLists.txt +0 -5
- data/ext/sources/ggml/src/ggml-hexagon/ggml-hexagon.cpp +1634 -1293
- data/ext/sources/ggml/src/ggml-hexagon/htp/CMakeLists.txt +11 -40
- data/ext/sources/ggml/src/ggml-hexagon/htp/cmake-toolchain.cmake +13 -15
- data/ext/sources/ggml/src/ggml-hexagon/htp/concat-ops.c +1 -1
- data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.c +1749 -399
- data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.h +303 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-common.h +80 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-dma.h +26 -23
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-profile.h +64 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-utils.h +1 -83
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-fa-kernels.h +555 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-mm-kernels-tiled.h +1303 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.c +9 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.h +27 -4
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-utils.h +59 -37
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ctx.h +11 -3
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ops.h +52 -12
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-vtcm.h +19 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp_iface.idl +2 -1
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-base.h +14 -30
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-exp.h +39 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-fa-kernels.h +232 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-flat.h +1511 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-tiled.h +1200 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-sigmoid.h +39 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/main.c +127 -32
- data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.c +3023 -4425
- data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.h +650 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/rope-ops.c +48 -13
- data/ext/sources/ggml/src/ggml-hexagon/htp/ssm-conv.c +10 -9
- data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.c +15 -3
- data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.h +8 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp-opnode.h +168 -50
- data/ext/sources/ggml/src/ggml-hexagon/libggml-htp.inf +0 -4
- data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +5 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.cpp +69 -5
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.h +4 -1
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.m +27 -6
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +38 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.cpp +132 -2
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.h +2 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal.metal +345 -87
- data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +13 -0
- data/ext/sources/ggml/src/ggml-opencl/fa_tune.h +92 -0
- data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +4060 -357
- data/ext/sources/ggml/src/ggml-opencl/kernels/cvt.cl +198 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f16.cl +81 -41
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32.cl +88 -39
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_f16.cl +1995 -96
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q4_0.cl +1615 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q8_0.cl +1486 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_pre_f16.cl +156 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_1_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_f32_ns.cl +71 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_0_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_1_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_k_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q1_0_f32.cl +94 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q1_0_f32.cl +121 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q8_0_f32.cl +1 -1
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mm_q1_0_f32_l4_lm.cl +156 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +1149 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32.cl +141 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32_flat.cl +190 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/norm.cl +5 -2
- data/ext/sources/ggml/src/ggml-opencl/kernels/set_rows.cl +500 -0
- data/ext/sources/ggml/src/ggml-opencl/libdl.h +79 -0
- data/ext/sources/ggml/src/ggml-openvino/.clang-format +0 -5
- data/ext/sources/ggml/src/ggml-openvino/CMakeLists.txt +2 -4
- data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.cpp +733 -130
- data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.h +76 -23
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.cpp +57 -3
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.h +29 -8
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino.cpp +307 -59
- data/ext/sources/ggml/src/ggml-openvino/ggml-quants.cpp +66 -0
- data/ext/sources/ggml/src/ggml-openvino/ggml-quants.h +10 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/decoder.h +56 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/frontend.h +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/input_model.h +4 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/node_context.h +94 -37
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/add_id.cpp +76 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/argsort.cpp +47 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/clamp.cpp +33 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/concat.cpp +48 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/cont.cpp +8 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/cpy.cpp +14 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/div.cpp +146 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/flash_attn_ext.cpp +108 -21
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.cpp +282 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.hpp +65 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/get_rows.cpp +2 -9
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_geglu.cpp +21 -7
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_swiglu.cpp +41 -8
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/im2col.cpp +120 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/l2_norm.cpp +44 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/mul_mat_id.cpp +226 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/mulmat.cpp +19 -9
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/norm.cpp +58 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/pad.cpp +95 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/permute.cpp +58 -13
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/repeat.cpp +74 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/reshape.cpp +13 -6
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/rms_norm.cpp +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/rope.cpp +134 -38
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/set_rows.cpp +3 -3
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/softmax.cpp +126 -49
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/ssm_conv.cpp +59 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/sum_rows.cpp +27 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/transpose.cpp +32 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_silu.cpp +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_softplus.cpp +38 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/view.cpp +90 -25
- data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.cpp +41 -23
- data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.h +18 -5
- data/ext/sources/ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.h +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.cpp +43 -40
- data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.h +5 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/utils.cpp +548 -3
- data/ext/sources/ggml/src/ggml-openvino/openvino/utils.h +28 -26
- data/ext/sources/ggml/src/ggml-openvino/utils.cpp +383 -94
- data/ext/sources/ggml/src/ggml-openvino/utils.h +11 -8
- data/ext/sources/ggml/src/ggml-quants.c +76 -0
- data/ext/sources/ggml/src/ggml-quants.h +3 -0
- data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +5 -5
- data/ext/sources/ggml/src/ggml-sycl/backend.hpp +2 -0
- data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +12 -0
- data/ext/sources/ggml/src/ggml-sycl/col2im-1d.cpp +102 -0
- data/ext/sources/ggml/src/ggml-sycl/col2im-1d.hpp +8 -0
- data/ext/sources/ggml/src/ggml-sycl/common.cpp +6 -8
- data/ext/sources/ggml/src/ggml-sycl/common.hpp +19 -2
- data/ext/sources/ggml/src/ggml-sycl/concat.cpp +21 -1
- data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.cpp +158 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.cpp +125 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d.cpp +150 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv3d.cpp +224 -0
- data/ext/sources/ggml/src/ggml-sycl/conv3d.hpp +8 -0
- data/ext/sources/ggml/src/ggml-sycl/convert.cpp +6 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +706 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.hpp +281 -0
- data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.cpp +255 -0
- data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.hpp +7 -0
- data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +15 -0
- data/ext/sources/ggml/src/ggml-sycl/dmmv.cpp +492 -319
- data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +15 -7
- data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +215 -115
- data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +2 -0
- data/ext/sources/ggml/src/ggml-sycl/ggml-sycl.cpp +1006 -336
- data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +252 -67
- data/ext/sources/ggml/src/ggml-sycl/mmvq.hpp +17 -0
- data/ext/sources/ggml/src/ggml-sycl/norm.cpp +103 -49
- data/ext/sources/ggml/src/ggml-sycl/outprod.cpp +45 -9
- data/ext/sources/ggml/src/ggml-sycl/pool.cpp +185 -0
- data/ext/sources/ggml/src/ggml-sycl/pool.hpp +22 -0
- data/ext/sources/ggml/src/ggml-sycl/presets.hpp +3 -1
- data/ext/sources/ggml/src/ggml-sycl/set_rows.cpp +10 -2
- data/ext/sources/ggml/src/ggml-sycl/softmax.cpp +9 -10
- data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +35 -0
- data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +5 -0
- data/ext/sources/ggml/src/ggml-vulkan/ggml-vulkan.cpp +833 -215
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/col2im_1d.comp +61 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_mm.comp +1 -1
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv3d_mm.comp +431 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/diag.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +1 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +1 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.glsl +21 -19
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_back.comp +25 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl +23 -4
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.glsl +14 -18
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +4 -7
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vecq.comp +21 -24
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +31 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +6 -5
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_funcs.glsl +84 -67
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +10 -10
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/roll.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tri.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/unary.comp +168 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +121 -74
- data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp +26 -19
- data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu.cpp +31 -36
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/common_decls.tmpl +16 -2
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_split.wgsl +7 -7
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/get_rows.wgsl +21 -0
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_decls.tmpl +439 -320
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id_vec.wgsl +2 -2
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec.wgsl +45 -39
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_acc.tmpl +586 -465
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_q_acc.tmpl +63 -69
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/quantize_q8.wgsl +14 -9
- data/ext/sources/ggml/src/ggml.c +36 -14
- data/ext/sources/include/whisper.h +21 -0
- data/ext/sources/src/whisper.cpp +164 -14
- data/lib/whisper/log_settable.rb +5 -8
- data/lib/whisper/model/uri.rb +0 -7
- data/sig/whisper.rbs +6 -0
- data/test/test_vad.rb +9 -0
- data/test/test_vad_context.rb +2 -2
- data/whispercpp.gemspec +1 -1
- metadata +62 -37
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-flash-attn-ops.c +0 -1878
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-matmul-ops.c +0 -2066
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.c +0 -6
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.h +0 -88
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-profile.h +0 -34
- data/ext/sources/ggml/src/ggml-hexagon/htp/vtcm-utils.h +0 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_gelu.cpp +0 -25
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/abs.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/ceil.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/clamp.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/cos.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/elu.comp +0 -27
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/exp.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/floor.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp +0 -25
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_erf.comp +0 -39
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp +0 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardsigmoid.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardswish.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/leaky_relu.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/neg.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/relu.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/round.comp +0 -29
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sgn.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/silu.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sin.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/softplus.comp +0 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sqrt.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/square.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/step.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/trunc.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/xielu.comp +0 -35
|
@@ -11,7 +11,24 @@
|
|
|
11
11
|
#define DK_VEC (DK/4)
|
|
12
12
|
#define DV_VEC (DV/4)
|
|
13
13
|
#define WG_SIZE (BLOCK_M)
|
|
14
|
-
|
|
14
|
+
// q1 reduces over a Q1_WG_SIZE-wide WG via work-group barriers; the launch WG
|
|
15
|
+
// must match. Defaults to the Adreno sg (64); host passes -D FA_SG=32 on Intel.
|
|
16
|
+
#ifndef FA_SG
|
|
17
|
+
#define FA_SG 64
|
|
18
|
+
#endif
|
|
19
|
+
#define Q1_WG_SIZE FA_SG
|
|
20
|
+
|
|
21
|
+
// The kernels are built with -cl-finite-math-only. On some older Adreno GPUs,
|
|
22
|
+
// infinite operand can cause undefined behavior and miscompilation for exp.
|
|
23
|
+
// Therefore, a large negative value is used instead.
|
|
24
|
+
#define FA_M_INIT (-3.0e38f)
|
|
25
|
+
|
|
26
|
+
// Drop full unroll at DK>=192 — Adreno compiler host-memory budget.
|
|
27
|
+
#if DK >= 192
|
|
28
|
+
#define FA_UNROLL
|
|
29
|
+
#else
|
|
30
|
+
#define FA_UNROLL _Pragma("unroll")
|
|
31
|
+
#endif
|
|
15
32
|
|
|
16
33
|
inline float get_alibi_slope(
|
|
17
34
|
const float max_bias, const uint h, const uint n_head_log2, const float m0, const float m1
|
|
@@ -82,18 +99,18 @@ __kernel void flash_attn_f32(
|
|
|
82
99
|
if (my_query_row < n_q) {
|
|
83
100
|
const ulong q_row_offset = batch_idx * q_nb3 + head_idx * q_nb2 + my_query_row * q_nb1;
|
|
84
101
|
const global DATA_TYPE4* q_ptr = (const global DATA_TYPE4*)(q_base + q_row_offset);
|
|
85
|
-
|
|
102
|
+
FA_UNROLL
|
|
86
103
|
for (int i = 0; i < DK_VEC; ++i) {
|
|
87
104
|
q_priv[i] = CONVERT_ACC4(q_ptr[i]);
|
|
88
105
|
}
|
|
89
106
|
}
|
|
90
107
|
|
|
91
108
|
ACC_TYPE4 o_acc[DV_VEC];
|
|
92
|
-
|
|
109
|
+
FA_UNROLL
|
|
93
110
|
for (int i = 0; i < DV_VEC; ++i) {
|
|
94
111
|
o_acc[i] = (ACC_TYPE4)(0.0f);
|
|
95
112
|
}
|
|
96
|
-
ACC_TYPE m_i =
|
|
113
|
+
ACC_TYPE m_i = FA_M_INIT;
|
|
97
114
|
ACC_TYPE l_i = 0.0f;
|
|
98
115
|
|
|
99
116
|
float slope = get_alibi_slope(max_bias, head_idx, n_head_log2, m0, m1);
|
|
@@ -102,6 +119,15 @@ __kernel void flash_attn_f32(
|
|
|
102
119
|
__local DATA_TYPE4 l_v[BLOCK_N][DV_VEC];
|
|
103
120
|
|
|
104
121
|
for (int k_start = 0; k_start < n_kv; k_start += BLOCK_N) {
|
|
122
|
+
#if FA_SG < 64
|
|
123
|
+
// WAR on l_k/l_v: threads with my_query_row >= n_q skip the compute below
|
|
124
|
+
// (continue) and would race ahead to reload the tiles while active threads
|
|
125
|
+
// still read them. A single 64-wide Adreno subgroup (WG == sg) runs lockstep
|
|
126
|
+
// and hides this; a WG that spans multiple narrower subgroups (Intel sg=32)
|
|
127
|
+
// corrupts the result. All threads reach this each iteration (no-op on the
|
|
128
|
+
// first), so it does not diverge with the continue. Compiled out at sg=64.
|
|
129
|
+
barrier(CLK_LOCAL_MEM_FENCE);
|
|
130
|
+
#endif
|
|
105
131
|
for (int i = tid; i < BLOCK_N * DK_VEC; i += WG_SIZE) {
|
|
106
132
|
const int row = i / DK_VEC;
|
|
107
133
|
const int col = i % DK_VEC;
|
|
@@ -126,49 +152,72 @@ __kernel void flash_attn_f32(
|
|
|
126
152
|
continue;
|
|
127
153
|
}
|
|
128
154
|
|
|
129
|
-
for (int j = 0; j < BLOCK_N; j +=
|
|
155
|
+
for (int j = 0; j < BLOCK_N; j += 4) {
|
|
130
156
|
const int k_row0 = k_start + j;
|
|
131
157
|
const int k_row1 = k_start + j + 1;
|
|
158
|
+
const int k_row2 = k_start + j + 2;
|
|
159
|
+
const int k_row3 = k_start + j + 3;
|
|
132
160
|
|
|
133
161
|
ACC_TYPE4 dot_acc0 = (ACC_TYPE4)(0.0f);
|
|
134
162
|
ACC_TYPE4 dot_acc1 = (ACC_TYPE4)(0.0f);
|
|
135
|
-
|
|
163
|
+
ACC_TYPE4 dot_acc2 = (ACC_TYPE4)(0.0f);
|
|
164
|
+
ACC_TYPE4 dot_acc3 = (ACC_TYPE4)(0.0f);
|
|
165
|
+
FA_UNROLL
|
|
136
166
|
for (int k = 0; k < DK_VEC; k++) {
|
|
137
|
-
|
|
138
|
-
|
|
167
|
+
const ACC_TYPE4 qk = q_priv[k];
|
|
168
|
+
dot_acc0 = mad(qk, CONVERT_ACC4(l_k[j][k]), dot_acc0);
|
|
169
|
+
dot_acc1 = mad(qk, CONVERT_ACC4(l_k[j+1][k]), dot_acc1);
|
|
170
|
+
dot_acc2 = mad(qk, CONVERT_ACC4(l_k[j+2][k]), dot_acc2);
|
|
171
|
+
dot_acc3 = mad(qk, CONVERT_ACC4(l_k[j+3][k]), dot_acc3);
|
|
139
172
|
}
|
|
140
|
-
ACC_TYPE
|
|
141
|
-
ACC_TYPE
|
|
173
|
+
ACC_TYPE s0 = (dot_acc0.s0 + dot_acc0.s1 + dot_acc0.s2 + dot_acc0.s3) * scale;
|
|
174
|
+
ACC_TYPE s1 = (dot_acc1.s0 + dot_acc1.s1 + dot_acc1.s2 + dot_acc1.s3) * scale;
|
|
175
|
+
ACC_TYPE s2 = (dot_acc2.s0 + dot_acc2.s1 + dot_acc2.s2 + dot_acc2.s3) * scale;
|
|
176
|
+
ACC_TYPE s3 = (dot_acc3.s0 + dot_acc3.s1 + dot_acc3.s2 + dot_acc3.s3) * scale;
|
|
142
177
|
|
|
143
178
|
if (is_causal) {
|
|
144
|
-
|
|
145
|
-
if (
|
|
179
|
+
const int causal_limit = n_kv - n_q + my_query_row;
|
|
180
|
+
if (k_row0 > causal_limit) s0 = FA_M_INIT;
|
|
181
|
+
if (k_row1 > causal_limit) s1 = FA_M_INIT;
|
|
182
|
+
if (k_row2 > causal_limit) s2 = FA_M_INIT;
|
|
183
|
+
if (k_row3 > causal_limit) s3 = FA_M_INIT;
|
|
146
184
|
}
|
|
147
|
-
|
|
148
|
-
if (
|
|
149
|
-
if (
|
|
185
|
+
if (k_row0 >= n_kv) s0 = FA_M_INIT;
|
|
186
|
+
if (k_row1 >= n_kv) s1 = FA_M_INIT;
|
|
187
|
+
if (k_row2 >= n_kv) s2 = FA_M_INIT;
|
|
188
|
+
if (k_row3 >= n_kv) s3 = FA_M_INIT;
|
|
150
189
|
|
|
151
190
|
if (mask_base != NULL) {
|
|
152
191
|
const global MASK_DATA_TYPE* mask_ptr = (const global MASK_DATA_TYPE*)(mask_base + my_query_row * mask_nb1);
|
|
153
|
-
if (k_row0 < n_kv)
|
|
154
|
-
if (k_row1 < n_kv)
|
|
192
|
+
if (k_row0 < n_kv) s0 += slope * (ACC_TYPE)mask_ptr[k_row0];
|
|
193
|
+
if (k_row1 < n_kv) s1 += slope * (ACC_TYPE)mask_ptr[k_row1];
|
|
194
|
+
if (k_row2 < n_kv) s2 += slope * (ACC_TYPE)mask_ptr[k_row2];
|
|
195
|
+
if (k_row3 < n_kv) s3 += slope * (ACC_TYPE)mask_ptr[k_row3];
|
|
155
196
|
}
|
|
156
197
|
|
|
157
198
|
if (logit_softcap > 0.0f) {
|
|
158
|
-
|
|
159
|
-
|
|
199
|
+
s0 = logit_softcap * tanh(s0 / logit_softcap);
|
|
200
|
+
s1 = logit_softcap * tanh(s1 / logit_softcap);
|
|
201
|
+
s2 = logit_softcap * tanh(s2 / logit_softcap);
|
|
202
|
+
s3 = logit_softcap * tanh(s3 / logit_softcap);
|
|
160
203
|
}
|
|
161
204
|
|
|
162
|
-
const ACC_TYPE m_new
|
|
163
|
-
const ACC_TYPE
|
|
164
|
-
const ACC_TYPE
|
|
165
|
-
const ACC_TYPE
|
|
205
|
+
const ACC_TYPE m_new = max(m_i, max(max(s0, s1), max(s2, s3)));
|
|
206
|
+
const ACC_TYPE scale_prev = native_exp(m_i - m_new);
|
|
207
|
+
const ACC_TYPE p0 = native_exp(s0 - m_new);
|
|
208
|
+
const ACC_TYPE p1 = native_exp(s1 - m_new);
|
|
209
|
+
const ACC_TYPE p2 = native_exp(s2 - m_new);
|
|
210
|
+
const ACC_TYPE p3 = native_exp(s3 - m_new);
|
|
166
211
|
|
|
167
|
-
|
|
212
|
+
FA_UNROLL
|
|
168
213
|
for (int i = 0; i < DV_VEC; ++i) {
|
|
169
|
-
o_acc[i] =
|
|
214
|
+
o_acc[i] = mad(p3, CONVERT_ACC4(l_v[j+3][i]),
|
|
215
|
+
mad(p2, CONVERT_ACC4(l_v[j+2][i]),
|
|
216
|
+
mad(p1, CONVERT_ACC4(l_v[j+1][i]),
|
|
217
|
+
mad(p0, CONVERT_ACC4(l_v[j][i]),
|
|
218
|
+
o_acc[i] * scale_prev))));
|
|
170
219
|
}
|
|
171
|
-
l_i = l_i * scale_prev + p0 + p1;
|
|
220
|
+
l_i = l_i * scale_prev + p0 + p1 + p2 + p3;
|
|
172
221
|
m_i = m_new;
|
|
173
222
|
}
|
|
174
223
|
}
|
|
@@ -180,7 +229,7 @@ __kernel void flash_attn_f32(
|
|
|
180
229
|
const ACC_TYPE m_final = max(m_i, m_sink);
|
|
181
230
|
|
|
182
231
|
const ACC_TYPE scale_o = exp(m_i - m_final);
|
|
183
|
-
|
|
232
|
+
FA_UNROLL
|
|
184
233
|
for (int i = 0; i < DV_VEC; ++i) {
|
|
185
234
|
o_acc[i] *= scale_o;
|
|
186
235
|
}
|
|
@@ -192,12 +241,12 @@ __kernel void flash_attn_f32(
|
|
|
192
241
|
global DATA_TYPE4 *o_row = (global DATA_TYPE4 *)(o_base + o_row_offset);
|
|
193
242
|
if (l_i > 0.0f) {
|
|
194
243
|
const ACC_TYPE l_inv = 1.0f / l_i;
|
|
195
|
-
|
|
244
|
+
FA_UNROLL
|
|
196
245
|
for (int i = 0; i < DV_VEC; ++i) {
|
|
197
246
|
o_row[i] = CONVERT_DATA4(o_acc[i] * l_inv);
|
|
198
247
|
}
|
|
199
248
|
} else {
|
|
200
|
-
|
|
249
|
+
FA_UNROLL
|
|
201
250
|
for (int i = 0; i < DV_VEC; ++i) {
|
|
202
251
|
o_row[i] = (DATA_TYPE4)(0.0f);
|
|
203
252
|
}
|
|
@@ -259,7 +308,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
259
308
|
ACC_TYPE4 q_priv[DK_VEC];
|
|
260
309
|
const ulong q_row_offset = batch_idx * q_nb3 + head_idx * q_nb2;
|
|
261
310
|
const global DATA_TYPE4* q_ptr = (const global DATA_TYPE4*)(q_base + q_row_offset);
|
|
262
|
-
|
|
311
|
+
FA_UNROLL
|
|
263
312
|
for (int i = 0; i < DK_VEC; ++i) {
|
|
264
313
|
q_priv[i] = CONVERT_ACC4(q_ptr[i]);
|
|
265
314
|
}
|
|
@@ -271,12 +320,12 @@ __kernel void flash_attn_f32_q1(
|
|
|
271
320
|
sinks_ptr = (const global ACC_TYPE*)((const global char*)sinks_void + sinks_offset);
|
|
272
321
|
}
|
|
273
322
|
|
|
274
|
-
ACC_TYPE m_i = (sinks_ptr != NULL) ? sinks_ptr[head_idx] :
|
|
323
|
+
ACC_TYPE m_i = (sinks_ptr != NULL) ? sinks_ptr[head_idx] : FA_M_INIT;
|
|
275
324
|
for (int k_idx = tid; k_idx < n_kv; k_idx += Q1_WG_SIZE) {
|
|
276
325
|
const ulong k_row_offset = batch_idx * k_nb3 + head_kv_idx * k_nb2 + k_idx * k_nb1;
|
|
277
326
|
const global DATA_TYPE4* k_ptr = (const global DATA_TYPE4*)(k_base + k_row_offset);
|
|
278
327
|
ACC_TYPE4 dot_acc = (ACC_TYPE4)(0.0f);
|
|
279
|
-
|
|
328
|
+
FA_UNROLL
|
|
280
329
|
for (int k = 0; k < DK_VEC; k++) {
|
|
281
330
|
dot_acc = mad(q_priv[k], CONVERT_ACC4(k_ptr[k]), dot_acc);
|
|
282
331
|
}
|
|
@@ -294,7 +343,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
294
343
|
__local ACC_TYPE local_m[Q1_WG_SIZE];
|
|
295
344
|
local_m[tid] = m_i;
|
|
296
345
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
297
|
-
|
|
346
|
+
FA_UNROLL
|
|
298
347
|
for (int s = Q1_WG_SIZE / 2; s > 0; s >>= 1) {
|
|
299
348
|
if (tid < s) local_m[tid] = max(local_m[tid], local_m[tid + s]);
|
|
300
349
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
@@ -302,7 +351,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
302
351
|
const ACC_TYPE m_final = local_m[0];
|
|
303
352
|
|
|
304
353
|
ACC_TYPE4 o_acc[DV_VEC];
|
|
305
|
-
|
|
354
|
+
FA_UNROLL
|
|
306
355
|
for (int i = 0; i < DV_VEC; ++i) o_acc[i] = (ACC_TYPE4)(0.0f);
|
|
307
356
|
ACC_TYPE l_i = 0.0f;
|
|
308
357
|
|
|
@@ -312,7 +361,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
312
361
|
const global DATA_TYPE4* k_ptr = (const global DATA_TYPE4*)(k_base + k_row_offset);
|
|
313
362
|
const global DATA_TYPE4* v_ptr = (const global DATA_TYPE4*)(v_base + v_row_offset);
|
|
314
363
|
ACC_TYPE4 dot_acc = (ACC_TYPE4)(0.0f);
|
|
315
|
-
|
|
364
|
+
FA_UNROLL
|
|
316
365
|
for (int k = 0; k < DK_VEC; k++) {
|
|
317
366
|
dot_acc = mad(q_priv[k], CONVERT_ACC4(k_ptr[k]), dot_acc);
|
|
318
367
|
}
|
|
@@ -326,7 +375,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
326
375
|
}
|
|
327
376
|
const ACC_TYPE p = exp(score - m_final);
|
|
328
377
|
l_i += p;
|
|
329
|
-
|
|
378
|
+
FA_UNROLL
|
|
330
379
|
for (int i = 0; i < DV_VEC; i++) {
|
|
331
380
|
o_acc[i] = mad(p, CONVERT_ACC4(v_ptr[i]), o_acc[i]);
|
|
332
381
|
}
|
|
@@ -336,7 +385,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
336
385
|
__local ACC_TYPE4 local_o_comp[Q1_WG_SIZE];
|
|
337
386
|
local_l[tid] = l_i;
|
|
338
387
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
339
|
-
|
|
388
|
+
FA_UNROLL
|
|
340
389
|
for (int s = Q1_WG_SIZE / 2; s > 0; s >>= 1) {
|
|
341
390
|
if (tid < s) local_l[tid] += local_l[tid + s];
|
|
342
391
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
@@ -355,7 +404,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
355
404
|
for (int i = 0; i < DV_VEC; i++) {
|
|
356
405
|
local_o_comp[tid] = o_acc[i];
|
|
357
406
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
358
|
-
|
|
407
|
+
FA_UNROLL
|
|
359
408
|
for (int s = Q1_WG_SIZE / 2; s > 0; s >>= 1) {
|
|
360
409
|
if (tid < s) local_o_comp[tid] += local_o_comp[tid + s];
|
|
361
410
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
@@ -365,7 +414,7 @@ __kernel void flash_attn_f32_q1(
|
|
|
365
414
|
}
|
|
366
415
|
}
|
|
367
416
|
} else if (tid == 0) {
|
|
368
|
-
|
|
417
|
+
FA_UNROLL
|
|
369
418
|
for (int i = 0; i < DV_VEC; ++i) o_row[i] = (DATA_TYPE4)(0.0f);
|
|
370
419
|
}
|
|
371
420
|
}
|