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,272 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.18) # for CMAKE_CUDA_ARCHITECTURES
|
|
2
|
+
|
|
3
|
+
find_package(CUDAToolkit)
|
|
4
|
+
|
|
5
|
+
if (CUDAToolkit_FOUND)
|
|
6
|
+
message(STATUS "CUDA Toolkit found")
|
|
7
|
+
|
|
8
|
+
if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
|
|
9
|
+
# native == GPUs available at build time
|
|
10
|
+
# 50 == Maxwell, lowest CUDA 12 standard
|
|
11
|
+
# 60 == P100, FP16 CUDA intrinsics
|
|
12
|
+
# 61 == Pascal, __dp4a instruction (per-byte integer dot product)
|
|
13
|
+
# 70 == V100, FP16 tensor cores
|
|
14
|
+
# 75 == Turing, int8 tensor cores
|
|
15
|
+
# 80 == Ampere, asynchronous data loading, faster tensor core instructions
|
|
16
|
+
# 86 == RTX 3000, needs CUDA v11.1
|
|
17
|
+
# 89 == RTX 4000, needs CUDA v11.8
|
|
18
|
+
# 120 == Blackwell, needs CUDA v12.8, FP4 tensor cores
|
|
19
|
+
#
|
|
20
|
+
# XX-virtual == compile CUDA code as PTX, do JIT compilation to binary code on first run
|
|
21
|
+
# XX-real == compile CUDA code as device code for this specific architecture
|
|
22
|
+
# no suffix == compile as both PTX and device code
|
|
23
|
+
#
|
|
24
|
+
# The default behavior for a non-native is to build virtual architectures as needed to cover all features needed
|
|
25
|
+
# for best performance and to also build real architectures for the most commonly used GPUs.
|
|
26
|
+
if (GGML_NATIVE AND CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.6" AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
|
|
27
|
+
set(CMAKE_CUDA_ARCHITECTURES "native")
|
|
28
|
+
else()
|
|
29
|
+
if (CUDAToolkit_VERSION VERSION_LESS "13")
|
|
30
|
+
list(APPEND CMAKE_CUDA_ARCHITECTURES 50-virtual 61-virtual 70-virtual)
|
|
31
|
+
endif ()
|
|
32
|
+
|
|
33
|
+
list(APPEND CMAKE_CUDA_ARCHITECTURES 75-virtual 80-virtual 86-real)
|
|
34
|
+
|
|
35
|
+
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.8")
|
|
36
|
+
list(APPEND CMAKE_CUDA_ARCHITECTURES 89-real)
|
|
37
|
+
endif()
|
|
38
|
+
|
|
39
|
+
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "12.8")
|
|
40
|
+
# The CUDA architecture 120f-virtual would in principle work for Blackwell support
|
|
41
|
+
# but the newly added "f" suffix conflicted with a preexising regex for validating CUDA architectures in CMake.
|
|
42
|
+
# So either a recent CMake version or one with the backported fix is needed.
|
|
43
|
+
# The following versions should work:
|
|
44
|
+
# - CMake >= v3.31.8 && CMake < v4.0.0
|
|
45
|
+
# - CMake >= v4.0.2
|
|
46
|
+
# This is NOT documented in the CMake release notes,
|
|
47
|
+
# check Modules/Internal/CMakeCUDAArchitecturesValidate.cmake in the CMake git repository instead.
|
|
48
|
+
# However, the architectures 120a-real and 121a-real should work with basically any CMake version and
|
|
49
|
+
# until the release of e.g. Rubin there is no benefit to shipping virtual architectures for Blackwell.
|
|
50
|
+
list(APPEND CMAKE_CUDA_ARCHITECTURES 120a-real)
|
|
51
|
+
endif()
|
|
52
|
+
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "12.9")
|
|
53
|
+
list(APPEND CMAKE_CUDA_ARCHITECTURES 121a-real)
|
|
54
|
+
endif()
|
|
55
|
+
endif()
|
|
56
|
+
endif()
|
|
57
|
+
|
|
58
|
+
enable_language(CUDA)
|
|
59
|
+
|
|
60
|
+
# TODO: Remove once CCCL 3.2 has been released and bundled with CUDA Toolkit
|
|
61
|
+
if (GGML_CUDA_CUB_3DOT2)
|
|
62
|
+
include(FetchContent)
|
|
63
|
+
|
|
64
|
+
FetchContent_Declare(
|
|
65
|
+
CCCL
|
|
66
|
+
GIT_REPOSITORY https://github.com/nvidia/cccl.git
|
|
67
|
+
GIT_TAG v3.2.0
|
|
68
|
+
GIT_SHALLOW TRUE
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
FetchContent_MakeAvailable(CCCL)
|
|
72
|
+
endif()
|
|
73
|
+
|
|
74
|
+
# Replace any plain 12X CUDA architectures with their "architecture-specific" equivalents 12Xa.
|
|
75
|
+
# 12X is forwards-compatible, 12Xa is not.
|
|
76
|
+
# Notably the Blackwell FP4 tensor core instructions are not forwards compatible and therefore need 12Xa.
|
|
77
|
+
# But while 12X vs. 12Xa can be checked in device code there is (to my knowledge) no easy way to do the same check in host code.
|
|
78
|
+
# So for now just replace all instances of 12X with 12Xa, this should be fine until Rubin is released.
|
|
79
|
+
foreach(ARCHS IN ITEMS CMAKE_CUDA_ARCHITECTURES CMAKE_CUDA_ARCHITECTURES_NATIVE)
|
|
80
|
+
set(FIXED_ARCHS "")
|
|
81
|
+
foreach(ARCH IN LISTS ${ARCHS})
|
|
82
|
+
if (ARCH MATCHES "^12[0-9](-real|-virtual)?$")
|
|
83
|
+
string(REGEX REPLACE "^(12[0-9])((-real|-virtual)?)$" "\\1a\\2" FIXED_ARCH ${ARCH})
|
|
84
|
+
message(STATUS "Replacing ${ARCH} in ${ARCHS} with ${FIXED_ARCH}")
|
|
85
|
+
list(APPEND FIXED_ARCHS "${FIXED_ARCH}")
|
|
86
|
+
else()
|
|
87
|
+
list(APPEND FIXED_ARCHS "${ARCH}")
|
|
88
|
+
endif()
|
|
89
|
+
endforeach()
|
|
90
|
+
set(${ARCHS} ${FIXED_ARCHS})
|
|
91
|
+
endforeach()
|
|
92
|
+
|
|
93
|
+
# If we try to compile a "native" build it will use the 12X architectures and fail.
|
|
94
|
+
# So we should instead use the native architectures as determined by CMake after replacing 12X with 12Xa.
|
|
95
|
+
# But if at the time of the build no GPUs are connected at all CMAKE_CUDA_ARCHITECTURES will contain garbage that we should not use.
|
|
96
|
+
if (CMAKE_CUDA_ARCHITECTURES STREQUAL "native" AND CMAKE_CUDA_ARCHITECTURES_NATIVE MATCHES "^[0-9]+(a|f)?(-real|-virtual)?(;[0-9]+(a|f)?(-real|-virtual)?|;)*$")
|
|
97
|
+
set(CMAKE_CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES_NATIVE})
|
|
98
|
+
endif()
|
|
99
|
+
message(STATUS "Using CMAKE_CUDA_ARCHITECTURES=${CMAKE_CUDA_ARCHITECTURES} CMAKE_CUDA_ARCHITECTURES_NATIVE=${CMAKE_CUDA_ARCHITECTURES_NATIVE}")
|
|
100
|
+
|
|
101
|
+
file(GLOB GGML_HEADERS_CUDA "*.cuh")
|
|
102
|
+
list(APPEND GGML_HEADERS_CUDA "../../include/ggml-cuda.h")
|
|
103
|
+
|
|
104
|
+
file(GLOB GGML_SOURCES_CUDA "*.cu")
|
|
105
|
+
file(GLOB SRCS "template-instances/fattn-tile*.cu")
|
|
106
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
107
|
+
file(GLOB SRCS "template-instances/fattn-mma*.cu")
|
|
108
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
109
|
+
file(GLOB SRCS "template-instances/mmq*.cu")
|
|
110
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
111
|
+
file(GLOB SRCS "template-instances/mmf*.cu")
|
|
112
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
113
|
+
|
|
114
|
+
if (GGML_CUDA_FA_ALL_QUANTS)
|
|
115
|
+
file(GLOB SRCS "template-instances/fattn-vec*.cu")
|
|
116
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
117
|
+
add_compile_definitions(GGML_CUDA_FA_ALL_QUANTS)
|
|
118
|
+
else()
|
|
119
|
+
list(APPEND GGML_SOURCES_CUDA
|
|
120
|
+
template-instances/fattn-vec-instance-f16-f16.cu
|
|
121
|
+
template-instances/fattn-vec-instance-q4_0-q4_0.cu
|
|
122
|
+
template-instances/fattn-vec-instance-q8_0-q8_0.cu
|
|
123
|
+
template-instances/fattn-vec-instance-bf16-bf16.cu)
|
|
124
|
+
endif()
|
|
125
|
+
|
|
126
|
+
ggml_add_backend_library(ggml-cuda
|
|
127
|
+
${GGML_HEADERS_CUDA}
|
|
128
|
+
${GGML_SOURCES_CUDA}
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
add_compile_definitions(GGML_CUDA_PEER_MAX_BATCH_SIZE=${GGML_CUDA_PEER_MAX_BATCH_SIZE})
|
|
132
|
+
|
|
133
|
+
if (GGML_CUDA_GRAPHS)
|
|
134
|
+
add_compile_definitions(GGML_CUDA_USE_GRAPHS)
|
|
135
|
+
endif()
|
|
136
|
+
|
|
137
|
+
if (GGML_CUDA_CRISPASR_FA_PERHEAD_MASK)
|
|
138
|
+
add_compile_definitions(GGML_CUDA_CRISPASR_FA_PERHEAD_MASK)
|
|
139
|
+
endif()
|
|
140
|
+
|
|
141
|
+
if (GGML_CUDA_FORCE_MMQ)
|
|
142
|
+
add_compile_definitions(GGML_CUDA_FORCE_MMQ)
|
|
143
|
+
endif()
|
|
144
|
+
|
|
145
|
+
if (GGML_CUDA_FORCE_CUBLAS)
|
|
146
|
+
add_compile_definitions(GGML_CUDA_FORCE_CUBLAS)
|
|
147
|
+
endif()
|
|
148
|
+
|
|
149
|
+
if (GGML_CUDA_NO_VMM)
|
|
150
|
+
add_compile_definitions(GGML_CUDA_NO_VMM)
|
|
151
|
+
endif()
|
|
152
|
+
|
|
153
|
+
if (NOT GGML_CUDA_FA)
|
|
154
|
+
add_compile_definitions(GGML_CUDA_NO_FA)
|
|
155
|
+
endif()
|
|
156
|
+
|
|
157
|
+
if (GGML_CUDA_NO_PEER_COPY)
|
|
158
|
+
add_compile_definitions(GGML_CUDA_NO_PEER_COPY)
|
|
159
|
+
endif()
|
|
160
|
+
|
|
161
|
+
if (GGML_STATIC)
|
|
162
|
+
if (WIN32)
|
|
163
|
+
# As of 12.3.1 CUDA Toolkit for Windows does not offer a static cublas library
|
|
164
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cudart_static CUDA::cublas)
|
|
165
|
+
else ()
|
|
166
|
+
if (GGML_CUDA_CUB_3DOT2)
|
|
167
|
+
target_link_libraries(ggml-cuda PRIVATE CCCL::CCCL)
|
|
168
|
+
endif()
|
|
169
|
+
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "10.1")
|
|
170
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cudart_static CUDA::cublas_static CUDA::cublasLt_static)
|
|
171
|
+
else()
|
|
172
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cudart_static CUDA::cublas_static)
|
|
173
|
+
endif()
|
|
174
|
+
endif()
|
|
175
|
+
else()
|
|
176
|
+
if (GGML_CUDA_CUB_3DOT2)
|
|
177
|
+
target_link_libraries(ggml-cuda PRIVATE CCCL::CCCL)
|
|
178
|
+
endif()
|
|
179
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cudart CUDA::cublas)
|
|
180
|
+
endif()
|
|
181
|
+
|
|
182
|
+
if (GGML_CUDA_NO_VMM)
|
|
183
|
+
# No VMM requested, no need to link directly with the cuda driver lib (libcuda.so)
|
|
184
|
+
else()
|
|
185
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cuda_driver)
|
|
186
|
+
endif()
|
|
187
|
+
|
|
188
|
+
if (GGML_CUDA_NCCL)
|
|
189
|
+
find_package(NCCL)
|
|
190
|
+
if (NCCL_FOUND)
|
|
191
|
+
add_compile_definitions(GGML_USE_NCCL)
|
|
192
|
+
target_link_libraries(ggml-cuda PRIVATE NCCL::NCCL)
|
|
193
|
+
else()
|
|
194
|
+
message(STATUS "Warning: NCCL not found, performance for multiple CUDA GPUs will be suboptimal")
|
|
195
|
+
endif()
|
|
196
|
+
endif()
|
|
197
|
+
|
|
198
|
+
set(CUDA_CXX_FLAGS "")
|
|
199
|
+
|
|
200
|
+
set(CUDA_FLAGS -use_fast_math -extended-lambda)
|
|
201
|
+
|
|
202
|
+
if (GGML_CUDA_DEBUG)
|
|
203
|
+
list(APPEND CUDA_FLAGS -lineinfo)
|
|
204
|
+
add_compile_definitions(GGML_CUDA_DEBUG)
|
|
205
|
+
endif()
|
|
206
|
+
|
|
207
|
+
if (CUDAToolkit_VERSION VERSION_GREATER_EQUAL "12.8")
|
|
208
|
+
# Options are:
|
|
209
|
+
# - none (not recommended)
|
|
210
|
+
# - speed (nvcc's default)
|
|
211
|
+
# - balance
|
|
212
|
+
# - size
|
|
213
|
+
list(APPEND CUDA_FLAGS -compress-mode=${GGML_CUDA_COMPRESSION_MODE})
|
|
214
|
+
endif()
|
|
215
|
+
|
|
216
|
+
if (GGML_FATAL_WARNINGS)
|
|
217
|
+
list(APPEND CUDA_FLAGS -Werror all-warnings)
|
|
218
|
+
endif()
|
|
219
|
+
|
|
220
|
+
if (GGML_ALL_WARNINGS AND NOT MSVC)
|
|
221
|
+
set(NVCC_CMD ${CMAKE_CUDA_COMPILER} .c)
|
|
222
|
+
if (NOT CMAKE_CUDA_HOST_COMPILER STREQUAL "")
|
|
223
|
+
list(APPEND NVCC_CMD -ccbin ${CMAKE_CUDA_HOST_COMPILER})
|
|
224
|
+
endif()
|
|
225
|
+
|
|
226
|
+
execute_process(
|
|
227
|
+
COMMAND ${NVCC_CMD} -Xcompiler --version
|
|
228
|
+
OUTPUT_VARIABLE CUDA_CCFULLVER
|
|
229
|
+
ERROR_QUIET
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
if (NOT CUDA_CCFULLVER MATCHES clang)
|
|
233
|
+
set(CUDA_CCID "GNU")
|
|
234
|
+
execute_process(
|
|
235
|
+
COMMAND ${NVCC_CMD} -Xcompiler "-dumpfullversion -dumpversion"
|
|
236
|
+
OUTPUT_VARIABLE CUDA_CCVER
|
|
237
|
+
ERROR_QUIET
|
|
238
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
239
|
+
)
|
|
240
|
+
else()
|
|
241
|
+
if (CUDA_CCFULLVER MATCHES Apple)
|
|
242
|
+
set(CUDA_CCID "AppleClang")
|
|
243
|
+
else()
|
|
244
|
+
set(CUDA_CCID "Clang")
|
|
245
|
+
endif()
|
|
246
|
+
string(REGEX REPLACE "^.* version ([0-9.]*).*$" "\\1" CUDA_CCVER ${CUDA_CCFULLVER})
|
|
247
|
+
endif()
|
|
248
|
+
|
|
249
|
+
message(STATUS "CUDA host compiler is ${CUDA_CCID} ${CUDA_CCVER}")
|
|
250
|
+
|
|
251
|
+
ggml_get_flags(${CUDA_CCID} ${CUDA_CCVER})
|
|
252
|
+
list(APPEND CUDA_CXX_FLAGS ${CXX_FLAGS} ${GF_CXX_FLAGS}) # This is passed to -Xcompiler later
|
|
253
|
+
endif()
|
|
254
|
+
|
|
255
|
+
if (NOT MSVC)
|
|
256
|
+
list(APPEND CUDA_CXX_FLAGS -Wno-pedantic)
|
|
257
|
+
else()
|
|
258
|
+
# CCCL 3.2 onwards will require a cpp-standard-compliant preprocessor for MSVC
|
|
259
|
+
# https://github.com/NVIDIA/cccl/pull/6827
|
|
260
|
+
list(APPEND CUDA_CXX_FLAGS /Zc:preprocessor)
|
|
261
|
+
endif()
|
|
262
|
+
|
|
263
|
+
list(JOIN CUDA_CXX_FLAGS " " CUDA_CXX_FLAGS_JOINED) # pass host compiler flags as a single argument
|
|
264
|
+
|
|
265
|
+
if (NOT CUDA_CXX_FLAGS_JOINED STREQUAL "")
|
|
266
|
+
list(APPEND CUDA_FLAGS -Xcompiler ${CUDA_CXX_FLAGS_JOINED})
|
|
267
|
+
endif()
|
|
268
|
+
|
|
269
|
+
target_compile_options(ggml-cuda PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:${CUDA_FLAGS}>")
|
|
270
|
+
else()
|
|
271
|
+
message(FATAL_ERROR "CUDA Toolkit not found")
|
|
272
|
+
endif()
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#include "acc.cuh"
|
|
2
|
+
|
|
3
|
+
static __global__ void acc_f32(const float * x, const float * y, float * dst, const int64_t ne,
|
|
4
|
+
const int64_t ne10, const int64_t ne11, const int64_t ne12, const int64_t ne13,
|
|
5
|
+
const int64_t s11, const int64_t s12, const int64_t s13, const int64_t offset) {
|
|
6
|
+
const int64_t i = blockDim.x * blockIdx.x + threadIdx.x;
|
|
7
|
+
|
|
8
|
+
if (i >= ne) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
int64_t src1_idx = i - offset;
|
|
13
|
+
|
|
14
|
+
int64_t tmp = src1_idx;
|
|
15
|
+
const int64_t i13 = tmp / s13;
|
|
16
|
+
tmp -= i13 * s13;
|
|
17
|
+
const int64_t i12 = tmp / s12;
|
|
18
|
+
tmp -= i12 * s12;
|
|
19
|
+
const int64_t i11 = tmp / s11;
|
|
20
|
+
tmp -= i11 * s11;
|
|
21
|
+
const int64_t i10 = tmp;
|
|
22
|
+
|
|
23
|
+
float val = x[i];
|
|
24
|
+
if (src1_idx >= 0 && i10 < ne10 && i11 < ne11 && i12 < ne12 && i13 < ne13) {
|
|
25
|
+
val += y[((i13*ne12 + i12) * ne11 + i11) * ne10 + i10];
|
|
26
|
+
}
|
|
27
|
+
dst[i] = val;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static void acc_f32_cuda(const float * x, const float * y, float * dst, const int64_t n_elements,
|
|
31
|
+
const int64_t ne10, const int64_t ne11, const int64_t ne12, const int64_t ne13,
|
|
32
|
+
const int64_t s1, const int64_t s2, const int64_t s3, const int64_t offset, cudaStream_t stream) {
|
|
33
|
+
const int num_blocks = (n_elements + CUDA_ACC_BLOCK_SIZE - 1) / CUDA_ACC_BLOCK_SIZE;
|
|
34
|
+
acc_f32<<<num_blocks, CUDA_ACC_BLOCK_SIZE, 0, stream>>>(x, y, dst, n_elements, ne10, ne11, ne12, ne13, s1, s2, s3, offset);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
void ggml_cuda_op_acc(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
38
|
+
const ggml_tensor * src0 = dst->src[0];
|
|
39
|
+
const ggml_tensor * src1 = dst->src[1];
|
|
40
|
+
|
|
41
|
+
const float * src0_d = (const float *) src0->data;
|
|
42
|
+
const float * src1_d = (const float *) src1->data;
|
|
43
|
+
float * dst_d = (float *) dst->data;
|
|
44
|
+
|
|
45
|
+
cudaStream_t stream = ctx.stream();
|
|
46
|
+
|
|
47
|
+
GGML_ASSERT(src0->type == GGML_TYPE_F32);
|
|
48
|
+
GGML_ASSERT(src1->type == GGML_TYPE_F32);
|
|
49
|
+
GGML_ASSERT( dst->type == GGML_TYPE_F32);
|
|
50
|
+
|
|
51
|
+
GGML_ASSERT(ggml_is_contiguous(src1));
|
|
52
|
+
GGML_ASSERT(dst->nb[0] == ggml_element_size(dst));
|
|
53
|
+
GGML_ASSERT(ggml_is_contiguously_allocated(dst));
|
|
54
|
+
|
|
55
|
+
const int64_t s1 = dst->op_params[0] / sizeof(float);
|
|
56
|
+
const int64_t s2 = dst->op_params[1] / sizeof(float);
|
|
57
|
+
const int64_t s3 = dst->op_params[2] / sizeof(float);
|
|
58
|
+
const int64_t offset = dst->op_params[3] / sizeof(float);
|
|
59
|
+
|
|
60
|
+
acc_f32_cuda(src0_d, src1_d, dst_d, ggml_nelements(dst), src1->ne[0], src1->ne[1], src1->ne[2], src1->ne[3], s1, s2, s3, offset, stream);
|
|
61
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#include "add-id.cuh"
|
|
2
|
+
|
|
3
|
+
static __global__ void add_id_kernel(
|
|
4
|
+
const float * src0, const float * src1, const int32_t * src2, float * dst,
|
|
5
|
+
int64_t ne0, int64_t ne1,
|
|
6
|
+
size_t nb01, size_t nb02,
|
|
7
|
+
size_t nb11,
|
|
8
|
+
size_t nb21
|
|
9
|
+
) {
|
|
10
|
+
|
|
11
|
+
const int64_t i1 = blockIdx.x;
|
|
12
|
+
const int64_t i2 = blockIdx.y;
|
|
13
|
+
|
|
14
|
+
const int i11 = *(const int32_t *) ((const char *) src2 + i1*sizeof(int32_t) + i2*nb21);
|
|
15
|
+
|
|
16
|
+
const size_t nb1 = ne0 * sizeof(float);
|
|
17
|
+
const size_t nb2 = ne1 * nb1;
|
|
18
|
+
|
|
19
|
+
float * dst_row = (float *)((char *)dst + i1*nb1 + i2*nb2);
|
|
20
|
+
const float * src0_row = (const float *)((const char *)src0 + i1*nb01 + i2*nb02);
|
|
21
|
+
const float * src1_row = (const float *)((const char *)src1 + i11*nb11);
|
|
22
|
+
|
|
23
|
+
for (int64_t i0 = threadIdx.x; i0 < ne0; i0 += blockDim.x) {
|
|
24
|
+
dst_row[i0] = src0_row[i0] + src1_row[i0];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void ggml_cuda_op_add_id(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
29
|
+
const ggml_tensor * src0 = dst->src[0];
|
|
30
|
+
const ggml_tensor * src1 = dst->src[1];
|
|
31
|
+
const ggml_tensor * src2 = dst->src[2];
|
|
32
|
+
|
|
33
|
+
GGML_TENSOR_TERNARY_OP_LOCALS
|
|
34
|
+
|
|
35
|
+
GGML_ASSERT(dst->type == GGML_TYPE_F32);
|
|
36
|
+
GGML_ASSERT(src0->type == GGML_TYPE_F32);
|
|
37
|
+
GGML_ASSERT(src1->type == GGML_TYPE_F32);
|
|
38
|
+
GGML_ASSERT(src2->type == GGML_TYPE_I32);
|
|
39
|
+
|
|
40
|
+
GGML_ASSERT(nb00 == sizeof(float));
|
|
41
|
+
GGML_ASSERT(nb10 == sizeof(float));
|
|
42
|
+
GGML_ASSERT(nb20 == sizeof(int32_t));
|
|
43
|
+
|
|
44
|
+
const float * src0_d = (const float *)src0->data;
|
|
45
|
+
const float * src1_d = (const float *)src1->data;
|
|
46
|
+
const int32_t * src2_d = (const int32_t *)src2->data;
|
|
47
|
+
float * dst_d = (float *)dst->data;
|
|
48
|
+
|
|
49
|
+
int threads = std::min((int)ne00, 768); // cols
|
|
50
|
+
dim3 blocks(ne01, ne02); // n_experts_used, n_tokens
|
|
51
|
+
add_id_kernel<<<blocks, threads, 0, ctx.stream()>>>(
|
|
52
|
+
src0_d, src1_d, src2_d, dst_d,
|
|
53
|
+
ne0, ne1,
|
|
54
|
+
nb01, nb02,
|
|
55
|
+
nb11,
|
|
56
|
+
nb21
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#include "arange.cuh"
|
|
2
|
+
|
|
3
|
+
static __global__ void arange_f32(float * dst, const int ne0, const float start, const float step) {
|
|
4
|
+
// blockIDx.x: idx of ne0 / BLOCK_SIZE
|
|
5
|
+
int nidx = threadIdx.x + blockIdx.x * blockDim.x;
|
|
6
|
+
if (nidx >= ne0) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
dst[nidx] = start + step * nidx;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static void arange_f32_cuda(float * dst, const int ne0, const float start, const float step, cudaStream_t stream) {
|
|
13
|
+
int num_blocks = (ne0 + CUDA_ARANGE_BLOCK_SIZE - 1) / CUDA_ARANGE_BLOCK_SIZE;
|
|
14
|
+
arange_f32<<<num_blocks, CUDA_ARANGE_BLOCK_SIZE, 0, stream>>>(dst, ne0, start, step);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void ggml_cuda_op_arange(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
18
|
+
float * dst_d = (float *)dst->data;
|
|
19
|
+
cudaStream_t stream = ctx.stream();
|
|
20
|
+
|
|
21
|
+
GGML_ASSERT(dst->type == GGML_TYPE_F32);
|
|
22
|
+
|
|
23
|
+
float start;
|
|
24
|
+
float stop;
|
|
25
|
+
float step;
|
|
26
|
+
memcpy(&start, (float *)dst->op_params + 0, sizeof(float));
|
|
27
|
+
memcpy(&stop, (float *)dst->op_params + 1, sizeof(float));
|
|
28
|
+
memcpy(&step, (float *)dst->op_params + 2, sizeof(float));
|
|
29
|
+
|
|
30
|
+
int64_t steps = (int64_t)ceil((stop - start) / step);
|
|
31
|
+
GGML_ASSERT(ggml_nelements(dst) == steps);
|
|
32
|
+
|
|
33
|
+
arange_f32_cuda(dst_d, dst->ne[0], start, step, stream);
|
|
34
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#include <algorithm>
|
|
2
|
+
#include <cstdint>
|
|
3
|
+
|
|
4
|
+
#include "argmax.cuh"
|
|
5
|
+
#include "common.cuh"
|
|
6
|
+
#include "sum.cuh"
|
|
7
|
+
|
|
8
|
+
static __global__ void argmax_f32(const float * __restrict__ x, int32_t * __restrict__ dst, const int64_t ncols) {
|
|
9
|
+
const int64_t row = blockIdx.x;
|
|
10
|
+
|
|
11
|
+
float maxval = -FLT_MAX;
|
|
12
|
+
int argmax = -1;
|
|
13
|
+
const float * rowx = x + row * ncols;
|
|
14
|
+
|
|
15
|
+
for (int32_t col = threadIdx.x; col < ncols; col += blockDim.x) {
|
|
16
|
+
const float val = rowx[col];
|
|
17
|
+
if (val > maxval) {
|
|
18
|
+
maxval = val;
|
|
19
|
+
argmax = col;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#pragma unroll
|
|
24
|
+
for (int offset = WARP_SIZE/2; offset > 0; offset >>= 1) {
|
|
25
|
+
const float val = __shfl_xor_sync(0xFFFFFFFF, maxval, offset, WARP_SIZE);
|
|
26
|
+
const int col = __shfl_xor_sync(0xFFFFFFFF, argmax, offset, WARP_SIZE);
|
|
27
|
+
if (val > maxval) {
|
|
28
|
+
maxval = val;
|
|
29
|
+
argmax = col;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const int n_warps = blockDim.x / WARP_SIZE;
|
|
34
|
+
const int lane_id = threadIdx.x % WARP_SIZE;
|
|
35
|
+
const int warp_id = threadIdx.x / WARP_SIZE;
|
|
36
|
+
if (n_warps > 1) {
|
|
37
|
+
constexpr int max_warps = 1024 / WARP_SIZE;
|
|
38
|
+
__shared__ float shared_maxval[max_warps];
|
|
39
|
+
__shared__ int shared_argmax[max_warps];
|
|
40
|
+
if (lane_id == 0) {
|
|
41
|
+
shared_maxval[warp_id] = maxval;
|
|
42
|
+
shared_argmax[warp_id] = argmax;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
__syncthreads();
|
|
46
|
+
|
|
47
|
+
if (warp_id == 0) {
|
|
48
|
+
if (lane_id < n_warps) {
|
|
49
|
+
maxval = shared_maxval[lane_id];
|
|
50
|
+
argmax = shared_argmax[lane_id];
|
|
51
|
+
}
|
|
52
|
+
#pragma unroll
|
|
53
|
+
for (int offset = WARP_SIZE/2; offset > 0; offset >>= 1) {
|
|
54
|
+
const float val = __shfl_xor_sync(0xFFFFFFFF, maxval, offset, WARP_SIZE);
|
|
55
|
+
const int col = __shfl_xor_sync(0xFFFFFFFF, argmax, offset, WARP_SIZE);
|
|
56
|
+
if (val > maxval) {
|
|
57
|
+
maxval = val;
|
|
58
|
+
argmax = col;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (warp_id == 0 && lane_id == 0) {
|
|
65
|
+
dst[row] = argmax;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
void ggml_cuda_argmax(ggml_backend_cuda_context & ctx, ggml_tensor * dst) {
|
|
70
|
+
const ggml_tensor * src0 = dst->src[0];
|
|
71
|
+
|
|
72
|
+
GGML_ASSERT(src0->type == GGML_TYPE_F32);
|
|
73
|
+
GGML_ASSERT( dst->type == GGML_TYPE_I32);
|
|
74
|
+
|
|
75
|
+
GGML_ASSERT(ggml_is_contiguous(src0));
|
|
76
|
+
|
|
77
|
+
const int64_t ne00 = src0->ne[0];
|
|
78
|
+
const int64_t nrows = ggml_nrows(src0);
|
|
79
|
+
|
|
80
|
+
const float * src0_d = (const float *) src0->data;
|
|
81
|
+
int32_t * dst_d = (int32_t *) dst->data;
|
|
82
|
+
|
|
83
|
+
cudaStream_t stream = ctx.stream();
|
|
84
|
+
|
|
85
|
+
const int64_t num_blocks = nrows;
|
|
86
|
+
const int64_t num_threads = std::min<int64_t>(1024, (ne00 + WARP_SIZE - 1) / WARP_SIZE * WARP_SIZE);
|
|
87
|
+
const dim3 blocks_dim(num_threads, 1, 1);
|
|
88
|
+
const dim3 blocks_num(num_blocks, 1, 1);
|
|
89
|
+
|
|
90
|
+
argmax_f32<<<blocks_num, blocks_dim, 0, stream>>>(src0_d, dst_d, ne00);
|
|
91
|
+
}
|