@fugood/llama.node 0.2.3 → 0.3.1
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 +6 -3
- 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 +8 -1
- package/package.json +3 -3
- package/patches/llama.patch +12 -12
- package/src/DetokenizeWorker.cpp +1 -1
- package/src/LlamaContext.cpp +33 -1
- package/src/LlamaContext.h +1 -0
- package/src/llama.cpp/.github/workflows/bench.yml +310 -0
- package/src/llama.cpp/.github/workflows/build.yml +1315 -0
- package/src/llama.cpp/.github/workflows/close-issue.yml +23 -0
- package/src/llama.cpp/.github/workflows/docker.yml +116 -0
- package/src/llama.cpp/.github/workflows/editorconfig.yml +27 -0
- package/src/llama.cpp/.github/workflows/gguf-publish.yml +44 -0
- package/src/llama.cpp/.github/workflows/labeler.yml +17 -0
- package/src/llama.cpp/.github/workflows/nix-ci-aarch64.yml +65 -0
- package/src/llama.cpp/.github/workflows/nix-ci.yml +72 -0
- package/src/llama.cpp/.github/workflows/nix-flake-update.yml +22 -0
- package/src/llama.cpp/.github/workflows/nix-publish-flake.yml +36 -0
- package/src/llama.cpp/.github/workflows/python-check-requirements.yml +35 -0
- package/src/llama.cpp/.github/workflows/python-lint.yml +23 -0
- package/src/llama.cpp/.github/workflows/python-type-check.yml +38 -0
- package/src/llama.cpp/.github/workflows/server.yml +183 -0
- package/src/llama.cpp/CMakeLists.txt +91 -1245
- package/src/llama.cpp/cmake/arm64-windows-llvm.cmake +1 -1
- package/src/llama.cpp/cmake/build-info.cmake +58 -0
- package/src/llama.cpp/cmake/git-vars.cmake +22 -0
- package/src/llama.cpp/common/CMakeLists.txt +4 -3
- package/src/llama.cpp/common/build-info.cpp.in +4 -0
- package/src/llama.cpp/common/common.cpp +1116 -877
- package/src/llama.cpp/common/common.h +191 -77
- package/src/llama.cpp/common/grammar-parser.cpp +118 -31
- package/src/llama.cpp/common/json-schema-to-grammar.cpp +346 -65
- package/src/llama.cpp/common/log.h +1 -1
- package/src/llama.cpp/common/ngram-cache.h +10 -3
- package/src/llama.cpp/common/sampling.cpp +19 -10
- package/src/llama.cpp/docs/build.md +353 -0
- package/src/llama.cpp/examples/CMakeLists.txt +22 -22
- package/src/llama.cpp/examples/baby-llama/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/baby-llama/baby-llama.cpp +6 -6
- package/src/llama.cpp/examples/batched/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/batched/batched.cpp +52 -55
- package/src/llama.cpp/examples/batched-bench/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/batched-bench/batched-bench.cpp +20 -72
- package/src/llama.cpp/examples/benchmark/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/chat-13B.bat +57 -0
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/{finetune → cvector-generator}/CMakeLists.txt +2 -2
- package/src/llama.cpp/examples/cvector-generator/completions.txt +582 -0
- package/src/llama.cpp/examples/cvector-generator/cvector-generator.cpp +503 -0
- package/src/llama.cpp/examples/cvector-generator/mean.hpp +48 -0
- package/src/llama.cpp/examples/cvector-generator/negative.txt +4 -0
- package/src/llama.cpp/examples/cvector-generator/pca.hpp +325 -0
- package/src/llama.cpp/examples/cvector-generator/positive.txt +4 -0
- package/src/llama.cpp/examples/deprecation-warning/deprecation-warning.cpp +35 -0
- package/src/llama.cpp/examples/embedding/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/embedding/embedding.cpp +94 -46
- package/src/llama.cpp/examples/eval-callback/CMakeLists.txt +2 -2
- package/src/llama.cpp/examples/eval-callback/eval-callback.cpp +4 -6
- package/src/llama.cpp/examples/export-lora/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/export-lora/export-lora.cpp +344 -386
- package/src/llama.cpp/examples/gbnf-validator/CMakeLists.txt +2 -2
- package/src/llama.cpp/examples/gbnf-validator/gbnf-validator.cpp +30 -25
- package/src/llama.cpp/examples/gguf/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gguf/gguf.cpp +5 -0
- package/src/llama.cpp/examples/gguf-hash/CMakeLists.txt +15 -0
- package/src/llama.cpp/examples/gguf-hash/deps/rotate-bits/rotate-bits.h +46 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.c +295 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.h +52 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.c +221 -0
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.h +24 -0
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.c +42 -0
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.h +7093 -0
- package/src/llama.cpp/examples/gguf-hash/gguf-hash.cpp +693 -0
- package/src/llama.cpp/examples/gguf-split/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gguf-split/gguf-split.cpp +3 -3
- package/src/llama.cpp/examples/gritlm/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/gritlm/gritlm.cpp +6 -2
- package/src/llama.cpp/examples/imatrix/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/imatrix/imatrix.cpp +137 -176
- package/src/llama.cpp/examples/infill/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/infill/infill.cpp +38 -153
- package/src/llama.cpp/examples/llama-bench/llama-bench.cpp +175 -94
- package/src/llama.cpp/examples/llama.android/app/build.gradle.kts +65 -0
- package/src/llama.cpp/examples/llama.android/build.gradle.kts +6 -0
- package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +68 -0
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/CMakeLists.txt +11 -7
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/llama-android.cpp +2 -2
- package/src/llama.cpp/examples/llama.android/settings.gradle.kts +18 -0
- package/src/llama.cpp/examples/llava/CMakeLists.txt +6 -5
- package/src/llama.cpp/examples/llava/android/build_64.sh +8 -0
- package/src/llama.cpp/examples/llava/clip.cpp +23 -14
- package/src/llama.cpp/examples/llava/llava-cli.cpp +8 -6
- package/src/llama.cpp/examples/llava/requirements.txt +3 -2
- package/src/llama.cpp/examples/lookahead/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/lookahead/lookahead.cpp +2 -1
- package/src/llama.cpp/examples/lookup/CMakeLists.txt +4 -4
- package/src/llama.cpp/examples/lookup/lookup-create.cpp +2 -0
- package/src/llama.cpp/examples/lookup/lookup-merge.cpp +4 -4
- package/src/llama.cpp/examples/lookup/lookup-stats.cpp +2 -2
- package/src/llama.cpp/examples/lookup/lookup.cpp +1 -1
- package/src/llama.cpp/examples/main/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/main/main.cpp +98 -75
- package/src/llama.cpp/examples/main-cmake-pkg/CMakeLists.txt +4 -5
- package/src/llama.cpp/examples/parallel/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/parallel/parallel.cpp +2 -1
- package/src/llama.cpp/examples/passkey/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/passkey/passkey.cpp +23 -43
- package/src/llama.cpp/examples/perplexity/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/perplexity/perplexity.cpp +13 -10
- package/src/llama.cpp/examples/quantize/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/quantize/quantize.cpp +37 -34
- package/src/llama.cpp/examples/quantize-stats/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/quantize-stats/quantize-stats.cpp +1 -1
- package/src/llama.cpp/examples/retrieval/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/retrieval/retrieval.cpp +26 -77
- package/src/llama.cpp/examples/save-load-state/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/save-load-state/save-load-state.cpp +14 -7
- package/src/llama.cpp/examples/server/CMakeLists.txt +26 -2
- package/src/llama.cpp/examples/server/server.cpp +274 -671
- package/src/llama.cpp/examples/server/tests/requirements.txt +2 -2
- package/src/llama.cpp/examples/server/utils.hpp +28 -29
- package/src/llama.cpp/examples/simple/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/simple/simple.cpp +21 -29
- package/src/llama.cpp/examples/speculative/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/speculative/speculative.cpp +2 -1
- package/src/llama.cpp/examples/sycl/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/sycl/build.sh +23 -0
- package/src/llama.cpp/examples/sycl/run-llama2.sh +36 -0
- package/src/llama.cpp/examples/sycl/win-build-sycl.bat +33 -0
- package/src/llama.cpp/examples/sycl/win-run-llama2.bat +9 -0
- package/src/llama.cpp/examples/tokenize/CMakeLists.txt +1 -1
- package/src/llama.cpp/examples/tokenize/tokenize.cpp +16 -2
- package/src/llama.cpp/ggml/CMakeLists.txt +253 -0
- package/src/llama.cpp/{cmake → ggml/cmake}/FindSIMD.cmake +6 -6
- package/src/llama.cpp/{ggml-backend.h → ggml/include/ggml-backend.h} +22 -17
- package/src/llama.cpp/ggml/include/ggml-blas.h +23 -0
- package/src/llama.cpp/ggml/include/ggml-cann.h +125 -0
- package/src/llama.cpp/{ggml-cuda.h → ggml/include/ggml-cuda.h} +3 -0
- package/src/llama.cpp/{ggml-metal.h → ggml/include/ggml-metal.h} +1 -2
- package/src/llama.cpp/{ggml-sycl.h → ggml/include/ggml-sycl.h} +3 -10
- package/src/llama.cpp/{ggml.h → ggml/include/ggml.h} +80 -85
- package/src/llama.cpp/ggml/src/CMakeLists.txt +1329 -0
- package/src/llama.cpp/ggml/src/ggml-aarch64.c +2193 -0
- package/src/llama.cpp/ggml/src/ggml-aarch64.h +39 -0
- package/src/llama.cpp/{ggml-alloc.c → ggml/src/ggml-alloc.c} +100 -49
- package/src/llama.cpp/{ggml-backend-impl.h → ggml/src/ggml-backend-impl.h} +20 -8
- package/src/llama.cpp/{ggml-backend.c → ggml/src/ggml-backend.c} +307 -167
- package/src/llama.cpp/ggml/src/ggml-blas.cpp +367 -0
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.cpp +198 -0
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.h +230 -0
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +2944 -0
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +592 -0
- package/src/llama.cpp/ggml/src/ggml-cann/common.h +282 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/CMakeLists.txt +32 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/ascendc_kernels.h +17 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/dup.cpp +223 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f16.cpp +186 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f32.cpp +180 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_q4_0.cpp +193 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_q8_0.cpp +191 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f16_q8_0.cpp +208 -0
- package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f32_q8_0.cpp +206 -0
- package/src/llama.cpp/ggml/src/ggml-cann.cpp +2023 -0
- package/src/llama.cpp/{ggml-common.h → ggml/src/ggml-common.h} +41 -7
- package/src/llama.cpp/{ggml-impl.h → ggml/src/ggml-impl.h} +113 -9
- package/src/llama.cpp/{ggml-kompute.cpp → ggml/src/ggml-kompute.cpp} +33 -18
- package/src/llama.cpp/{ggml-quants.c → ggml/src/ggml-quants.c} +1460 -940
- package/src/llama.cpp/{ggml-quants.h → ggml/src/ggml-quants.h} +19 -20
- package/src/llama.cpp/{ggml-rpc.cpp → ggml/src/ggml-rpc.cpp} +95 -72
- package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +53 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +355 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.cpp +195 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.hpp +21 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +547 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +698 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +1023 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +3011 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +3031 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.hpp +33 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +1027 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.hpp +27 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +374 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.hpp +35 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/presets.hpp +66 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +275 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.hpp +22 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +251 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.hpp +24 -0
- package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +1140 -0
- package/src/llama.cpp/ggml/src/ggml-sycl.cpp +5314 -0
- package/src/llama.cpp/{ggml-vulkan.cpp → ggml/src/ggml-vulkan.cpp} +1781 -1868
- package/src/llama.cpp/{ggml.c → ggml/src/ggml.c} +1245 -2087
- package/src/llama.cpp/{sgemm.cpp → ggml/src/llamafile/sgemm.cpp} +21 -24
- package/src/llama.cpp/{sgemm.h → ggml/src/llamafile/sgemm.h} +1 -1
- package/src/llama.cpp/ggml/src/vulkan-shaders/CMakeLists.txt +5 -0
- package/src/llama.cpp/ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp +552 -0
- package/src/llama.cpp/{llama.h → include/llama.h} +175 -100
- package/src/llama.cpp/models/.editorconfig +1 -0
- package/src/llama.cpp/models/ggml-vocab-aquila.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-baichuan.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-neox.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.out +46 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.inp +112 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.out +46 -0
- package/src/llama.cpp/pocs/vdot/CMakeLists.txt +2 -2
- package/src/llama.cpp/requirements/requirements-all.txt +12 -0
- package/src/llama.cpp/requirements/requirements-compare-llama-bench.txt +2 -0
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf.txt +3 -0
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf_update.txt +3 -0
- package/src/llama.cpp/requirements/{requirements-convert.txt → requirements-convert_legacy_llama.txt} +1 -1
- package/src/llama.cpp/requirements/requirements-convert_llama_ggml_to_gguf.txt +1 -0
- package/src/llama.cpp/requirements/requirements-convert_lora_to_gguf.txt +2 -0
- package/src/llama.cpp/requirements/requirements-pydantic.txt +3 -0
- package/src/llama.cpp/requirements/requirements-test-tokenizer-random.txt +1 -0
- package/src/llama.cpp/requirements.txt +5 -4
- package/src/llama.cpp/scripts/build-info.sh +30 -0
- package/src/llama.cpp/scripts/install-oneapi.bat +19 -0
- package/src/llama.cpp/src/CMakeLists.txt +33 -0
- package/src/llama.cpp/src/llama-grammar.cpp +539 -0
- package/src/llama.cpp/src/llama-grammar.h +39 -0
- package/src/llama.cpp/src/llama-impl.h +26 -0
- package/src/llama.cpp/src/llama-sampling.cpp +635 -0
- package/src/llama.cpp/src/llama-sampling.h +56 -0
- package/src/llama.cpp/src/llama-vocab.cpp +1721 -0
- package/src/llama.cpp/src/llama-vocab.h +130 -0
- package/src/llama.cpp/{llama.cpp → src/llama.cpp} +5979 -5260
- package/src/llama.cpp/{unicode-data.cpp → src/unicode-data.cpp} +851 -802
- package/src/llama.cpp/{unicode.cpp → src/unicode.cpp} +52 -30
- package/src/llama.cpp/{unicode.h → src/unicode.h} +5 -1
- package/src/llama.cpp/tests/CMakeLists.txt +19 -20
- package/src/llama.cpp/tests/test-backend-ops.cpp +245 -67
- package/src/llama.cpp/tests/test-chat-template.cpp +57 -3
- package/src/llama.cpp/tests/test-double-float.cpp +2 -2
- package/src/llama.cpp/tests/test-grad0.cpp +2 -2
- package/src/llama.cpp/tests/test-grammar-integration.cpp +978 -31
- package/src/llama.cpp/tests/test-grammar-parser.cpp +423 -158
- package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +508 -135
- package/src/llama.cpp/tests/test-llama-grammar.cpp +15 -9
- package/src/llama.cpp/tests/test-quantize-fns.cpp +1 -1
- package/src/llama.cpp/tests/test-quantize-perf.cpp +1 -1
- package/src/llama.cpp/tests/test-rope.cpp +3 -4
- package/src/llama.cpp/tests/test-sampling.cpp +5 -5
- package/src/llama.cpp/tests/test-tokenizer-0.cpp +6 -6
- package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +20 -15
- package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +22 -11
- package/bin/darwin/arm64/default.metallib +0 -0
- package/bin/darwin/x64/default.metallib +0 -0
- package/src/llama.cpp/examples/beam-search/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/beam-search/beam-search.cpp +0 -188
- package/src/llama.cpp/examples/finetune/finetune.cpp +0 -1862
- package/src/llama.cpp/examples/llama.android/llama/CMakeLists.txt +0 -55
- package/src/llama.cpp/examples/train-text-from-scratch/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/train-text-from-scratch/train-text-from-scratch.cpp +0 -1253
- package/src/llama.cpp/ggml-opencl.cpp +0 -2305
- package/src/llama.cpp/ggml-opencl.h +0 -36
- package/src/llama.cpp/ggml-sycl.cpp +0 -17340
- package/src/llama.cpp/ggml-vulkan-shaders.hpp +0 -81211
- package/src/llama.cpp/requirements/requirements-convert-hf-to-gguf-update.txt +0 -2
- package/src/llama.cpp/requirements/requirements-convert-hf-to-gguf.txt +0 -2
- package/src/llama.cpp/requirements/requirements-convert-llama-ggml-to-gguf.txt +0 -1
- package/src/llama.cpp/scripts/gen-build-info-cpp.cmake +0 -24
- /package/src/llama.cpp/{ggml-alloc.h → ggml/include/ggml-alloc.h} +0 -0
- /package/src/llama.cpp/{ggml-kompute.h → ggml/include/ggml-kompute.h} +0 -0
- /package/src/llama.cpp/{ggml-rpc.h → ggml/include/ggml-rpc.h} +0 -0
- /package/src/llama.cpp/{ggml-vulkan.h → ggml/include/ggml-vulkan.h} +0 -0
- /package/src/llama.cpp/{unicode-data.h → src/unicode-data.h} +0 -0
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
#include "convert.hpp"
|
|
2
|
+
#include "dequantize.hpp"
|
|
3
|
+
#include "presets.hpp"
|
|
4
|
+
|
|
5
|
+
template <int qk, int qr, dequantize_kernel_t dequantize_kernel, typename dst_t>
|
|
6
|
+
static void dequantize_block(const void * __restrict__ vx, dst_t * __restrict__ y, const int k,
|
|
7
|
+
const sycl::nd_item<3> &item_ct1) {
|
|
8
|
+
const int i = 2 * (item_ct1.get_local_range(2) * item_ct1.get_group(2) +
|
|
9
|
+
item_ct1.get_local_id(2));
|
|
10
|
+
|
|
11
|
+
if (i >= k) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const int ib = i/qk; // block index
|
|
16
|
+
const int iqs = (i%qk)/qr; // quant index
|
|
17
|
+
const int iybs = i - i%qk; // y block start index
|
|
18
|
+
const int y_offset = qr == 1 ? 1 : qk/2;
|
|
19
|
+
|
|
20
|
+
// dequantize
|
|
21
|
+
dfloat2 v;
|
|
22
|
+
dequantize_kernel(vx, ib, iqs, v);
|
|
23
|
+
|
|
24
|
+
y[iybs + iqs + 0] = v.x();
|
|
25
|
+
y[iybs + iqs + y_offset] = v.y();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
template <int qk, int qr, dequantize_kernel_t dequantize_kernel, typename dst_t>
|
|
29
|
+
static void dequantize_block_sycl(const void *__restrict__ vx,
|
|
30
|
+
dst_t *__restrict__ y, const int k,
|
|
31
|
+
dpct::queue_ptr stream) {
|
|
32
|
+
const int num_blocks = (k + 2*SYCL_DEQUANTIZE_BLOCK_SIZE - 1) / (2*SYCL_DEQUANTIZE_BLOCK_SIZE);
|
|
33
|
+
{
|
|
34
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
35
|
+
{sycl::aspect::fp16});
|
|
36
|
+
stream->parallel_for(
|
|
37
|
+
sycl::nd_range<3>(
|
|
38
|
+
sycl::range<3>(1, 1, num_blocks) *
|
|
39
|
+
sycl::range<3>(1, 1, SYCL_DEQUANTIZE_BLOCK_SIZE),
|
|
40
|
+
sycl::range<3>(1, 1, SYCL_DEQUANTIZE_BLOCK_SIZE)),
|
|
41
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
42
|
+
dequantize_block<qk, qr, dequantize_kernel>(vx, y, k, item_ct1);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
template <typename dst_t>
|
|
48
|
+
static void dequantize_row_q2_K_sycl(const void *vx, dst_t *y, const int k,
|
|
49
|
+
dpct::queue_ptr stream) {
|
|
50
|
+
const int nb = k / QK_K;
|
|
51
|
+
#if QK_K == 256
|
|
52
|
+
{
|
|
53
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
54
|
+
{sycl::aspect::fp16});
|
|
55
|
+
|
|
56
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
57
|
+
sycl::range<3>(1, 1, 64),
|
|
58
|
+
sycl::range<3>(1, 1, 64)),
|
|
59
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
60
|
+
dequantize_block_q2_K(vx, y, item_ct1);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
#else
|
|
64
|
+
{
|
|
65
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
66
|
+
{sycl::aspect::fp16});
|
|
67
|
+
|
|
68
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
69
|
+
sycl::range<3>(1, 1, 32),
|
|
70
|
+
sycl::range<3>(1, 1, 32)),
|
|
71
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
72
|
+
dequantize_block_q2_K(vx, y, item_ct1);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#endif
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
template <typename dst_t>
|
|
80
|
+
static void dequantize_row_q3_K_sycl(const void *vx, dst_t *y, const int k,
|
|
81
|
+
dpct::queue_ptr stream) {
|
|
82
|
+
const int nb = k / QK_K;
|
|
83
|
+
#if QK_K == 256
|
|
84
|
+
{
|
|
85
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
86
|
+
{sycl::aspect::fp16});
|
|
87
|
+
|
|
88
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
89
|
+
sycl::range<3>(1, 1, 64),
|
|
90
|
+
sycl::range<3>(1, 1, 64)),
|
|
91
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
92
|
+
dequantize_block_q3_K(vx, y, item_ct1);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
#else
|
|
96
|
+
{
|
|
97
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
98
|
+
{sycl::aspect::fp16});
|
|
99
|
+
|
|
100
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
101
|
+
sycl::range<3>(1, 1, 32),
|
|
102
|
+
sycl::range<3>(1, 1, 32)),
|
|
103
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
104
|
+
dequantize_block_q3_K(vx, y, item_ct1);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
#endif
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
template <typename dst_t>
|
|
111
|
+
static void dequantize_row_q4_0_sycl(const void *vx, dst_t *y, const int k,
|
|
112
|
+
dpct::queue_ptr stream) {
|
|
113
|
+
const int nb32 = k / 32;
|
|
114
|
+
const int nb = (k + 255) / 256;
|
|
115
|
+
{
|
|
116
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
117
|
+
{sycl::aspect::fp16});
|
|
118
|
+
|
|
119
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
120
|
+
sycl::range<3>(1, 1, 32),
|
|
121
|
+
sycl::range<3>(1, 1, 32)),
|
|
122
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
123
|
+
dequantize_block_q4_0(vx, y, nb32, item_ct1);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
template <typename dst_t>
|
|
129
|
+
static void dequantize_row_q4_1_sycl(const void *vx, dst_t *y, const int k,
|
|
130
|
+
dpct::queue_ptr stream) {
|
|
131
|
+
const int nb32 = k / 32;
|
|
132
|
+
const int nb = (k + 255) / 256;
|
|
133
|
+
{
|
|
134
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
135
|
+
{sycl::aspect::fp16});
|
|
136
|
+
|
|
137
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
138
|
+
sycl::range<3>(1, 1, 32),
|
|
139
|
+
sycl::range<3>(1, 1, 32)),
|
|
140
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
141
|
+
dequantize_block_q4_1(vx, y, nb32, item_ct1);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
template <typename dst_t>
|
|
148
|
+
static void dequantize_row_q4_K_sycl(const void *vx, dst_t *y, const int k,
|
|
149
|
+
dpct::queue_ptr stream) {
|
|
150
|
+
const int nb = k / QK_K;
|
|
151
|
+
{
|
|
152
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
153
|
+
{sycl::aspect::fp16});
|
|
154
|
+
|
|
155
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
156
|
+
sycl::local_accessor<uint8_t, 1> scale_local_acc(sycl::range<1>(12), cgh);
|
|
157
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
158
|
+
sycl::range<3>(1, 1, 32),
|
|
159
|
+
sycl::range<3>(1, 1, 32)),
|
|
160
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
161
|
+
dequantize_block_q4_K(vx, y, get_pointer(scale_local_acc), item_ct1);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
template <typename dst_t>
|
|
168
|
+
static void dequantize_row_q5_K_sycl(const void *vx, dst_t *y, const int k,
|
|
169
|
+
dpct::queue_ptr stream) {
|
|
170
|
+
const int nb = k / QK_K;
|
|
171
|
+
#if QK_K == 256
|
|
172
|
+
{
|
|
173
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
174
|
+
{sycl::aspect::fp16});
|
|
175
|
+
|
|
176
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
177
|
+
sycl::range<3>(1, 1, 64),
|
|
178
|
+
sycl::range<3>(1, 1, 64)),
|
|
179
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
180
|
+
dequantize_block_q5_K(vx, y, item_ct1);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
#else
|
|
184
|
+
{
|
|
185
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
186
|
+
{sycl::aspect::fp16});
|
|
187
|
+
|
|
188
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
189
|
+
sycl::range<3>(1, 1, 32),
|
|
190
|
+
sycl::range<3>(1, 1, 32)),
|
|
191
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
192
|
+
dequantize_block_q5_K(vx, y, item_ct1);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
#endif
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
template <typename dst_t>
|
|
200
|
+
static void dequantize_row_q6_K_sycl(const void *vx, dst_t *y, const int k,
|
|
201
|
+
dpct::queue_ptr stream) {
|
|
202
|
+
const int nb = k / QK_K;
|
|
203
|
+
#if QK_K == 256
|
|
204
|
+
{
|
|
205
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
206
|
+
{sycl::aspect::fp16});
|
|
207
|
+
|
|
208
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
209
|
+
sycl::range<3>(1, 1, 64),
|
|
210
|
+
sycl::range<3>(1, 1, 64)),
|
|
211
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
212
|
+
dequantize_block_q6_K(vx, y, item_ct1);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
#else
|
|
216
|
+
{
|
|
217
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
218
|
+
{sycl::aspect::fp16});
|
|
219
|
+
|
|
220
|
+
stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
221
|
+
sycl::range<3>(1, 1, 32),
|
|
222
|
+
sycl::range<3>(1, 1, 32)),
|
|
223
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
224
|
+
dequantize_block_q6_K(vx, y, item_ct1);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
#endif
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
template <typename dst_t>
|
|
232
|
+
static void dequantize_row_iq1_s_sycl(const void *vx, dst_t *y, const int k,
|
|
233
|
+
dpct::queue_ptr stream) {
|
|
234
|
+
const int nb = k / QK_K;
|
|
235
|
+
{
|
|
236
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
237
|
+
{sycl::aspect::fp16});
|
|
238
|
+
|
|
239
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
240
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
241
|
+
sycl::range<3>(1, 1, 32),
|
|
242
|
+
sycl::range<3>(1, 1, 32)),
|
|
243
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
244
|
+
dequantize_block_iq1_s(
|
|
245
|
+
vx, y, item_ct1, iq1s_grid_gpu
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
template <typename dst_t>
|
|
253
|
+
static void dequantize_row_iq1_m_sycl(const void *vx, dst_t *y, const int k,
|
|
254
|
+
dpct::queue_ptr stream) {
|
|
255
|
+
const int nb = k / QK_K;
|
|
256
|
+
{
|
|
257
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
258
|
+
{sycl::aspect::fp16});
|
|
259
|
+
|
|
260
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
261
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
262
|
+
sycl::range<3>(1, 1, 32),
|
|
263
|
+
sycl::range<3>(1, 1, 32)),
|
|
264
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
265
|
+
dequantize_block_iq1_m(
|
|
266
|
+
vx, y, item_ct1, iq1s_grid_gpu
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
template <typename dst_t>
|
|
274
|
+
static void dequantize_row_iq2_xxs_sycl(const void *vx, dst_t *y, const int k,
|
|
275
|
+
dpct::queue_ptr stream) {
|
|
276
|
+
const int nb = k / QK_K;
|
|
277
|
+
{
|
|
278
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
279
|
+
{sycl::aspect::fp16});
|
|
280
|
+
|
|
281
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
282
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
283
|
+
sycl::range<3>(1, 1, 32),
|
|
284
|
+
sycl::range<3>(1, 1, 32)),
|
|
285
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
286
|
+
dequantize_block_iq2_xxs(
|
|
287
|
+
vx, y, item_ct1, iq2xxs_grid,
|
|
288
|
+
ksigns_iq2xs, kmask_iq2xs);
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
template <typename dst_t>
|
|
295
|
+
static void dequantize_row_iq2_xs_sycl(const void *vx, dst_t *y, const int k,
|
|
296
|
+
dpct::queue_ptr stream) {
|
|
297
|
+
const int nb = k / QK_K;
|
|
298
|
+
{
|
|
299
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
300
|
+
{sycl::aspect::fp16});
|
|
301
|
+
|
|
302
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
303
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
304
|
+
sycl::range<3>(1, 1, 32),
|
|
305
|
+
sycl::range<3>(1, 1, 32)),
|
|
306
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
307
|
+
dequantize_block_iq2_xs(
|
|
308
|
+
vx, y, item_ct1, iq2xs_grid,
|
|
309
|
+
ksigns_iq2xs, kmask_iq2xs);
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
template <typename dst_t>
|
|
316
|
+
static void dequantize_row_iq2_s_sycl(const void *vx, dst_t *y, const int k,
|
|
317
|
+
dpct::queue_ptr stream) {
|
|
318
|
+
const int nb = k / QK_K;
|
|
319
|
+
{
|
|
320
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
321
|
+
{sycl::aspect::fp16});
|
|
322
|
+
|
|
323
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
324
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
325
|
+
sycl::range<3>(1, 1, 32),
|
|
326
|
+
sycl::range<3>(1, 1, 32)),
|
|
327
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
328
|
+
dequantize_block_iq2_s(vx, y, item_ct1);
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
template <typename dst_t>
|
|
336
|
+
static void dequantize_row_iq3_xxs_sycl(const void *vx, dst_t *y, const int k,
|
|
337
|
+
dpct::queue_ptr stream) {
|
|
338
|
+
const int nb = k / QK_K;
|
|
339
|
+
{
|
|
340
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
341
|
+
{sycl::aspect::fp16});
|
|
342
|
+
|
|
343
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
344
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
345
|
+
sycl::range<3>(1, 1, 32),
|
|
346
|
+
sycl::range<3>(1, 1, 32)),
|
|
347
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
348
|
+
dequantize_block_iq3_xxs(
|
|
349
|
+
vx, y, item_ct1, iq3xxs_grid,
|
|
350
|
+
ksigns_iq2xs, kmask_iq2xs);
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
template <typename dst_t>
|
|
357
|
+
static void dequantize_row_iq3_s_sycl(const void *vx, dst_t *y, const int k,
|
|
358
|
+
dpct::queue_ptr stream) {
|
|
359
|
+
const int nb = k / QK_K;
|
|
360
|
+
{
|
|
361
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
362
|
+
{sycl::aspect::fp16});
|
|
363
|
+
|
|
364
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
365
|
+
cgh.parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
366
|
+
sycl::range<3>(1, 1, 32),
|
|
367
|
+
sycl::range<3>(1, 1, 32)),
|
|
368
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
369
|
+
dequantize_block_iq3_s(
|
|
370
|
+
vx, y, item_ct1, kmask_iq2xs, iq3s_grid);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
template <typename dst_t>
|
|
377
|
+
static void dequantize_row_iq4_xs_sycl(const void *vx, dst_t *y, const int k,
|
|
378
|
+
dpct::queue_ptr stream) {
|
|
379
|
+
const int nb = (k + QK_K - 1) / QK_K;
|
|
380
|
+
#if QK_K == 64
|
|
381
|
+
dequantize_row_iq4_nl_sycl(vx, y, k, stream);
|
|
382
|
+
#else
|
|
383
|
+
{
|
|
384
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
385
|
+
{sycl::aspect::fp16});
|
|
386
|
+
|
|
387
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
388
|
+
cgh.parallel_for(
|
|
389
|
+
sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
390
|
+
sycl::range<3>(1, 1, 32),
|
|
391
|
+
sycl::range<3>(1, 1, 32)),
|
|
392
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
393
|
+
dequantize_block_iq4_xs(vx, y, item_ct1);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
#endif
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
template <typename dst_t>
|
|
401
|
+
static void dequantize_row_iq4_nl_sycl(const void *vx, dst_t *y, const int k,
|
|
402
|
+
dpct::queue_ptr stream) {
|
|
403
|
+
const int nb = (k + QK_K - 1) / QK_K;
|
|
404
|
+
{
|
|
405
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
406
|
+
{sycl::aspect::fp16});
|
|
407
|
+
|
|
408
|
+
stream->submit([&](sycl::handler &cgh) {
|
|
409
|
+
cgh.parallel_for(
|
|
410
|
+
sycl::nd_range<3>(sycl::range<3>(1, 1, nb) *
|
|
411
|
+
sycl::range<3>(1, 1, 32),
|
|
412
|
+
sycl::range<3>(1, 1, 32)),
|
|
413
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
414
|
+
dequantize_block_iq4_nl(vx, y, item_ct1);
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
template <typename src_t, typename dst_t>
|
|
421
|
+
static void convert_unary(const void * __restrict__ vx, dst_t * __restrict__ y, const int k,
|
|
422
|
+
const sycl::nd_item<3> &item_ct1) {
|
|
423
|
+
const int i = item_ct1.get_local_range(2) * item_ct1.get_group(2) +
|
|
424
|
+
item_ct1.get_local_id(2);
|
|
425
|
+
|
|
426
|
+
if (i >= k) {
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const src_t * x = (src_t *) vx;
|
|
431
|
+
|
|
432
|
+
y[i] = x[i];
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
template <typename src_t, typename dst_t>
|
|
436
|
+
static void convert_unary_sycl(const void *__restrict__ vx,
|
|
437
|
+
dst_t *__restrict__ y, const int k,
|
|
438
|
+
dpct::queue_ptr stream) {
|
|
439
|
+
const int num_blocks = (k + SYCL_DEQUANTIZE_BLOCK_SIZE - 1) / SYCL_DEQUANTIZE_BLOCK_SIZE;
|
|
440
|
+
{
|
|
441
|
+
dpct::has_capability_or_fail(stream->get_device(),
|
|
442
|
+
{sycl::aspect::fp16});
|
|
443
|
+
|
|
444
|
+
stream->parallel_for(
|
|
445
|
+
sycl::nd_range<3>(
|
|
446
|
+
sycl::range<3>(1, 1, num_blocks) *
|
|
447
|
+
sycl::range<3>(1, 1, SYCL_DEQUANTIZE_BLOCK_SIZE),
|
|
448
|
+
sycl::range<3>(1, 1, SYCL_DEQUANTIZE_BLOCK_SIZE)),
|
|
449
|
+
[=](sycl::nd_item<3> item_ct1) {
|
|
450
|
+
convert_unary<src_t>(vx, y, k, item_ct1);
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
to_fp16_sycl_t ggml_get_to_fp16_sycl(ggml_type type) {
|
|
456
|
+
switch (type) {
|
|
457
|
+
case GGML_TYPE_Q4_0:
|
|
458
|
+
return dequantize_block_sycl<QK4_0, QR4_0, dequantize_q4_0>;
|
|
459
|
+
case GGML_TYPE_Q4_1:
|
|
460
|
+
return dequantize_block_sycl<QK4_1, QR4_1, dequantize_q4_1>;
|
|
461
|
+
case GGML_TYPE_Q5_0:
|
|
462
|
+
return dequantize_block_sycl<QK5_0, QR5_0, dequantize_q5_0>;
|
|
463
|
+
case GGML_TYPE_Q5_1:
|
|
464
|
+
return dequantize_block_sycl<QK5_1, QR5_1, dequantize_q5_1>;
|
|
465
|
+
case GGML_TYPE_Q8_0:
|
|
466
|
+
return dequantize_block_sycl<QK8_0, QR8_0, dequantize_q8_0>;
|
|
467
|
+
case GGML_TYPE_Q2_K:
|
|
468
|
+
return dequantize_row_q2_K_sycl;
|
|
469
|
+
case GGML_TYPE_Q3_K:
|
|
470
|
+
return dequantize_row_q3_K_sycl;
|
|
471
|
+
case GGML_TYPE_Q4_K:
|
|
472
|
+
return dequantize_row_q4_K_sycl;
|
|
473
|
+
case GGML_TYPE_Q5_K:
|
|
474
|
+
return dequantize_row_q5_K_sycl;
|
|
475
|
+
case GGML_TYPE_Q6_K:
|
|
476
|
+
return dequantize_row_q6_K_sycl;
|
|
477
|
+
case GGML_TYPE_IQ1_S:
|
|
478
|
+
return dequantize_row_iq1_s_sycl;
|
|
479
|
+
case GGML_TYPE_IQ1_M:
|
|
480
|
+
return dequantize_row_iq1_m_sycl;
|
|
481
|
+
case GGML_TYPE_IQ2_XXS:
|
|
482
|
+
return dequantize_row_iq2_xxs_sycl;
|
|
483
|
+
case GGML_TYPE_IQ2_XS:
|
|
484
|
+
return dequantize_row_iq2_xs_sycl;
|
|
485
|
+
case GGML_TYPE_IQ2_S:
|
|
486
|
+
return dequantize_row_iq2_s_sycl;
|
|
487
|
+
case GGML_TYPE_IQ3_XXS:
|
|
488
|
+
return dequantize_row_iq3_xxs_sycl;
|
|
489
|
+
case GGML_TYPE_IQ3_S:
|
|
490
|
+
return dequantize_row_iq3_s_sycl;
|
|
491
|
+
case GGML_TYPE_IQ4_XS:
|
|
492
|
+
return dequantize_row_iq4_xs_sycl;
|
|
493
|
+
case GGML_TYPE_IQ4_NL:
|
|
494
|
+
return dequantize_row_iq4_nl_sycl;
|
|
495
|
+
case GGML_TYPE_F32:
|
|
496
|
+
return convert_unary_sycl<float>;
|
|
497
|
+
default:
|
|
498
|
+
return nullptr;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
to_fp32_sycl_t ggml_get_to_fp32_sycl(ggml_type type) {
|
|
503
|
+
switch (type) {
|
|
504
|
+
case GGML_TYPE_Q4_0:
|
|
505
|
+
return dequantize_row_q4_0_sycl;
|
|
506
|
+
case GGML_TYPE_Q4_1:
|
|
507
|
+
return dequantize_row_q4_1_sycl;
|
|
508
|
+
case GGML_TYPE_Q5_0:
|
|
509
|
+
return dequantize_block_sycl<QK5_0, QR5_0, dequantize_q5_0>;
|
|
510
|
+
case GGML_TYPE_Q5_1:
|
|
511
|
+
return dequantize_block_sycl<QK5_1, QR5_1, dequantize_q5_1>;
|
|
512
|
+
case GGML_TYPE_Q8_0:
|
|
513
|
+
return dequantize_block_sycl<QK8_0, QR8_0, dequantize_q8_0>;
|
|
514
|
+
case GGML_TYPE_Q2_K:
|
|
515
|
+
return dequantize_row_q2_K_sycl;
|
|
516
|
+
case GGML_TYPE_Q3_K:
|
|
517
|
+
return dequantize_row_q3_K_sycl;
|
|
518
|
+
case GGML_TYPE_Q4_K:
|
|
519
|
+
return dequantize_row_q4_K_sycl;
|
|
520
|
+
case GGML_TYPE_Q5_K:
|
|
521
|
+
return dequantize_row_q5_K_sycl;
|
|
522
|
+
case GGML_TYPE_Q6_K:
|
|
523
|
+
return dequantize_row_q6_K_sycl;
|
|
524
|
+
case GGML_TYPE_IQ1_S:
|
|
525
|
+
return dequantize_row_iq1_s_sycl;
|
|
526
|
+
case GGML_TYPE_IQ1_M:
|
|
527
|
+
return dequantize_row_iq1_m_sycl;
|
|
528
|
+
case GGML_TYPE_IQ2_XXS:
|
|
529
|
+
return dequantize_row_iq2_xxs_sycl;
|
|
530
|
+
case GGML_TYPE_IQ2_XS:
|
|
531
|
+
return dequantize_row_iq2_xs_sycl;
|
|
532
|
+
case GGML_TYPE_IQ2_S:
|
|
533
|
+
return dequantize_row_iq2_s_sycl;
|
|
534
|
+
case GGML_TYPE_IQ3_XXS:
|
|
535
|
+
return dequantize_row_iq3_xxs_sycl;
|
|
536
|
+
case GGML_TYPE_IQ3_S:
|
|
537
|
+
return dequantize_row_iq3_s_sycl;
|
|
538
|
+
case GGML_TYPE_IQ4_XS:
|
|
539
|
+
return dequantize_row_iq4_xs_sycl;
|
|
540
|
+
case GGML_TYPE_IQ4_NL:
|
|
541
|
+
return dequantize_row_iq4_nl_sycl;
|
|
542
|
+
case GGML_TYPE_F16:
|
|
543
|
+
return convert_unary_sycl<sycl::half>;
|
|
544
|
+
default:
|
|
545
|
+
return nullptr;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// MIT license
|
|
3
|
+
// Copyright (C) 2024 Intel Corporation
|
|
4
|
+
// SPDX-License-Identifier: MIT
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
9
|
+
// See https://llvm.org/LICENSE.txt for license information.
|
|
10
|
+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
11
|
+
//
|
|
12
|
+
|
|
13
|
+
#ifndef GGML_SYCL_CONVERT_HPP
|
|
14
|
+
#define GGML_SYCL_CONVERT_HPP
|
|
15
|
+
|
|
16
|
+
#include "common.hpp"
|
|
17
|
+
|
|
18
|
+
template <typename T>
|
|
19
|
+
using to_t_sycl_t = void (*)(const void *__restrict__ x, T *__restrict__ y,
|
|
20
|
+
int k, dpct::queue_ptr stream);
|
|
21
|
+
typedef to_t_sycl_t<float> to_fp32_sycl_t;
|
|
22
|
+
typedef to_t_sycl_t<sycl::half> to_fp16_sycl_t;
|
|
23
|
+
|
|
24
|
+
to_fp16_sycl_t ggml_get_to_fp16_sycl(ggml_type type);
|
|
25
|
+
to_fp32_sycl_t ggml_get_to_fp32_sycl(ggml_type type);
|
|
26
|
+
|
|
27
|
+
#endif // GGML_SYCL_CONVERT_HPP
|