@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
|
@@ -7,124 +7,75 @@ git clone https://github.com/ggerganov/llama.cpp
|
|
|
7
7
|
cd llama.cpp
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
The following sections describe how to build with different backends and options.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
- On Linux or MacOS:
|
|
12
|
+
## CPU Build
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
make
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
- On Windows (x86/x64 only, arm64 requires cmake):
|
|
14
|
+
Build llama.cpp using `CMake`:
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
5. From here you can run:
|
|
26
|
-
```bash
|
|
27
|
-
make
|
|
28
|
-
```
|
|
16
|
+
```bash
|
|
17
|
+
cmake -B build
|
|
18
|
+
cmake --build build --config Release
|
|
19
|
+
```
|
|
29
20
|
|
|
30
|
-
|
|
31
|
-
- For `Q4_0_4_4` quantization type build, add the `GGML_NO_LLAMAFILE=1` flag. For example, use `make GGML_NO_LLAMAFILE=1`.
|
|
32
|
-
- For faster compilation, add the `-j` argument to run multiple jobs in parallel. For example, `make -j 8` will run 8 jobs in parallel.
|
|
33
|
-
- For faster repeated compilation, install [ccache](https://ccache.dev/).
|
|
34
|
-
- For debug builds, run `make LLAMA_DEBUG=1`
|
|
21
|
+
**Notes**:
|
|
35
22
|
|
|
36
|
-
-
|
|
23
|
+
- For faster compilation, add the `-j` argument to run multiple jobs in parallel, or use a generator that does this automatically such as Ninja. For example, `cmake --build build --config Release -j 8` will run 8 jobs in parallel.
|
|
24
|
+
- For faster repeated compilation, install [ccache](https://ccache.dev/)
|
|
25
|
+
- For debug builds, there are two cases:
|
|
37
26
|
|
|
38
|
-
|
|
39
|
-
cmake -B build
|
|
40
|
-
cmake --build build --config Release
|
|
41
|
-
```
|
|
27
|
+
1. Single-config generators (e.g. default = `Unix Makefiles`; note that they just ignore the `--config` flag):
|
|
42
28
|
|
|
43
|
-
|
|
29
|
+
```bash
|
|
30
|
+
cmake -B build -DCMAKE_BUILD_TYPE=Debug
|
|
31
|
+
cmake --build build
|
|
32
|
+
```
|
|
44
33
|
|
|
45
|
-
-
|
|
46
|
-
- For faster compilation, add the `-j` argument to run multiple jobs in parallel. For example, `cmake --build build --config Release -j 8` will run 8 jobs in parallel.
|
|
47
|
-
- For faster repeated compilation, install [ccache](https://ccache.dev/).
|
|
48
|
-
- For debug builds, there are two cases:
|
|
34
|
+
2. Multi-config generators (`-G` param set to Visual Studio, XCode...):
|
|
49
35
|
|
|
50
|
-
|
|
36
|
+
```bash
|
|
37
|
+
cmake -B build -G "Xcode"
|
|
38
|
+
cmake --build build --config Debug
|
|
39
|
+
```
|
|
51
40
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
For more details and a list of supported generators, see the [CMake documentation](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html).
|
|
42
|
+
- For static builds, add `-DBUILD_SHARED_LIBS=OFF`:
|
|
43
|
+
```
|
|
44
|
+
cmake -B build -DBUILD_SHARED_LIBS=OFF
|
|
45
|
+
cmake --build build --config Release
|
|
46
|
+
```
|
|
56
47
|
|
|
57
|
-
|
|
48
|
+
- Building for Windows (x86, x64 and arm64) with MSVC or clang as compilers:
|
|
49
|
+
- Install Visual Studio 2022, e.g. via the [Community Edition](https://visualstudio.microsoft.com/de/vs/community/). In the installer, select at least the following options (this also automatically installs the required additional tools like CMake,...):
|
|
50
|
+
- Tab Workload: Desktop-development with C++
|
|
51
|
+
- Tab Components (select quickly via search): C++-_CMake_ Tools for Windows, _Git_ for Windows, C++-_Clang_ Compiler for Windows, MS-Build Support for LLVM-Toolset (clang)
|
|
52
|
+
- Please remember to always use a Developer Command Prompt / PowerShell for VS2022 for git, build, test
|
|
53
|
+
- For Windows on ARM (arm64, WoA) build with:
|
|
54
|
+
```bash
|
|
55
|
+
cmake --preset arm64-windows-llvm-release -D GGML_OPENMP=OFF
|
|
56
|
+
cmake --build build-arm64-windows-llvm-release
|
|
57
|
+
```
|
|
58
|
+
Building for arm64 can also be done with the MSVC compiler with the build-arm64-windows-MSVC preset, or the standard CMake build instructions. However, note that the MSVC compiler does not support inline ARM assembly code, used e.g. for the accelerated Q4_0_N_M CPU kernels.
|
|
58
59
|
|
|
60
|
+
For building with ninja generator and clang compiler as default:
|
|
61
|
+
-set path:set LIB=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.41.34120\lib\x64\uwp;C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64
|
|
59
62
|
```bash
|
|
60
|
-
cmake
|
|
61
|
-
cmake --build build
|
|
63
|
+
cmake --preset x64-windows-llvm-release
|
|
64
|
+
cmake --build build-x64-windows-llvm-release
|
|
62
65
|
```
|
|
63
|
-
- Building for Windows (x86, x64 and arm64) with MSVC or clang as compilers:
|
|
64
|
-
- Install Visual Studio 2022, e.g. via the [Community Edition](https://visualstudio.microsoft.com/de/vs/community/). In the installer, select at least the following options (this also automatically installs the required additional tools like CMake,...):
|
|
65
|
-
- Tab Workload: Desktop-development with C++
|
|
66
|
-
- Tab Components (select quickly via search): C++-_CMake_ Tools for Windows, _Git_ for Windows, C++-_Clang_ Compiler for Windows, MS-Build Support for LLVM-Toolset (clang)
|
|
67
|
-
- Please remember to always use a Developer Command Prompt / PowerShell for VS2022 for git, build, test
|
|
68
|
-
- For Windows on ARM (arm64, WoA) build with:
|
|
69
|
-
```bash
|
|
70
|
-
cmake --preset arm64-windows-llvm-release -D GGML_OPENMP=OFF
|
|
71
|
-
cmake --build build-arm64-windows-llvm-release
|
|
72
|
-
```
|
|
73
|
-
Note: Building for arm64 could also be done just with MSVC (with the build-arm64-windows-MSVC preset, or the standard CMake build instructions). But MSVC does not support inline ARM assembly-code, used e.g. for the accelerated Q4_0_4_8 CPU kernels.
|
|
74
|
-
|
|
75
|
-
- Using `gmake` (FreeBSD):
|
|
76
|
-
|
|
77
|
-
1. Install and activate [DRM in FreeBSD](https://wiki.freebsd.org/Graphics)
|
|
78
|
-
2. Add your user to **video** group
|
|
79
|
-
3. Install compilation dependencies.
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
sudo pkg install gmake automake autoconf pkgconf llvm15 openblas
|
|
83
|
-
|
|
84
|
-
gmake CC=/usr/local/bin/clang15 CXX=/usr/local/bin/clang++15 -j4
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Metal Build
|
|
88
|
-
|
|
89
|
-
On MacOS, Metal is enabled by default. Using Metal makes the computation run on the GPU.
|
|
90
|
-
To disable the Metal build at compile time use the `GGML_NO_METAL=1` flag or the `GGML_METAL=OFF` cmake option.
|
|
91
|
-
|
|
92
|
-
When built with Metal support, you can explicitly disable GPU inference with the `--n-gpu-layers|-ngl 0` command-line
|
|
93
|
-
argument.
|
|
94
66
|
|
|
95
67
|
## BLAS Build
|
|
96
68
|
|
|
97
|
-
Building the program with BLAS support may lead to some performance improvements in prompt processing using batch sizes higher than 32 (the default is 512).
|
|
69
|
+
Building the program with BLAS support may lead to some performance improvements in prompt processing using batch sizes higher than 32 (the default is 512). Using BLAS doesn't affect the generation performance. There are currently several different BLAS implementations available for build and use:
|
|
98
70
|
|
|
99
|
-
### Accelerate Framework
|
|
71
|
+
### Accelerate Framework
|
|
100
72
|
|
|
101
73
|
This is only available on Mac PCs and it's enabled by default. You can just build using the normal instructions.
|
|
102
74
|
|
|
103
|
-
### OpenBLAS
|
|
75
|
+
### OpenBLAS
|
|
104
76
|
|
|
105
77
|
This provides BLAS acceleration using only the CPU. Make sure to have OpenBLAS installed on your machine.
|
|
106
78
|
|
|
107
|
-
- Using `make`:
|
|
108
|
-
- On Linux:
|
|
109
|
-
```bash
|
|
110
|
-
make GGML_OPENBLAS=1
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
- On Windows:
|
|
114
|
-
|
|
115
|
-
1. Download the latest fortran version of [w64devkit](https://github.com/skeeto/w64devkit/releases).
|
|
116
|
-
2. Download the latest version of [OpenBLAS for Windows](https://github.com/xianyi/OpenBLAS/releases).
|
|
117
|
-
3. Extract `w64devkit` on your pc.
|
|
118
|
-
4. From the OpenBLAS zip that you just downloaded copy `libopenblas.a`, located inside the `lib` folder, inside `w64devkit\x86_64-w64-mingw32\lib`.
|
|
119
|
-
5. From the same OpenBLAS zip copy the content of the `include` folder inside `w64devkit\x86_64-w64-mingw32\include`.
|
|
120
|
-
6. Run `w64devkit.exe`.
|
|
121
|
-
7. Use the `cd` command to reach the `llama.cpp` folder.
|
|
122
|
-
8. From here you can run:
|
|
123
|
-
|
|
124
|
-
```bash
|
|
125
|
-
make GGML_OPENBLAS=1
|
|
126
|
-
```
|
|
127
|
-
|
|
128
79
|
- Using `CMake` on Linux:
|
|
129
80
|
|
|
130
81
|
```bash
|
|
@@ -136,14 +87,6 @@ This provides BLAS acceleration using only the CPU. Make sure to have OpenBLAS i
|
|
|
136
87
|
|
|
137
88
|
Check [BLIS.md](./backend/BLIS.md) for more information.
|
|
138
89
|
|
|
139
|
-
### SYCL
|
|
140
|
-
|
|
141
|
-
SYCL is a higher-level programming model to improve programming productivity on various hardware accelerators.
|
|
142
|
-
|
|
143
|
-
llama.cpp based on SYCL is used to **support Intel GPU** (Data Center Max series, Flex series, Arc series, Built-in GPU and iGPU).
|
|
144
|
-
|
|
145
|
-
For detailed info, please refer to [llama.cpp for SYCL](./backend/SYCL.md).
|
|
146
|
-
|
|
147
90
|
### Intel oneMKL
|
|
148
91
|
|
|
149
92
|
Building through oneAPI compilers will make avx_vnni instruction set available for intel processors that do not support avx512 and avx512_vnni. Please note that this build config **does not support Intel GPU**. For Intel GPU support, please refer to [llama.cpp for SYCL](./backend/SYCL.md).
|
|
@@ -161,16 +104,29 @@ Building through oneAPI compilers will make avx_vnni instruction set available f
|
|
|
161
104
|
|
|
162
105
|
Check [Optimizing and Running LLaMA2 on Intel® CPU](https://www.intel.com/content/www/us/en/content-details/791610/optimizing-and-running-llama2-on-intel-cpu.html) for more information.
|
|
163
106
|
|
|
164
|
-
###
|
|
107
|
+
### Other BLAS libraries
|
|
165
108
|
|
|
166
|
-
|
|
109
|
+
Any other BLAS library can be used by setting the `GGML_BLAS_VENDOR` option. See the [CMake documentation](https://cmake.org/cmake/help/latest/module/FindBLAS.html#blas-lapack-vendors) for a list of supported vendors.
|
|
167
110
|
|
|
168
|
-
|
|
111
|
+
## Metal Build
|
|
112
|
+
|
|
113
|
+
On MacOS, Metal is enabled by default. Using Metal makes the computation run on the GPU.
|
|
114
|
+
To disable the Metal build at compile time use the `-DGGML_METAL=OFF` cmake option.
|
|
115
|
+
|
|
116
|
+
When built with Metal support, you can explicitly disable GPU inference with the `--n-gpu-layers 0` command-line argument.
|
|
117
|
+
|
|
118
|
+
## SYCL
|
|
119
|
+
|
|
120
|
+
SYCL is a higher-level programming model to improve programming productivity on various hardware accelerators.
|
|
121
|
+
|
|
122
|
+
llama.cpp based on SYCL is used to **support Intel GPU** (Data Center Max series, Flex series, Arc series, Built-in GPU and iGPU).
|
|
123
|
+
|
|
124
|
+
For detailed info, please refer to [llama.cpp for SYCL](./backend/SYCL.md).
|
|
125
|
+
|
|
126
|
+
## CUDA
|
|
127
|
+
|
|
128
|
+
This provides GPU acceleration using an NVIDIA GPU. Make sure to have the CUDA toolkit installed. You can download it from your Linux distro's package manager (e.g. `apt install nvidia-cuda-toolkit`) or from the [NVIDIA developer site](https://developer.nvidia.com/cuda-downloads).
|
|
169
129
|
|
|
170
|
-
- Using `make`:
|
|
171
|
-
```bash
|
|
172
|
-
make GGML_CUDA=1
|
|
173
|
-
```
|
|
174
130
|
- Using `CMake`:
|
|
175
131
|
|
|
176
132
|
```bash
|
|
@@ -186,22 +142,16 @@ The following compilation options are also available to tweak performance:
|
|
|
186
142
|
|
|
187
143
|
| Option | Legal values | Default | Description |
|
|
188
144
|
|-------------------------------|------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
189
|
-
| GGML_CUDA_FORCE_DMMV | Boolean | false | Force the use of dequantization + matrix vector multiplication kernels instead of using kernels that do matrix vector multiplication on quantized data. By default the decision is made based on compute capability (MMVQ for 6.1/Pascal/GTX 1000 or higher). Does not affect k-quants. |
|
|
190
|
-
| GGML_CUDA_DMMV_X | Positive integer >= 32 | 32 | Number of values in x direction processed by the CUDA dequantization + matrix vector multiplication kernel per iteration. Increasing this value can improve performance on fast GPUs. Power of 2 heavily recommended. Does not affect k-quants. |
|
|
191
|
-
| GGML_CUDA_MMV_Y | Positive integer | 1 | Block size in y direction for the CUDA mul mat vec kernels. Increasing this value can improve performance on fast GPUs. Power of 2 recommended. |
|
|
192
145
|
| GGML_CUDA_FORCE_MMQ | Boolean | false | Force the use of custom matrix multiplication kernels for quantized models instead of FP16 cuBLAS even if there is no int8 tensor core implementation available (affects V100, RDNA3). MMQ kernels are enabled by default on GPUs with int8 tensor core support. With MMQ force enabled, speed for large batch sizes will be worse but VRAM consumption will be lower. |
|
|
193
146
|
| GGML_CUDA_FORCE_CUBLAS | Boolean | false | Force the use of FP16 cuBLAS instead of custom matrix multiplication kernels for quantized models |
|
|
194
147
|
| GGML_CUDA_F16 | Boolean | false | If enabled, use half-precision floating point arithmetic for the CUDA dequantization + mul mat vec kernels and for the q4_1 and q5_1 matrix matrix multiplication kernels. Can improve performance on relatively recent GPUs. |
|
|
195
|
-
| GGML_CUDA_KQUANTS_ITER | 1 or 2 | 2 | Number of values processed per iteration and per CUDA thread for Q2_K and Q6_K quantization formats. Setting this value to 1 can improve performance for slow GPUs. |
|
|
196
148
|
| GGML_CUDA_PEER_MAX_BATCH_SIZE | Positive integer | 128 | Maximum batch size for which to enable peer access between multiple GPUs. Peer access requires either Linux or NVLink. When using NVLink enabling peer access for larger batch sizes is potentially beneficial. |
|
|
197
149
|
| GGML_CUDA_FA_ALL_QUANTS | Boolean | false | Compile support for all KV cache quantization type (combinations) for the FlashAttention CUDA kernels. More fine-grained control over KV cache size but compilation takes much longer. |
|
|
198
150
|
|
|
199
|
-
|
|
151
|
+
## MUSA
|
|
152
|
+
|
|
153
|
+
This provides GPU acceleration using the MUSA cores of your Moore Threads MTT GPU. Make sure to have the MUSA SDK installed. You can download it from here: [MUSA SDK](https://developer.mthreads.com/sdk/download/musa).
|
|
200
154
|
|
|
201
|
-
- Using `make`:
|
|
202
|
-
```bash
|
|
203
|
-
make GGML_MUSA=1
|
|
204
|
-
```
|
|
205
155
|
- Using `CMake`:
|
|
206
156
|
|
|
207
157
|
```bash
|
|
@@ -209,20 +159,22 @@ The following compilation options are also available to tweak performance:
|
|
|
209
159
|
cmake --build build --config Release
|
|
210
160
|
```
|
|
211
161
|
|
|
212
|
-
|
|
162
|
+
The environment variable [`MUSA_VISIBLE_DEVICES`](https://docs.mthreads.com/musa-sdk/musa-sdk-doc-online/programming_guide/Z%E9%99%84%E5%BD%95/) can be used to specify which GPU(s) will be used.
|
|
163
|
+
|
|
164
|
+
The environment variable `GGML_CUDA_ENABLE_UNIFIED_MEMORY=1` can be used to enable unified memory in Linux. This allows swapping to system RAM instead of crashing when the GPU VRAM is exhausted.
|
|
165
|
+
|
|
166
|
+
Most of the compilation options available for CUDA should also be available for MUSA, though they haven't been thoroughly tested yet.
|
|
167
|
+
|
|
168
|
+
## HIP
|
|
213
169
|
|
|
214
|
-
This provides
|
|
170
|
+
This provides GPU acceleration on HIP-supported AMD GPUs.
|
|
215
171
|
Make sure to have ROCm installed.
|
|
216
172
|
You can download it from your Linux distro's package manager or from here: [ROCm Quick Start (Linux)](https://rocm.docs.amd.com/projects/install-on-linux/en/latest/tutorial/quick-start.html#rocm-install-quick).
|
|
217
173
|
|
|
218
|
-
- Using `make`:
|
|
219
|
-
```bash
|
|
220
|
-
make GGML_HIPBLAS=1
|
|
221
|
-
```
|
|
222
174
|
- Using `CMake` for Linux (assuming a gfx1030-compatible AMD GPU):
|
|
223
175
|
```bash
|
|
224
176
|
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \
|
|
225
|
-
cmake -S . -B build -
|
|
177
|
+
cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
|
|
226
178
|
&& cmake --build build --config Release -- -j 16
|
|
227
179
|
```
|
|
228
180
|
On Linux it is also possible to use unified memory architecture (UMA) to share main memory between the CPU and integrated GPU by setting `-DGGML_HIP_UMA=ON`.
|
|
@@ -239,19 +191,14 @@ You can download it from your Linux distro's package manager or from here: [ROCm
|
|
|
239
191
|
```bash
|
|
240
192
|
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -p)" \
|
|
241
193
|
HIP_DEVICE_LIB_PATH=<directory-you-just-found> \
|
|
242
|
-
cmake -S . -B build -
|
|
194
|
+
cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
|
|
243
195
|
&& cmake --build build -- -j 16
|
|
244
196
|
```
|
|
245
197
|
|
|
246
|
-
- Using `make` (example for target gfx1030, build with 16 CPU threads):
|
|
247
|
-
```bash
|
|
248
|
-
make -j16 GGML_HIPBLAS=1 GGML_HIP_UMA=1 AMDGPU_TARGETS=gfx1030
|
|
249
|
-
```
|
|
250
|
-
|
|
251
198
|
- Using `CMake` for Windows (using x64 Native Tools Command Prompt for VS, and assuming a gfx1100-compatible AMD GPU):
|
|
252
199
|
```bash
|
|
253
200
|
set PATH=%HIP_PATH%\bin;%PATH%
|
|
254
|
-
cmake -S . -B build -G Ninja -DAMDGPU_TARGETS=gfx1100 -
|
|
201
|
+
cmake -S . -B build -G Ninja -DAMDGPU_TARGETS=gfx1100 -DGGML_HIP=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
|
|
255
202
|
cmake --build build
|
|
256
203
|
```
|
|
257
204
|
Make sure that `AMDGPU_TARGETS` is set to the GPU arch you want to compile for. The above example uses `gfx1100` that corresponds to Radeon RX 7900XTX/XT/GRE. You can find a list of targets [here](https://llvm.org/docs/AMDGPUUsage.html#processors)
|
|
@@ -260,23 +207,16 @@ You can download it from your Linux distro's package manager or from here: [ROCm
|
|
|
260
207
|
|
|
261
208
|
The environment variable [`HIP_VISIBLE_DEVICES`](https://rocm.docs.amd.com/en/latest/understand/gpu_isolation.html#hip-visible-devices) can be used to specify which GPU(s) will be used.
|
|
262
209
|
If your GPU is not officially supported you can use the environment variable [`HSA_OVERRIDE_GFX_VERSION`] set to a similar GPU, for example 10.3.0 on RDNA2 (e.g. gfx1030, gfx1031, or gfx1035) or 11.0.0 on RDNA3.
|
|
263
|
-
The following compilation options are also available to tweak performance (yes, they refer to CUDA, not HIP, because it uses the same code as the cuBLAS version above):
|
|
264
|
-
|
|
265
|
-
| Option | Legal values | Default | Description |
|
|
266
|
-
|------------------------|------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
267
|
-
| GGML_CUDA_DMMV_X | Positive integer >= 32 | 32 | Number of values in x direction processed by the HIP dequantization + matrix vector multiplication kernel per iteration. Increasing this value can improve performance on fast GPUs. Power of 2 heavily recommended. Does not affect k-quants. |
|
|
268
|
-
| GGML_CUDA_MMV_Y | Positive integer | 1 | Block size in y direction for the HIP mul mat vec kernels. Increasing this value can improve performance on fast GPUs. Power of 2 recommended. Does not affect k-quants. |
|
|
269
|
-
| GGML_CUDA_KQUANTS_ITER | 1 or 2 | 2 | Number of values processed per iteration and per HIP thread for Q2_K and Q6_K quantization formats. Setting this value to 1 can improve performance for slow GPUs. |
|
|
270
210
|
|
|
271
|
-
|
|
211
|
+
## Vulkan
|
|
272
212
|
|
|
273
213
|
**Windows**
|
|
274
214
|
|
|
275
|
-
|
|
215
|
+
### w64devkit
|
|
276
216
|
|
|
277
|
-
Download and extract [w64devkit](https://github.com/skeeto/w64devkit/releases).
|
|
217
|
+
Download and extract [`w64devkit`](https://github.com/skeeto/w64devkit/releases).
|
|
278
218
|
|
|
279
|
-
Download and install the [Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows)
|
|
219
|
+
Download and install the [`Vulkan SDK`](https://vulkan.lunarg.com/sdk/home#windows) with the default settings.
|
|
280
220
|
|
|
281
221
|
Launch `w64devkit.exe` and run the following commands to copy Vulkan dependencies:
|
|
282
222
|
```sh
|
|
@@ -292,18 +232,47 @@ Libs: -lvulkan-1
|
|
|
292
232
|
EOF
|
|
293
233
|
|
|
294
234
|
```
|
|
295
|
-
Switch into the `llama.cpp` directory and run `make GGML_VULKAN=1`.
|
|
296
235
|
|
|
297
|
-
|
|
236
|
+
Switch into the `llama.cpp` directory and build using CMake.
|
|
237
|
+
```sh
|
|
238
|
+
cmake -B build -DGGML_VULKAN=ON
|
|
239
|
+
cmake --build build --config Release
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Git Bash MINGW64
|
|
243
|
+
|
|
244
|
+
Download and install [`Git-SCM`](https://git-scm.com/downloads/win) with the default settings
|
|
245
|
+
|
|
246
|
+
Download and install [`Visual Studio Community Edition`](https://visualstudio.microsoft.com/) and make sure you select `C++`
|
|
247
|
+
|
|
248
|
+
Download and install [`CMake`](https://cmake.org/download/) with the default settings
|
|
249
|
+
|
|
250
|
+
Download and install the [`Vulkan SDK`](https://vulkan.lunarg.com/sdk/home#windows) with the default settings.
|
|
251
|
+
|
|
252
|
+
Go into your `llama.cpp` directory and right click, select `Open Git Bash Here` and then run the following commands
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
cmake -B build -DGGML_VULKAN=ON
|
|
256
|
+
cmake --build build --config Release
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Now you can load the model in conversation mode using `Vulkan`
|
|
260
|
+
|
|
261
|
+
```sh
|
|
262
|
+
build/bin/Release/llama-cli -m "[PATH TO MODEL]" -ngl 100 -c 16384 -t 10 -n -2 -cnv
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### MSYS2
|
|
298
266
|
Install [MSYS2](https://www.msys2.org/) and then run the following commands in a UCRT terminal to install dependencies.
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
267
|
+
```sh
|
|
268
|
+
pacman -S git \
|
|
269
|
+
mingw-w64-ucrt-x86_64-gcc \
|
|
270
|
+
mingw-w64-ucrt-x86_64-cmake \
|
|
271
|
+
mingw-w64-ucrt-x86_64-vulkan-devel \
|
|
272
|
+
mingw-w64-ucrt-x86_64-shaderc
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Switch into the `llama.cpp` directory and build using CMake.
|
|
307
276
|
```sh
|
|
308
277
|
cmake -B build -DGGML_VULKAN=ON
|
|
309
278
|
cmake --build build --config Release
|
|
@@ -352,7 +321,7 @@ cmake --build build --config Release
|
|
|
352
321
|
# ggml_vulkan: Using Intel(R) Graphics (ADL GT2) | uma: 1 | fp16: 1 | warp size: 32
|
|
353
322
|
```
|
|
354
323
|
|
|
355
|
-
|
|
324
|
+
## CANN
|
|
356
325
|
This provides NPU acceleration using the AI cores of your Ascend NPU. And [CANN](https://www.hiascend.com/en/software/cann) is a hierarchical APIs to help you to quickly build AI applications and service based on Ascend NPU.
|
|
357
326
|
|
|
358
327
|
For more information about Ascend NPU in [Ascend Community](https://www.hiascend.com/en/).
|
|
@@ -367,22 +336,26 @@ cmake --build build --config release
|
|
|
367
336
|
|
|
368
337
|
You can test with:
|
|
369
338
|
|
|
370
|
-
|
|
339
|
+
```bash
|
|
340
|
+
./build/bin/llama-cli -m PATH_TO_MODEL -p "Building a website can be done in 10 steps:" -ngl 32
|
|
341
|
+
```
|
|
371
342
|
|
|
372
|
-
If the
|
|
343
|
+
If the following info is output on screen, you are using `llama.cpp` with the CANN backend:
|
|
373
344
|
```bash
|
|
374
|
-
llm_load_tensors: CANN buffer size = 13313.00 MiB
|
|
345
|
+
llm_load_tensors: CANN model buffer size = 13313.00 MiB
|
|
375
346
|
llama_new_context_with_model: CANN compute buffer size = 1260.81 MiB
|
|
376
347
|
```
|
|
377
348
|
|
|
378
349
|
For detailed info, such as model/device supports, CANN install, please refer to [llama.cpp for CANN](./backend/CANN.md).
|
|
379
350
|
|
|
380
|
-
|
|
351
|
+
## Android
|
|
381
352
|
|
|
382
353
|
To read documentation for how to build on Android, [click here](./android.md)
|
|
383
354
|
|
|
384
|
-
|
|
355
|
+
## Notes about GPU-accelerated backends
|
|
356
|
+
|
|
357
|
+
The GPU may still be used to accelerate some parts of the computation even when using the `-ngl 0` option. You can fully disable GPU acceleration by using `--device none`.
|
|
385
358
|
|
|
386
|
-
|
|
359
|
+
In most cases, it is possible to build and use multiple backends at the same time. For example, you can build llama.cpp with both CUDA and Vulkan support by using the `-DGGML_CUDA=ON -DGGML_VULKAN=ON` options with CMake. At runtime, you can specify which backend devices to use with the `--device` option. To see a list of available devices, use the `--list-devices` option.
|
|
387
360
|
|
|
388
|
-
|
|
361
|
+
Backends can be built as dynamic libraries that can be loaded dynamically at runtime. This allows you to use the same llama.cpp binary on different machines with different GPUs. To enable this feature, use the `GGML_BACKEND_DL` option when building.
|
|
@@ -6,21 +6,26 @@ find_package(Threads REQUIRED)
|
|
|
6
6
|
|
|
7
7
|
# ...
|
|
8
8
|
|
|
9
|
+
# flags
|
|
10
|
+
|
|
11
|
+
llama_add_compile_flags()
|
|
12
|
+
|
|
9
13
|
# examples
|
|
10
14
|
|
|
11
15
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
|
12
16
|
|
|
13
17
|
if (EMSCRIPTEN)
|
|
14
18
|
else()
|
|
15
|
-
add_subdirectory(cvector-generator)
|
|
16
|
-
add_subdirectory(baby-llama)
|
|
17
19
|
add_subdirectory(batched-bench)
|
|
18
20
|
add_subdirectory(batched)
|
|
19
|
-
add_subdirectory(convert-llama2c-to-ggml)
|
|
20
21
|
add_subdirectory(embedding)
|
|
21
22
|
add_subdirectory(eval-callback)
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
if (NOT WIN32)
|
|
25
|
+
# disabled on Windows because it uses internal functions not exported with LLAMA_API
|
|
26
|
+
add_subdirectory(gbnf-validator)
|
|
27
|
+
endif()
|
|
28
|
+
|
|
24
29
|
add_subdirectory(gguf-hash)
|
|
25
30
|
add_subdirectory(gguf-split)
|
|
26
31
|
add_subdirectory(gguf)
|
|
@@ -28,27 +33,41 @@ else()
|
|
|
28
33
|
add_subdirectory(imatrix)
|
|
29
34
|
add_subdirectory(infill)
|
|
30
35
|
add_subdirectory(llama-bench)
|
|
31
|
-
add_subdirectory(llava)
|
|
32
36
|
add_subdirectory(lookahead)
|
|
33
37
|
add_subdirectory(lookup)
|
|
34
38
|
add_subdirectory(main)
|
|
35
39
|
add_subdirectory(parallel)
|
|
36
40
|
add_subdirectory(passkey)
|
|
37
41
|
add_subdirectory(perplexity)
|
|
38
|
-
add_subdirectory(quantize-stats)
|
|
39
42
|
add_subdirectory(quantize)
|
|
40
43
|
add_subdirectory(retrieval)
|
|
41
|
-
if (GGML_RPC)
|
|
42
|
-
add_subdirectory(rpc)
|
|
43
|
-
endif()
|
|
44
44
|
if (LLAMA_BUILD_SERVER)
|
|
45
|
-
|
|
46
|
-
endif()
|
|
47
|
-
if (GGML_SYCL)
|
|
48
|
-
add_subdirectory(sycl)
|
|
45
|
+
add_subdirectory(server)
|
|
49
46
|
endif()
|
|
50
47
|
add_subdirectory(save-load-state)
|
|
48
|
+
add_subdirectory(run)
|
|
51
49
|
add_subdirectory(simple)
|
|
50
|
+
add_subdirectory(simple-chat)
|
|
52
51
|
add_subdirectory(speculative)
|
|
52
|
+
add_subdirectory(speculative-simple)
|
|
53
53
|
add_subdirectory(tokenize)
|
|
54
|
+
add_subdirectory(tts)
|
|
55
|
+
add_subdirectory(gen-docs)
|
|
56
|
+
if (NOT GGML_BACKEND_DL)
|
|
57
|
+
# these examples use the backends directly and cannot be built with dynamic loading
|
|
58
|
+
add_subdirectory(convert-llama2c-to-ggml)
|
|
59
|
+
add_subdirectory(cvector-generator)
|
|
60
|
+
add_subdirectory(export-lora)
|
|
61
|
+
if (NOT WIN32)
|
|
62
|
+
# disabled on Windows because it uses internal functions not exported with LLAMA_API
|
|
63
|
+
add_subdirectory(quantize-stats)
|
|
64
|
+
endif()
|
|
65
|
+
add_subdirectory(llava)
|
|
66
|
+
if (GGML_RPC)
|
|
67
|
+
add_subdirectory(rpc)
|
|
68
|
+
endif()
|
|
69
|
+
if (GGML_SYCL)
|
|
70
|
+
add_subdirectory(sycl)
|
|
71
|
+
endif()
|
|
72
|
+
endif()
|
|
54
73
|
endif()
|
|
@@ -2,4 +2,4 @@ set(TARGET llama-batched)
|
|
|
2
2
|
add_executable(${TARGET} batched.cpp)
|
|
3
3
|
install(TARGETS ${TARGET} RUNTIME)
|
|
4
4
|
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
|
|
5
|
-
target_compile_features(${TARGET} PRIVATE
|
|
5
|
+
target_compile_features(${TARGET} PRIVATE cxx_std_17)
|
|
@@ -15,16 +15,16 @@ static void print_usage(int, char ** argv) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
int main(int argc, char ** argv) {
|
|
18
|
-
|
|
18
|
+
common_params params;
|
|
19
19
|
|
|
20
20
|
params.prompt = "Hello my name is";
|
|
21
21
|
params.n_predict = 32;
|
|
22
22
|
|
|
23
|
-
if (!
|
|
23
|
+
if (!common_params_parse(argc, argv, params, LLAMA_EXAMPLE_COMMON, print_usage)) {
|
|
24
24
|
return 1;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
common_init();
|
|
28
28
|
|
|
29
29
|
// number of parallel batches
|
|
30
30
|
int n_parallel = params.n_parallel;
|
|
@@ -39,7 +39,7 @@ int main(int argc, char ** argv) {
|
|
|
39
39
|
|
|
40
40
|
// initialize the model
|
|
41
41
|
|
|
42
|
-
llama_model_params model_params =
|
|
42
|
+
llama_model_params model_params = common_model_params_to_llama(params);
|
|
43
43
|
|
|
44
44
|
llama_model * model = llama_load_model_from_file(params.model.c_str(), model_params);
|
|
45
45
|
|
|
@@ -51,13 +51,13 @@ int main(int argc, char ** argv) {
|
|
|
51
51
|
// tokenize the prompt
|
|
52
52
|
|
|
53
53
|
std::vector<llama_token> tokens_list;
|
|
54
|
-
tokens_list =
|
|
54
|
+
tokens_list = common_tokenize(model, params.prompt, true);
|
|
55
55
|
|
|
56
56
|
const int n_kv_req = tokens_list.size() + (n_predict - tokens_list.size())*n_parallel;
|
|
57
57
|
|
|
58
58
|
// initialize the context
|
|
59
59
|
|
|
60
|
-
llama_context_params ctx_params =
|
|
60
|
+
llama_context_params ctx_params = common_context_params_to_llama(params);
|
|
61
61
|
|
|
62
62
|
ctx_params.n_ctx = n_kv_req;
|
|
63
63
|
ctx_params.n_batch = std::max(n_predict, n_parallel);
|
|
@@ -65,13 +65,14 @@ int main(int argc, char ** argv) {
|
|
|
65
65
|
llama_context * ctx = llama_new_context_with_model(model, ctx_params);
|
|
66
66
|
|
|
67
67
|
auto sparams = llama_sampler_chain_default_params();
|
|
68
|
+
sparams.no_perf = false;
|
|
68
69
|
|
|
69
70
|
llama_sampler * smpl = llama_sampler_chain_init(sparams);
|
|
70
71
|
|
|
71
|
-
llama_sampler_chain_add(smpl, llama_sampler_init_top_k(params.
|
|
72
|
-
llama_sampler_chain_add(smpl, llama_sampler_init_top_p(params.
|
|
73
|
-
llama_sampler_chain_add(smpl, llama_sampler_init_temp (params.
|
|
74
|
-
llama_sampler_chain_add(smpl, llama_sampler_init_dist (params.
|
|
72
|
+
llama_sampler_chain_add(smpl, llama_sampler_init_top_k(params.sampling.top_k));
|
|
73
|
+
llama_sampler_chain_add(smpl, llama_sampler_init_top_p(params.sampling.top_p, params.sampling.min_keep));
|
|
74
|
+
llama_sampler_chain_add(smpl, llama_sampler_init_temp (params.sampling.temp));
|
|
75
|
+
llama_sampler_chain_add(smpl, llama_sampler_init_dist (params.sampling.seed));
|
|
75
76
|
|
|
76
77
|
if (ctx == NULL) {
|
|
77
78
|
LOG_ERR("%s: error: failed to create the llama_context\n" , __func__);
|
|
@@ -94,7 +95,7 @@ int main(int argc, char ** argv) {
|
|
|
94
95
|
LOG("\n");
|
|
95
96
|
|
|
96
97
|
for (auto id : tokens_list) {
|
|
97
|
-
LOG("%s",
|
|
98
|
+
LOG("%s", common_token_to_piece(ctx, id).c_str());
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
// create a llama_batch
|
|
@@ -108,7 +109,7 @@ int main(int argc, char ** argv) {
|
|
|
108
109
|
|
|
109
110
|
// evaluate the initial prompt
|
|
110
111
|
for (size_t i = 0; i < tokens_list.size(); ++i) {
|
|
111
|
-
|
|
112
|
+
common_batch_add(batch, tokens_list[i], i, seq_ids, false);
|
|
112
113
|
}
|
|
113
114
|
GGML_ASSERT(batch.n_tokens == (int) tokens_list.size());
|
|
114
115
|
|
|
@@ -123,8 +124,8 @@ int main(int argc, char ** argv) {
|
|
|
123
124
|
decoder_start_token_id = llama_token_bos(model);
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
common_batch_clear(batch);
|
|
128
|
+
common_batch_add(batch, decoder_start_token_id, 0, seq_ids, false);
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
// llama_decode will output logits only for the last token of the prompt
|
|
@@ -161,7 +162,7 @@ int main(int argc, char ** argv) {
|
|
|
161
162
|
|
|
162
163
|
while (n_cur <= n_predict) {
|
|
163
164
|
// prepare the next batch
|
|
164
|
-
|
|
165
|
+
common_batch_clear(batch);
|
|
165
166
|
|
|
166
167
|
// sample the next token for each parallel sequence / stream
|
|
167
168
|
for (int32_t i = 0; i < n_parallel; ++i) {
|
|
@@ -185,15 +186,15 @@ int main(int argc, char ** argv) {
|
|
|
185
186
|
|
|
186
187
|
// if there is only one stream, we print immediately to stdout
|
|
187
188
|
if (n_parallel == 1) {
|
|
188
|
-
LOG("%s",
|
|
189
|
+
LOG("%s", common_token_to_piece(ctx, new_token_id).c_str());
|
|
189
190
|
}
|
|
190
191
|
|
|
191
|
-
streams[i] +=
|
|
192
|
+
streams[i] += common_token_to_piece(ctx, new_token_id);
|
|
192
193
|
|
|
193
194
|
i_batch[i] = batch.n_tokens;
|
|
194
195
|
|
|
195
196
|
// push this new token for next evaluation
|
|
196
|
-
|
|
197
|
+
common_batch_add(batch, new_token_id, n_cur, { i }, true);
|
|
197
198
|
|
|
198
199
|
n_decode += 1;
|
|
199
200
|
}
|
|
@@ -2,4 +2,4 @@ set(TARGET llama-batched-bench)
|
|
|
2
2
|
add_executable(${TARGET} batched-bench.cpp)
|
|
3
3
|
install(TARGETS ${TARGET} RUNTIME)
|
|
4
4
|
target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
|
|
5
|
-
target_compile_features(${TARGET} PRIVATE
|
|
5
|
+
target_compile_features(${TARGET} PRIVATE cxx_std_17)
|