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
|
@@ -368,5 +368,12 @@ bool ggml_cuda_should_use_mmq(enum ggml_type type, int cc, int64_t ne11, int64_t
|
|
|
368
368
|
return true;
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
// gfx900 (Vega 10) lacks native dp4a, loses to dequant + hipBLAS
|
|
372
|
+
// for dense matrices; keep MMQ only for MoE, where the
|
|
373
|
+
// hipBLAS path is much slower.
|
|
374
|
+
if (cc == GGML_CUDA_CC_VEGA) {
|
|
375
|
+
return n_experts > 0;
|
|
376
|
+
}
|
|
377
|
+
|
|
371
378
|
return (!GGML_CUDA_CC_IS_CDNA(cc)) || ne11 < MMQ_DP4A_MAX_BATCH_SIZE;
|
|
372
379
|
}
|
|
@@ -278,6 +278,9 @@ int get_mmvq_mmid_max_batch(ggml_type type, int cc) {
|
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
bool ggml_cuda_should_use_mmvq(enum ggml_type type, int cc, int64_t ne11) {
|
|
281
|
+
if (!ggml_is_quantized(type)) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
281
284
|
if (GGML_CUDA_CC_IS_CDNA(cc)) {
|
|
282
285
|
if (GGML_CUDA_CC_IS_CDNA1(cc)) {
|
|
283
286
|
switch (type) {
|
|
@@ -518,9 +521,13 @@ static __global__ void mul_mat_vec_q(
|
|
|
518
521
|
bool use_gate = false;
|
|
519
522
|
bool use_bias = false;
|
|
520
523
|
bool use_gate_bias = false;
|
|
524
|
+
bool use_scale = false;
|
|
525
|
+
bool use_gate_scale = false;
|
|
521
526
|
[[maybe_unused]] const void * vgate = nullptr;
|
|
522
527
|
const float * x_bias = nullptr;
|
|
523
528
|
const float * gate_bias = nullptr;
|
|
529
|
+
const float * x_scale = nullptr;
|
|
530
|
+
const float * gate_scale = nullptr;
|
|
524
531
|
ggml_glu_op active_glu;
|
|
525
532
|
|
|
526
533
|
if constexpr (has_fusion) {
|
|
@@ -531,34 +538,47 @@ static __global__ void mul_mat_vec_q(
|
|
|
531
538
|
x_bias = (const float *) fusion.x_bias;
|
|
532
539
|
gate_bias = (const float *) fusion.gate_bias;
|
|
533
540
|
active_glu = fusion.glu_op;
|
|
541
|
+
if constexpr (type == GGML_TYPE_NVFP4) {
|
|
542
|
+
use_scale = fusion.x_scale != nullptr;
|
|
543
|
+
use_gate_scale = fusion.gate_scale != nullptr && use_gate;
|
|
544
|
+
x_scale = (const float *) fusion.x_scale;
|
|
545
|
+
gate_scale = (const float *) fusion.gate_scale;
|
|
546
|
+
}
|
|
534
547
|
}
|
|
535
548
|
|
|
536
549
|
|
|
537
550
|
[[maybe_unused]] float x_biases[ncols_dst] = { 0.0f };
|
|
538
551
|
[[maybe_unused]] float gate_biases[ncols_dst] = { 0.0f };
|
|
552
|
+
[[maybe_unused]] float x_scales = 1.0f;
|
|
553
|
+
[[maybe_unused]] float gate_scales = 1.0f;
|
|
539
554
|
if constexpr (has_fusion) {
|
|
555
|
+
// 1. Hide latency by prefetching bias, gates and scales here
|
|
556
|
+
// 2. load only on threads that won't die after partial sum calculation
|
|
540
557
|
const uint32_t channel_bias = ids ? channel_x : channel_dst;
|
|
541
|
-
if (
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
if (threadIdx.x < rows_per_cuda_block && threadIdx.y == 0 &&
|
|
546
|
-
(rows_per_cuda_block == 1 || uint32_t(row0 + threadIdx.x) < stride_col_dst)) {
|
|
558
|
+
if (threadIdx.x < rows_per_cuda_block && threadIdx.y == 0 &&
|
|
559
|
+
(rows_per_cuda_block == 1 || uint32_t(row0 + threadIdx.x) < stride_col_dst)) {
|
|
560
|
+
if (use_bias) {
|
|
561
|
+
x_bias = x_bias + sample_dst * stride_sample_dst + channel_bias * stride_channel_dst + row0;
|
|
547
562
|
#pragma unroll
|
|
548
563
|
for (int j = 0; j < ncols_dst; ++j) {
|
|
549
564
|
x_biases[j] = x_bias[j * stride_col_dst + threadIdx.x];
|
|
550
565
|
}
|
|
551
566
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
gate_bias = gate_bias + sample_dst*stride_sample_dst + channel_bias*stride_channel_dst + row0;
|
|
555
|
-
if (threadIdx.x < rows_per_cuda_block && threadIdx.y == 0 &&
|
|
556
|
-
(rows_per_cuda_block == 1 || uint32_t(row0 + threadIdx.x) < stride_col_dst)) {
|
|
567
|
+
if (use_gate_bias) {
|
|
568
|
+
gate_bias = gate_bias + sample_dst * stride_sample_dst + channel_bias * stride_channel_dst + row0;
|
|
557
569
|
#pragma unroll
|
|
558
570
|
for (int j = 0; j < ncols_dst; ++j) {
|
|
559
571
|
gate_biases[j] = gate_bias[j * stride_col_dst + threadIdx.x];
|
|
560
572
|
}
|
|
561
573
|
}
|
|
574
|
+
if constexpr (type == GGML_TYPE_NVFP4) {
|
|
575
|
+
if (use_scale) {
|
|
576
|
+
x_scales = x_scale[ids ? channel_x : 0];
|
|
577
|
+
}
|
|
578
|
+
if (use_gate_scale) {
|
|
579
|
+
gate_scales = gate_scale[ids ? channel_x : 0];
|
|
580
|
+
}
|
|
581
|
+
}
|
|
562
582
|
}
|
|
563
583
|
}
|
|
564
584
|
|
|
@@ -635,42 +655,46 @@ static __global__ void mul_mat_vec_q(
|
|
|
635
655
|
tmp_gate[j][i] = warp_reduce_sum<warp_size>(tmp_gate[j][i]);
|
|
636
656
|
}
|
|
637
657
|
}
|
|
638
|
-
}
|
|
639
658
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
659
|
+
if (threadIdx.x == i && (rows_per_cuda_block == 1 || uint32_t(row0 + i) < stride_col_dst)) {
|
|
660
|
+
float result = tmp[j][i];
|
|
661
|
+
if constexpr (has_fusion) {
|
|
662
|
+
if constexpr (type == GGML_TYPE_NVFP4) {
|
|
663
|
+
result *= x_scales;
|
|
664
|
+
}
|
|
644
665
|
result += x_biases[j];
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
666
|
+
if (use_gate) {
|
|
667
|
+
float gate_value = tmp_gate[j][i];
|
|
668
|
+
if constexpr (type == GGML_TYPE_NVFP4) {
|
|
669
|
+
gate_value *= gate_scales;
|
|
670
|
+
}
|
|
649
671
|
gate_value += gate_biases[j];
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
672
|
+
switch (active_glu) {
|
|
673
|
+
case GGML_GLU_OP_SWIGLU:
|
|
674
|
+
result *= ggml_cuda_op_silu_single(gate_value);
|
|
675
|
+
break;
|
|
676
|
+
case GGML_GLU_OP_GEGLU:
|
|
677
|
+
result *= ggml_cuda_op_gelu_single(gate_value);
|
|
678
|
+
break;
|
|
679
|
+
case GGML_GLU_OP_SWIGLU_OAI:
|
|
680
|
+
result = ggml_cuda_op_swiglu_oai_single(gate_value, result);
|
|
681
|
+
break;
|
|
682
|
+
default:
|
|
683
|
+
result = result * gate_value;
|
|
684
|
+
break;
|
|
661
685
|
}
|
|
662
|
-
default:
|
|
663
|
-
result = result * gate_value;
|
|
664
|
-
break;
|
|
665
686
|
}
|
|
666
687
|
}
|
|
688
|
+
dst[j*stride_col_dst + i] = result;
|
|
667
689
|
}
|
|
668
|
-
dst[j*stride_col_dst + threadIdx.x] = result;
|
|
669
690
|
}
|
|
670
691
|
}
|
|
671
692
|
|
|
672
693
|
if constexpr (!has_fusion) {
|
|
673
|
-
GGML_UNUSED_VARS(use_gate, use_bias, use_gate_bias, active_glu, gate_bias, x_bias, tmp_gate);
|
|
694
|
+
GGML_UNUSED_VARS(use_gate, use_bias, use_gate_bias, use_scale, use_gate_scale, active_glu, gate_bias, x_bias, x_scale, gate_scale, tmp_gate);
|
|
695
|
+
}
|
|
696
|
+
if constexpr (type != GGML_TYPE_NVFP4) {
|
|
697
|
+
GGML_UNUSED_VARS(use_scale, use_gate_scale, x_scale, gate_scale, x_scales, gate_scales);
|
|
674
698
|
}
|
|
675
699
|
}
|
|
676
700
|
|
|
@@ -766,7 +790,8 @@ static void mul_mat_vec_q_switch_fusion(
|
|
|
766
790
|
const dim3 & block_nums, const dim3 & block_dims, const int nbytes_shared,
|
|
767
791
|
const uint32_t ids_stride, cudaStream_t stream) {
|
|
768
792
|
|
|
769
|
-
const bool has_fusion = fusion.gate != nullptr || fusion.x_bias != nullptr || fusion.gate_bias != nullptr
|
|
793
|
+
const bool has_fusion = fusion.gate != nullptr || fusion.x_bias != nullptr || fusion.gate_bias != nullptr ||
|
|
794
|
+
fusion.x_scale != nullptr || fusion.gate_scale != nullptr;
|
|
770
795
|
if constexpr (c_ncols_dst == 1) {
|
|
771
796
|
if (has_fusion) {
|
|
772
797
|
const ggml_cuda_kernel_launch_params launch_params = ggml_cuda_kernel_launch_params(block_nums, block_dims, nbytes_shared, stream);
|
|
@@ -831,7 +856,6 @@ static void mul_mat_vec_q_switch_ncols_dst(
|
|
|
831
856
|
const int warp_size = ggml_cuda_info().devices[device].warp_size;
|
|
832
857
|
const mmvq_parameter_table_id table_id = get_device_table_id(cc);
|
|
833
858
|
|
|
834
|
-
const bool has_fusion = fusion.gate != nullptr || fusion.x_bias != nullptr || fusion.gate_bias != nullptr;
|
|
835
859
|
const bool has_ids = ids != nullptr;
|
|
836
860
|
|
|
837
861
|
const auto should_use_small_k = [&](int c_ncols_dst) {
|
|
@@ -970,8 +994,6 @@ static void mul_mat_vec_q_switch_ncols_dst(
|
|
|
970
994
|
GGML_ABORT("fatal error");
|
|
971
995
|
break;
|
|
972
996
|
}
|
|
973
|
-
|
|
974
|
-
GGML_UNUSED(has_fusion);
|
|
975
997
|
}
|
|
976
998
|
static void mul_mat_vec_q_switch_type(
|
|
977
999
|
const void * vx, const ggml_type type_x, const void * vy, const int32_t * ids, const ggml_cuda_mm_fusion_args_device fusion, float * dst,
|
|
@@ -1151,6 +1173,9 @@ void ggml_cuda_mul_mat_vec_q(
|
|
|
1151
1173
|
if (fusion) {
|
|
1152
1174
|
GGML_ASSERT( !ids || dst->ne[2] == 1);
|
|
1153
1175
|
GGML_ASSERT( ids || dst->ne[1] == 1);
|
|
1176
|
+
// Scale fusion is only allowed for NVFP4 currently as the cost of checking this at run-time in the prologue is
|
|
1177
|
+
// non-negligible for some models such as gpt-oss-20b
|
|
1178
|
+
GGML_ASSERT((fusion->x_scale == nullptr && fusion->gate_scale == nullptr) || src0->type == GGML_TYPE_NVFP4);
|
|
1154
1179
|
|
|
1155
1180
|
if (fusion->x_bias) {
|
|
1156
1181
|
GGML_ASSERT(fusion->x_bias->type == GGML_TYPE_F32);
|
|
@@ -1168,6 +1193,18 @@ void ggml_cuda_mul_mat_vec_q(
|
|
|
1168
1193
|
GGML_ASSERT(!ids || fusion->gate_bias->ne[1] == src0->ne[2]);
|
|
1169
1194
|
fusion_local.gate_bias = fusion->gate_bias->data;
|
|
1170
1195
|
}
|
|
1196
|
+
if (fusion->x_scale) {
|
|
1197
|
+
GGML_ASSERT(fusion->x_scale->type == GGML_TYPE_F32);
|
|
1198
|
+
GGML_ASSERT(ggml_is_contiguous(fusion->x_scale));
|
|
1199
|
+
GGML_ASSERT(ggml_nelements(fusion->x_scale) == (ids ? src0->ne[2] : 1));
|
|
1200
|
+
fusion_local.x_scale = fusion->x_scale->data;
|
|
1201
|
+
}
|
|
1202
|
+
if (fusion->gate_scale) {
|
|
1203
|
+
GGML_ASSERT(fusion->gate_scale->type == GGML_TYPE_F32);
|
|
1204
|
+
GGML_ASSERT(ggml_is_contiguous(fusion->gate_scale));
|
|
1205
|
+
GGML_ASSERT(ggml_nelements(fusion->gate_scale) == (ids ? src0->ne[2] : 1));
|
|
1206
|
+
fusion_local.gate_scale = fusion->gate_scale->data;
|
|
1207
|
+
}
|
|
1171
1208
|
fusion_local.glu_op = fusion->glu_op;
|
|
1172
1209
|
}
|
|
1173
1210
|
|
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
#include <cstdint>
|
|
4
4
|
|
|
5
|
+
static __global__ void k_compute_out_prod_ptrs(
|
|
6
|
+
const float * src0_d, const float * src1_d, float * dst_d,
|
|
7
|
+
const float ** ptrs_a, const float ** ptrs_b, float ** ptrs_c,
|
|
8
|
+
const int64_t ne2, const int64_t ne3,
|
|
9
|
+
const int64_t dps2, const int64_t dps3,
|
|
10
|
+
const size_t s02, const size_t s03,
|
|
11
|
+
const size_t s12, const size_t s13,
|
|
12
|
+
const size_t s2, const size_t s3) {
|
|
13
|
+
const int64_t i2 = blockIdx.x*blockDim.x + threadIdx.x;
|
|
14
|
+
const int64_t i3 = blockIdx.y*blockDim.y + threadIdx.y;
|
|
15
|
+
|
|
16
|
+
if (i2 >= ne2 || i3 >= ne3) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const int64_t idx = i3*ne2 + i2;
|
|
21
|
+
|
|
22
|
+
ptrs_a[idx] = src0_d + (i3/dps3)*s03 + (i2/dps2)*s02;
|
|
23
|
+
ptrs_b[idx] = src1_d + i3 *s13 + i2 *s12;
|
|
24
|
+
ptrs_c[idx] = dst_d + i3 *s3 + i2 *s2;
|
|
25
|
+
}
|
|
26
|
+
|
|
5
27
|
void ggml_cuda_out_prod(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
6
28
|
const ggml_tensor * src0 = dst->src[0];
|
|
7
29
|
const ggml_tensor * src1 = dst->src[1];
|
|
@@ -67,18 +89,39 @@ void ggml_cuda_out_prod(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
|
67
89
|
&beta, dst_d + i3 *s3, ldc, s2,
|
|
68
90
|
batch_count));
|
|
69
91
|
}
|
|
92
|
+
} else if (ne2 > 1 || ne3 > 1) {
|
|
93
|
+
// dps2 > 1 (src0 broadcast along dim 2 with non-uniform stride) or multiple GEMMs
|
|
94
|
+
// along dim 3: compute per-GEMM pointers on the device and use a single batched GEMM.
|
|
95
|
+
GGML_ASSERT(ne3 > 0);
|
|
96
|
+
GGML_ASSERT(ne2 <= (int64_t) std::numeric_limits<int>::max() / ne3);
|
|
97
|
+
const int batch_count = (int) (ne2 * ne3);
|
|
98
|
+
|
|
99
|
+
ggml_cuda_pool_alloc<const float *> ptrs_a(ctx.pool(), batch_count);
|
|
100
|
+
ggml_cuda_pool_alloc<const float *> ptrs_b(ctx.pool(), batch_count);
|
|
101
|
+
ggml_cuda_pool_alloc< float *> ptrs_c(ctx.pool(), batch_count);
|
|
102
|
+
|
|
103
|
+
const dim3 block_dims(16, 16);
|
|
104
|
+
const dim3 grid_dims((ne2 + block_dims.x - 1)/block_dims.x, (ne3 + block_dims.y - 1)/block_dims.y);
|
|
105
|
+
k_compute_out_prod_ptrs<<<grid_dims, block_dims, 0, stream>>>(
|
|
106
|
+
src0_d, src1_d, dst_d,
|
|
107
|
+
ptrs_a.get(), ptrs_b.get(), ptrs_c.get(),
|
|
108
|
+
ne2, ne3, dps2, dps3, s02, s03, s12, s13, s2, s3);
|
|
109
|
+
CUDA_CHECK(cudaGetLastError());
|
|
110
|
+
|
|
111
|
+
CUBLAS_CHECK(
|
|
112
|
+
cublasSgemmBatched(handle, CUBLAS_OP_N, src1_cublas_op,
|
|
113
|
+
ne0, ne1, ne01,
|
|
114
|
+
&alpha, ptrs_a.get(), lda,
|
|
115
|
+
ptrs_b.get(), ldb,
|
|
116
|
+
&beta, ptrs_c.get(), ldc,
|
|
117
|
+
batch_count));
|
|
70
118
|
} else {
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
&alpha, src0_d + (i3/dps3)*s03 + (i2/dps2)*s02, lda,
|
|
79
|
-
src1_d + i3 *s13 + i2 *s12, ldb,
|
|
80
|
-
&beta, dst_d + i3 *s3 + i2 *s2, ldc));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
119
|
+
// ne2 == 1 && ne3 == 1: single GEMM
|
|
120
|
+
CUBLAS_CHECK(
|
|
121
|
+
cublasSgemm(handle, CUBLAS_OP_N, src1_cublas_op,
|
|
122
|
+
ne0, ne1, ne01,
|
|
123
|
+
&alpha, src0_d, lda,
|
|
124
|
+
src1_d, ldb,
|
|
125
|
+
&beta, dst_d, ldc));
|
|
83
126
|
}
|
|
84
127
|
}
|
|
@@ -322,17 +322,77 @@ static void set_rows_cuda(ggml_backend_cuda_context & ctx, const ggml_tensor * s
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
template<>
|
|
326
|
+
void set_rows_cuda<half, int32_t>(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst) {
|
|
327
|
+
const half * src0_d = (const half *)src0->data;
|
|
328
|
+
const int32_t * src1_d = (const int32_t *)src1->data;
|
|
329
|
+
|
|
330
|
+
GGML_TENSOR_BINARY_OP_LOCALS
|
|
331
|
+
|
|
332
|
+
cudaStream_t stream = ctx.stream();
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
if (dst->type == GGML_TYPE_F16) {
|
|
336
|
+
set_rows_cuda(
|
|
337
|
+
src0_d, src1_d, (half*)dst->data,
|
|
338
|
+
ne00, ne01, ne02, ne03,
|
|
339
|
+
ne10, ne11, ne12, ne13,
|
|
340
|
+
nb01, nb02, nb03,
|
|
341
|
+
nb10, nb11, nb12,
|
|
342
|
+
nb1, nb2, nb3,
|
|
343
|
+
stream
|
|
344
|
+
);
|
|
345
|
+
} else {
|
|
346
|
+
GGML_ABORT("unsupported type %s", ggml_type_name(dst->type));
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
template<>
|
|
351
|
+
void set_rows_cuda<half, int64_t>(ggml_backend_cuda_context & ctx, const ggml_tensor * src0, const ggml_tensor * src1, ggml_tensor * dst) {
|
|
352
|
+
const half * src0_d = (const half *)src0->data;
|
|
353
|
+
const int64_t * src1_d = (const int64_t *)src1->data;
|
|
354
|
+
|
|
355
|
+
GGML_TENSOR_BINARY_OP_LOCALS
|
|
356
|
+
|
|
357
|
+
cudaStream_t stream = ctx.stream();
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
if (dst->type == GGML_TYPE_F16) {
|
|
361
|
+
set_rows_cuda(
|
|
362
|
+
src0_d, src1_d, (half*)dst->data,
|
|
363
|
+
ne00, ne01, ne02, ne03,
|
|
364
|
+
ne10, ne11, ne12, ne13,
|
|
365
|
+
nb01, nb02, nb03,
|
|
366
|
+
nb10, nb11, nb12,
|
|
367
|
+
nb1, nb2, nb3,
|
|
368
|
+
stream
|
|
369
|
+
);
|
|
370
|
+
} else {
|
|
371
|
+
GGML_ABORT("unsupported type %s", ggml_type_name(dst->type));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
325
375
|
|
|
326
376
|
void ggml_cuda_op_set_rows(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
327
377
|
const ggml_tensor * src0 = dst->src[0];
|
|
328
378
|
const ggml_tensor * src1 = dst->src[1];
|
|
329
379
|
|
|
330
|
-
GGML_ASSERT(src0->type == GGML_TYPE_F32);
|
|
380
|
+
GGML_ASSERT(src0->type == GGML_TYPE_F32 || (src0->type == GGML_TYPE_F16 && dst->type == GGML_TYPE_F16));
|
|
331
381
|
GGML_ASSERT(src1->type == GGML_TYPE_I64 || src1->type == GGML_TYPE_I32);
|
|
332
382
|
|
|
333
|
-
if (
|
|
334
|
-
|
|
383
|
+
if (src0->type == GGML_TYPE_F32) {
|
|
384
|
+
if (src1->type == GGML_TYPE_I64) {
|
|
385
|
+
set_rows_cuda<float, int64_t>(ctx, src0, src1, dst);
|
|
386
|
+
} else {
|
|
387
|
+
set_rows_cuda<float, int32_t>(ctx, src0, src1, dst);
|
|
388
|
+
}
|
|
389
|
+
} else if (src0->type == GGML_TYPE_F16) {
|
|
390
|
+
if (src1->type == GGML_TYPE_I64) {
|
|
391
|
+
set_rows_cuda<half, int64_t>(ctx, src0, src1, dst);
|
|
392
|
+
} else {
|
|
393
|
+
set_rows_cuda<half, int32_t>(ctx, src0, src1, dst);
|
|
394
|
+
}
|
|
335
395
|
} else {
|
|
336
|
-
|
|
396
|
+
GGML_ABORT("unsupported type %s", ggml_type_name(src0->type));
|
|
337
397
|
}
|
|
338
398
|
}
|
|
@@ -312,6 +312,10 @@ static void launch_topk_moe_cuda(ggml_backend_cuda_context & ctx,
|
|
|
312
312
|
ggml_cuda_kernel_launch(topk_moe_cuda<256, has_bias>, launch_params,
|
|
313
313
|
logits, weights, ids, bias, n_rows, n_expert_used, clamp_val, scale_val, config);
|
|
314
314
|
break;
|
|
315
|
+
case 288: // StepFun 3.7
|
|
316
|
+
ggml_cuda_kernel_launch(topk_moe_cuda<288, has_bias>, launch_params,
|
|
317
|
+
logits, weights, ids, bias, n_rows, n_expert_used, clamp_val, scale_val, config);
|
|
318
|
+
break;
|
|
315
319
|
case 512:
|
|
316
320
|
ggml_cuda_kernel_launch(topk_moe_cuda<512, has_bias>, launch_params,
|
|
317
321
|
logits, weights, ids, bias, n_rows, n_expert_used, clamp_val, scale_val, config);
|
|
@@ -377,8 +381,10 @@ bool ggml_cuda_should_use_topk_moe(const ggml_tensor * gating_op,
|
|
|
377
381
|
const ggml_tensor * weights,
|
|
378
382
|
const ggml_tensor * logits,
|
|
379
383
|
const ggml_tensor * ids) {
|
|
384
|
+
// must match an instantiation of launch_topk_moe_cuda: a power of 2 up to 512,
|
|
385
|
+
// or one of the non-power-of-2 expert counts of supported models
|
|
380
386
|
const int n_expert = ids->nb[1] / ids->nb[0];
|
|
381
|
-
if (((n_expert & (n_expert - 1)) != 0 || n_expert > 512) && n_expert != 576) {
|
|
387
|
+
if (((n_expert & (n_expert - 1)) != 0 || n_expert > 512) && n_expert != 288 && n_expert != 576) {
|
|
382
388
|
return false;
|
|
383
389
|
}
|
|
384
390
|
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
#define cublasSetMathMode(handle, mode) CUBLAS_STATUS_SUCCESS
|
|
49
49
|
#define cublasSetStream hipblasSetStream
|
|
50
50
|
#define cublasSgemm hipblasSgemm
|
|
51
|
+
#define cublasSgemmBatched hipblasSgemmBatched
|
|
51
52
|
#define cublasSgemmStridedBatched hipblasSgemmStridedBatched
|
|
52
53
|
#define cublasStatus_t hipblasStatus_t
|
|
53
54
|
#define cublasOperation_t hipblasOperation_t
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
#define cublasSetMathMode mublasSetMathMode
|
|
33
33
|
#define cublasSetStream mublasSetStream
|
|
34
34
|
#define cublasSgemm mublasSgemm
|
|
35
|
+
#define cublasSgemmBatched mublasSgemmBatched
|
|
35
36
|
#define cublasSgemmStridedBatched mublasSgemmStridedBatched
|
|
36
37
|
#define cublasStatus_t mublasStatus_t
|
|
37
38
|
#define cublasOperation_t mublasOperation_t
|
|
@@ -23,9 +23,7 @@ include(${HEXAGON_SDK_ROOT}/build/cmake/hexagon_fun.cmake)
|
|
|
23
23
|
include(ExternalProject)
|
|
24
24
|
|
|
25
25
|
option(GGML_HEXAGON_HTP_DEBUG "ggml-hexagon: enable HTP debug output" OFF)
|
|
26
|
-
option(GGML_HEXAGON_FA_EXP2_HF "ggml-hexagon: use FP16 exp2 polynomial in FA softmax instead of F32 exp round-trip" OFF)
|
|
27
26
|
set(GGML_HEXAGON_HTP_CERT "$ENV{HEXAGON_HTP_CERT}" CACHE PATH "ggml-hexagon: enable HTP library signing using certificate")
|
|
28
|
-
set(GGML_HEXAGON_FP32_QUANTIZE_GROUP_SIZE 128 CACHE STRING "ggml-hexagon: quantize group size (32, 64, or 128)")
|
|
29
27
|
|
|
30
28
|
add_library(htp_iface OBJECT
|
|
31
29
|
${CMAKE_CURRENT_BINARY_DIR}/htp_iface_stub.c)
|
|
@@ -72,15 +70,12 @@ function(build_htp_skel V)
|
|
|
72
70
|
-DHEXAGON_SDK_ROOT=${HEXAGON_SDK_ROOT}
|
|
73
71
|
-DHEXAGON_TOOLS_ROOT=${HEXAGON_TOOLS_ROOT}
|
|
74
72
|
-DHEXAGON_HTP_DEBUG=${GGML_HEXAGON_HTP_DEBUG}
|
|
75
|
-
-DGGML_HEXAGON_FP32_QUANTIZE_GROUP_SIZE=${GGML_HEXAGON_FP32_QUANTIZE_GROUP_SIZE}
|
|
76
73
|
-DDSP_VERSION=${V}
|
|
77
74
|
-DPREBUILT_LIB_DIR="toolv19_${V}")
|
|
78
75
|
list(APPEND HTP_SKELS ${CMAKE_CURRENT_BINARY_DIR}/libggml-htp-${V}.so)
|
|
79
76
|
set(HTP_SKELS ${HTP_SKELS} PARENT_SCOPE)
|
|
80
77
|
endfunction()
|
|
81
78
|
|
|
82
|
-
build_htp_skel(v68)
|
|
83
|
-
build_htp_skel(v69)
|
|
84
79
|
build_htp_skel(v73)
|
|
85
80
|
build_htp_skel(v75)
|
|
86
81
|
build_htp_skel(v79)
|