cohere-transcribe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +21 -0
- data/LICENSE.txt +201 -0
- data/NOTICE +5 -0
- data/README.md +265 -0
- data/THIRD_PARTY_NOTICES.md +67 -0
- data/exe/cohere-transcribe +8 -0
- data/exe/cohere-transcribe-doctor +8 -0
- data/ext/cohere_transcribe_native/CMakeLists.txt +262 -0
- data/ext/cohere_transcribe_native/README.md +26 -0
- data/ext/cohere_transcribe_native/audio_abi.cpp +1416 -0
- data/ext/cohere_transcribe_native/audio_exports.macos +5 -0
- data/ext/cohere_transcribe_native/audio_exports.map +10 -0
- data/ext/cohere_transcribe_native/cohere_abi.cpp +1209 -0
- data/ext/cohere_transcribe_native/exports.macos +40 -0
- data/ext/cohere_transcribe_native/exports.map +45 -0
- data/ext/cohere_transcribe_native/extconf.rb +89 -0
- data/ext/cohere_transcribe_native/test/abi_smoke.rb +232 -0
- data/ext/cohere_transcribe_native/test/audio_matrix_smoke.cpp +121 -0
- data/ext/cohere_transcribe_native/test/audio_reliability_smoke.cpp +198 -0
- data/ext/cohere_transcribe_native/test/native_abi_reliability_smoke.cpp +186 -0
- data/ext/cohere_transcribe_native/test/native_batch_projection_probe.rb +81 -0
- data/ext/cohere_transcribe_native/test/native_cancellation_smoke.cpp +194 -0
- data/lib/cohere/transcribe/alignment/ATTRIBUTION.md +23 -0
- data/lib/cohere/transcribe/alignment/LICENSE.ctc-forced-aligner +407 -0
- data/lib/cohere/transcribe/alignment/LICENSE.torchaudio +25 -0
- data/lib/cohere/transcribe/alignment/LICENSE.uroman +26 -0
- data/lib/cohere/transcribe/alignment/aligner.rb +476 -0
- data/lib/cohere/transcribe/alignment/ctc.rb +224 -0
- data/lib/cohere/transcribe/alignment/text.rb +237 -0
- data/lib/cohere/transcribe/alignment/uroman_data.rb +4950 -0
- data/lib/cohere/transcribe/api.rb +173 -0
- data/lib/cohere/transcribe/asr/batching.rb +472 -0
- data/lib/cohere/transcribe/asr/failure_policy.rb +112 -0
- data/lib/cohere/transcribe/asr/native.rb +676 -0
- data/lib/cohere/transcribe/audio/ATTRIBUTION.md +8 -0
- data/lib/cohere/transcribe/audio/LICENSE.auditok +21 -0
- data/lib/cohere/transcribe/audio/decoder.rb +315 -0
- data/lib/cohere/transcribe/audio/ffmpeg_native.rb +248 -0
- data/lib/cohere/transcribe/audio/segmentation.rb +260 -0
- data/lib/cohere/transcribe/cli.rb +727 -0
- data/lib/cohere/transcribe/configuration.rb +282 -0
- data/lib/cohere/transcribe/constants.rb +14 -0
- data/lib/cohere/transcribe/dense_converter.rb +548 -0
- data/lib/cohere/transcribe/doctor.rb +576 -0
- data/lib/cohere/transcribe/errors.rb +57 -0
- data/lib/cohere/transcribe/gguf_writer.rb +268 -0
- data/lib/cohere/transcribe/hub.rb +436 -0
- data/lib/cohere/transcribe/input.rb +110 -0
- data/lib/cohere/transcribe/licenses/crispasr.txt +21 -0
- data/lib/cohere/transcribe/loader.rb +128 -0
- data/lib/cohere/transcribe/model_identity.rb +440 -0
- data/lib/cohere/transcribe/output/publication.rb +1118 -0
- data/lib/cohere/transcribe/output/rendering.rb +105 -0
- data/lib/cohere/transcribe/output/timing.rb +86 -0
- data/lib/cohere/transcribe/python_text.rb +70 -0
- data/lib/cohere/transcribe/pytorch_checkpoint.rb +1180 -0
- data/lib/cohere/transcribe/runtime/engine.rb +1676 -0
- data/lib/cohere/transcribe/runtime/model_provider.rb +390 -0
- data/lib/cohere/transcribe/runtime/precision.rb +57 -0
- data/lib/cohere/transcribe/runtime/preparation.rb +215 -0
- data/lib/cohere/transcribe/runtime/resources.rb +165 -0
- data/lib/cohere/transcribe/runtime/word_pipeline.rb +364 -0
- data/lib/cohere/transcribe/safetensors.rb +579 -0
- data/lib/cohere/transcribe/state/checkpoint.rb +224 -0
- data/lib/cohere/transcribe/state/contracts.rb +141 -0
- data/lib/cohere/transcribe/state/io.rb +727 -0
- data/lib/cohere/transcribe/state/locking.rb +211 -0
- data/lib/cohere/transcribe/state/manifest.rb +155 -0
- data/lib/cohere/transcribe/state.rb +7 -0
- data/lib/cohere/transcribe/types.rb +535 -0
- data/lib/cohere/transcribe/vad/ATTRIBUTION.md +14 -0
- data/lib/cohere/transcribe/vad/LICENSE.faster-whisper +21 -0
- data/lib/cohere/transcribe/vad/LICENSE.silero-vad +21 -0
- data/lib/cohere/transcribe/vad/silero.rb +344 -0
- data/lib/cohere/transcribe/vad/silero_vad_v6.onnx +0 -0
- data/lib/cohere/transcribe/vad/timestamps.rb +219 -0
- data/lib/cohere/transcribe/version.rb +7 -0
- data/lib/cohere/transcribe.rb +26 -0
- data/sig/cohere/transcribe.rbs +250 -0
- data/vendor/crispasr/AUTHORS +510 -0
- data/vendor/crispasr/LICENSE +21 -0
- data/vendor/crispasr/UPSTREAM.md +9 -0
- data/vendor/crispasr/VERSION +1 -0
- data/vendor/crispasr/ggml/AUTHORS +335 -0
- data/vendor/crispasr/ggml/CMakeLists.txt +512 -0
- data/vendor/crispasr/ggml/LICENSE +21 -0
- data/vendor/crispasr/ggml/README.md +49 -0
- data/vendor/crispasr/ggml/cmake/FindNCCL.cmake +36 -0
- data/vendor/crispasr/ggml/cmake/GitVars.cmake +22 -0
- data/vendor/crispasr/ggml/cmake/common.cmake +50 -0
- data/vendor/crispasr/ggml/cmake/ggml-config.cmake.in +191 -0
- data/vendor/crispasr/ggml/ggml.pc.in +10 -0
- data/vendor/crispasr/ggml/include/ggml-alloc.h +85 -0
- data/vendor/crispasr/ggml/include/ggml-backend.h +431 -0
- data/vendor/crispasr/ggml/include/ggml-blas.h +25 -0
- data/vendor/crispasr/ggml/include/ggml-cann.h +123 -0
- data/vendor/crispasr/ggml/include/ggml-cpp.h +39 -0
- data/vendor/crispasr/ggml/include/ggml-cpu.h +151 -0
- data/vendor/crispasr/ggml/include/ggml-cuda.h +50 -0
- data/vendor/crispasr/ggml/include/ggml-hexagon.h +19 -0
- data/vendor/crispasr/ggml/include/ggml-metal.h +61 -0
- data/vendor/crispasr/ggml/include/ggml-opencl.h +26 -0
- data/vendor/crispasr/ggml/include/ggml-openvino.h +37 -0
- data/vendor/crispasr/ggml/include/ggml-opt.h +256 -0
- data/vendor/crispasr/ggml/include/ggml-rpc.h +35 -0
- data/vendor/crispasr/ggml/include/ggml-sycl.h +49 -0
- data/vendor/crispasr/ggml/include/ggml-virtgpu.h +14 -0
- data/vendor/crispasr/ggml/include/ggml-vulkan.h +29 -0
- data/vendor/crispasr/ggml/include/ggml-webgpu.h +19 -0
- data/vendor/crispasr/ggml/include/ggml-zdnn.h +17 -0
- data/vendor/crispasr/ggml/include/ggml-zendnn.h +22 -0
- data/vendor/crispasr/ggml/include/ggml.h +2887 -0
- data/vendor/crispasr/ggml/include/gguf.h +204 -0
- data/vendor/crispasr/ggml/src/CMakeLists.txt +493 -0
- data/vendor/crispasr/ggml/src/ggml-alloc.c +1323 -0
- data/vendor/crispasr/ggml/src/ggml-backend-dl.cpp +48 -0
- data/vendor/crispasr/ggml/src/ggml-backend-dl.h +44 -0
- data/vendor/crispasr/ggml/src/ggml-backend-impl.h +275 -0
- data/vendor/crispasr/ggml/src/ggml-backend-meta.cpp +2145 -0
- data/vendor/crispasr/ggml/src/ggml-backend-reg.cpp +586 -0
- data/vendor/crispasr/ggml/src/ggml-backend.cpp +2437 -0
- data/vendor/crispasr/ggml/src/ggml-common.h +1900 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/CMakeLists.txt +718 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.cpp +249 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/amx.h +8 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/common.h +115 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.cpp +2512 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/amx/mmq.h +10 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +98 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/quants.c +4244 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/arm/repack.cpp +5156 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/loongarch/quants.c +2158 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/powerpc/quants.c +2304 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/cpu-feats.cpp +38 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/quants.c +4455 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/riscv/repack.cpp +1703 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/cpu-feats.cpp +50 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/s390/quants.c +1465 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/wasm/quants.c +1220 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/quants.c +3970 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch/x86/repack.cpp +6407 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/arch-fallback.h +349 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.cpp +154 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/binary-ops.h +16 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/common.h +95 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu-impl.h +539 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.c +3791 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ggml-cpu.cpp +703 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/hbm.cpp +55 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/hbm.h +8 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.cpp +939 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kernels.h +90 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1513 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.cpp +4051 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/llamafile/sgemm.h +25 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ops.cpp +11662 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/ops.h +121 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/quants.c +1288 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/quants.h +103 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/repack.cpp +4836 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/repack.h +245 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/simd-gemm.h +226 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/simd-mappings.h +1329 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.cpp +1025 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime.h +13 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime1_kernels.cpp +3196 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/spacemit/ime_kernels.h +26 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/traits.cpp +36 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/traits.h +38 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.cpp +336 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/unary-ops.h +35 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/vec.cpp +681 -0
- data/vendor/crispasr/ggml/src/ggml-cpu/vec.h +1606 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/CMakeLists.txt +272 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/acc.cu +61 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/acc.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cu +58 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/add-id.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/arange.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/arange.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cu +91 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argmax.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cu +265 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/argsort.cuh +19 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cu +534 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/binbcast.cuh +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cu +45 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/clamp.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/common.cuh +1489 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/concat.cu +204 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/concat.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cu +97 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cu +115 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d-transpose.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cu +166 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/conv2d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/convert.cu +892 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/convert.cuh +66 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cu +64 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/count-equal.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cp-async.cuh +57 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy-utils.cuh +217 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cu +581 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cpy.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cu +177 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cu +307 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/cumsum.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/dequantize.cuh +99 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diag.cu +77 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diag.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cu +40 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/diagmask.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-common.cuh +1212 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-mma-f16.cuh +1860 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cu +57 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-tile.cuh +1309 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-vec.cuh +600 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cu +696 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn-wmma-f16.cuh +51 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cu +620 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fattn.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fill.cu +37 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/fill.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cu +273 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gated_delta_net.cuh +4 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cu +332 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/getrows.cuh +15 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ggml-cuda.cu +5580 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gla.cu +93 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/gla.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cu +274 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/im2col.cuh +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mean.cu +75 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mean.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mma.cuh +1333 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cu +191 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmf.cuh +908 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cu +164 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmid.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cu +372 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmq.cuh +4175 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cu +862 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvf.cuh +14 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cu +1161 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/mmvq.cuh +16 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/norm.cu +756 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/norm.cuh +20 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cu +49 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/opt-step-sgd.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cu +68 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/out-prod.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad.cu +106 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cu +91 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pad_reflect_1d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cu +94 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/pool2d.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cu +443 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/quantize.cuh +41 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/reduce_rows.cuh +39 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/roll.cu +67 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/roll.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/rope.cu +665 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/rope.cuh +9 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/scale.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/scale.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cu +330 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set-rows.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set.cu +39 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/set.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cu +34 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softcap.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cu +472 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/softmax.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cu +275 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/solve_tri.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cu +197 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cu +342 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sum.cu +41 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sum.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cu +43 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/sumrows.cuh +4 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_32.cu +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_32.cu +6 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +10 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +12 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +11 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq112-dv112.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq128-dv128.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq256-dv256.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq320-dv256.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq40-dv40.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq512-dv512.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq576-dv512.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq64-dv64.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq72-dv72.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq80-dv80.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq96-dv96.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-bf16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-f16.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_1.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q8_0.cu +7 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_10.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_11.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_12.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_13.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_14.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_15.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_16.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_2.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_3.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_5.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_6.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_7.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_8.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_9.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-mxfp4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-nvfp4.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q1_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cu +95 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/top-k.cuh +3 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cu +415 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/topk-moe.cuh +27 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tri.cu +136 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tri.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cu +47 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/tsembd.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/unary.cu +644 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/unary.cuh +116 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cu +293 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/upscale.cuh +5 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vecdotq.cuh +1317 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/cuda.h +28 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/hip.h +306 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/vendors/musa.h +148 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cu +199 -0
- data/vendor/crispasr/ggml/src/ggml-cuda/wkv.cuh +7 -0
- data/vendor/crispasr/ggml/src/ggml-impl.h +783 -0
- data/vendor/crispasr/ggml/src/ggml-metal/CMakeLists.txt +124 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.cpp +457 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-common.h +52 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.h +41 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-context.m +778 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.cpp +2117 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.h +299 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-device.m +2093 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-impl.h +1267 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.cpp +5023 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal-ops.h +111 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.cpp +954 -0
- data/vendor/crispasr/ggml/src/ggml-metal/ggml-metal.metal +11756 -0
- data/vendor/crispasr/ggml/src/ggml-opt.cpp +1094 -0
- data/vendor/crispasr/ggml/src/ggml-quants.c +5491 -0
- data/vendor/crispasr/ggml/src/ggml-quants.h +112 -0
- data/vendor/crispasr/ggml/src/ggml-threading.cpp +12 -0
- data/vendor/crispasr/ggml/src/ggml-threading.h +14 -0
- data/vendor/crispasr/ggml/src/ggml.c +7925 -0
- data/vendor/crispasr/ggml/src/ggml.cpp +26 -0
- data/vendor/crispasr/ggml/src/gguf.cpp +1556 -0
- data/vendor/crispasr/src/cohere-arch.h +137 -0
- data/vendor/crispasr/src/cohere.cpp +5642 -0
- data/vendor/crispasr/src/cohere.h +327 -0
- data/vendor/crispasr/src/cohere_batch_planner.h +82 -0
- data/vendor/crispasr/src/cohere_chunking.h +64 -0
- data/vendor/crispasr/src/cohere_decoder_batch_layout.h +60 -0
- data/vendor/crispasr/src/cohere_encoder_padded_layout.h +27 -0
- data/vendor/crispasr/src/cohere_frontend.cpp +189 -0
- data/vendor/crispasr/src/cohere_frontend.h +31 -0
- data/vendor/crispasr/src/cohere_ragged_controller.h +149 -0
- data/vendor/crispasr/src/cohere_token_renderer.h +181 -0
- data/vendor/crispasr/src/core/attention.h +924 -0
- data/vendor/crispasr/src/core/audio_chunking.h +97 -0
- data/vendor/crispasr/src/core/beam_decode.h +486 -0
- data/vendor/crispasr/src/core/cpu_ops.h +135 -0
- data/vendor/crispasr/src/core/gguf_loader.cpp +1021 -0
- data/vendor/crispasr/src/core/gguf_loader.h +216 -0
- data/vendor/crispasr/src/core/gpu_backend_pref.h +119 -0
- data/vendor/crispasr/src/core/mel.cpp +519 -0
- data/vendor/crispasr/src/core/mel.h +265 -0
- data/vendor/crispasr/src/core/ngram_loop_fix.h +173 -0
- data/vendor/crispasr/src/core/repetition_loop_guard.h +54 -0
- data/vendor/crispasr/src/crispasr_imatrix.cpp +255 -0
- data/vendor/crispasr/src/crispasr_imatrix.h +38 -0
- metadata +596 -0
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
#if !defined(GGML_USE_HIP) && !defined(GGML_USE_MUSA) && CUDART_VERSION >= 11070
|
|
2
|
+
#define USE_CUB
|
|
3
|
+
#endif // !defined(GGML_USE_HIP) && !defined(GGML_USE_MUSA) && CUDART_VERSION >= 11070
|
|
4
|
+
|
|
5
|
+
#ifdef USE_CUB
|
|
6
|
+
#include <cub/cub.cuh>
|
|
7
|
+
using namespace cub;
|
|
8
|
+
#endif // USE_CUB
|
|
9
|
+
|
|
10
|
+
#include "ssm-scan.cuh"
|
|
11
|
+
|
|
12
|
+
// We would like to keep pragma unroll for cases where L_template is not 0,
|
|
13
|
+
// so we suppress the clang transformation warning.
|
|
14
|
+
#ifdef __clang__
|
|
15
|
+
#pragma clang diagnostic push
|
|
16
|
+
#pragma clang diagnostic ignored "-Wpass-failed"
|
|
17
|
+
#endif // __clang__
|
|
18
|
+
template <size_t splitD, size_t N, size_t L_template>
|
|
19
|
+
__global__ void __launch_bounds__(splitD, 1)
|
|
20
|
+
ssm_scan_f32(const float *__restrict__ src0, const float *__restrict__ src1, const float *__restrict__ src2,
|
|
21
|
+
const float *__restrict__ src3, const float *__restrict__ src4, const float *__restrict__ src5,
|
|
22
|
+
const int32_t * __restrict__ src6, float * __restrict__ dst,
|
|
23
|
+
const int src0_nb2, const int src0_nb3, const int src1_nb2, const int src1_nb3,
|
|
24
|
+
const int src2_nb1, const int src2_nb2, const int src3_nb1,
|
|
25
|
+
const int src4_nb2, const int src4_nb3, const int src5_nb2, const int src5_nb3,
|
|
26
|
+
const int64_t s_off, const int64_t d_inner, const int64_t L_param)
|
|
27
|
+
{
|
|
28
|
+
const size_t L = L_template == 0 ? L_param : L_template;
|
|
29
|
+
const float *s0_block = (const float *)((const char *)src0 + src6[blockIdx.x] * src0_nb3 + blockIdx.y * splitD * src0_nb2);
|
|
30
|
+
const float *x_block = (const float *)((const char *)src1 + (blockIdx.x * src1_nb3) + blockIdx.y * splitD * sizeof(float));
|
|
31
|
+
const float *dt_block = (const float *)((const char *)src2 + (blockIdx.x * src2_nb2) + blockIdx.y * splitD * sizeof(float));
|
|
32
|
+
const float *A_block = (const float *)((const char *)src3 + blockIdx.y * splitD * src3_nb1);
|
|
33
|
+
const float *B_block = (const float *)((const char *)src4 + (blockIdx.x * src4_nb3));
|
|
34
|
+
const float *C_block = (const float *)((const char *)src5 + (blockIdx.x * src5_nb3));
|
|
35
|
+
float *y_block = (float *)((char *)dst + (blockIdx.x * d_inner * L * sizeof(float)) + blockIdx.y * splitD * sizeof(float));
|
|
36
|
+
float *s_block = (float *)((char *)dst + s_off + blockIdx.x * src0_nb3 + blockIdx.y * splitD * src0_nb2);
|
|
37
|
+
|
|
38
|
+
const int stride_x = src1_nb2 / sizeof(float);
|
|
39
|
+
const int stride_dt = src2_nb1 / sizeof(float);
|
|
40
|
+
const int stride_B = src4_nb2 / sizeof(float);
|
|
41
|
+
const int stride_C = src5_nb2 / sizeof(float);
|
|
42
|
+
const int stride_y = d_inner;
|
|
43
|
+
|
|
44
|
+
float regA[N];
|
|
45
|
+
float regs0[N];
|
|
46
|
+
|
|
47
|
+
__shared__ float smemB[N];
|
|
48
|
+
__shared__ float smemC[N];
|
|
49
|
+
|
|
50
|
+
#ifdef USE_CUB
|
|
51
|
+
using BlockLoad = cub::BlockLoad<float, splitD, N, cub::BLOCK_LOAD_WARP_TRANSPOSE>;
|
|
52
|
+
using BlockStore = cub::BlockStore<float, splitD, N, cub::BLOCK_STORE_WARP_TRANSPOSE>;
|
|
53
|
+
|
|
54
|
+
union CubTempStorage {
|
|
55
|
+
typename BlockLoad::TempStorage load_temp;
|
|
56
|
+
typename BlockStore::TempStorage store_temp;
|
|
57
|
+
};
|
|
58
|
+
__shared__ CubTempStorage cub_temp_storage;
|
|
59
|
+
|
|
60
|
+
BlockLoad(cub_temp_storage.load_temp).Load(A_block, regA);
|
|
61
|
+
BlockLoad(cub_temp_storage.load_temp).Load(s0_block, regs0);
|
|
62
|
+
#else
|
|
63
|
+
const int stride_s0 = src0_nb2 / sizeof(float);
|
|
64
|
+
const int stride_A = src3_nb1 / sizeof(float);
|
|
65
|
+
#pragma unroll
|
|
66
|
+
for (size_t n = 0; n < N; ++n)
|
|
67
|
+
{
|
|
68
|
+
regA[n] = A_block[threadIdx.x * stride_A + n];
|
|
69
|
+
regs0[n] = s0_block[threadIdx.x * stride_s0 + n];
|
|
70
|
+
}
|
|
71
|
+
#endif
|
|
72
|
+
|
|
73
|
+
#pragma unroll
|
|
74
|
+
for (size_t i = 0; i < L; i++)
|
|
75
|
+
{
|
|
76
|
+
if (threadIdx.x < N)
|
|
77
|
+
{
|
|
78
|
+
smemB[threadIdx.x] = B_block[i * stride_B + threadIdx.x];
|
|
79
|
+
smemC[threadIdx.x] = C_block[i * stride_C + threadIdx.x];
|
|
80
|
+
}
|
|
81
|
+
__syncthreads();
|
|
82
|
+
|
|
83
|
+
float dt_soft_plus = dt_block[i * stride_dt + threadIdx.x];
|
|
84
|
+
if (dt_soft_plus <= 20.0f)
|
|
85
|
+
{
|
|
86
|
+
dt_soft_plus = log1pf(expf(dt_soft_plus));
|
|
87
|
+
}
|
|
88
|
+
float x_dt = x_block[i * stride_x + threadIdx.x] * dt_soft_plus;
|
|
89
|
+
|
|
90
|
+
float sumf = 0.0f;
|
|
91
|
+
#pragma unroll
|
|
92
|
+
for (size_t n = 0; n < N; n++)
|
|
93
|
+
{
|
|
94
|
+
float state = regs0[n] * expf(dt_soft_plus * regA[n]) + smemB[n] * x_dt;
|
|
95
|
+
sumf += state * smemC[n];
|
|
96
|
+
regs0[n] = state;
|
|
97
|
+
}
|
|
98
|
+
y_block[i * stride_y + threadIdx.x] = sumf;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#ifdef USE_CUB
|
|
102
|
+
BlockStore(cub_temp_storage.store_temp).Store(s_block, regs0);
|
|
103
|
+
#else
|
|
104
|
+
const int stride_s = stride_s0;
|
|
105
|
+
#pragma unroll
|
|
106
|
+
for (size_t n = 0; n < N; ++n)
|
|
107
|
+
{
|
|
108
|
+
s_block[threadIdx.x * stride_s + n] = regs0[n];
|
|
109
|
+
}
|
|
110
|
+
#endif
|
|
111
|
+
}
|
|
112
|
+
#ifdef __clang__
|
|
113
|
+
#pragma clang diagnostic pop
|
|
114
|
+
#endif // __clang__
|
|
115
|
+
|
|
116
|
+
// assumes as many threads as d_state
|
|
117
|
+
template <int c_factor, int d_state>
|
|
118
|
+
__global__ void __launch_bounds__(d_state, 1)
|
|
119
|
+
ssm_scan_f32_group(
|
|
120
|
+
const float * __restrict__ src0, const float * __restrict__ src1, const float * __restrict__ src2,
|
|
121
|
+
const float * __restrict__ src3, const float * __restrict__ src4, const float * __restrict__ src5,
|
|
122
|
+
const int32_t * __restrict__ src6, float * __restrict__ dst,
|
|
123
|
+
const int src0_nb2, const int src0_nb3, const int src1_nb2, const int src1_nb3,
|
|
124
|
+
const int src2_nb1, const int src2_nb2, const int src3_nb1,
|
|
125
|
+
const int src4_nb2, const int src4_nb3, const int src5_nb2, const int src5_nb3,
|
|
126
|
+
const int64_t s_off, const int64_t n_head, const int64_t d_head, const int64_t n_group, const int64_t n_tok) {
|
|
127
|
+
|
|
128
|
+
const int warp = threadIdx.x / WARP_SIZE;
|
|
129
|
+
const int lane = threadIdx.x % WARP_SIZE;
|
|
130
|
+
const int warp_idx = blockIdx.x * c_factor + warp;
|
|
131
|
+
|
|
132
|
+
const int head_idx = warp_idx / d_head;
|
|
133
|
+
const int head_off = (warp_idx % d_head) * sizeof(float);
|
|
134
|
+
const int seq_idx = blockIdx.y;
|
|
135
|
+
|
|
136
|
+
const int group_off = (head_idx / (n_head / n_group)) * d_state * sizeof(float);
|
|
137
|
+
|
|
138
|
+
// TODO: refactor strides to be in elements/floats instead of bytes to be cleaner and consistent with the rest of the codebase
|
|
139
|
+
const float * s0_warp = (const float *) ((const char *) src0 + src6[seq_idx] * src0_nb3 + head_idx * src0_nb2 + head_off * d_state);
|
|
140
|
+
const float * x_warp = (const float *) ((const char *) src1 + (seq_idx * src1_nb3) + (warp_idx * sizeof(float)));
|
|
141
|
+
const float * dt_warp = (const float *) ((const char *) src2 + (seq_idx * src2_nb2) + head_idx * sizeof(float));
|
|
142
|
+
const float * A_warp = (const float *) ((const char *) src3 + head_idx * src3_nb1);
|
|
143
|
+
const float * B_warp = (const float *) ((const char *) src4 + (seq_idx * src4_nb3) + (group_off));
|
|
144
|
+
const float * C_warp = (const float *) ((const char *) src5 + (seq_idx * src5_nb3) + (group_off));
|
|
145
|
+
float * y_warp = dst + (seq_idx * n_tok * n_head * d_head) + warp_idx;
|
|
146
|
+
float * s_warp = (float *) ((char *) dst + s_off + seq_idx * src0_nb3 + head_idx * src0_nb2 + head_off * d_state);
|
|
147
|
+
|
|
148
|
+
// strides across n_seq_tokens
|
|
149
|
+
const int stride_x = src1_nb2 / sizeof(float);
|
|
150
|
+
const int stride_dt = src2_nb1 / sizeof(float);
|
|
151
|
+
const int stride_B = src4_nb2 / sizeof(float);
|
|
152
|
+
const int stride_C = src5_nb2 / sizeof(float);
|
|
153
|
+
const int stride_y = n_head * d_head;
|
|
154
|
+
|
|
155
|
+
float state[c_factor];
|
|
156
|
+
float state_sum = 0.0f;
|
|
157
|
+
|
|
158
|
+
#pragma unroll
|
|
159
|
+
for (int j = 0; j < c_factor; j++) {
|
|
160
|
+
state[j] = s0_warp[WARP_SIZE * j + lane];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
for (int64_t i = 0; i < n_tok; i++) {
|
|
164
|
+
// NOTE: dt_soft_plus, dA and x_dt have the same value for a warp here.
|
|
165
|
+
// Recalculation is intentional; sharing via shuffles/smem proved slower due to sync overhead.
|
|
166
|
+
const float dt_soft_plus = (dt_warp[i * stride_dt] <= 20.0f ? log1pf(expf(dt_warp[i * stride_dt])) : dt_warp[i * stride_dt]);
|
|
167
|
+
|
|
168
|
+
state_sum = 0.0f;
|
|
169
|
+
const float dA = expf(dt_soft_plus * A_warp[0]);
|
|
170
|
+
const float x_dt = x_warp[i * stride_x] * dt_soft_plus;
|
|
171
|
+
#pragma unroll
|
|
172
|
+
for (int j = 0; j < c_factor; j++) {
|
|
173
|
+
const float B_val = B_warp[i * stride_B + WARP_SIZE * j + lane];
|
|
174
|
+
const float C_val = C_warp[i * stride_C + WARP_SIZE * j + lane];
|
|
175
|
+
state[j] = (state[j] * dA) + (B_val * x_dt);
|
|
176
|
+
state_sum += state[j] * C_val;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// parallel accumulation for output
|
|
180
|
+
state_sum = warp_reduce_sum(state_sum);
|
|
181
|
+
|
|
182
|
+
if (lane == 0) {
|
|
183
|
+
y_warp[i * stride_y] = state_sum;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// write back the state
|
|
188
|
+
#pragma unroll
|
|
189
|
+
for (int j = 0; j < c_factor; j++) {
|
|
190
|
+
s_warp[WARP_SIZE * j + lane] = state[j];
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
static void ssm_scan_f32_cuda(const float * src0, const float * src1, const float * src2, const float * src3,
|
|
195
|
+
const float * src4, const float * src5, const int32_t * src6, float * dst,
|
|
196
|
+
const int src0_nb2, const int src0_nb3, const int src1_nb2, const int src1_nb3, const int src2_nb1,
|
|
197
|
+
const int src2_nb2, const int src3_nb1, const int src4_nb2, const int src4_nb3, const int src5_nb2,
|
|
198
|
+
const int src5_nb3, const int64_t s_off, const int64_t d_state, const int64_t head_dim,
|
|
199
|
+
const int64_t n_head, const int64_t n_group, const int64_t n_tok, const int64_t n_seq,
|
|
200
|
+
cudaStream_t stream) {
|
|
201
|
+
// NOTE: if you change conditions here, be sure to update the corresponding supports_op condition!
|
|
202
|
+
if (src3_nb1 == sizeof(float)) {
|
|
203
|
+
// Mamba-2
|
|
204
|
+
if (d_state == 128) {
|
|
205
|
+
constexpr int threads = 128;
|
|
206
|
+
constexpr int num_warps = threads/WARP_SIZE;
|
|
207
|
+
|
|
208
|
+
const dim3 blocks((n_head * head_dim + (num_warps - 1)) / num_warps, n_seq, 1);
|
|
209
|
+
ssm_scan_f32_group<128/WARP_SIZE, 128><<<blocks, threads, 0, stream>>>(
|
|
210
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
211
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2, src3_nb1,
|
|
212
|
+
src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, head_dim, n_group, n_tok);
|
|
213
|
+
} else if (d_state == 256) { // Falcon-H1
|
|
214
|
+
constexpr int threads = 256;
|
|
215
|
+
constexpr int num_warps = threads/WARP_SIZE;
|
|
216
|
+
|
|
217
|
+
const dim3 blocks((n_head * head_dim + (num_warps - 1)) / num_warps, n_seq, 1);
|
|
218
|
+
ssm_scan_f32_group<256/WARP_SIZE, 256><<<blocks, threads, 0, stream>>>(
|
|
219
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
220
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2, src3_nb1,
|
|
221
|
+
src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, head_dim, n_group, n_tok);
|
|
222
|
+
} else {
|
|
223
|
+
GGML_ABORT("doesn't support d_state!=(128 or 256).");
|
|
224
|
+
}
|
|
225
|
+
} else {
|
|
226
|
+
// Mamba-1
|
|
227
|
+
constexpr int threads = 128;
|
|
228
|
+
GGML_ASSERT(n_head % threads == 0);
|
|
229
|
+
GGML_ASSERT(head_dim == 1);
|
|
230
|
+
GGML_ASSERT(n_group == 1);
|
|
231
|
+
const dim3 blocks(n_seq, (n_head + threads - 1) / threads, 1);
|
|
232
|
+
const int smem_size = (threads * (d_state + 1) * 2) * sizeof(float);
|
|
233
|
+
if (d_state == 16) {
|
|
234
|
+
switch (n_tok)
|
|
235
|
+
{
|
|
236
|
+
case 1:
|
|
237
|
+
ssm_scan_f32<threads, 16, 1><<<blocks, threads, smem_size, stream>>>(
|
|
238
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
239
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
240
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
241
|
+
break;
|
|
242
|
+
case 2:
|
|
243
|
+
ssm_scan_f32<threads, 16, 2><<<blocks, threads, smem_size, stream>>>(
|
|
244
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
245
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
246
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
247
|
+
break;
|
|
248
|
+
case 3:
|
|
249
|
+
ssm_scan_f32<threads, 16, 3><<<blocks, threads, smem_size, stream>>>(
|
|
250
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
251
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
252
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
253
|
+
break;
|
|
254
|
+
case 4:
|
|
255
|
+
ssm_scan_f32<threads, 16, 4><<<blocks, threads, smem_size, stream>>>(
|
|
256
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
257
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
258
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
259
|
+
break;
|
|
260
|
+
case 5:
|
|
261
|
+
ssm_scan_f32<threads, 16, 5><<<blocks, threads, smem_size, stream>>>(
|
|
262
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
263
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
264
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
265
|
+
break;
|
|
266
|
+
case 6:
|
|
267
|
+
ssm_scan_f32<threads, 16, 6><<<blocks, threads, smem_size, stream>>>(
|
|
268
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
269
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
270
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
271
|
+
break;
|
|
272
|
+
case 7:
|
|
273
|
+
ssm_scan_f32<threads, 16, 7><<<blocks, threads, smem_size, stream>>>(
|
|
274
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
275
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
276
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
277
|
+
break;
|
|
278
|
+
case 8:
|
|
279
|
+
ssm_scan_f32<threads, 16, 8><<<blocks, threads, smem_size, stream>>>(
|
|
280
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
281
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
282
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
283
|
+
break;
|
|
284
|
+
default:
|
|
285
|
+
ssm_scan_f32<threads, 16, 0><<<blocks, threads, smem_size, stream>>>(
|
|
286
|
+
src0, src1, src2, src3, src4, src5, src6, dst,
|
|
287
|
+
src0_nb2, src0_nb3, src1_nb2, src1_nb3, src2_nb1, src2_nb2,
|
|
288
|
+
src3_nb1, src4_nb2, src4_nb3, src5_nb2, src5_nb3, s_off, n_head, n_tok);
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
GGML_ABORT("doesn't support d_state!=16.");
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
void ggml_cuda_op_ssm_scan(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
298
|
+
const struct ggml_tensor * src0 = dst->src[0]; // s
|
|
299
|
+
const struct ggml_tensor * src1 = dst->src[1]; // x
|
|
300
|
+
const struct ggml_tensor * src2 = dst->src[2]; // dt
|
|
301
|
+
const struct ggml_tensor * src3 = dst->src[3]; // A
|
|
302
|
+
const struct ggml_tensor * src4 = dst->src[4]; // B
|
|
303
|
+
const struct ggml_tensor * src5 = dst->src[5]; // C
|
|
304
|
+
const struct ggml_tensor * src6 = dst->src[6]; // ids
|
|
305
|
+
|
|
306
|
+
const int64_t nc = src0->ne[0]; // d_state
|
|
307
|
+
const int64_t nr = src0->ne[1]; // head_dim or 1
|
|
308
|
+
const int64_t nh = src1->ne[1]; // n_head
|
|
309
|
+
const int64_t ng = src4->ne[1]; // n_group
|
|
310
|
+
const int64_t n_t = src1->ne[2]; // number of tokens per sequence
|
|
311
|
+
const int64_t n_s = src1->ne[3]; // number of sequences in the batch
|
|
312
|
+
|
|
313
|
+
const int64_t s_off = ggml_nelements(src1) * sizeof(float);
|
|
314
|
+
|
|
315
|
+
GGML_ASSERT(ggml_nelements(src1) + nc*nr*nh*n_s == ggml_nelements(dst));
|
|
316
|
+
GGML_ASSERT(src0->nb[0] == sizeof(float));
|
|
317
|
+
GGML_ASSERT(src1->nb[0] == sizeof(float));
|
|
318
|
+
GGML_ASSERT(src2->nb[0] == sizeof(float));
|
|
319
|
+
GGML_ASSERT(src3->nb[0] == sizeof(float));
|
|
320
|
+
GGML_ASSERT(src4->nb[0] == sizeof(float));
|
|
321
|
+
GGML_ASSERT(src5->nb[0] == sizeof(float));
|
|
322
|
+
GGML_ASSERT(src6->nb[0] == sizeof(int32_t));
|
|
323
|
+
|
|
324
|
+
const float * src0_d = (const float *) src0->data;
|
|
325
|
+
const float * src1_d = (const float *) src1->data;
|
|
326
|
+
const float * src2_d = (const float *) src2->data;
|
|
327
|
+
const float * src3_d = (const float *) src3->data;
|
|
328
|
+
const float * src4_d = (const float *) src4->data;
|
|
329
|
+
const float * src5_d = (const float *) src5->data;
|
|
330
|
+
const int32_t * src6_d = (const int32_t *) src6->data;
|
|
331
|
+
float * dst_d = (float *) dst->data;
|
|
332
|
+
cudaStream_t stream = ctx.stream();
|
|
333
|
+
|
|
334
|
+
GGML_ASSERT(src0->type == GGML_TYPE_F32);
|
|
335
|
+
GGML_ASSERT(src6->type == GGML_TYPE_I32);
|
|
336
|
+
GGML_ASSERT(dst->type == GGML_TYPE_F32);
|
|
337
|
+
|
|
338
|
+
ssm_scan_f32_cuda(src0_d, src1_d, src2_d, src3_d, src4_d, src5_d, src6_d, dst_d,
|
|
339
|
+
src0->nb[2], src0->nb[3], src1->nb[2], src1->nb[3], src2->nb[1], src2->nb[2],
|
|
340
|
+
src3->nb[1], src4->nb[2], src4->nb[3], src5->nb[2], src5->nb[3],
|
|
341
|
+
s_off, nc, nr, nh, ng, n_t, n_s, stream);
|
|
342
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#include "sum.cuh"
|
|
2
|
+
#include "sumrows.cuh"
|
|
3
|
+
|
|
4
|
+
#ifdef GGML_CUDA_USE_CUB
|
|
5
|
+
#include <cub/cub.cuh>
|
|
6
|
+
using namespace cub;
|
|
7
|
+
#endif // GGML_CUDA_USE_CUB
|
|
8
|
+
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
|
|
11
|
+
void sum_f32_cuda(ggml_cuda_pool & pool, const float * x, float * dst, const int64_t ne, cudaStream_t stream) {
|
|
12
|
+
#ifdef GGML_CUDA_USE_CUB
|
|
13
|
+
size_t tmp_size = 0;
|
|
14
|
+
DeviceReduce::Sum(nullptr, tmp_size, x, dst, ne, stream);
|
|
15
|
+
ggml_cuda_pool_alloc<uint8_t> tmp_alloc(pool, tmp_size);
|
|
16
|
+
DeviceReduce::Sum(tmp_alloc.ptr, tmp_size, x, dst, ne, stream);
|
|
17
|
+
#else
|
|
18
|
+
// Use (inefficient) sum_rows implementation as a fallback.
|
|
19
|
+
// For AMD there is rocPRIM which could be used as a drop-in replacement via hipcub but this would require C++11 -> C++14.
|
|
20
|
+
sum_rows_f32_cuda(x, dst, ne, 1, stream);
|
|
21
|
+
GGML_UNUSED(pool);
|
|
22
|
+
#endif // GGML_CUDA_USE_CUB
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void ggml_cuda_op_sum(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
26
|
+
const ggml_tensor * src0 = dst->src[0];
|
|
27
|
+
|
|
28
|
+
GGML_ASSERT(src0->type == GGML_TYPE_F32);
|
|
29
|
+
GGML_ASSERT( dst->type == GGML_TYPE_F32);
|
|
30
|
+
GGML_ASSERT(ggml_is_contiguously_allocated(src0));
|
|
31
|
+
|
|
32
|
+
const float * src0_d = (const float *) src0->data;
|
|
33
|
+
float * dst_d = (float *) dst->data;
|
|
34
|
+
|
|
35
|
+
const int64_t ne = ggml_nelements(src0);
|
|
36
|
+
|
|
37
|
+
ggml_cuda_pool & pool = ctx.pool();
|
|
38
|
+
cudaStream_t stream = ctx.stream();
|
|
39
|
+
|
|
40
|
+
sum_f32_cuda(pool, src0_d, dst_d, ne, stream);
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#include "reduce_rows.cuh"
|
|
2
|
+
#include "sumrows.cuh"
|
|
3
|
+
|
|
4
|
+
void sum_rows_f32_cuda(const float * x, float * dst, const int ncols, const int nrows, cudaStream_t stream) {
|
|
5
|
+
const int id = ggml_cuda_get_device();
|
|
6
|
+
const int nsm = ggml_cuda_info().devices[id].nsm;
|
|
7
|
+
const dim3 block_nums(nrows, 1, 1);
|
|
8
|
+
if ((nrows / nsm) < 2) {
|
|
9
|
+
const dim3 block_dims(512, 1, 1);
|
|
10
|
+
reduce_rows_f32</*norm=*/false><<<block_nums, block_dims, 0, stream>>>(x, dst, ncols);
|
|
11
|
+
} else {
|
|
12
|
+
const dim3 block_dims(ncols < 1024 ? 32 : 128, 1, 1);
|
|
13
|
+
reduce_rows_f32</*norm=*/false><<<block_nums, block_dims, 0, stream>>>(x, dst, ncols);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void ggml_cuda_op_sum_rows(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
18
|
+
const ggml_tensor * src0 = dst->src[0];
|
|
19
|
+
const float * src0_d = (const float *)src0->data;
|
|
20
|
+
float * dst_d = (float *)dst->data;
|
|
21
|
+
cudaStream_t stream = ctx.stream();
|
|
22
|
+
|
|
23
|
+
GGML_ASSERT(src0->type == GGML_TYPE_F32);
|
|
24
|
+
GGML_ASSERT( dst->type == GGML_TYPE_F32);
|
|
25
|
+
GGML_ASSERT(ggml_is_contiguous(src0));
|
|
26
|
+
|
|
27
|
+
const int64_t ncols = src0->ne[0];
|
|
28
|
+
const int64_t nrows = ggml_nrows(src0);
|
|
29
|
+
|
|
30
|
+
const dim3 block_nums(nrows, 1, 1);
|
|
31
|
+
|
|
32
|
+
const int id = ggml_cuda_get_device();
|
|
33
|
+
const int nsm = ggml_cuda_info().devices[id].nsm;
|
|
34
|
+
if ((nrows / nsm) < 2) {
|
|
35
|
+
// Increase num threads to 512 for small nrows to better hide the latency
|
|
36
|
+
const dim3 block_dims(512, 1, 1);
|
|
37
|
+
reduce_rows_f32</*norm=*/false><<<block_nums, block_dims, 0, stream>>>(src0_d, dst_d, ncols);
|
|
38
|
+
} else {
|
|
39
|
+
// Enough active SMs to hide latency, use smaller blocks to allow better scheduling
|
|
40
|
+
const dim3 block_dims(ncols < 1024 ? 32 : 128, 1, 1);
|
|
41
|
+
reduce_rows_f32</*norm=*/false><<<block_nums, block_dims, 0, stream>>>(src0_d, dst_d, ncols);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 1, 8);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 1, 8);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 1, 8);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 1, 8);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 1, 8);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 1, 8);
|
|
11
|
+
DECL_FATTN_MMA_F16_CASE(512, 512, 1, 8);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 16, 1);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 16, 1);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 16, 1);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 16, 1);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 16, 1);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 16, 1);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 16, 2);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 16, 2);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 16, 2);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 16, 2);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 16, 2);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 16, 2);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 16, 4);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 16, 4);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 16, 4);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 16, 4);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 16, 4);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 16, 4);
|
|
11
|
+
DECL_FATTN_MMA_F16_CASE(512, 512, 16, 4);
|
|
12
|
+
DECL_FATTN_MMA_F16_CASE(576, 512, 16, 4);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 2, 4);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 2, 4);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 2, 4);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 2, 4);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 2, 4);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 2, 4);
|
|
11
|
+
DECL_FATTN_MMA_F16_CASE(512, 512, 2, 4);
|
|
12
|
+
DECL_FATTN_MMA_F16_CASE(576, 512, 2, 4);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 2, 8);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 2, 8);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 2, 8);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 2, 8);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 2, 8);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 2, 8);
|
|
11
|
+
DECL_FATTN_MMA_F16_CASE(512, 512, 2, 8);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 32, 1);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 32, 1);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 32, 1);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 32, 1);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 32, 1);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 32, 1);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 32, 2);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 32, 2);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 32, 2);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 32, 2);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 32, 2);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 32, 2);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 4, 2);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 4, 2);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 4, 2);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 4, 2);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 4, 2);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 4, 2);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 4, 4);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 4, 4);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 4, 4);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 4, 4);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 4, 4);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 4, 4);
|
|
11
|
+
DECL_FATTN_MMA_F16_CASE(512, 512, 4, 4);
|
|
12
|
+
DECL_FATTN_MMA_F16_CASE(576, 512, 4, 4);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 4, 8);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 4, 8);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 4, 8);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 4, 8);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 4, 8);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 4, 8);
|
|
11
|
+
DECL_FATTN_MMA_F16_CASE(512, 512, 4, 8);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 64, 1);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 64, 1);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 64, 1);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 64, 1);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 64, 1);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 64, 1);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 8, 1);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 8, 1);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 8, 1);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 8, 1);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 8, 1);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 8, 1);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// This file has been autogenerated by generate_cu_files.py, do not edit manually.
|
|
2
|
+
|
|
3
|
+
#include "../fattn-mma-f16.cuh"
|
|
4
|
+
|
|
5
|
+
DECL_FATTN_MMA_F16_CASE(64, 64, 8, 2);
|
|
6
|
+
DECL_FATTN_MMA_F16_CASE(80, 80, 8, 2);
|
|
7
|
+
DECL_FATTN_MMA_F16_CASE(96, 96, 8, 2);
|
|
8
|
+
DECL_FATTN_MMA_F16_CASE(112, 112, 8, 2);
|
|
9
|
+
DECL_FATTN_MMA_F16_CASE(128, 128, 8, 2);
|
|
10
|
+
DECL_FATTN_MMA_F16_CASE(256, 256, 8, 2);
|