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
|
@@ -662,13 +662,12 @@ static void reorder_mul_mat_vec_q4_0_q8_1_sycl(const void * vx, const void * vy,
|
|
|
662
662
|
GGML_ASSERT(ncols % QK4_0 == 0);
|
|
663
663
|
// Round up to a whole number of subgroup-sized workgroups; out-of-range rows are skipped inside the kernel.
|
|
664
664
|
constexpr size_t num_subgroups = WARP_SIZE;
|
|
665
|
-
const int
|
|
666
|
-
|
|
667
|
-
const sycl::range<3>
|
|
668
|
-
const sycl::range<3> workgroup_size(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
665
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
666
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
667
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
669
668
|
|
|
670
669
|
stream->submit([&](sycl::handler & cgh) {
|
|
671
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
670
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
672
671
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
673
672
|
mul_mat_vec_q_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q4_0>>(vx, vy, dst, ncols, nrows,
|
|
674
673
|
nd_item);
|
|
@@ -683,13 +682,13 @@ static void reorder_mul_mat_vec_q4_0_q8_1_sycl_ncols(
|
|
|
683
682
|
const int stride_col_y_bytes, const int stride_col_dst,
|
|
684
683
|
dpct::queue_ptr stream) {
|
|
685
684
|
GGML_ASSERT(ncols % QK4_0 == 0);
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
const sycl::range<3>
|
|
690
|
-
|
|
685
|
+
constexpr size_t num_subgroups = WARP_SIZE;
|
|
686
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
687
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
688
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
689
|
+
|
|
691
690
|
stream->submit([&](sycl::handler & cgh) {
|
|
692
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
691
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
693
692
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
694
693
|
mul_mat_vec_q_reorder_ncols<reorder_vec_dot_q_sycl<GGML_TYPE_Q4_0>, ncols_dst>(
|
|
695
694
|
vx, vy, dst, ncols, nrows, stride_col_y_bytes, stride_col_dst, nd_item);
|
|
@@ -1080,13 +1079,12 @@ static void reorder_mul_mat_vec_q8_0_q8_1_sycl(const void * vx, const void * vy,
|
|
|
1080
1079
|
GGML_ASSERT(ncols % QK8_0 == 0);
|
|
1081
1080
|
// Round up to a whole number of subgroup-sized workgroups; out-of-range rows are skipped inside the kernel.
|
|
1082
1081
|
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1083
|
-
const int
|
|
1084
|
-
|
|
1085
|
-
const sycl::range<3>
|
|
1086
|
-
const sycl::range<3> workgroup_size(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1082
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1083
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1084
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1087
1085
|
|
|
1088
1086
|
stream->submit([&](sycl::handler & cgh) {
|
|
1089
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1087
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1090
1088
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1091
1089
|
mul_mat_vec_q_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q8_0>>(vx, vy, dst, ncols, nrows,
|
|
1092
1090
|
nd_item);
|
|
@@ -1101,13 +1099,13 @@ static void reorder_mul_mat_vec_q8_0_q8_1_sycl_ncols(
|
|
|
1101
1099
|
const int stride_col_y_bytes, const int stride_col_dst,
|
|
1102
1100
|
dpct::queue_ptr stream) {
|
|
1103
1101
|
GGML_ASSERT(ncols % QK8_0 == 0);
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
const sycl::range<3>
|
|
1108
|
-
|
|
1102
|
+
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1103
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1104
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1105
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1106
|
+
|
|
1109
1107
|
stream->submit([&](sycl::handler & cgh) {
|
|
1110
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1108
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1111
1109
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1112
1110
|
mul_mat_vec_q_reorder_ncols<reorder_vec_dot_q_sycl<GGML_TYPE_Q8_0>, ncols_dst>(
|
|
1113
1111
|
vx, vy, dst, ncols, nrows, stride_col_y_bytes, stride_col_dst, nd_item);
|
|
@@ -1196,6 +1194,66 @@ static void mul_mat_vec_q8_0_q8_1_sycl_switch_ncols(
|
|
|
1196
1194
|
}
|
|
1197
1195
|
}
|
|
1198
1196
|
|
|
1197
|
+
static void mul_mat_vec_q1_0_q8_1_sycl(const void * vx, const void * vy,
|
|
1198
|
+
float * dst, const int ncols,
|
|
1199
|
+
const int nrows,
|
|
1200
|
+
dpct::queue_ptr stream) {
|
|
1201
|
+
GGML_ASSERT(ncols % QK1_0 == 0);
|
|
1202
|
+
const int block_num_y = (nrows + GGML_SYCL_MMV_Y - 1) / GGML_SYCL_MMV_Y;
|
|
1203
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1204
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, WARP_SIZE);
|
|
1205
|
+
|
|
1206
|
+
stream->submit([&](sycl::handler & cgh) {
|
|
1207
|
+
cgh.parallel_for(
|
|
1208
|
+
sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1209
|
+
[=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1210
|
+
mul_mat_vec_q<QK1_0, QI1_0, block_q1_0,
|
|
1211
|
+
VDR_Q1_0_Q8_1_MMVQ, vec_dot_q1_0_q8_1>(
|
|
1212
|
+
vx, vy, dst, ncols, nrows, item_ct1);
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
template <int ncols_dst>
|
|
1218
|
+
static void mul_mat_vec_q1_0_q8_1_sycl_ncols(
|
|
1219
|
+
const void * vx, const void * vy, float * dst,
|
|
1220
|
+
const int ncols, const int nrows,
|
|
1221
|
+
const int stride_col_y, const int stride_col_dst,
|
|
1222
|
+
dpct::queue_ptr stream) {
|
|
1223
|
+
GGML_ASSERT(ncols % QK1_0 == 0);
|
|
1224
|
+
const int block_num_y = (nrows + GGML_SYCL_MMV_Y - 1) / GGML_SYCL_MMV_Y;
|
|
1225
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1226
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, WARP_SIZE);
|
|
1227
|
+
|
|
1228
|
+
stream->submit([&](sycl::handler & cgh) {
|
|
1229
|
+
cgh.parallel_for(
|
|
1230
|
+
sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1231
|
+
[=](sycl::nd_item<3> item_ct1) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1232
|
+
mul_mat_vec_q_ncols<QK1_0, QI1_0, block_q1_0,
|
|
1233
|
+
VDR_Q1_0_Q8_1_MMVQ, vec_dot_q1_0_q8_1, ncols_dst>(
|
|
1234
|
+
vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, item_ct1);
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
static void mul_mat_vec_q1_0_q8_1_sycl_switch_ncols(
|
|
1240
|
+
const void * vx, const void * vy, float * dst,
|
|
1241
|
+
const int ncols, const int nrows, const int ncols_dst,
|
|
1242
|
+
const int stride_col_y, const int stride_col_dst,
|
|
1243
|
+
dpct::queue_ptr stream) {
|
|
1244
|
+
switch (ncols_dst) {
|
|
1245
|
+
case 1: mul_mat_vec_q1_0_q8_1_sycl(vx, vy, dst, ncols, nrows, stream); break;
|
|
1246
|
+
case 2: mul_mat_vec_q1_0_q8_1_sycl_ncols<2>(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break;
|
|
1247
|
+
case 3: mul_mat_vec_q1_0_q8_1_sycl_ncols<3>(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break;
|
|
1248
|
+
case 4: mul_mat_vec_q1_0_q8_1_sycl_ncols<4>(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break;
|
|
1249
|
+
case 5: mul_mat_vec_q1_0_q8_1_sycl_ncols<5>(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break;
|
|
1250
|
+
case 6: mul_mat_vec_q1_0_q8_1_sycl_ncols<6>(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break;
|
|
1251
|
+
case 7: mul_mat_vec_q1_0_q8_1_sycl_ncols<7>(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break;
|
|
1252
|
+
case 8: mul_mat_vec_q1_0_q8_1_sycl_ncols<8>(vx, vy, dst, ncols, nrows, stride_col_y, stride_col_dst, stream); break;
|
|
1253
|
+
default: GGML_ABORT("unsupported ncols_dst=%d for Q1_0 multi-col MMVQ", ncols_dst);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1199
1257
|
static void mul_mat_vec_q2_K_q8_1_sycl(const void *vx, const void *vy,
|
|
1200
1258
|
float *dst, const int ncols,
|
|
1201
1259
|
const int nrows,
|
|
@@ -1289,13 +1347,12 @@ static void reorder_mul_mat_vec_q3_k_q8_1_sycl(const void * vx, const void * vy,
|
|
|
1289
1347
|
|
|
1290
1348
|
// Round up to a whole number of subgroup-sized workgroups; out-of-range rows are skipped inside the kernel.
|
|
1291
1349
|
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1292
|
-
const int
|
|
1293
|
-
|
|
1294
|
-
const sycl::range<3>
|
|
1295
|
-
const sycl::range<3> workgroup_size(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1350
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1351
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1352
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1296
1353
|
|
|
1297
1354
|
stream->submit([&](sycl::handler & cgh) {
|
|
1298
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1355
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1299
1356
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1300
1357
|
mul_mat_vec_q_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q3_K>>(vx, vy, dst, ncols, nrows,
|
|
1301
1358
|
nd_item);
|
|
@@ -1310,13 +1367,13 @@ static void reorder_mul_mat_vec_q3_k_q8_1_sycl_ncols(
|
|
|
1310
1367
|
const int stride_col_y_bytes, const int stride_col_dst,
|
|
1311
1368
|
dpct::queue_ptr stream) {
|
|
1312
1369
|
GGML_ASSERT(ncols % QK_K == 0);
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
const sycl::range<3>
|
|
1317
|
-
|
|
1370
|
+
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1371
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1372
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1373
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1374
|
+
|
|
1318
1375
|
stream->submit([&](sycl::handler & cgh) {
|
|
1319
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1376
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1320
1377
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1321
1378
|
mul_mat_vec_q_reorder_ncols<reorder_vec_dot_q_sycl<GGML_TYPE_Q3_K>, ncols_dst>(
|
|
1322
1379
|
vx, vy, dst, ncols, nrows, stride_col_y_bytes, stride_col_dst, nd_item);
|
|
@@ -1457,13 +1514,12 @@ static void reorder_mul_mat_vec_q4_k_q8_1_sycl(const void * vx, const void * vy,
|
|
|
1457
1514
|
|
|
1458
1515
|
// Round up to a whole number of subgroup-sized workgroups; out-of-range rows are skipped inside the kernel.
|
|
1459
1516
|
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1460
|
-
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups)
|
|
1461
|
-
|
|
1462
|
-
const sycl::range<3>
|
|
1463
|
-
const sycl::range<3> workgroup_size(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1517
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1518
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1519
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1464
1520
|
|
|
1465
1521
|
stream->submit([&](sycl::handler & cgh) {
|
|
1466
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1522
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1467
1523
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1468
1524
|
mul_mat_vec_q_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q4_K>>(vx, vy, dst, ncols,
|
|
1469
1525
|
nrows, nd_item);
|
|
@@ -1478,13 +1534,14 @@ static void reorder_mul_mat_vec_q4_k_q8_1_sycl_ncols(
|
|
|
1478
1534
|
const int stride_col_y_bytes, const int stride_col_dst,
|
|
1479
1535
|
dpct::queue_ptr stream) {
|
|
1480
1536
|
GGML_ASSERT(ncols % QK_K == 0);
|
|
1481
|
-
|
|
1482
|
-
constexpr size_t num_subgroups =
|
|
1483
|
-
|
|
1484
|
-
const sycl::range<3>
|
|
1485
|
-
const sycl::range<3>
|
|
1537
|
+
|
|
1538
|
+
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1539
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1540
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1541
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1542
|
+
|
|
1486
1543
|
stream->submit([&](sycl::handler & cgh) {
|
|
1487
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1544
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1488
1545
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1489
1546
|
mul_mat_vec_q_reorder_ncols<reorder_vec_dot_q_sycl<GGML_TYPE_Q4_K>, ncols_dst>(
|
|
1490
1547
|
vx, vy, dst, ncols, nrows, stride_col_y_bytes, stride_col_dst, nd_item);
|
|
@@ -1583,15 +1640,13 @@ static void reorder_mul_mat_vec_q5_k_q8_1_sycl(const void * vx, const void * vy,
|
|
|
1583
1640
|
const int nrows, dpct::queue_ptr stream) {
|
|
1584
1641
|
GGML_ASSERT(ncols % QK_K == 0);
|
|
1585
1642
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
const sycl::range<3> global_size(1, GGML_SYCL_MMV_Y, block_num_y * WARP_SIZE);
|
|
1591
|
-
const sycl::range<3> workgroup_size(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1643
|
+
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1644
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1645
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1646
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1592
1647
|
|
|
1593
1648
|
stream->submit([&](sycl::handler & cgh) {
|
|
1594
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1649
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1595
1650
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1596
1651
|
mul_mat_vec_q_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q5_K>>(vx, vy, dst, ncols,
|
|
1597
1652
|
nrows, nd_item);
|
|
@@ -1606,13 +1661,14 @@ static void reorder_mul_mat_vec_q5_k_q8_1_sycl_ncols(
|
|
|
1606
1661
|
const int stride_col_y_bytes, const int stride_col_dst,
|
|
1607
1662
|
dpct::queue_ptr stream) {
|
|
1608
1663
|
GGML_ASSERT(ncols % QK_K == 0);
|
|
1609
|
-
|
|
1610
|
-
constexpr size_t num_subgroups =
|
|
1611
|
-
|
|
1612
|
-
const sycl::range<3>
|
|
1613
|
-
const sycl::range<3>
|
|
1664
|
+
|
|
1665
|
+
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1666
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1667
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1668
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1669
|
+
|
|
1614
1670
|
stream->submit([&](sycl::handler & cgh) {
|
|
1615
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1671
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1616
1672
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1617
1673
|
mul_mat_vec_q_reorder_ncols<reorder_vec_dot_q_sycl<GGML_TYPE_Q5_K>, ncols_dst>(
|
|
1618
1674
|
vx, vy, dst, ncols, nrows, stride_col_y_bytes, stride_col_dst, nd_item);
|
|
@@ -1643,13 +1699,13 @@ static void reorder_mul_mat_vec_q6_k_q8_1_sycl(const void * vx, const void * vy,
|
|
|
1643
1699
|
GGML_ASSERT(ncols % QK_K == 0);
|
|
1644
1700
|
// Round up to a whole number of subgroup-sized workgroups; out-of-range rows are skipped inside the kernel.
|
|
1645
1701
|
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1646
|
-
const int
|
|
1702
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1703
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1704
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1647
1705
|
|
|
1648
|
-
const sycl::range<3> global_size(1, GGML_SYCL_MMV_Y, block_num_y * WARP_SIZE);
|
|
1649
|
-
const sycl::range<3> workgroup_size(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1650
1706
|
|
|
1651
1707
|
stream->submit([&](sycl::handler & cgh) {
|
|
1652
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1708
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1653
1709
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1654
1710
|
mul_mat_vec_q_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q6_K>>(vx, vy, dst, ncols, nrows,
|
|
1655
1711
|
nd_item);
|
|
@@ -1664,13 +1720,13 @@ static void reorder_mul_mat_vec_q6_k_q8_1_sycl_ncols(
|
|
|
1664
1720
|
const int stride_col_y_bytes, const int stride_col_dst,
|
|
1665
1721
|
dpct::queue_ptr stream) {
|
|
1666
1722
|
GGML_ASSERT(ncols % QK_K == 0);
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
const sycl::range<3>
|
|
1671
|
-
|
|
1723
|
+
constexpr size_t num_subgroups = WARP_SIZE;
|
|
1724
|
+
const int block_num_y = ceil_div(nrows, GGML_SYCL_MMV_Y * (int) num_subgroups);
|
|
1725
|
+
const sycl::range<3> block_nums(1, 1, block_num_y);
|
|
1726
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, num_subgroups * WARP_SIZE);
|
|
1727
|
+
|
|
1672
1728
|
stream->submit([&](sycl::handler & cgh) {
|
|
1673
|
-
cgh.parallel_for(sycl::nd_range<3>(
|
|
1729
|
+
cgh.parallel_for(sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
1674
1730
|
[=](sycl::nd_item<3> nd_item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
1675
1731
|
mul_mat_vec_q_reorder_ncols<reorder_vec_dot_q_sycl<GGML_TYPE_Q6_K>, ncols_dst>(
|
|
1676
1732
|
vx, vy, dst, ncols, nrows, stride_col_y_bytes, stride_col_dst, nd_item);
|
|
@@ -2124,6 +2180,20 @@ void ggml_sycl_op_mul_mat_vec_q(ggml_backend_sycl_context & ctx, const ggml_tens
|
|
|
2124
2180
|
mul_mat_vec_q8_0_q8_1_sycl(src0_dd_i, src1_ddq_i_bs, dst_dd_i_bs, ne00, row_diff, stream);
|
|
2125
2181
|
}
|
|
2126
2182
|
break;
|
|
2183
|
+
case GGML_TYPE_Q1_0:
|
|
2184
|
+
if (i == 0 && src1_ncols > 1 && src1_ncols <= 8) {
|
|
2185
|
+
const int stride_col_y = src1_padded_col_size / QK8_1;
|
|
2186
|
+
const int stride_col_dst = dst->ne[0];
|
|
2187
|
+
GGML_SYCL_DEBUG("Calling mul_mat_vec_q1_0_q8_1_sycl_switch_ncols ncols=%d\n", (int)src1_ncols);
|
|
2188
|
+
mul_mat_vec_q1_0_q8_1_sycl_switch_ncols(
|
|
2189
|
+
src0_dd_i, src1_ddq_i, dst_dd_i, ne00, row_diff,
|
|
2190
|
+
src1_ncols, stride_col_y, stride_col_dst, stream);
|
|
2191
|
+
return;
|
|
2192
|
+
} else if (i == 0 || src1_ncols == 1) {
|
|
2193
|
+
GGML_SYCL_DEBUG("Calling mul_mat_vec_q1_0_q8_1_sycl\n");
|
|
2194
|
+
mul_mat_vec_q1_0_q8_1_sycl(src0_dd_i, src1_ddq_i_bs, dst_dd_i_bs, ne00, row_diff, stream);
|
|
2195
|
+
}
|
|
2196
|
+
break;
|
|
2127
2197
|
case GGML_TYPE_Q2_K:
|
|
2128
2198
|
if (i == 0 && src1_ncols > 1 && src1_ncols <= 8) {
|
|
2129
2199
|
const int stride_col_y = src1_padded_col_size / QK8_1;
|
|
@@ -2472,3 +2542,118 @@ bool ggml_sycl_mul_mat_vec_q_id(
|
|
|
2472
2542
|
return false;
|
|
2473
2543
|
}
|
|
2474
2544
|
}
|
|
2545
|
+
|
|
2546
|
+
// Reorder (SoA) MoE expert GEMV: MoE expert/row/lane indexing (from mul_mat_vec_q_moe) with the
|
|
2547
|
+
// dense-reorder per-block reads (from mul_mat_vec_q_reorder). Each expert slice in vx_base is a
|
|
2548
|
+
// self-contained SoA, so nblocks = nrows*(ncols/qk) per expert and the constant expert stride holds.
|
|
2549
|
+
template <typename reorder_vec_dot_q_sycl>
|
|
2550
|
+
static void mul_mat_vec_q_moe_reorder(
|
|
2551
|
+
const void * __restrict__ vx_base, const void * __restrict__ vy_base,
|
|
2552
|
+
float * __restrict__ dst_base, const int32_t * __restrict__ ids_dev,
|
|
2553
|
+
const int ncols, const int nrows,
|
|
2554
|
+
const size_t expert_weight_stride, const size_t dst_row_stride,
|
|
2555
|
+
const size_t src1_row_stride,
|
|
2556
|
+
const sycl::nd_item<3> & item_ct1) {
|
|
2557
|
+
using block_type = ggml_sycl_reordered::block_q_t<reorder_vec_dot_q_sycl::gtype>;
|
|
2558
|
+
using block_traits = typename block_type::traits;
|
|
2559
|
+
|
|
2560
|
+
const int expert_idx = item_ct1.get_group(1);
|
|
2561
|
+
const int i02 = ids_dev[expert_idx];
|
|
2562
|
+
|
|
2563
|
+
const char * vx = (const char *) vx_base + (size_t) i02 * expert_weight_stride;
|
|
2564
|
+
const char * vy = (const char *) vy_base + (size_t) expert_idx * src1_row_stride;
|
|
2565
|
+
float * dst = (float *) ((char *) dst_base + (size_t) expert_idx * dst_row_stride);
|
|
2566
|
+
|
|
2567
|
+
const int row = item_ct1.get_group(2) * item_ct1.get_local_range(1) + item_ct1.get_local_id(1);
|
|
2568
|
+
if (row >= nrows) {
|
|
2569
|
+
return;
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
const auto sg = item_ct1.get_sub_group();
|
|
2573
|
+
|
|
2574
|
+
const int blocks_per_row = ncols / block_traits::qk;
|
|
2575
|
+
constexpr int blocks_per_subgroup = ceil_div(block_traits::vdr_mmvq * WARP_SIZE, block_traits::qi);
|
|
2576
|
+
constexpr int block_elements_per_subgroup = block_traits::qi / block_traits::vdr_mmvq;
|
|
2577
|
+
const int nblocks = nrows * (ncols / block_traits::qk);
|
|
2578
|
+
|
|
2579
|
+
static_assert(blocks_per_subgroup > 0);
|
|
2580
|
+
static_assert(block_elements_per_subgroup > 0);
|
|
2581
|
+
|
|
2582
|
+
float partial_sum = 0.0f;
|
|
2583
|
+
for (int i = sg.get_local_linear_id() / block_elements_per_subgroup; i < blocks_per_row; i += blocks_per_subgroup) {
|
|
2584
|
+
const int ibx = row * blocks_per_row + i;
|
|
2585
|
+
|
|
2586
|
+
const auto bx_offset = block_type::get_block_offset(ibx, nblocks);
|
|
2587
|
+
const auto d_offset = block_type::get_d_offset(nrows, ncols, ibx);
|
|
2588
|
+
|
|
2589
|
+
const int iby = i * block_type::block_to_q8_1_ratio();
|
|
2590
|
+
const int8_t * q8_1_quant_ptr = (const int8_t *) vy + iby * QK8_1;
|
|
2591
|
+
const sycl::half2 * q8_1_ds_ptr = (const sycl::half2 *) ((const char *) vy + ncols + iby * sizeof(sycl::half2));
|
|
2592
|
+
|
|
2593
|
+
#pragma unroll
|
|
2594
|
+
for (int elem = 0; elem < block_elements_per_subgroup; elem += WARP_SIZE) {
|
|
2595
|
+
const int iqs = elem + block_traits::vdr_mmvq * (sg.get_local_linear_id() % block_elements_per_subgroup);
|
|
2596
|
+
partial_sum += reorder_vec_dot_q_sycl()(vx, bx_offset, d_offset, q8_1_quant_ptr, q8_1_ds_ptr, iqs);
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
auto sum = sycl::reduce_over_group(sg, partial_sum, std::plus<>());
|
|
2601
|
+
if (sg.leader()) {
|
|
2602
|
+
dst[row] = sum;
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
|
|
2606
|
+
template <typename reorder_vec_dot_q_sycl>
|
|
2607
|
+
static void launch_mul_mat_vec_q_moe_reorder(
|
|
2608
|
+
const void * vx_base, const void * vy, const int32_t * ids_dev,
|
|
2609
|
+
float * dst_base, const int ncols, const int nrows, const int n_experts_used,
|
|
2610
|
+
const size_t expert_weight_stride, const size_t dst_row_stride,
|
|
2611
|
+
const size_t src1_row_stride,
|
|
2612
|
+
dpct::queue_ptr stream) {
|
|
2613
|
+
const int block_num_y = (nrows + GGML_SYCL_MMV_Y - 1) / GGML_SYCL_MMV_Y;
|
|
2614
|
+
const sycl::range<3> block_nums(1, (unsigned) n_experts_used, (unsigned) block_num_y);
|
|
2615
|
+
const sycl::range<3> block_dims(1, GGML_SYCL_MMV_Y, WARP_SIZE);
|
|
2616
|
+
stream->submit([&](sycl::handler & cgh) {
|
|
2617
|
+
cgh.parallel_for(
|
|
2618
|
+
sycl::nd_range<3>(block_nums * block_dims, block_dims),
|
|
2619
|
+
[=](sycl::nd_item<3> item) [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
|
|
2620
|
+
mul_mat_vec_q_moe_reorder<reorder_vec_dot_q_sycl>(
|
|
2621
|
+
vx_base, vy, dst_base, ids_dev, ncols, nrows,
|
|
2622
|
+
expert_weight_stride, dst_row_stride, src1_row_stride, item);
|
|
2623
|
+
});
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
bool ggml_sycl_mul_mat_vec_q_id_reorder(
|
|
2628
|
+
enum ggml_type src0_type,
|
|
2629
|
+
const void * vx_base,
|
|
2630
|
+
const void * vy,
|
|
2631
|
+
const int32_t * ids_dev,
|
|
2632
|
+
float * dst_base,
|
|
2633
|
+
int ncols,
|
|
2634
|
+
int nrows,
|
|
2635
|
+
int n_experts_used,
|
|
2636
|
+
size_t expert_weight_stride,
|
|
2637
|
+
size_t dst_row_stride,
|
|
2638
|
+
size_t src1_row_stride,
|
|
2639
|
+
dpct::queue_ptr stream) {
|
|
2640
|
+
switch (src0_type) {
|
|
2641
|
+
case GGML_TYPE_Q4_K:
|
|
2642
|
+
launch_mul_mat_vec_q_moe_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q4_K>>(
|
|
2643
|
+
vx_base, vy, ids_dev, dst_base, ncols, nrows, n_experts_used,
|
|
2644
|
+
expert_weight_stride, dst_row_stride, src1_row_stride, stream);
|
|
2645
|
+
return true;
|
|
2646
|
+
case GGML_TYPE_Q5_K:
|
|
2647
|
+
launch_mul_mat_vec_q_moe_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q5_K>>(
|
|
2648
|
+
vx_base, vy, ids_dev, dst_base, ncols, nrows, n_experts_used,
|
|
2649
|
+
expert_weight_stride, dst_row_stride, src1_row_stride, stream);
|
|
2650
|
+
return true;
|
|
2651
|
+
case GGML_TYPE_Q6_K:
|
|
2652
|
+
launch_mul_mat_vec_q_moe_reorder<reorder_vec_dot_q_sycl<GGML_TYPE_Q6_K>>(
|
|
2653
|
+
vx_base, vy, ids_dev, dst_base, ncols, nrows, n_experts_used,
|
|
2654
|
+
expert_weight_stride, dst_row_stride, src1_row_stride, stream);
|
|
2655
|
+
return true;
|
|
2656
|
+
default:
|
|
2657
|
+
return false;
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
@@ -40,4 +40,21 @@ bool ggml_sycl_mul_mat_vec_q_id(
|
|
|
40
40
|
size_t src1_row_stride, // 0 = shared src1, else per-expert stride in bytes
|
|
41
41
|
dpct::queue_ptr stream);
|
|
42
42
|
|
|
43
|
+
// Reorder (SoA) variant of the fused MoE expert GEMV.
|
|
44
|
+
// vx_base: each expert slice (stride expert_weight_stride == src0->nb[2]) is a self-contained reorder/SoA layout.
|
|
45
|
+
// vy: src1 quantized with quantize_and_reorder_q8_1_soa (per-row SoA). Returns false if src0_type isn't handled.
|
|
46
|
+
bool ggml_sycl_mul_mat_vec_q_id_reorder(
|
|
47
|
+
enum ggml_type src0_type,
|
|
48
|
+
const void * vx_base,
|
|
49
|
+
const void * vy,
|
|
50
|
+
const int32_t * ids_dev,
|
|
51
|
+
float * dst_base,
|
|
52
|
+
int ncols,
|
|
53
|
+
int nrows,
|
|
54
|
+
int n_experts_used,
|
|
55
|
+
size_t expert_weight_stride,
|
|
56
|
+
size_t dst_row_stride,
|
|
57
|
+
size_t src1_row_stride,
|
|
58
|
+
dpct::queue_ptr stream);
|
|
59
|
+
|
|
43
60
|
#endif // GGML_SYCL_MMVQ_HPP
|