@fugood/llama.node 0.3.2 → 0.3.4
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.
- package/CMakeLists.txt +7 -0
- package/bin/darwin/arm64/llama-node.node +0 -0
- package/bin/darwin/x64/llama-node.node +0 -0
- package/bin/linux/arm64/llama-node.node +0 -0
- package/bin/linux/x64/llama-node.node +0 -0
- package/bin/linux-vulkan/arm64/llama-node.node +0 -0
- package/bin/linux-vulkan/x64/llama-node.node +0 -0
- package/bin/win32/arm64/llama-node.node +0 -0
- package/bin/win32/arm64/node.lib +0 -0
- package/bin/win32/x64/llama-node.node +0 -0
- package/bin/win32/x64/node.lib +0 -0
- package/bin/win32-vulkan/arm64/llama-node.node +0 -0
- package/bin/win32-vulkan/arm64/node.lib +0 -0
- package/bin/win32-vulkan/x64/llama-node.node +0 -0
- package/bin/win32-vulkan/x64/node.lib +0 -0
- package/lib/binding.ts +18 -1
- package/package.json +1 -1
- package/src/DetokenizeWorker.cpp +1 -1
- package/src/EmbeddingWorker.cpp +17 -7
- package/src/EmbeddingWorker.h +2 -1
- package/src/LlamaCompletionWorker.cpp +8 -8
- package/src/LlamaCompletionWorker.h +2 -2
- package/src/LlamaContext.cpp +89 -27
- package/src/LlamaContext.h +2 -0
- package/src/TokenizeWorker.cpp +1 -1
- package/src/common.hpp +4 -4
- package/src/llama.cpp/.github/workflows/build.yml +240 -168
- package/src/llama.cpp/.github/workflows/docker.yml +8 -8
- package/src/llama.cpp/.github/workflows/python-lint.yml +8 -1
- package/src/llama.cpp/.github/workflows/server.yml +21 -14
- package/src/llama.cpp/CMakeLists.txt +14 -6
- package/src/llama.cpp/Sources/llama/llama.h +4 -0
- package/src/llama.cpp/cmake/arm64-apple-clang.cmake +16 -0
- package/src/llama.cpp/cmake/common.cmake +33 -0
- package/src/llama.cpp/cmake/x64-windows-llvm.cmake +11 -0
- package/src/llama.cpp/common/CMakeLists.txt +6 -4
- package/src/llama.cpp/common/arg.cpp +986 -770
- package/src/llama.cpp/common/arg.h +22 -22
- package/src/llama.cpp/common/common.cpp +212 -351
- package/src/llama.cpp/common/common.h +204 -117
- package/src/llama.cpp/common/json-schema-to-grammar.cpp +1 -1
- package/src/llama.cpp/common/log.cpp +50 -50
- package/src/llama.cpp/common/log.h +18 -18
- package/src/llama.cpp/common/ngram-cache.cpp +36 -36
- package/src/llama.cpp/common/ngram-cache.h +19 -19
- package/src/llama.cpp/common/sampling.cpp +163 -121
- package/src/llama.cpp/common/sampling.h +41 -20
- package/src/llama.cpp/common/speculative.cpp +274 -0
- package/src/llama.cpp/common/speculative.h +28 -0
- package/src/llama.cpp/docs/build.md +134 -161
- package/src/llama.cpp/examples/CMakeLists.txt +33 -14
- package/src/llama.cpp/examples/batched/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/batched/batched.cpp +19 -18
- package/src/llama.cpp/examples/batched-bench/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/batched-bench/batched-bench.cpp +10 -11
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp +1 -1
- package/src/llama.cpp/examples/cvector-generator/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/cvector-generator/cvector-generator.cpp +9 -9
- package/src/llama.cpp/examples/deprecation-warning/deprecation-warning.cpp +1 -1
- package/src/llama.cpp/examples/embedding/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/embedding/embedding.cpp +12 -12
- package/src/llama.cpp/examples/eval-callback/CMakeLists.txt +3 -2
- package/src/llama.cpp/examples/eval-callback/eval-callback.cpp +8 -8
- package/src/llama.cpp/examples/export-lora/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/export-lora/export-lora.cpp +5 -5
- package/src/llama.cpp/examples/gbnf-validator/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gbnf-validator/gbnf-validator.cpp +4 -7
- package/src/llama.cpp/examples/gen-docs/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gen-docs/gen-docs.cpp +7 -7
- package/src/llama.cpp/examples/gguf/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gguf-hash/CMakeLists.txt +8 -1
- package/src/llama.cpp/examples/gguf-split/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gguf-split/gguf-split.cpp +2 -2
- package/src/llama.cpp/examples/gritlm/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gritlm/gritlm.cpp +18 -18
- package/src/llama.cpp/examples/imatrix/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/imatrix/imatrix.cpp +31 -13
- package/src/llama.cpp/examples/infill/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/infill/infill.cpp +41 -87
- package/src/llama.cpp/examples/llama-bench/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/llama-bench/llama-bench.cpp +439 -459
- package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +2 -0
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/llama-android.cpp +11 -14
- package/src/llama.cpp/examples/llava/CMakeLists.txt +10 -3
- package/src/llama.cpp/examples/llava/clip.cpp +263 -66
- package/src/llama.cpp/examples/llava/clip.h +8 -2
- package/src/llama.cpp/examples/llava/llava-cli.cpp +23 -23
- package/src/llama.cpp/examples/llava/llava.cpp +83 -22
- package/src/llama.cpp/examples/llava/minicpmv-cli.cpp +21 -21
- package/src/llama.cpp/examples/llava/qwen2vl-cli.cpp +581 -0
- package/src/llama.cpp/examples/lookahead/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/lookahead/lookahead.cpp +26 -26
- package/src/llama.cpp/examples/lookup/CMakeLists.txt +4 -4
- package/src/llama.cpp/examples/lookup/lookup-create.cpp +7 -7
- package/src/llama.cpp/examples/lookup/lookup-merge.cpp +4 -4
- package/src/llama.cpp/examples/lookup/lookup-stats.cpp +16 -15
- package/src/llama.cpp/examples/lookup/lookup.cpp +30 -30
- package/src/llama.cpp/examples/main/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/main/main.cpp +73 -114
- package/src/llama.cpp/examples/main-cmake-pkg/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/parallel/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/parallel/parallel.cpp +18 -19
- package/src/llama.cpp/examples/passkey/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/passkey/passkey.cpp +14 -14
- package/src/llama.cpp/examples/perplexity/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/perplexity/perplexity.cpp +99 -120
- package/src/llama.cpp/examples/quantize/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/quantize/quantize.cpp +0 -3
- package/src/llama.cpp/examples/quantize-stats/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/quantize-stats/quantize-stats.cpp +10 -9
- package/src/llama.cpp/examples/retrieval/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/retrieval/retrieval.cpp +16 -16
- package/src/llama.cpp/examples/rpc/rpc-server.cpp +3 -1
- package/src/llama.cpp/examples/run/CMakeLists.txt +5 -0
- package/src/llama.cpp/examples/run/run.cpp +911 -0
- package/src/llama.cpp/examples/save-load-state/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/save-load-state/save-load-state.cpp +38 -21
- package/src/llama.cpp/examples/server/CMakeLists.txt +3 -16
- package/src/llama.cpp/examples/server/server.cpp +2073 -1339
- package/src/llama.cpp/examples/server/tests/requirements.txt +2 -2
- package/src/llama.cpp/examples/server/utils.hpp +354 -277
- package/src/llama.cpp/examples/simple/CMakeLists.txt +2 -2
- package/src/llama.cpp/examples/simple/simple.cpp +130 -94
- package/src/llama.cpp/examples/simple-chat/CMakeLists.txt +5 -0
- package/src/llama.cpp/examples/simple-chat/simple-chat.cpp +200 -0
- package/src/llama.cpp/examples/speculative/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/speculative/speculative.cpp +68 -64
- package/src/llama.cpp/examples/speculative-simple/CMakeLists.txt +5 -0
- package/src/llama.cpp/examples/speculative-simple/speculative-simple.cpp +265 -0
- package/src/llama.cpp/examples/tokenize/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/tokenize/tokenize.cpp +3 -3
- package/src/llama.cpp/examples/tts/CMakeLists.txt +5 -0
- package/src/llama.cpp/examples/tts/tts.cpp +932 -0
- package/src/llama.cpp/ggml/CMakeLists.txt +54 -36
- package/src/llama.cpp/ggml/include/ggml-backend.h +63 -34
- package/src/llama.cpp/ggml/include/ggml-blas.h +5 -3
- package/src/llama.cpp/ggml/include/ggml-cann.h +9 -7
- package/src/llama.cpp/ggml/include/ggml-cpp.h +38 -0
- package/src/llama.cpp/ggml/include/ggml-cpu.h +135 -0
- package/src/llama.cpp/ggml/include/ggml-cuda.h +12 -12
- package/src/llama.cpp/ggml/include/ggml-kompute.h +7 -3
- package/src/llama.cpp/ggml/include/ggml-metal.h +11 -7
- package/src/llama.cpp/ggml/include/ggml-opencl.h +26 -0
- package/src/llama.cpp/ggml/include/ggml-opt.h +216 -0
- package/src/llama.cpp/ggml/include/ggml-rpc.h +9 -5
- package/src/llama.cpp/ggml/include/ggml-sycl.h +18 -11
- package/src/llama.cpp/ggml/include/ggml-vulkan.h +10 -8
- package/src/llama.cpp/ggml/include/ggml.h +159 -417
- package/src/llama.cpp/ggml/src/CMakeLists.txt +121 -1155
- package/src/llama.cpp/ggml/src/ggml-alloc.c +23 -28
- package/src/llama.cpp/ggml/src/ggml-backend-impl.h +57 -36
- package/src/llama.cpp/ggml/src/ggml-backend-reg.cpp +552 -0
- package/src/llama.cpp/ggml/src/ggml-backend.cpp +306 -867
- package/src/llama.cpp/ggml/src/ggml-blas/CMakeLists.txt +87 -0
- package/src/llama.cpp/ggml/src/{ggml-blas.cpp → ggml-blas/ggml-blas.cpp} +216 -65
- package/src/llama.cpp/ggml/src/ggml-cann/CMakeLists.txt +76 -0
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +456 -111
- package/src/llama.cpp/ggml/src/ggml-cann/common.h +6 -3
- package/src/llama.cpp/ggml/src/{ggml-cann.cpp → ggml-cann/ggml-cann.cpp} +343 -177
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/CMakeLists.txt +2 -5
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/dup.cpp +22 -9
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f16.cpp +24 -13
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f32.cpp +23 -13
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_q4_0.cpp +11 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f16_q8_0.cpp +10 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f32_q8_0.cpp +10 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_float_to_q4_0.cpp +17 -0
- package/src/llama.cpp/ggml/src/ggml-common.h +42 -42
- package/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt +336 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/amx/amx.cpp +220 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/amx/amx.h +8 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/amx/common.h +91 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/amx/mmq.cpp +2511 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/amx/mmq.h +10 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/cpu-feats-x86.cpp +323 -0
- package/src/llama.cpp/ggml/src/{ggml-aarch64.c → ggml-cpu/ggml-cpu-aarch64.cpp} +1299 -246
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-aarch64.h +8 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-hbm.cpp +55 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-hbm.h +8 -0
- package/src/llama.cpp/ggml/src/{ggml-cpu-impl.h → ggml-cpu/ggml-cpu-impl.h} +14 -242
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-quants.c +10835 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-quants.h +63 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-traits.cpp +36 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-traits.h +38 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c +14123 -0
- package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +628 -0
- package/src/llama.cpp/ggml/src/{llamafile → ggml-cpu/llamafile}/sgemm.cpp +666 -0
- package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +152 -0
- package/src/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +8 -0
- package/src/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt +104 -0
- package/src/llama.cpp/ggml/src/ggml-impl.h +393 -22
- package/src/llama.cpp/ggml/src/ggml-kompute/CMakeLists.txt +166 -0
- package/src/llama.cpp/ggml/src/{ggml-kompute.cpp → ggml-kompute/ggml-kompute.cpp} +360 -127
- package/src/llama.cpp/ggml/src/ggml-metal/CMakeLists.txt +105 -0
- package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +288 -0
- package/src/llama.cpp/ggml/src/ggml-musa/CMakeLists.txt +107 -0
- package/src/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +147 -0
- package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +4004 -0
- package/src/llama.cpp/ggml/src/ggml-opt.cpp +854 -0
- package/src/llama.cpp/ggml/src/ggml-quants.c +188 -10702
- package/src/llama.cpp/ggml/src/ggml-quants.h +78 -125
- package/src/llama.cpp/ggml/src/ggml-rpc/CMakeLists.txt +9 -0
- package/src/llama.cpp/ggml/src/{ggml-rpc.cpp → ggml-rpc/ggml-rpc.cpp} +478 -300
- package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +84 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +3 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +36 -5
- package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +259 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.cpp +3 -2
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +1 -1
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +5 -5
- package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +34 -35
- package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +1030 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.hpp +76 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +4 -4
- package/src/llama.cpp/ggml/src/{ggml-sycl.cpp → ggml-sycl/ggml-sycl.cpp} +3638 -4151
- package/src/llama.cpp/ggml/src/ggml-sycl/im2col.cpp +3 -2
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +6 -6
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +75 -87
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +7 -6
- package/src/llama.cpp/ggml/src/ggml-sycl/outprod.cpp +56 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/outprod.hpp +11 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/presets.hpp +6 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +4 -3
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +7 -7
- package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.cpp +1 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +4 -4
- package/src/llama.cpp/ggml/src/ggml-sycl/wkv6.cpp +141 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/wkv6.hpp +10 -0
- package/src/llama.cpp/ggml/src/ggml-threading.cpp +12 -0
- package/src/llama.cpp/ggml/src/ggml-threading.h +14 -0
- package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +92 -0
- package/src/llama.cpp/ggml/src/{ggml-vulkan.cpp → ggml-vulkan/ggml-vulkan.cpp} +2138 -887
- package/src/llama.cpp/ggml/src/{vulkan-shaders → ggml-vulkan/vulkan-shaders}/CMakeLists.txt +3 -1
- package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +593 -0
- package/src/llama.cpp/ggml/src/ggml.c +4427 -20125
- package/src/llama.cpp/include/llama-cpp.h +25 -0
- package/src/llama.cpp/include/llama.h +93 -52
- package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.out +46 -0
- package/src/llama.cpp/pocs/CMakeLists.txt +3 -1
- package/src/llama.cpp/pocs/vdot/CMakeLists.txt +2 -2
- package/src/llama.cpp/pocs/vdot/q8dot.cpp +4 -3
- package/src/llama.cpp/pocs/vdot/vdot.cpp +8 -7
- package/src/llama.cpp/src/CMakeLists.txt +4 -8
- package/src/llama.cpp/src/llama-grammar.cpp +15 -15
- package/src/llama.cpp/src/llama-grammar.h +2 -5
- package/src/llama.cpp/src/llama-sampling.cpp +779 -194
- package/src/llama.cpp/src/llama-sampling.h +21 -2
- package/src/llama.cpp/src/llama-vocab.cpp +55 -10
- package/src/llama.cpp/src/llama-vocab.h +35 -11
- package/src/llama.cpp/src/llama.cpp +4317 -2979
- package/src/llama.cpp/src/unicode-data.cpp +2 -2
- package/src/llama.cpp/src/unicode.cpp +62 -51
- package/src/llama.cpp/src/unicode.h +9 -10
- package/src/llama.cpp/tests/CMakeLists.txt +48 -38
- package/src/llama.cpp/tests/test-arg-parser.cpp +15 -15
- package/src/llama.cpp/tests/test-backend-ops.cpp +324 -80
- package/src/llama.cpp/tests/test-barrier.cpp +1 -0
- package/src/llama.cpp/tests/test-chat-template.cpp +59 -9
- package/src/llama.cpp/tests/test-gguf.cpp +1303 -0
- package/src/llama.cpp/tests/test-grammar-integration.cpp +3 -6
- package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +17 -4
- package/src/llama.cpp/tests/test-llama-grammar.cpp +2 -4
- package/src/llama.cpp/tests/test-log.cpp +2 -2
- package/src/llama.cpp/tests/test-opt.cpp +853 -142
- package/src/llama.cpp/tests/test-quantize-fns.cpp +24 -21
- package/src/llama.cpp/tests/test-quantize-perf.cpp +16 -14
- package/src/llama.cpp/tests/test-rope.cpp +62 -20
- package/src/llama.cpp/tests/test-sampling.cpp +163 -138
- package/src/llama.cpp/tests/test-tokenizer-0.cpp +7 -7
- package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +5 -5
- package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +5 -5
- package/src/llama.cpp/.github/workflows/nix-ci-aarch64.yml +0 -72
- package/src/llama.cpp/.github/workflows/nix-ci.yml +0 -79
- package/src/llama.cpp/.github/workflows/nix-flake-update.yml +0 -22
- package/src/llama.cpp/.github/workflows/nix-publish-flake.yml +0 -36
- package/src/llama.cpp/common/train.cpp +0 -1515
- package/src/llama.cpp/common/train.h +0 -233
- package/src/llama.cpp/examples/baby-llama/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/baby-llama/baby-llama.cpp +0 -1639
- package/src/llama.cpp/ggml/src/ggml-aarch64.h +0 -39
- package/src/llama.cpp/ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp +0 -600
- package/src/llama.cpp/tests/test-grad0.cpp +0 -1683
- /package/src/llama.cpp/ggml/{cmake → src/ggml-cpu/cmake}/FindSIMD.cmake +0 -0
- /package/src/llama.cpp/ggml/src/{llamafile → ggml-cpu/llamafile}/sgemm.h +0 -0
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
# 52 == 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
|
+
if (GGML_NATIVE AND CUDAToolkit_VERSION VERSION_GREATER_EQUAL "11.6" AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
|
|
16
|
+
set(CMAKE_CUDA_ARCHITECTURES "native")
|
|
17
|
+
elseif(GGML_CUDA_F16 OR GGML_CUDA_DMMV_F16)
|
|
18
|
+
set(CMAKE_CUDA_ARCHITECTURES "60;61;70;75")
|
|
19
|
+
else()
|
|
20
|
+
set(CMAKE_CUDA_ARCHITECTURES "52;61;70;75")
|
|
21
|
+
endif()
|
|
22
|
+
endif()
|
|
23
|
+
message(STATUS "Using CUDA architectures: ${CMAKE_CUDA_ARCHITECTURES}")
|
|
24
|
+
|
|
25
|
+
enable_language(CUDA)
|
|
26
|
+
|
|
27
|
+
file(GLOB GGML_HEADERS_CUDA "*.cuh")
|
|
28
|
+
list(APPEND GGML_HEADERS_CUDA "../../include/ggml-cuda.h")
|
|
29
|
+
|
|
30
|
+
file(GLOB GGML_SOURCES_CUDA "*.cu")
|
|
31
|
+
file(GLOB SRCS "template-instances/fattn-wmma*.cu")
|
|
32
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
33
|
+
file(GLOB SRCS "template-instances/mmq*.cu")
|
|
34
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
35
|
+
|
|
36
|
+
if (GGML_CUDA_FA_ALL_QUANTS)
|
|
37
|
+
file(GLOB SRCS "template-instances/fattn-vec*.cu")
|
|
38
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
39
|
+
add_compile_definitions(GGML_CUDA_FA_ALL_QUANTS)
|
|
40
|
+
else()
|
|
41
|
+
file(GLOB SRCS "template-instances/fattn-vec*q4_0-q4_0.cu")
|
|
42
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
43
|
+
file(GLOB SRCS "template-instances/fattn-vec*q8_0-q8_0.cu")
|
|
44
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
45
|
+
file(GLOB SRCS "template-instances/fattn-vec*f16-f16.cu")
|
|
46
|
+
list(APPEND GGML_SOURCES_CUDA ${SRCS})
|
|
47
|
+
endif()
|
|
48
|
+
|
|
49
|
+
ggml_add_backend_library(ggml-cuda
|
|
50
|
+
${GGML_HEADERS_CUDA}
|
|
51
|
+
${GGML_SOURCES_CUDA}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
add_compile_definitions(GGML_CUDA_PEER_MAX_BATCH_SIZE=${GGML_CUDA_PEER_MAX_BATCH_SIZE})
|
|
55
|
+
|
|
56
|
+
if (GGML_CUDA_GRAPHS)
|
|
57
|
+
add_compile_definitions(GGML_CUDA_USE_GRAPHS)
|
|
58
|
+
endif()
|
|
59
|
+
|
|
60
|
+
if (GGML_CUDA_FORCE_MMQ)
|
|
61
|
+
add_compile_definitions(GGML_CUDA_FORCE_MMQ)
|
|
62
|
+
endif()
|
|
63
|
+
|
|
64
|
+
if (GGML_CUDA_FORCE_CUBLAS)
|
|
65
|
+
add_compile_definitions(GGML_CUDA_FORCE_CUBLAS)
|
|
66
|
+
endif()
|
|
67
|
+
|
|
68
|
+
if (GGML_CUDA_NO_VMM)
|
|
69
|
+
add_compile_definitions(GGML_CUDA_NO_VMM)
|
|
70
|
+
endif()
|
|
71
|
+
|
|
72
|
+
if (GGML_CUDA_F16 OR GGML_CUDA_DMMV_F16)
|
|
73
|
+
add_compile_definitions(GGML_CUDA_F16)
|
|
74
|
+
endif()
|
|
75
|
+
|
|
76
|
+
if (GGML_CUDA_NO_PEER_COPY)
|
|
77
|
+
add_compile_definitions(GGML_CUDA_NO_PEER_COPY)
|
|
78
|
+
endif()
|
|
79
|
+
|
|
80
|
+
if (GGML_STATIC)
|
|
81
|
+
if (WIN32)
|
|
82
|
+
# As of 12.3.1 CUDA Toolkit for Windows does not offer a static cublas library
|
|
83
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cudart_static CUDA::cublas CUDA::cublasLt)
|
|
84
|
+
else ()
|
|
85
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cudart_static CUDA::cublas_static CUDA::cublasLt_static)
|
|
86
|
+
endif()
|
|
87
|
+
else()
|
|
88
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cudart CUDA::cublas CUDA::cublasLt)
|
|
89
|
+
endif()
|
|
90
|
+
|
|
91
|
+
if (GGML_CUDA_NO_VMM)
|
|
92
|
+
# No VMM requested, no need to link directly with the cuda driver lib (libcuda.so)
|
|
93
|
+
else()
|
|
94
|
+
target_link_libraries(ggml-cuda PRIVATE CUDA::cuda_driver)
|
|
95
|
+
endif()
|
|
96
|
+
|
|
97
|
+
set(CUDA_CXX_FLAGS "")
|
|
98
|
+
|
|
99
|
+
set(CUDA_FLAGS -use_fast_math)
|
|
100
|
+
|
|
101
|
+
if (GGML_FATAL_WARNINGS)
|
|
102
|
+
list(APPEND CUDA_FLAGS -Werror all-warnings)
|
|
103
|
+
endif()
|
|
104
|
+
|
|
105
|
+
if (GGML_ALL_WARNINGS AND NOT MSVC)
|
|
106
|
+
set(NVCC_CMD ${CMAKE_CUDA_COMPILER} .c)
|
|
107
|
+
if (NOT CMAKE_CUDA_HOST_COMPILER STREQUAL "")
|
|
108
|
+
list(APPEND NVCC_CMD -ccbin ${CMAKE_CUDA_HOST_COMPILER})
|
|
109
|
+
endif()
|
|
110
|
+
|
|
111
|
+
execute_process(
|
|
112
|
+
COMMAND ${NVCC_CMD} -Xcompiler --version
|
|
113
|
+
OUTPUT_VARIABLE CUDA_CCFULLVER
|
|
114
|
+
ERROR_QUIET
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
if (NOT CUDA_CCFULLVER MATCHES clang)
|
|
118
|
+
set(CUDA_CCID "GNU")
|
|
119
|
+
execute_process(
|
|
120
|
+
COMMAND ${NVCC_CMD} -Xcompiler "-dumpfullversion -dumpversion"
|
|
121
|
+
OUTPUT_VARIABLE CUDA_CCVER
|
|
122
|
+
ERROR_QUIET
|
|
123
|
+
)
|
|
124
|
+
else()
|
|
125
|
+
if (CUDA_CCFULLVER MATCHES Apple)
|
|
126
|
+
set(CUDA_CCID "AppleClang")
|
|
127
|
+
else()
|
|
128
|
+
set(CUDA_CCID "Clang")
|
|
129
|
+
endif()
|
|
130
|
+
string(REGEX REPLACE "^.* version ([0-9.]*).*$" "\\1" CUDA_CCVER ${CUDA_CCFULLVER})
|
|
131
|
+
endif()
|
|
132
|
+
|
|
133
|
+
message("-- CUDA host compiler is ${CUDA_CCID} ${CUDA_CCVER}")
|
|
134
|
+
|
|
135
|
+
ggml_get_flags(${CUDA_CCID} ${CUDA_CCVER})
|
|
136
|
+
list(APPEND CUDA_CXX_FLAGS ${CXX_FLAGS} ${GF_CXX_FLAGS}) # This is passed to -Xcompiler later
|
|
137
|
+
endif()
|
|
138
|
+
|
|
139
|
+
if (NOT MSVC)
|
|
140
|
+
list(APPEND CUDA_CXX_FLAGS -Wno-pedantic)
|
|
141
|
+
endif()
|
|
142
|
+
|
|
143
|
+
list(JOIN CUDA_CXX_FLAGS " " CUDA_CXX_FLAGS_JOINED) # pass host compiler flags as a single argument
|
|
144
|
+
|
|
145
|
+
if (NOT CUDA_CXX_FLAGS_JOINED STREQUAL "")
|
|
146
|
+
list(APPEND CUDA_FLAGS -Xcompiler ${CUDA_CXX_FLAGS_JOINED})
|
|
147
|
+
endif()
|
|
148
|
+
|
|
149
|
+
target_compile_options(ggml-cuda PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:${CUDA_FLAGS}>")
|
|
150
|
+
else()
|
|
151
|
+
message(FATAL_ERROR "CUDA Toolkit not found")
|
|
152
|
+
endif()
|
|
@@ -95,6 +95,14 @@
|
|
|
95
95
|
|
|
96
96
|
#define __CUDA_ARCH__ 1300
|
|
97
97
|
|
|
98
|
+
#if defined(__gfx803__) || defined(__gfx900__) || defined(__gfx906__)
|
|
99
|
+
#define GCN
|
|
100
|
+
#endif
|
|
101
|
+
|
|
102
|
+
#if defined(__gfx908__) || defined(__gfx90a__) || defined(__gfx942__)
|
|
103
|
+
#define CDNA
|
|
104
|
+
#endif
|
|
105
|
+
|
|
98
106
|
#if defined(__gfx1100__) || defined(__gfx1101__) || defined(__gfx1102__) || defined(__gfx1103__) || \
|
|
99
107
|
defined(__gfx1150__) || defined(__gfx1151__)
|
|
100
108
|
#define RDNA3
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
if (NOT EXISTS $ENV{ROCM_PATH})
|
|
2
|
+
if (NOT EXISTS /opt/rocm)
|
|
3
|
+
set(ROCM_PATH /usr)
|
|
4
|
+
else()
|
|
5
|
+
set(ROCM_PATH /opt/rocm)
|
|
6
|
+
endif()
|
|
7
|
+
else()
|
|
8
|
+
set(ROCM_PATH $ENV{ROCM_PATH})
|
|
9
|
+
endif()
|
|
10
|
+
|
|
11
|
+
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})
|
|
12
|
+
list(APPEND CMAKE_PREFIX_PATH "${ROCM_PATH}/lib64/cmake")
|
|
13
|
+
|
|
14
|
+
# CMake on Windows doesn't support the HIP language yet
|
|
15
|
+
if (WIN32)
|
|
16
|
+
set(CXX_IS_HIPCC TRUE)
|
|
17
|
+
else()
|
|
18
|
+
string(REGEX MATCH "hipcc(\.bat)?$" CXX_IS_HIPCC "${CMAKE_CXX_COMPILER}")
|
|
19
|
+
endif()
|
|
20
|
+
|
|
21
|
+
if (CXX_IS_HIPCC)
|
|
22
|
+
if (LINUX)
|
|
23
|
+
if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
|
24
|
+
message(WARNING "Only LLVM is supported for HIP, hint: CXX=/opt/rocm/llvm/bin/clang++")
|
|
25
|
+
endif()
|
|
26
|
+
|
|
27
|
+
message(WARNING "Setting hipcc as the C++ compiler is legacy behavior."
|
|
28
|
+
" Prefer setting the HIP compiler directly. See README for details.")
|
|
29
|
+
endif()
|
|
30
|
+
else()
|
|
31
|
+
# Forward AMDGPU_TARGETS to CMAKE_HIP_ARCHITECTURES.
|
|
32
|
+
if (AMDGPU_TARGETS AND NOT CMAKE_HIP_ARCHITECTURES)
|
|
33
|
+
set(CMAKE_HIP_ARCHITECTURES ${AMDGPU_TARGETS})
|
|
34
|
+
endif()
|
|
35
|
+
cmake_minimum_required(VERSION 3.21)
|
|
36
|
+
enable_language(HIP)
|
|
37
|
+
endif()
|
|
38
|
+
|
|
39
|
+
find_package(hip REQUIRED)
|
|
40
|
+
find_package(hipblas REQUIRED)
|
|
41
|
+
find_package(rocblas REQUIRED)
|
|
42
|
+
|
|
43
|
+
message(STATUS "HIP and hipBLAS found")
|
|
44
|
+
|
|
45
|
+
file(GLOB GGML_HEADERS_ROCM "../ggml-cuda/*.cuh")
|
|
46
|
+
list(APPEND GGML_HEADERS_ROCM "../../include/ggml-cuda.h")
|
|
47
|
+
|
|
48
|
+
file(GLOB GGML_SOURCES_ROCM "../ggml-cuda/*.cu")
|
|
49
|
+
file(GLOB SRCS "../ggml-cuda/template-instances/fattn-wmma*.cu")
|
|
50
|
+
list(APPEND GGML_SOURCES_ROCM ${SRCS})
|
|
51
|
+
file(GLOB SRCS "../ggml-cuda/template-instances/mmq*.cu")
|
|
52
|
+
list(APPEND GGML_SOURCES_ROCM ${SRCS})
|
|
53
|
+
|
|
54
|
+
if (GGML_CUDA_FA_ALL_QUANTS)
|
|
55
|
+
file(GLOB SRCS "../ggml-cuda/template-instances/fattn-vec*.cu")
|
|
56
|
+
list(APPEND GGML_SOURCES_ROCM ${SRCS})
|
|
57
|
+
add_compile_definitions(GGML_CUDA_FA_ALL_QUANTS)
|
|
58
|
+
else()
|
|
59
|
+
file(GLOB SRCS "../ggml-cuda/template-instances/fattn-vec*q4_0-q4_0.cu")
|
|
60
|
+
list(APPEND GGML_SOURCES_ROCM ${SRCS})
|
|
61
|
+
file(GLOB SRCS "../ggml-cuda/template-instances/fattn-vec*q8_0-q8_0.cu")
|
|
62
|
+
list(APPEND GGML_SOURCES_ROCM ${SRCS})
|
|
63
|
+
file(GLOB SRCS "../ggml-cuda/template-instances/fattn-vec*f16-f16.cu")
|
|
64
|
+
list(APPEND GGML_SOURCES_ROCM ${SRCS})
|
|
65
|
+
endif()
|
|
66
|
+
|
|
67
|
+
ggml_add_backend_library(ggml-hip
|
|
68
|
+
${GGML_HEADERS_ROCM}
|
|
69
|
+
${GGML_SOURCES_ROCM}
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# TODO: do not use CUDA definitions for HIP
|
|
73
|
+
target_compile_definitions(ggml PUBLIC GGML_USE_CUDA)
|
|
74
|
+
|
|
75
|
+
add_compile_definitions(GGML_USE_HIP)
|
|
76
|
+
|
|
77
|
+
if (GGML_HIP_UMA)
|
|
78
|
+
add_compile_definitions(GGML_HIP_UMA)
|
|
79
|
+
endif()
|
|
80
|
+
|
|
81
|
+
if (GGML_CUDA_FORCE_MMQ)
|
|
82
|
+
add_compile_definitions(GGML_CUDA_FORCE_MMQ)
|
|
83
|
+
endif()
|
|
84
|
+
|
|
85
|
+
if (GGML_CUDA_FORCE_CUBLAS)
|
|
86
|
+
add_compile_definitions(GGML_CUDA_FORCE_CUBLAS)
|
|
87
|
+
endif()
|
|
88
|
+
|
|
89
|
+
if (GGML_CUDA_NO_PEER_COPY)
|
|
90
|
+
add_compile_definitions(GGML_CUDA_NO_PEER_COPY)
|
|
91
|
+
endif()
|
|
92
|
+
|
|
93
|
+
if (CXX_IS_HIPCC)
|
|
94
|
+
set_source_files_properties(${GGML_SOURCES_ROCM} PROPERTIES LANGUAGE CXX)
|
|
95
|
+
target_link_libraries(ggml-hip PRIVATE hip::device)
|
|
96
|
+
else()
|
|
97
|
+
set_source_files_properties(${GGML_SOURCES_ROCM} PROPERTIES LANGUAGE HIP)
|
|
98
|
+
endif()
|
|
99
|
+
|
|
100
|
+
if (GGML_STATIC)
|
|
101
|
+
message(FATAL_ERROR "Static linking not supported for HIP/ROCm")
|
|
102
|
+
endif()
|
|
103
|
+
|
|
104
|
+
target_link_libraries(ggml-hip PRIVATE ggml-base hip::host roc::rocblas roc::hipblas)
|