-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[llama-cpp] add new port (and its ggml dependency) #43925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f00b565
[llama.cpp] port scaffolding
cenit f4088e3
simplify patches, introduce features
cenit 97f1085
partial test on features
cenit 1e25cca
fix references
cenit 6d6b31e
handle python scripts
cenit 0b296df
fix references
cenit 69588eb
move tools to a feature
cenit b9a4359
fix references
cenit ed52ab9
fix multiple find_package calls
cenit 6ba765f
fix references
cenit 02652be
Merge branch 'master' into dev/cenit/llamacpp
cenit 47deb79
fix regression in llama static builds
cenit 32a1a9d
fix references
cenit 9d8f4a9
fix static opencl build and remove support for vulkan on x86 (32bit) …
cenit e3a33da
format manifest
cenit 609ba67
fix references
cenit a9b6238
apply review suggestions
cenit f0c7b3d
fix references
cenit 5d1e655
remove hip and sycl
cenit fd409ba
fix references
cenit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- a/CMakeLists.txt | ||
| +++ b/CMakeLists.txt | ||
| @@ -202,7 +202,7 @@ option(GGML_BUILD_EXAMPLES "ggml: build examples" ${GGML_STANDALONE}) | ||
| set(CMAKE_C_STANDARD 11) | ||
| set(CMAKE_C_STANDARD_REQUIRED true) | ||
|
|
||
| -set(CMAKE_CXX_STANDARD 17) | ||
| +set(CMAKE_CXX_STANDARD 20) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED true) | ||
|
|
||
| set(THREADS_PREFER_PTHREAD_FLAG ON) | ||
| @@ -238,6 +238,7 @@ include(CMakePackageConfigHelpers) | ||
| # all public headers | ||
| set(GGML_PUBLIC_HEADERS | ||
| include/ggml.h | ||
| + include/ggml-cpp.h | ||
| include/ggml-cpu.h | ||
| include/ggml-alloc.h | ||
| include/ggml-backend.h | ||
| @@ -245,6 +246,7 @@ set(GGML_PUBLIC_HEADERS | ||
| include/ggml-cann.h | ||
| include/ggml-cuda.h | ||
| include/ggml-kompute.h | ||
| + include/ggml-opencl.h | ||
| include/ggml-opt.h | ||
| include/ggml-metal.h | ||
| include/ggml-rpc.h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| vcpkg_from_github( | ||
| OUT_SOURCE_PATH SOURCE_PATH | ||
| REPO ggml-org/ggml | ||
| REF 9a4acb374565f4146b8d6eb1cffdcd7d437d1ba2 | ||
| SHA512 091a794baf669616ee20dc19d0232e64456c07cd50cbe6d81aa68b98f178801be1b62da9eea417e7a563a6b73bb3136777f860c756270569676fb760f2e751ed | ||
| HEAD_REF master | ||
| PATCHES | ||
| 0001-fix-cmakelists.patch | ||
| ) | ||
|
|
||
| vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS | ||
| FEATURES | ||
| cuda GGML_CUDA | ||
| vulkan GGML_VULKAN | ||
| metal GGML_METAL | ||
| opencl GGML_OPENCL | ||
| openmp GGML_OPENMP | ||
| ) | ||
|
|
||
| string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" GGML_STATIC) | ||
|
|
||
| vcpkg_cmake_configure( | ||
| SOURCE_PATH "${SOURCE_PATH}" | ||
| OPTIONS | ||
| -DGGML_STATIC=${GGML_STATIC} | ||
| -DGGML_CCACHE=OFF | ||
| -DGGML_BUILD_NUMBER=1 | ||
| -DGGML_BUILD_TESTS=OFF | ||
| -DGGML_BUILD_EXAMPLES=OFF | ||
| -DGGML_HIP=OFF | ||
| -DGGML_SYCL=OFF | ||
| ${FEATURE_OPTIONS} | ||
| ) | ||
|
|
||
| vcpkg_cmake_install() | ||
| vcpkg_cmake_config_fixup(PACKAGE_NAME ggml CONFIG_PATH "lib/cmake/ggml") | ||
| vcpkg_copy_pdbs() | ||
|
|
||
| if (VCPKG_LIBRARY_LINKAGE MATCHES "static") | ||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/ggml/ggml-config.cmake" | ||
| "set_and_check(GGML_BIN_DIR \"\${PACKAGE_PREFIX_DIR}/bin\")" | ||
| "" | ||
| ) | ||
| endif() | ||
|
|
||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/ggml/ggml-config.cmake" | ||
| "add_library(ggml::ggml UNKNOWN IMPORTED)" | ||
| "if (NOT TARGET ggml::ggml) | ||
| add_library(ggml::ggml UNKNOWN IMPORTED) | ||
| endif()" | ||
| ) | ||
|
|
||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/ggml/ggml-config.cmake" | ||
| "add_library(ggml::ggml-base UNKNOWN IMPORTED)" | ||
| "if (NOT TARGET ggml::ggml-base) | ||
| add_library(ggml::ggml-base UNKNOWN IMPORTED) | ||
| endif()" | ||
| ) | ||
|
|
||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/ggml/ggml-config.cmake" | ||
| "add_library(ggml::\${_ggml_backend} UNKNOWN IMPORTED)" | ||
| "if (NOT TARGET ggml::\${_ggml_backend}) | ||
| add_library(ggml::\${_ggml_backend} UNKNOWN IMPORTED) | ||
| endif()" | ||
| ) | ||
|
|
||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/ggml/ggml-config.cmake" | ||
| "add_library(ggml::all INTERFACE IMPORTED)" | ||
| "if (NOT TARGET ggml::all) | ||
| add_library(ggml::all INTERFACE IMPORTED) | ||
| endif()" | ||
| ) | ||
|
|
||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/ggml/ggml-config.cmake" | ||
| "if (NOT GGML_SHARED_LIB)" | ||
| "if (NOT GGML_SHARED_LIB) | ||
| if (GGML_OPENCL) | ||
| find_package(OpenCL REQUIRED) | ||
| list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES OpenCL::OpenCL) | ||
| endif()" | ||
| ) | ||
|
|
||
| if (NOT VCPKG_BUILD_TYPE) | ||
| file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig") | ||
| file(RENAME "${CURRENT_PACKAGES_DIR}/debug/share/pkgconfig/ggml.pc" "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/ggml.pc") | ||
| endif() | ||
| file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/lib/pkgconfig") | ||
| file(RENAME "${CURRENT_PACKAGES_DIR}/share/pkgconfig/ggml.pc" "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/ggml.pc") | ||
| vcpkg_fixup_pkgconfig() | ||
|
|
||
| if ("vulkan" IN_LIST FEATURES) | ||
| vcpkg_copy_tools(AUTO_CLEAN TOOL_NAMES vulkan-shaders-gen) | ||
| endif() | ||
|
|
||
|
|
||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/pkgconfig") | ||
|
|
||
| vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| { | ||
| "name": "ggml", | ||
| "version-date": "2025-02-12", | ||
| "description": "Tensor library for machine learning", | ||
| "homepage": "https://github.com/ggml-org/ggml", | ||
| "license": "MIT", | ||
| "supports": "!(windows & arm) & !uwp & !android", | ||
| "dependencies": [ | ||
| "blas", | ||
| { | ||
| "name": "vcpkg-cmake", | ||
| "host": true | ||
| }, | ||
| { | ||
| "name": "vcpkg-cmake-config", | ||
| "host": true | ||
| } | ||
| ], | ||
| "features": { | ||
| "cuda": { | ||
| "description": "Enable CUDA support", | ||
| "dependencies": [ | ||
| "cuda" | ||
| ] | ||
| }, | ||
| "metal": { | ||
| "description": "Enable Metal support", | ||
| "supports": "osx" | ||
| }, | ||
| "opencl": { | ||
| "description": "Enable OpenCL support", | ||
| "dependencies": [ | ||
| "opencl" | ||
| ] | ||
| }, | ||
| "openmp": { | ||
| "description": "Enable OpenMP support", | ||
| "supports": "!osx" | ||
| }, | ||
| "vulkan": { | ||
| "description": "Enable Vulkan support", | ||
| "supports": "!x86", | ||
| "dependencies": [ | ||
| "vulkan-sdk-components" | ||
| ] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- a/CMakeLists.txt | ||
| +++ b/CMakeLists.txt | ||
| @@ -145,10 +145,8 @@ endif() | ||
| # 3rd-party | ||
| # | ||
|
|
||
| -if (NOT TARGET ggml) | ||
| - add_subdirectory(ggml) | ||
| - # ... otherwise assume ggml is added by a parent CMakeLists.txt | ||
| -endif() | ||
| +find_package(ggml CONFIG REQUIRED) | ||
| +add_library(ggml ALIAS ggml::all) | ||
|
|
||
| # | ||
| # build the library |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| vcpkg_from_github( | ||
| OUT_SOURCE_PATH SOURCE_PATH | ||
| REPO ggml-org/llama.cpp | ||
| REF b${VERSION} | ||
| SHA512 e093f4c7d4b2de425932bb4960683527a8a3bba242132c2f5e5bfed8480f0e336a06f97baf2d20ee591c6deee7535e159d40884a5e3f7caf0ae0967b8a046850 | ||
| HEAD_REF master | ||
| PATCHES | ||
| 0001-external-ggml.patch | ||
| ) | ||
|
|
||
| file(REMOVE_RECURSE "${SOURCE_PATH}/ggml") | ||
|
|
||
| vcpkg_cmake_configure( | ||
| SOURCE_PATH "${SOURCE_PATH}" | ||
| OPTIONS | ||
| -DGGML_CCACHE=OFF | ||
| -DLLAMA_BUILD_TESTS=OFF | ||
cenit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| -DLLAMA_BUILD_EXAMPLES=OFF | ||
| -DLLAMA_ALL_WARNINGS=OFF | ||
| ${FEATURE_OPTIONS} | ||
| ) | ||
|
|
||
| vcpkg_cmake_install() | ||
| vcpkg_cmake_config_fixup(PACKAGE_NAME llama CONFIG_PATH "lib/cmake/llama") | ||
cenit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| vcpkg_copy_pdbs() | ||
| vcpkg_fixup_pkgconfig() | ||
|
|
||
| if (VCPKG_LIBRARY_LINKAGE MATCHES "static") | ||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/llama/llama-config.cmake" | ||
| "set_and_check(LLAMA_BIN_DIR \"${PACKAGE_PREFIX_DIR}/bin\")" | ||
| "" | ||
| IGNORE_UNCHANGED | ||
| ) | ||
| endif() | ||
|
|
||
| vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/llama/llama-config.cmake" | ||
| "add_library(llama UNKNOWN IMPORTED)" | ||
| "if (NOT TARGET llama) | ||
| add_library(llama UNKNOWN IMPORTED) | ||
| endif() | ||
| " | ||
| ) | ||
|
|
||
| file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/${PORT}") | ||
| file(RENAME "${CURRENT_PACKAGES_DIR}/bin/convert_hf_to_gguf.py" "${CURRENT_PACKAGES_DIR}/tools/${PORT}/convert-hf-to-gguf.py") | ||
| file(INSTALL "${SOURCE_PATH}/gguf-py" DESTINATION "${CURRENT_PACKAGES_DIR}/tools/${PORT}") | ||
| if (NOT VCPKG_BUILD_TYPE) | ||
| file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/convert_hf_to_gguf.py") | ||
| endif() | ||
|
|
||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") | ||
|
|
||
| if (VCPKG_LIBRARY_LINKAGE MATCHES "static") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin") | ||
| file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/bin") | ||
| endif() | ||
|
|
||
| vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "llama-cpp", | ||
| "version": "4743", | ||
| "description": "LLM inference in C/C++", | ||
| "homepage": "https://github.com/ggml-org/llama.cpp", | ||
| "license": "MIT", | ||
| "supports": "!android", | ||
| "dependencies": [ | ||
| "ggml", | ||
| { | ||
| "name": "vcpkg-cmake", | ||
| "host": true | ||
| }, | ||
| { | ||
| "name": "vcpkg-cmake-config", | ||
| "host": true | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "versions": [ | ||
| { | ||
| "git-tree": "d741b07274976f46443096ab695beb6314dbb8d7", | ||
| "version-date": "2025-02-12", | ||
| "port-version": 0 | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "versions": [ | ||
| { | ||
| "git-tree": "a626675dd61bb60eb67e115b5a23e0ecc378685f", | ||
| "version": "4743", | ||
| "port-version": 0 | ||
| } | ||
| ] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.