diff --git a/.flake8 b/.flake8 index d64c2564..a8bd3a81 100644 --- a/.flake8 +++ b/.flake8 @@ -10,8 +10,10 @@ exclude = .git, # There's no value in checking cache directories __pycache__, - # No need to include the build path + # No need to include generated build directories build, + build_*, + build-*, # This contains builds that we don't want to check dist # This is generated with `python build .` for package releases # max-complexity = 10 diff --git a/.gitignore b/.gitignore index 81b0a7ef..f1f9207b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.a *.bat *.bin +*.d *.dll *.dot *.etag @@ -19,13 +20,13 @@ *.so *.swp *.tmp +*.DS_Store # IDE / OS .cache/ .ccls-cache/ .direnv/ -.DS_Store .envrc .idea/ .swiftpm @@ -33,7 +34,6 @@ .vscode/ nppBackup - # Coverage gcovr-report/ @@ -41,29 +41,22 @@ lcov-report/ # Build Artifacts -tags -.build/ -build* -!build-info.cmake -!build-info.cpp.in -!build-info.sh -!build.zig -!docs/build.md -!scripts/build-*.sh -!scripts/build-*.bat +/tags +/.build/ +/build* +/cmake-build-* +/release +/debug +/CMakeSettings.json +/compile_commands.json /libllama.so /llama-* /vulkan-shaders-gen -android-ndk-* -arm_neon.h -cmake-build-* -CMakeSettings.json -compile_commands.json -ggml-metal-embed.metal -llama-batched-swift /rpc-server -out/ -tmp/ +/out/ +/tmp/ +/autogen-*.md +/common/build-info.cpp # Deprecated @@ -72,38 +65,43 @@ tmp/ # CI -!.github/workflows/*.yml +!/.github/workflows/*.yml # Models -models/* -models-mnt -!models/.editorconfig -!models/ggml-vocab-*.gguf* +/models/* +/models-mnt +!/models/.editorconfig +!/models/ggml-vocab-*.gguf* +!/models/templates # Zig -zig-out/ -zig-cache/ -# Logs - -ppl-*.txt -qnt-*.txt -perf-*.txt +/zig-out/ +/zig-cache/ # Examples -examples/jeopardy/results.txt -examples/server/*.css.hpp -examples/server/*.html.hpp -examples/server/*.js.hpp -examples/server/*.mjs.hpp -!build_64.sh -!examples/*.bat -!examples/*/*.kts -!examples/*/*/*.kts -!examples/sycl/*.bat -!examples/sycl/*.sh +/examples/jeopardy/results.txt +/examples/server/*.css.hpp +/examples/server/*.html.hpp +/examples/server/*.js.hpp +/examples/server/*.mjs.hpp +/examples/server/*.gz.hpp +!/build_64.sh +!/examples/*.bat +!/examples/*/*.kts +!/examples/*/*/*.kts +!/examples/sycl/*.bat +!/examples/sycl/*.sh + +# Server Web UI temporary files + +/examples/server/webui_llamacpp/.svelte-kit +/examples/server/webui_llamacpp/node_modules +/examples/server/webui_llamacpp/build +/examples/server/webui_llamacpp/test-results +/examples/server/webui_llamacpp/storybook-static # Python @@ -111,11 +109,16 @@ examples/server/*.mjs.hpp __pycache__/ */poetry.lock poetry.toml +poetry.lock +uv.lock # Nix + +flake.lock /result # Test binaries + /tests/test-backend-ops /tests/test-double-float /tests/test-grad0 @@ -131,17 +134,31 @@ poetry.toml /tests/test-tokenizer-1-spm # Scripts + !/scripts/install-oneapi.bat -/examples/server/webui_llamacpp/.gitignore + +# Generated by scripts +/hellaswag_val_full.txt +/winogrande-debiased-eval.csv +/wikitext-2-raw/ # Test models for lora adapters + /lora-tests # Local scripts + /run-vim.sh /run-chat.sh +/run-spec.sh .ccache/ # IDE + *.code-workspace .windsurf/ +# emscripten +a.out +a.out.* +.dev +.github diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 91d79162..69f3729e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,8 +9,9 @@ repos: - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files + - repo: https://github.com/PyCQA/flake8 rev: 7.0.0 hooks: - - id: flake8 - additional_dependencies: [flake8-no-print] + - id: flake8 + additional_dependencies: [flake8-print] diff --git a/CMakePresets.json b/CMakePresets.json index bdad3895..5b10a276 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -2,64 +2,143 @@ "version": 4, "configurePresets": [ { - "name": "base", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build-${presetName}", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", - "CMAKE_INSTALL_RPATH": "$ORIGIN;$ORIGIN/.." - } + "name": "base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build-${presetName}", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "CMAKE_INSTALL_RPATH": "$ORIGIN;$ORIGIN/.." + } }, { - "name": "sycl-base", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build-${presetName}", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", - "CMAKE_CXX_COMPILER": "icx", - "CMAKE_C_COMPILER": "cl", - "GGML_SYCL": "ON", - "CMAKE_INSTALL_RPATH": "$ORIGIN;$ORIGIN/.." - } + "name": "debug", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } }, - { "name": "debug", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" } }, - { "name": "release", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } }, - { "name": "reldbg", "hidden": true, "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" } }, - { "name": "static", "hidden": true, "cacheVariables": { "GGML_STATIC": "ON" } }, - { - "name": "arm64-windows-msvc", "hidden": true, - "architecture": { "value": "arm64", "strategy": "external" }, - "toolset": { "value": "host=x86_64", "strategy": "external" }, - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/arm64-windows-msvc.cmake" - } + "name": "release", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } }, - { - "name": "arm64-windows-llvm", "hidden": true, - "architecture": { "value": "arm64", "strategy": "external" }, - "toolset": { "value": "host=x86_64", "strategy": "external" }, - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/arm64-windows-llvm.cmake" - } + "name": "reldbg", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } }, - - { "name": "arm64-windows-llvm-debug" , "inherits": [ "base", "arm64-windows-llvm", "debug" ] }, - { "name": "arm64-windows-llvm-release", "inherits": [ "base", "arm64-windows-llvm", "reldbg" ] }, - { "name": "arm64-windows-llvm+static-release", "inherits": [ "base", "arm64-windows-llvm", "reldbg", "static" ] }, - - { "name": "arm64-windows-msvc-debug" , "inherits": [ "base", "arm64-windows-msvc", "debug" ] }, - { "name": "arm64-windows-msvc-release", "inherits": [ "base", "arm64-windows-msvc", "reldbg" ] }, - { "name": "arm64-windows-msvc+static-release", "inherits": [ "base", "arm64-windows-msvc", "reldbg", "static" ] }, - - { "name": "x64-windows-msvc-debug" , "inherits": [ "base", "debug" ] }, - { "name": "x64-windows-msvc-release", "inherits": [ "base", "reldbg" ] }, - { "name": "x64-windows-msvc+static-release", "inherits": [ "base", "reldbg", "static" ] }, - - { "name": "x64-windows-sycl-debug" , "inherits": [ "sycl-base", "debug" ] }, - { "name": "x64-windows-sycl-release", "inherits": [ "sycl-base", "release" ] } + { + "name": "cpu-avx2-base", + "hidden": true, + "inherits": "base", + "cacheVariables": { + "GGML_NATIVE": "OFF", + "GGML_AVX": "ON", + "GGML_AVX2": "ON", + "GGML_FMA": "ON", + "GGML_F16C": "ON", + "GGML_BLAS": "OFF", + "GGML_CUDA": "OFF" + } + }, + { + "name": "cuda-base", + "hidden": true, + "inherits": "base", + "cacheVariables": { + "GGML_CUDA": "ON", + "GGML_BLAS": "OFF" + } + }, + { + "name": "cpu-avx2-debug", + "inherits": [ + "cpu-avx2-base", + "debug" + ], + "binaryDir": "${sourceDir}/build_cpu_avx2_debug" + }, + { + "name": "cpu-avx2-release", + "inherits": [ + "cpu-avx2-base", + "release" + ], + "binaryDir": "${sourceDir}/build_cpu_avx2_release" + }, + { + "name": "cpu-avx2-reldbg", + "inherits": [ + "cpu-avx2-base", + "reldbg" + ], + "binaryDir": "${sourceDir}/build_cpu_avx2_reldbg" + }, + { + "name": "cuda-debug", + "inherits": [ + "cuda-base", + "debug" + ], + "binaryDir": "${sourceDir}/build_debug" + }, + { + "name": "cuda-release", + "inherits": [ + "cuda-base", + "release" + ], + "binaryDir": "${sourceDir}/build_release" + }, + { + "name": "cuda-reldbg", + "inherits": [ + "cuda-base", + "reldbg" + ], + "binaryDir": "${sourceDir}/build_cuda_reldbg" + } + ], + "buildPresets": [ + { + "name": "parallel-build", + "hidden": true, + "jobs": 0 + }, + { + "name": "cpu-avx2-debug", + "configurePreset": "cpu-avx2-debug", + "inherits": "parallel-build" + }, + { + "name": "cpu-avx2-release", + "configurePreset": "cpu-avx2-release", + "inherits": "parallel-build" + }, + { + "name": "cpu-avx2-reldbg", + "configurePreset": "cpu-avx2-reldbg", + "inherits": "parallel-build" + }, + { + "name": "cuda-debug", + "configurePreset": "cuda-debug", + "inherits": "parallel-build" + }, + { + "name": "cuda-release", + "configurePreset": "cuda-release", + "inherits": "parallel-build" + }, + { + "name": "cuda-reldbg", + "configurePreset": "cuda-reldbg", + "inherits": "parallel-build" + } ] } diff --git a/examples/quantize-stats/CMakeLists.txt b/examples/quantize-stats/CMakeLists.txt index ae74f016..db51004a 100644 --- a/examples/quantize-stats/CMakeLists.txt +++ b/examples/quantize-stats/CMakeLists.txt @@ -1,5 +1,5 @@ set(ARCH_FLAGS "") -if (NOT MSVC) +if (NOT MSVC AND GGML_NATIVE) list(APPEND ARCH_FLAGS -march=native) endif() message(STATUS "ARCH_FLAGS = ${ARCH_FLAGS}")