@fugood/llama.node 0.6.3 → 1.0.0-beta.2
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 +40 -30
- package/README.md +4 -1
- package/lib/binding.js +41 -29
- package/lib/binding.ts +26 -25
- package/package.json +40 -7
- package/scripts/build.js +47 -0
- package/scripts/llama.cpp.patch +109 -0
- package/src/anyascii.c +22223 -0
- package/src/anyascii.h +42 -0
- package/src/tts_utils.cpp +20 -7
- package/src/tts_utils.h +2 -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-cuda/arm64/llama-node.node +0 -0
- package/bin/linux-cuda/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/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/src/llama.cpp/.github/workflows/build-linux-cross.yml +0 -233
- package/src/llama.cpp/.github/workflows/build.yml +0 -1078
- package/src/llama.cpp/.github/workflows/close-issue.yml +0 -28
- package/src/llama.cpp/.github/workflows/docker.yml +0 -178
- package/src/llama.cpp/.github/workflows/editorconfig.yml +0 -29
- package/src/llama.cpp/.github/workflows/gguf-publish.yml +0 -44
- package/src/llama.cpp/.github/workflows/labeler.yml +0 -17
- package/src/llama.cpp/.github/workflows/python-check-requirements.yml +0 -33
- package/src/llama.cpp/.github/workflows/python-lint.yml +0 -30
- package/src/llama.cpp/.github/workflows/python-type-check.yml +0 -40
- package/src/llama.cpp/.github/workflows/release.yml +0 -739
- package/src/llama.cpp/.github/workflows/server.yml +0 -237
- package/src/llama.cpp/.github/workflows/winget.yml +0 -42
- package/src/llama.cpp/cmake/arm64-apple-clang.cmake +0 -16
- package/src/llama.cpp/cmake/arm64-windows-llvm.cmake +0 -16
- package/src/llama.cpp/cmake/build-info.cmake +0 -64
- package/src/llama.cpp/cmake/common.cmake +0 -35
- package/src/llama.cpp/cmake/git-vars.cmake +0 -22
- package/src/llama.cpp/cmake/x64-windows-llvm.cmake +0 -5
- package/src/llama.cpp/common/build-info.cpp.in +0 -4
- package/src/llama.cpp/docs/build.md +0 -561
- package/src/llama.cpp/examples/CMakeLists.txt +0 -43
- package/src/llama.cpp/examples/batched/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/batched/batched.cpp +0 -246
- package/src/llama.cpp/examples/chat-13B.bat +0 -57
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp +0 -941
- package/src/llama.cpp/examples/deprecation-warning/deprecation-warning.cpp +0 -35
- package/src/llama.cpp/examples/embedding/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/embedding/embedding.cpp +0 -323
- package/src/llama.cpp/examples/eval-callback/CMakeLists.txt +0 -10
- package/src/llama.cpp/examples/eval-callback/eval-callback.cpp +0 -194
- package/src/llama.cpp/examples/gen-docs/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/gen-docs/gen-docs.cpp +0 -83
- package/src/llama.cpp/examples/gguf/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/gguf/gguf.cpp +0 -265
- package/src/llama.cpp/examples/gguf-hash/CMakeLists.txt +0 -22
- package/src/llama.cpp/examples/gguf-hash/deps/rotate-bits/rotate-bits.h +0 -46
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.c +0 -295
- package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.h +0 -52
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.c +0 -221
- package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.h +0 -24
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.c +0 -42
- package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.h +0 -7093
- package/src/llama.cpp/examples/gguf-hash/gguf-hash.cpp +0 -694
- package/src/llama.cpp/examples/gritlm/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/gritlm/gritlm.cpp +0 -229
- package/src/llama.cpp/examples/jeopardy/questions.txt +0 -100
- package/src/llama.cpp/examples/llama.android/app/build.gradle.kts +0 -65
- package/src/llama.cpp/examples/llama.android/build.gradle.kts +0 -6
- package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +0 -71
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/CMakeLists.txt +0 -53
- package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/llama-android.cpp +0 -452
- package/src/llama.cpp/examples/llama.android/settings.gradle.kts +0 -18
- package/src/llama.cpp/examples/lookahead/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/lookahead/lookahead.cpp +0 -472
- package/src/llama.cpp/examples/lookup/CMakeLists.txt +0 -23
- package/src/llama.cpp/examples/lookup/lookup-create.cpp +0 -40
- package/src/llama.cpp/examples/lookup/lookup-merge.cpp +0 -47
- package/src/llama.cpp/examples/lookup/lookup-stats.cpp +0 -157
- package/src/llama.cpp/examples/lookup/lookup.cpp +0 -242
- package/src/llama.cpp/examples/parallel/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/parallel/parallel.cpp +0 -492
- package/src/llama.cpp/examples/passkey/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/passkey/passkey.cpp +0 -277
- package/src/llama.cpp/examples/retrieval/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/retrieval/retrieval.cpp +0 -304
- package/src/llama.cpp/examples/save-load-state/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/save-load-state/save-load-state.cpp +0 -246
- package/src/llama.cpp/examples/simple/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/simple/simple.cpp +0 -206
- package/src/llama.cpp/examples/simple-chat/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/simple-chat/simple-chat.cpp +0 -206
- package/src/llama.cpp/examples/simple-cmake-pkg/CMakeLists.txt +0 -11
- package/src/llama.cpp/examples/speculative/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/speculative/speculative.cpp +0 -644
- package/src/llama.cpp/examples/speculative-simple/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/speculative-simple/speculative-simple.cpp +0 -261
- package/src/llama.cpp/examples/sycl/CMakeLists.txt +0 -9
- package/src/llama.cpp/examples/sycl/build.sh +0 -23
- package/src/llama.cpp/examples/sycl/ls-sycl-device.cpp +0 -13
- package/src/llama.cpp/examples/sycl/run-llama2.sh +0 -27
- package/src/llama.cpp/examples/sycl/run-llama3.sh +0 -28
- package/src/llama.cpp/examples/sycl/win-build-sycl.bat +0 -33
- package/src/llama.cpp/examples/sycl/win-run-llama2.bat +0 -9
- package/src/llama.cpp/examples/sycl/win-run-llama3.bat +0 -9
- package/src/llama.cpp/examples/training/CMakeLists.txt +0 -5
- package/src/llama.cpp/examples/training/finetune.cpp +0 -96
- package/src/llama.cpp/ggml/cmake/GitVars.cmake +0 -22
- package/src/llama.cpp/ggml/cmake/common.cmake +0 -26
- package/src/llama.cpp/ggml/src/ggml-alloc.c +0 -1042
- package/src/llama.cpp/ggml/src/ggml-backend-impl.h +0 -255
- package/src/llama.cpp/ggml/src/ggml-backend-reg.cpp +0 -586
- package/src/llama.cpp/ggml/src/ggml-backend.cpp +0 -2008
- package/src/llama.cpp/ggml/src/ggml-blas/CMakeLists.txt +0 -87
- package/src/llama.cpp/ggml/src/ggml-blas/ggml-blas.cpp +0 -517
- package/src/llama.cpp/ggml/src/ggml-cann/CMakeLists.txt +0 -74
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.cpp +0 -179
- package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.h +0 -258
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +0 -2863
- package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +0 -1110
- package/src/llama.cpp/ggml/src/ggml-cann/common.h +0 -420
- package/src/llama.cpp/ggml/src/ggml-cann/ggml-cann.cpp +0 -2570
- package/src/llama.cpp/ggml/src/ggml-common.h +0 -1857
- package/src/llama.cpp/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +0 -100
- package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +0 -184
- package/src/llama.cpp/ggml/src/ggml-cuda/vendors/cuda.h +0 -15
- package/src/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +0 -243
- package/src/llama.cpp/ggml/src/ggml-cuda/vendors/musa.h +0 -140
- package/src/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt +0 -131
- package/src/llama.cpp/ggml/src/ggml-impl.h +0 -601
- package/src/llama.cpp/ggml/src/ggml-kompute/CMakeLists.txt +0 -166
- package/src/llama.cpp/ggml/src/ggml-kompute/ggml-kompute.cpp +0 -2251
- package/src/llama.cpp/ggml/src/ggml-metal/CMakeLists.txt +0 -120
- package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +0 -622
- package/src/llama.cpp/ggml/src/ggml-musa/CMakeLists.txt +0 -113
- package/src/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +0 -96
- package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +0 -5124
- package/src/llama.cpp/ggml/src/ggml-opt.cpp +0 -1037
- package/src/llama.cpp/ggml/src/ggml-quants.c +0 -5232
- package/src/llama.cpp/ggml/src/ggml-quants.h +0 -100
- package/src/llama.cpp/ggml/src/ggml-rpc/CMakeLists.txt +0 -9
- package/src/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +0 -1813
- package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +0 -189
- package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +0 -37
- package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +0 -239
- package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.hpp +0 -39
- package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +0 -83
- package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +0 -493
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.cpp +0 -197
- package/src/llama.cpp/ggml/src/ggml-sycl/concat.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/conv.cpp +0 -100
- package/src/llama.cpp/ggml/src/ggml-sycl/conv.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +0 -623
- package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +0 -34
- package/src/llama.cpp/ggml/src/ggml-sycl/cpy.cpp +0 -701
- package/src/llama.cpp/ggml/src/ggml-sycl/cpy.hpp +0 -11
- package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +0 -791
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +0 -1160
- package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.hpp +0 -27
- package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +0 -2957
- package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +0 -1536
- package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.hpp +0 -75
- package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +0 -99
- package/src/llama.cpp/ggml/src/ggml-sycl/getrows.cpp +0 -311
- package/src/llama.cpp/ggml/src/ggml-sycl/getrows.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +0 -4443
- package/src/llama.cpp/ggml/src/ggml-sycl/gla.cpp +0 -105
- package/src/llama.cpp/ggml/src/ggml-sycl/gla.hpp +0 -8
- package/src/llama.cpp/ggml/src/ggml-sycl/im2col.cpp +0 -136
- package/src/llama.cpp/ggml/src/ggml-sycl/im2col.hpp +0 -21
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +0 -3030
- package/src/llama.cpp/ggml/src/ggml-sycl/mmq.hpp +0 -33
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +0 -1108
- package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.hpp +0 -27
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +0 -474
- package/src/llama.cpp/ggml/src/ggml-sycl/norm.hpp +0 -26
- package/src/llama.cpp/ggml/src/ggml-sycl/outprod.cpp +0 -46
- package/src/llama.cpp/ggml/src/ggml-sycl/outprod.hpp +0 -10
- package/src/llama.cpp/ggml/src/ggml-sycl/presets.hpp +0 -74
- package/src/llama.cpp/ggml/src/ggml-sycl/quants.hpp +0 -83
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +0 -362
- package/src/llama.cpp/ggml/src/ggml-sycl/rope.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +0 -264
- package/src/llama.cpp/ggml/src/ggml-sycl/softmax.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.cpp +0 -13
- package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.hpp +0 -23
- package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.cpp +0 -73
- package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.hpp +0 -20
- package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +0 -1215
- package/src/llama.cpp/ggml/src/ggml-sycl/wkv.cpp +0 -305
- package/src/llama.cpp/ggml/src/ggml-sycl/wkv.hpp +0 -10
- package/src/llama.cpp/ggml/src/ggml-threading.cpp +0 -12
- package/src/llama.cpp/ggml/src/ggml-threading.h +0 -14
- package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +0 -196
- package/src/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +0 -10699
- package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +0 -39
- package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +0 -751
- package/src/llama.cpp/ggml/src/ggml.c +0 -6550
- package/src/llama.cpp/ggml/src/gguf.cpp +0 -1330
- package/src/llama.cpp/models/.editorconfig +0 -1
- 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 +0 -112
- package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-command-r.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-falcon.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.out +0 -46
- 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 +0 -112
- package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-llama4.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-llama4.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-mpt.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-refact.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-refact.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.out +0 -46
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf +0 -0
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.inp +0 -112
- package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.out +0 -46
- package/src/llama.cpp/pocs/CMakeLists.txt +0 -14
- package/src/llama.cpp/pocs/vdot/CMakeLists.txt +0 -9
- package/src/llama.cpp/pocs/vdot/q8dot.cpp +0 -173
- package/src/llama.cpp/pocs/vdot/vdot.cpp +0 -311
- package/src/llama.cpp/prompts/LLM-questions.txt +0 -49
- package/src/llama.cpp/prompts/alpaca.txt +0 -1
- package/src/llama.cpp/prompts/assistant.txt +0 -31
- package/src/llama.cpp/prompts/chat-with-baichuan.txt +0 -4
- package/src/llama.cpp/prompts/chat-with-bob.txt +0 -7
- package/src/llama.cpp/prompts/chat-with-qwen.txt +0 -1
- package/src/llama.cpp/prompts/chat-with-vicuna-v0.txt +0 -7
- package/src/llama.cpp/prompts/chat-with-vicuna-v1.txt +0 -7
- package/src/llama.cpp/prompts/chat.txt +0 -28
- package/src/llama.cpp/prompts/dan-modified.txt +0 -1
- package/src/llama.cpp/prompts/dan.txt +0 -1
- package/src/llama.cpp/prompts/mnemonics.txt +0 -93
- package/src/llama.cpp/prompts/parallel-questions.txt +0 -43
- package/src/llama.cpp/prompts/reason-act.txt +0 -18
- package/src/llama.cpp/requirements/requirements-all.txt +0 -15
- package/src/llama.cpp/requirements/requirements-compare-llama-bench.txt +0 -2
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf.txt +0 -7
- package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf_update.txt +0 -7
- package/src/llama.cpp/requirements/requirements-convert_legacy_llama.txt +0 -5
- package/src/llama.cpp/requirements/requirements-convert_llama_ggml_to_gguf.txt +0 -1
- package/src/llama.cpp/requirements/requirements-convert_lora_to_gguf.txt +0 -4
- package/src/llama.cpp/requirements/requirements-gguf_editor_gui.txt +0 -3
- package/src/llama.cpp/requirements/requirements-pydantic.txt +0 -3
- package/src/llama.cpp/requirements/requirements-test-tokenizer-random.txt +0 -1
- package/src/llama.cpp/requirements/requirements-tool_bench.txt +0 -12
- package/src/llama.cpp/requirements.txt +0 -13
- package/src/llama.cpp/scripts/build-info.sh +0 -30
- package/src/llama.cpp/scripts/install-oneapi.bat +0 -19
- package/src/llama.cpp/scripts/xxd.cmake +0 -16
- package/src/llama.cpp/tests/CMakeLists.txt +0 -177
- package/src/llama.cpp/tests/get-model.cpp +0 -21
- package/src/llama.cpp/tests/get-model.h +0 -2
- package/src/llama.cpp/tests/test-arg-parser.cpp +0 -178
- package/src/llama.cpp/tests/test-autorelease.cpp +0 -24
- package/src/llama.cpp/tests/test-backend-ops.cpp +0 -4793
- package/src/llama.cpp/tests/test-barrier.cpp +0 -94
- package/src/llama.cpp/tests/test-c.c +0 -7
- package/src/llama.cpp/tests/test-chat-template.cpp +0 -417
- package/src/llama.cpp/tests/test-chat.cpp +0 -985
- package/src/llama.cpp/tests/test-double-float.cpp +0 -57
- package/src/llama.cpp/tests/test-gbnf-validator.cpp +0 -109
- package/src/llama.cpp/tests/test-gguf.cpp +0 -1338
- package/src/llama.cpp/tests/test-grammar-integration.cpp +0 -1308
- package/src/llama.cpp/tests/test-grammar-llguidance.cpp +0 -1201
- package/src/llama.cpp/tests/test-grammar-parser.cpp +0 -519
- package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +0 -1304
- package/src/llama.cpp/tests/test-llama-grammar.cpp +0 -408
- package/src/llama.cpp/tests/test-log.cpp +0 -39
- package/src/llama.cpp/tests/test-model-load-cancel.cpp +0 -27
- package/src/llama.cpp/tests/test-mtmd-c-api.c +0 -63
- package/src/llama.cpp/tests/test-opt.cpp +0 -904
- package/src/llama.cpp/tests/test-quantize-fns.cpp +0 -186
- package/src/llama.cpp/tests/test-quantize-perf.cpp +0 -365
- package/src/llama.cpp/tests/test-quantize-stats.cpp +0 -424
- package/src/llama.cpp/tests/test-regex-partial.cpp +0 -288
- package/src/llama.cpp/tests/test-rope.cpp +0 -262
- package/src/llama.cpp/tests/test-sampling.cpp +0 -399
- package/src/llama.cpp/tests/test-tokenizer-0.cpp +0 -312
- package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +0 -155
- package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +0 -125
- package/src/llama.cpp/tools/CMakeLists.txt +0 -39
- package/src/llama.cpp/tools/batched-bench/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/batched-bench/batched-bench.cpp +0 -204
- package/src/llama.cpp/tools/cvector-generator/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/cvector-generator/completions.txt +0 -582
- package/src/llama.cpp/tools/cvector-generator/cvector-generator.cpp +0 -508
- package/src/llama.cpp/tools/cvector-generator/mean.hpp +0 -48
- package/src/llama.cpp/tools/cvector-generator/negative.txt +0 -4
- package/src/llama.cpp/tools/cvector-generator/pca.hpp +0 -315
- package/src/llama.cpp/tools/cvector-generator/positive.txt +0 -4
- package/src/llama.cpp/tools/export-lora/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/export-lora/export-lora.cpp +0 -434
- package/src/llama.cpp/tools/gguf-split/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/gguf-split/gguf-split.cpp +0 -583
- package/src/llama.cpp/tools/imatrix/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/imatrix/imatrix.cpp +0 -667
- package/src/llama.cpp/tools/llama-bench/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/llama-bench/llama-bench.cpp +0 -2024
- package/src/llama.cpp/tools/main/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/main/main.cpp +0 -977
- package/src/llama.cpp/tools/mtmd/CMakeLists.txt +0 -58
- package/src/llama.cpp/tools/mtmd/clip-impl.h +0 -462
- package/src/llama.cpp/tools/mtmd/clip.cpp +0 -4024
- package/src/llama.cpp/tools/mtmd/clip.h +0 -101
- package/src/llama.cpp/tools/mtmd/deprecation-warning.cpp +0 -22
- package/src/llama.cpp/tools/mtmd/miniaudio.h +0 -93468
- package/src/llama.cpp/tools/mtmd/mtmd-audio.cpp +0 -855
- package/src/llama.cpp/tools/mtmd/mtmd-audio.h +0 -62
- package/src/llama.cpp/tools/mtmd/mtmd-cli.cpp +0 -377
- package/src/llama.cpp/tools/mtmd/mtmd-helper.cpp +0 -297
- package/src/llama.cpp/tools/mtmd/mtmd.cpp +0 -942
- package/src/llama.cpp/tools/mtmd/mtmd.h +0 -362
- package/src/llama.cpp/tools/mtmd/requirements.txt +0 -5
- package/src/llama.cpp/tools/perplexity/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/perplexity/perplexity.cpp +0 -2063
- package/src/llama.cpp/tools/quantize/CMakeLists.txt +0 -6
- package/src/llama.cpp/tools/quantize/quantize.cpp +0 -519
- package/src/llama.cpp/tools/rpc/CMakeLists.txt +0 -4
- package/src/llama.cpp/tools/rpc/rpc-server.cpp +0 -322
- package/src/llama.cpp/tools/run/CMakeLists.txt +0 -16
- package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.cpp +0 -1995
- package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.h +0 -137
- package/src/llama.cpp/tools/run/run.cpp +0 -1261
- package/src/llama.cpp/tools/server/CMakeLists.txt +0 -51
- package/src/llama.cpp/tools/server/bench/requirements.txt +0 -2
- package/src/llama.cpp/tools/server/httplib.h +0 -10506
- package/src/llama.cpp/tools/server/server.cpp +0 -4966
- package/src/llama.cpp/tools/server/tests/requirements.txt +0 -8
- package/src/llama.cpp/tools/server/utils.hpp +0 -1337
- package/src/llama.cpp/tools/tokenize/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/tokenize/tokenize.cpp +0 -416
- package/src/llama.cpp/tools/tts/CMakeLists.txt +0 -5
- package/src/llama.cpp/tools/tts/tts.cpp +0 -1092
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
// Unit tests for quantization specific functions - quantize, dequantize and dot product
|
|
2
|
-
|
|
3
|
-
#include "ggml.h"
|
|
4
|
-
#include "ggml-cpu.h"
|
|
5
|
-
|
|
6
|
-
#undef NDEBUG
|
|
7
|
-
#include <assert.h>
|
|
8
|
-
#include <math.h>
|
|
9
|
-
#include <stdio.h>
|
|
10
|
-
#include <string>
|
|
11
|
-
#include <vector>
|
|
12
|
-
|
|
13
|
-
#if defined(_MSC_VER)
|
|
14
|
-
#pragma warning(disable: 4244 4267) // possible loss of data
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
|
-
constexpr float MAX_QUANTIZATION_REFERENCE_ERROR = 0.0001f;
|
|
18
|
-
constexpr float MAX_QUANTIZATION_TOTAL_ERROR = 0.002f;
|
|
19
|
-
constexpr float MAX_QUANTIZATION_TOTAL_ERROR_TERNARY = 0.01f;
|
|
20
|
-
constexpr float MAX_QUANTIZATION_TOTAL_ERROR_2BITS = 0.0075f;
|
|
21
|
-
constexpr float MAX_QUANTIZATION_TOTAL_ERROR_3BITS = 0.0040f;
|
|
22
|
-
constexpr float MAX_QUANTIZATION_TOTAL_ERROR_3BITS_XXS = 0.0050f;
|
|
23
|
-
constexpr float MAX_DOT_PRODUCT_ERROR = 0.02f;
|
|
24
|
-
constexpr float MAX_DOT_PRODUCT_ERROR_LOWBIT = 0.04f;
|
|
25
|
-
constexpr float MAX_DOT_PRODUCT_ERROR_TERNARY = 0.15f;
|
|
26
|
-
|
|
27
|
-
static const char* RESULT_STR[] = {"ok", "FAILED"};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Generate synthetic data
|
|
31
|
-
static void generate_data(float offset, size_t n, float * dst) {
|
|
32
|
-
for (size_t i = 0; i < n; i++) {
|
|
33
|
-
dst[i] = 0.1 + 2*cosf(i + offset);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Calculate RMSE between two float arrays
|
|
38
|
-
static float array_rmse(const float * a1, const float * a2, size_t n) {
|
|
39
|
-
double sum = 0;
|
|
40
|
-
for (size_t i = 0; i < n; i++) {
|
|
41
|
-
double diff = a1[i] - a2[i];
|
|
42
|
-
sum += diff * diff;
|
|
43
|
-
}
|
|
44
|
-
return sqrtf(sum) / n;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Total quantization error on test data
|
|
48
|
-
static float total_quantization_error(const ggml_type_traits * qfns, const ggml_type_traits_cpu * qfns_cpu, size_t test_size, const float * test_data) {
|
|
49
|
-
std::vector<uint8_t> tmp_q(2*test_size);
|
|
50
|
-
std::vector<float> tmp_out(test_size);
|
|
51
|
-
|
|
52
|
-
qfns_cpu->from_float(test_data, tmp_q.data(), test_size);
|
|
53
|
-
qfns->to_float(tmp_q.data(), tmp_out.data(), test_size);
|
|
54
|
-
return array_rmse(test_data, tmp_out.data(), test_size);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Total quantization error on test data
|
|
58
|
-
static float reference_quantization_error(const ggml_type_traits * qfns, const ggml_type_traits_cpu * qfns_cpu, size_t test_size, const float * test_data) {
|
|
59
|
-
std::vector<uint8_t> tmp_q(2*test_size);
|
|
60
|
-
std::vector<float> tmp_out(test_size);
|
|
61
|
-
std::vector<float> tmp_out_ref(test_size);
|
|
62
|
-
|
|
63
|
-
// FIXME: why is done twice?
|
|
64
|
-
qfns_cpu->from_float(test_data, tmp_q.data(), test_size);
|
|
65
|
-
qfns->to_float(tmp_q.data(), tmp_out.data(), test_size);
|
|
66
|
-
|
|
67
|
-
qfns->from_float_ref(test_data, tmp_q.data(), test_size);
|
|
68
|
-
qfns->to_float(tmp_q.data(), tmp_out_ref.data(), test_size);
|
|
69
|
-
|
|
70
|
-
return array_rmse(tmp_out.data(), tmp_out_ref.data(), test_size);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static float dot_product(const float * a1, const float * a2, size_t test_size) {
|
|
74
|
-
double sum = 0;
|
|
75
|
-
for (size_t i = 0; i < test_size; i++) {
|
|
76
|
-
sum += a1[i] * a2[i];
|
|
77
|
-
}
|
|
78
|
-
return sum;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Total dot product error
|
|
82
|
-
static float dot_product_error(const ggml_type_traits * qfns, const ggml_type_traits_cpu * qfns_cpu, size_t test_size, const float * test_data1, const float * test_data2) {
|
|
83
|
-
GGML_UNUSED(qfns);
|
|
84
|
-
|
|
85
|
-
std::vector<uint8_t> tmp_q1(2*test_size);
|
|
86
|
-
std::vector<uint8_t> tmp_q2(2*test_size);
|
|
87
|
-
|
|
88
|
-
const auto * vdot = ggml_get_type_traits_cpu(qfns_cpu->vec_dot_type);
|
|
89
|
-
|
|
90
|
-
qfns_cpu->from_float(test_data1, tmp_q1.data(), test_size);
|
|
91
|
-
vdot->from_float(test_data2, tmp_q2.data(), test_size);
|
|
92
|
-
|
|
93
|
-
float result = INFINITY;
|
|
94
|
-
qfns_cpu->vec_dot(test_size, &result, 0, tmp_q1.data(), 0, tmp_q2.data(), 0, 1);
|
|
95
|
-
|
|
96
|
-
const float dot_ref = dot_product(test_data1, test_data2, test_size);
|
|
97
|
-
|
|
98
|
-
return fabsf(result - dot_ref) / test_size;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
int main(int argc, char * argv[]) {
|
|
102
|
-
bool verbose = false;
|
|
103
|
-
const size_t test_size = 32 * 128;
|
|
104
|
-
|
|
105
|
-
std::string arg;
|
|
106
|
-
for (int i = 1; i < argc; i++) {
|
|
107
|
-
arg = argv[i];
|
|
108
|
-
|
|
109
|
-
if (arg == "-v") {
|
|
110
|
-
verbose = true;
|
|
111
|
-
} else {
|
|
112
|
-
fprintf(stderr, "error: unknown argument: %s\n", arg.c_str());
|
|
113
|
-
return 1;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
std::vector<float> test_data(test_size);
|
|
118
|
-
std::vector<float> test_data2(test_size);
|
|
119
|
-
|
|
120
|
-
generate_data(0.0, test_data.size(), test_data.data());
|
|
121
|
-
generate_data(1.0, test_data2.size(), test_data2.data());
|
|
122
|
-
|
|
123
|
-
ggml_cpu_init();
|
|
124
|
-
|
|
125
|
-
int num_failed = 0;
|
|
126
|
-
bool failed = false;
|
|
127
|
-
|
|
128
|
-
for (int i = 0; i < GGML_TYPE_COUNT; i++) {
|
|
129
|
-
ggml_type type = (ggml_type) i;
|
|
130
|
-
const auto * qfns = ggml_get_type_traits(type);
|
|
131
|
-
const auto * qfns_cpu = ggml_get_type_traits_cpu(type);
|
|
132
|
-
|
|
133
|
-
// deprecated - skip
|
|
134
|
-
if (qfns->blck_size == 0) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const ggml_type ei = (ggml_type)i;
|
|
139
|
-
|
|
140
|
-
printf("Testing %s\n", ggml_type_name((ggml_type) i));
|
|
141
|
-
ggml_quantize_init(ei);
|
|
142
|
-
|
|
143
|
-
if (qfns_cpu->from_float && qfns->to_float) {
|
|
144
|
-
const float total_error = total_quantization_error(qfns, qfns_cpu, test_size, test_data.data());
|
|
145
|
-
const float max_quantization_error =
|
|
146
|
-
type == GGML_TYPE_TQ1_0 ? MAX_QUANTIZATION_TOTAL_ERROR_TERNARY :
|
|
147
|
-
type == GGML_TYPE_TQ2_0 ? MAX_QUANTIZATION_TOTAL_ERROR_TERNARY :
|
|
148
|
-
type == GGML_TYPE_Q2_K ? MAX_QUANTIZATION_TOTAL_ERROR_2BITS :
|
|
149
|
-
type == GGML_TYPE_IQ2_S ? MAX_QUANTIZATION_TOTAL_ERROR_2BITS :
|
|
150
|
-
type == GGML_TYPE_Q3_K ? MAX_QUANTIZATION_TOTAL_ERROR_3BITS :
|
|
151
|
-
type == GGML_TYPE_IQ3_S ? MAX_QUANTIZATION_TOTAL_ERROR_3BITS :
|
|
152
|
-
type == GGML_TYPE_IQ3_XXS ? MAX_QUANTIZATION_TOTAL_ERROR_3BITS_XXS : MAX_QUANTIZATION_TOTAL_ERROR;
|
|
153
|
-
failed = !(total_error < max_quantization_error);
|
|
154
|
-
num_failed += failed;
|
|
155
|
-
if (failed || verbose) {
|
|
156
|
-
printf("%5s absolute quantization error: %s (%f)\n", ggml_type_name(type), RESULT_STR[failed], total_error);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const float reference_error = reference_quantization_error(qfns, qfns_cpu, test_size, test_data.data());
|
|
160
|
-
failed = !(reference_error < MAX_QUANTIZATION_REFERENCE_ERROR);
|
|
161
|
-
num_failed += failed;
|
|
162
|
-
if (failed || verbose) {
|
|
163
|
-
printf("%5s reference implementation error: %s (%f)\n", ggml_type_name(type), RESULT_STR[failed], reference_error);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const float vec_dot_error = dot_product_error(qfns, qfns_cpu, test_size, test_data.data(), test_data2.data());
|
|
167
|
-
const float max_allowed_error = type == GGML_TYPE_Q2_K || type == GGML_TYPE_IQ2_XS || type == GGML_TYPE_IQ2_XXS ||
|
|
168
|
-
type == GGML_TYPE_IQ3_XXS || type == GGML_TYPE_IQ3_S || type == GGML_TYPE_IQ2_S
|
|
169
|
-
? MAX_DOT_PRODUCT_ERROR_LOWBIT
|
|
170
|
-
: type == GGML_TYPE_TQ1_0 || type == GGML_TYPE_TQ2_0
|
|
171
|
-
? MAX_DOT_PRODUCT_ERROR_TERNARY
|
|
172
|
-
: MAX_DOT_PRODUCT_ERROR;
|
|
173
|
-
failed = !(vec_dot_error < max_allowed_error);
|
|
174
|
-
num_failed += failed;
|
|
175
|
-
if (failed || verbose) {
|
|
176
|
-
printf("%5s dot product error: %s (%f)\n", ggml_type_name(type), RESULT_STR[failed], vec_dot_error);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (num_failed || verbose) {
|
|
182
|
-
printf("%d tests failed\n", num_failed);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return num_failed > 0;
|
|
186
|
-
}
|
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
// Benchmark quantization specific functions on synthetic data
|
|
2
|
-
|
|
3
|
-
#include "ggml.h"
|
|
4
|
-
#include "ggml-cpu.h"
|
|
5
|
-
|
|
6
|
-
#undef NDEBUG
|
|
7
|
-
#include <algorithm>
|
|
8
|
-
#include <assert.h>
|
|
9
|
-
#include <functional>
|
|
10
|
-
#include <math.h>
|
|
11
|
-
#include <memory>
|
|
12
|
-
#include <stdio.h>
|
|
13
|
-
#include <string>
|
|
14
|
-
#include <vector>
|
|
15
|
-
|
|
16
|
-
#if defined(_MSC_VER)
|
|
17
|
-
#pragma warning(disable: 4244 4267) // possible loss of data
|
|
18
|
-
#endif
|
|
19
|
-
|
|
20
|
-
#define MAX_ALIGNMENT 64
|
|
21
|
-
#define QK 32
|
|
22
|
-
#define WARMUP 5
|
|
23
|
-
#define ITERATIONS 10
|
|
24
|
-
#define MAX_ITERATIONS 100000000
|
|
25
|
-
|
|
26
|
-
#define L1_SIZE 32*128
|
|
27
|
-
#define L2_SIZE 32*2048
|
|
28
|
-
#define L3_SIZE 32*20480
|
|
29
|
-
#define MEM_SIZE 32*2048000
|
|
30
|
-
|
|
31
|
-
struct quantize_perf_params {
|
|
32
|
-
std::vector<std::string> include_types;
|
|
33
|
-
std::vector<size_t> test_sizes;
|
|
34
|
-
size_t alignment_offset = 0;
|
|
35
|
-
bool op_quantize_row_q_reference = false;
|
|
36
|
-
bool op_quantize_row_q = false;
|
|
37
|
-
bool op_dequantize_row_q = false;
|
|
38
|
-
bool op_quantize_row_q_dot = false;
|
|
39
|
-
bool op_vec_dot_q = false;
|
|
40
|
-
int64_t iterations = ITERATIONS;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
#if defined(__x86_64__) || defined(__i386__)
|
|
44
|
-
|
|
45
|
-
#include <x86intrin.h>
|
|
46
|
-
inline int64_t cpu_cycles() {
|
|
47
|
-
// Rough way to detect new-ish CPUs
|
|
48
|
-
#ifdef __POPCNT__
|
|
49
|
-
unsigned int dummy;
|
|
50
|
-
return __rdtscp(&dummy);
|
|
51
|
-
#else
|
|
52
|
-
return __rdtsc();
|
|
53
|
-
#endif
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#else
|
|
57
|
-
|
|
58
|
-
#define cpu_cycles() 0
|
|
59
|
-
|
|
60
|
-
#endif
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
// Generate synthetic data
|
|
64
|
-
static void generate_data(float offset, size_t n, float * dst) {
|
|
65
|
-
for (size_t i = 0; i < n; i++) {
|
|
66
|
-
dst[i] = 0.1 + 2*cosf(i + offset);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static float gigabytes_per_second(size_t bytes, int64_t usecs) {
|
|
71
|
-
return bytes / (float) usecs * 1000000 / (1024*1024*1024);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static void * align_with_offset(void * ptr, int offset) {
|
|
75
|
-
size_t dummy_size = MAX_ALIGNMENT * 4;
|
|
76
|
-
return (char *) std::align(MAX_ALIGNMENT, MAX_ALIGNMENT, ptr, dummy_size) + offset;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static void benchmark_function(size_t size, size_t q_size, int64_t iterations, const std::function<float(void)> & func) {
|
|
80
|
-
int64_t min_time_us = INT64_MAX;
|
|
81
|
-
int64_t total_time_us = 0;
|
|
82
|
-
int64_t min_time_cycles = INT64_MAX;
|
|
83
|
-
int64_t total_time_cycles = 0;
|
|
84
|
-
|
|
85
|
-
for (int i = 0; i < WARMUP; i++) {
|
|
86
|
-
func();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
for (int i = 0; i < iterations; i++) {
|
|
90
|
-
const int64_t start_time = ggml_time_us();
|
|
91
|
-
const int64_t start_cycles = cpu_cycles();
|
|
92
|
-
|
|
93
|
-
func();
|
|
94
|
-
|
|
95
|
-
const int64_t end_cycles = cpu_cycles();
|
|
96
|
-
const int64_t end_time = ggml_time_us();
|
|
97
|
-
|
|
98
|
-
total_time_cycles += end_cycles - start_cycles;
|
|
99
|
-
min_time_cycles = std::min(min_time_cycles, end_cycles - start_cycles);
|
|
100
|
-
total_time_us += end_time - start_time;
|
|
101
|
-
min_time_us = std::min(min_time_us, end_time - start_time);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
printf(" min cycles/%d vals : %9.2f\n", QK, QK * min_time_cycles / (float) size);
|
|
105
|
-
printf(" avg cycles/%d vals : %9.2f\n", QK, QK * total_time_cycles / (float) (size * iterations));
|
|
106
|
-
printf(" float32 throughput : %9.2f GB/s\n", gigabytes_per_second(4 * size * iterations, total_time_us));
|
|
107
|
-
printf(" quantized throughput : %9.2f GB/s\n", gigabytes_per_second(q_size * iterations, total_time_us));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
static void usage(char * argv[]) {
|
|
111
|
-
printf("Benchmark quantization specific functions on synthetic data\n");
|
|
112
|
-
printf("\n");
|
|
113
|
-
printf("usage: %s [options]\n", argv[0]);
|
|
114
|
-
printf("\n");
|
|
115
|
-
printf("options: (default)\n");
|
|
116
|
-
printf(" -h, --help show this help message and exit\n");
|
|
117
|
-
printf(" --size SIZE set test size, divisible by 32 (L1_SIZE:%d)\n", L1_SIZE);
|
|
118
|
-
printf(" -3 use size as L1, L2, L3 sizes (L1:%d L2:%d L3:%d)\n", L1_SIZE, L2_SIZE, L3_SIZE);
|
|
119
|
-
printf(" -4 use size as L1, L2, L3, MEM sizes (L1:%d L2:%d L3:%d MEM:%d)\n", L1_SIZE, L2_SIZE, L3_SIZE, MEM_SIZE);
|
|
120
|
-
printf(" --op OP set test operation as quantize_row_q_reference, quantize_row_q, dequantize_row_q,\n");
|
|
121
|
-
printf(" quantize_row_q_dot, vec_dot_q (all)\n");
|
|
122
|
-
printf(" --type TYPE set test type as");
|
|
123
|
-
for (int i = 0; i < GGML_TYPE_COUNT; i++) {
|
|
124
|
-
ggml_type type = (ggml_type) i;
|
|
125
|
-
const auto * qfns = ggml_get_type_traits(type);
|
|
126
|
-
const auto * qfns_cpu = ggml_get_type_traits_cpu(type);
|
|
127
|
-
if (ggml_type_name(type) != NULL) {
|
|
128
|
-
if (qfns_cpu->from_float && qfns->to_float) {
|
|
129
|
-
printf(" %s", ggml_type_name(type));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
printf(" (all)\n");
|
|
134
|
-
printf(" --alignment-offset OFFSET\n");
|
|
135
|
-
printf(" set alignment offset as OFFSET (0)\n");
|
|
136
|
-
printf(" -i NUM, --iterations NUM\n");
|
|
137
|
-
printf(" set test iteration number (%d)\n", ITERATIONS);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
int main(int argc, char * argv[]) {
|
|
141
|
-
quantize_perf_params params {};
|
|
142
|
-
|
|
143
|
-
// read command line
|
|
144
|
-
|
|
145
|
-
bool invalid_param = false;
|
|
146
|
-
std::string arg;
|
|
147
|
-
for (int i = 1; i < argc; i++) {
|
|
148
|
-
arg = argv[i];
|
|
149
|
-
|
|
150
|
-
if (arg == "--size") {
|
|
151
|
-
if (++i >= argc) {
|
|
152
|
-
invalid_param = true;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
size_t size = std::stoi(argv[i]);
|
|
156
|
-
if (size % 32 != 0) {
|
|
157
|
-
fprintf(stderr, "error: size %zu not divisible by 32\n", size);
|
|
158
|
-
invalid_param = true;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
params.test_sizes.push_back(size);
|
|
162
|
-
} else if (arg == "-3") {
|
|
163
|
-
// quick select sizes that probably fit in CPU caches
|
|
164
|
-
params.test_sizes.push_back(L1_SIZE);
|
|
165
|
-
params.test_sizes.push_back(L2_SIZE);
|
|
166
|
-
params.test_sizes.push_back(L3_SIZE);
|
|
167
|
-
} else if (arg == "-4") {
|
|
168
|
-
// quick select cache sizes + memory
|
|
169
|
-
params.test_sizes.push_back(L1_SIZE);
|
|
170
|
-
params.test_sizes.push_back(L2_SIZE);
|
|
171
|
-
params.test_sizes.push_back(L3_SIZE);
|
|
172
|
-
params.test_sizes.push_back(MEM_SIZE);
|
|
173
|
-
} else if (arg == "--op") {
|
|
174
|
-
if (++i >= argc) {
|
|
175
|
-
invalid_param = true;
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
std::string op {argv[i]};
|
|
179
|
-
if (op == "quantize_row_q_reference") {
|
|
180
|
-
params.op_quantize_row_q_reference = true;
|
|
181
|
-
} else if (op == "quantize_row_q") {
|
|
182
|
-
params.op_quantize_row_q = true;
|
|
183
|
-
} else if (op == "dequantize_row_q") {
|
|
184
|
-
params.op_dequantize_row_q = true;
|
|
185
|
-
} else if (op == "quantize_row_q_dot") {
|
|
186
|
-
params.op_quantize_row_q_dot = true;
|
|
187
|
-
} else if (op == "vec_dot_q") {
|
|
188
|
-
params.op_vec_dot_q = true;
|
|
189
|
-
} else {
|
|
190
|
-
invalid_param = true;
|
|
191
|
-
break;
|
|
192
|
-
}
|
|
193
|
-
} else if (arg == "--type") {
|
|
194
|
-
if (++i >= argc) {
|
|
195
|
-
invalid_param = true;
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
params.include_types.push_back(argv[i]);
|
|
199
|
-
} else if (arg == "--alignment-offset") {
|
|
200
|
-
if (++i >= argc) {
|
|
201
|
-
invalid_param = true;
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
int alignment = std::stoi(argv[i]);
|
|
205
|
-
if (alignment < 0 || alignment > MAX_ALIGNMENT) {
|
|
206
|
-
fprintf(stderr, "error: alignment-offset must be less than %d\n", MAX_ALIGNMENT);
|
|
207
|
-
invalid_param = true;
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
params.alignment_offset = alignment;
|
|
211
|
-
} else if ((arg == "-i") || (arg == "--iterations")) {
|
|
212
|
-
if (++i >= argc) {
|
|
213
|
-
invalid_param = true;
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
int number = std::stoi(argv[i]);
|
|
217
|
-
if (number < 0 || number > MAX_ITERATIONS) {
|
|
218
|
-
fprintf(stderr, "error: iterations must be less than %d\n", MAX_ITERATIONS);
|
|
219
|
-
invalid_param = true;
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
params.iterations = number;
|
|
223
|
-
} else if ((arg == "-h") || (arg == "--help")) {
|
|
224
|
-
usage(argv);
|
|
225
|
-
return 1;
|
|
226
|
-
} else {
|
|
227
|
-
fprintf(stderr, "error: unknown argument: %s\n", arg.c_str());
|
|
228
|
-
return 1;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (invalid_param) {
|
|
232
|
-
fprintf(stderr, "error: invalid parameter for argument: %s\n", arg.c_str());
|
|
233
|
-
return 1;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if (params.test_sizes.empty()) {
|
|
237
|
-
params.test_sizes.push_back(L1_SIZE);
|
|
238
|
-
}
|
|
239
|
-
if (!(params.op_quantize_row_q_reference || params.op_quantize_row_q || params.op_dequantize_row_q || params.op_quantize_row_q_dot || params.op_vec_dot_q)) {
|
|
240
|
-
params.op_quantize_row_q_reference = params.op_quantize_row_q = params.op_dequantize_row_q = params.op_quantize_row_q_dot = params.op_vec_dot_q = true;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
std::sort(params.test_sizes.begin(), params.test_sizes.end());
|
|
244
|
-
size_t largest = params.test_sizes.back();
|
|
245
|
-
|
|
246
|
-
std::vector<uint8_t> test_data1_v(largest*4 + MAX_ALIGNMENT*2);
|
|
247
|
-
std::vector<uint8_t> test_data2_v(largest*4 + MAX_ALIGNMENT*2);
|
|
248
|
-
std::vector<uint8_t> test_q1_v (largest*4 + MAX_ALIGNMENT*2);
|
|
249
|
-
std::vector<uint8_t> test_q2_v (largest*4 + MAX_ALIGNMENT*2);
|
|
250
|
-
std::vector<uint8_t> test_out_v (largest*4 + MAX_ALIGNMENT*2);
|
|
251
|
-
|
|
252
|
-
float * test_data1 = (float *) align_with_offset(test_data1_v.data(), params.alignment_offset);
|
|
253
|
-
float * test_data2 = (float *) align_with_offset(test_data2_v.data(), params.alignment_offset);
|
|
254
|
-
float * test_q1 = (float *) align_with_offset(test_q1_v.data(), params.alignment_offset);
|
|
255
|
-
float * test_q2 = (float *) align_with_offset(test_q2_v.data(), params.alignment_offset);
|
|
256
|
-
float * test_out = (float *) align_with_offset(test_out_v.data(), params.alignment_offset);
|
|
257
|
-
|
|
258
|
-
generate_data(0, largest, test_data1);
|
|
259
|
-
generate_data(1, largest, test_data2);
|
|
260
|
-
|
|
261
|
-
int64_t iterations = params.iterations;
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
// Initialize GGML, ensures float conversion tables are initialized
|
|
265
|
-
struct ggml_init_params ggml_params = {
|
|
266
|
-
/* .mem_size = */ 1*1024,
|
|
267
|
-
/* .mem_buffer = */ NULL,
|
|
268
|
-
/* .no_alloc = */ true,
|
|
269
|
-
};
|
|
270
|
-
struct ggml_context * ctx = ggml_init(ggml_params);
|
|
271
|
-
|
|
272
|
-
for (int i = 0; i < GGML_TYPE_COUNT; i++) {
|
|
273
|
-
ggml_type type = (ggml_type) i;
|
|
274
|
-
const auto * qfns = ggml_get_type_traits(type);
|
|
275
|
-
const auto * qfns_cpu = ggml_get_type_traits_cpu(type);
|
|
276
|
-
if (!params.include_types.empty() && ggml_type_name(type) && std::find(params.include_types.begin(), params.include_types.end(), ggml_type_name(type)) == params.include_types.end()) {
|
|
277
|
-
continue;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
if (qfns_cpu->from_float && qfns->to_float) {
|
|
281
|
-
printf("%s\n", ggml_type_name(type));
|
|
282
|
-
|
|
283
|
-
ggml_quantize_init(type);
|
|
284
|
-
|
|
285
|
-
if (params.op_quantize_row_q_reference) {
|
|
286
|
-
printf(" quantize_row_q_reference\n");
|
|
287
|
-
for (size_t size : params.test_sizes) {
|
|
288
|
-
printf(" %zu values (%.2f MB)\n", size, 4*size/(float)(1024*1024));
|
|
289
|
-
auto quantize_fn = [&](void) -> float {
|
|
290
|
-
qfns->from_float_ref(test_data1, test_q1, size);
|
|
291
|
-
return test_q1[0];
|
|
292
|
-
};
|
|
293
|
-
size_t quantized_size = ggml_row_size(type, size);
|
|
294
|
-
benchmark_function(size, quantized_size, iterations, quantize_fn);
|
|
295
|
-
}
|
|
296
|
-
printf("\n");
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (params.op_quantize_row_q) {
|
|
300
|
-
printf(" quantize_row_q\n");
|
|
301
|
-
for (size_t size : params.test_sizes) {
|
|
302
|
-
printf(" %zu values (%.2f MB)\n", size, 4*size/(float)(1024*1024));
|
|
303
|
-
auto quantize_fn = [&](void) -> float {
|
|
304
|
-
qfns_cpu->from_float(test_data1, test_q1, size);
|
|
305
|
-
return test_q1[0];
|
|
306
|
-
};
|
|
307
|
-
size_t quantized_size = ggml_row_size(type, size);
|
|
308
|
-
benchmark_function(size, quantized_size, iterations, quantize_fn);
|
|
309
|
-
}
|
|
310
|
-
printf("\n");
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (params.op_dequantize_row_q) {
|
|
314
|
-
printf(" dequantize_row_q\n");
|
|
315
|
-
qfns_cpu->from_float(test_data1, test_q1, largest);
|
|
316
|
-
for (size_t size : params.test_sizes) {
|
|
317
|
-
printf(" %zu values (%.2f MB)\n", size, 4*size/(float)(1024*1024));
|
|
318
|
-
auto quantize_fn = [&](void) -> float {
|
|
319
|
-
qfns->to_float(test_q1, test_out, size);
|
|
320
|
-
return test_out[0];
|
|
321
|
-
};
|
|
322
|
-
size_t quantized_size = ggml_row_size(type, size);
|
|
323
|
-
benchmark_function(size, quantized_size, iterations, quantize_fn);
|
|
324
|
-
}
|
|
325
|
-
printf("\n");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
if (params.op_quantize_row_q_dot) {
|
|
329
|
-
printf(" quantize_row_q_dot\n");
|
|
330
|
-
for (size_t size : params.test_sizes) {
|
|
331
|
-
printf(" %zu values (%.2f MB)\n", size, 4*size/(float)(1024*1024));
|
|
332
|
-
auto quantize_fn = [&](void) -> float {
|
|
333
|
-
const auto * vdot = ggml_get_type_traits_cpu(qfns_cpu->vec_dot_type);
|
|
334
|
-
vdot->from_float(test_data1, test_q1, size);
|
|
335
|
-
return test_q1[0];
|
|
336
|
-
};
|
|
337
|
-
size_t quantized_size = ggml_row_size(type, size);
|
|
338
|
-
benchmark_function(size, quantized_size, iterations, quantize_fn);
|
|
339
|
-
}
|
|
340
|
-
printf("\n");
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (params.op_vec_dot_q) {
|
|
344
|
-
printf(" vec_dot_q\n");
|
|
345
|
-
qfns_cpu->from_float(test_data1, test_q1, largest);
|
|
346
|
-
qfns_cpu->from_float(test_data2, test_q2, largest);
|
|
347
|
-
for (size_t size : params.test_sizes) {
|
|
348
|
-
printf(" %zu values (%.2f MB)\n", size, 4*size/(float)(1024*1024));
|
|
349
|
-
auto quantize_fn = [&](void) -> float {
|
|
350
|
-
float result;
|
|
351
|
-
qfns_cpu->vec_dot(size, &result, 0, test_q1, 0, test_q2, 0, 1);
|
|
352
|
-
return result;
|
|
353
|
-
};
|
|
354
|
-
size_t quantized_size = ggml_row_size(type, size);
|
|
355
|
-
benchmark_function(size, quantized_size, iterations, quantize_fn);
|
|
356
|
-
}
|
|
357
|
-
printf("\n");
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
ggml_free(ctx);
|
|
363
|
-
|
|
364
|
-
return 0;
|
|
365
|
-
}
|