From 7ac9b995646a18f0f230cc25bf2f06d52fec89b6 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 28 Sep 2026 23:53:06 +0800 Subject: [PATCH] refactor: cleanup project root 1 --- CMakeLists.txt | 22 +-- Makefile | 28 ++-- README.md | 4 +- hash.cpp | 5 - kcpp_src/README.md | 5 + expose.cpp => kcpp_src/expose.cpp | 4 +- expose.h => kcpp_src/expose.h | 1 + .../gpttype_adapter.cpp | 4 +- kcpp_src/hash.cpp | 5 + kcpp_backend.cpp => kcpp_src/kcpp_backend.cpp | 2 +- kcpp_backend.h => kcpp_src/kcpp_backend.h | 1 - {lib => kcpp_src/lib}/vulkan-1.lib | Bin .../model_adapter.cpp | 2 +- model_adapter.h => kcpp_src/model_adapter.h | 2 +- .../simplecpuinfo.cpp | 4 +- scripts/check-release-apiabi.sh | 131 ------------------ 16 files changed, 47 insertions(+), 173 deletions(-) delete mode 100644 hash.cpp create mode 100644 kcpp_src/README.md rename expose.cpp => kcpp_src/expose.cpp (99%) rename expose.h => kcpp_src/expose.h (99%) rename gpttype_adapter.cpp => kcpp_src/gpttype_adapter.cpp (99%) create mode 100644 kcpp_src/hash.cpp rename kcpp_backend.cpp => kcpp_src/kcpp_backend.cpp (99%) rename kcpp_backend.h => kcpp_src/kcpp_backend.h (99%) rename {lib => kcpp_src/lib}/vulkan-1.lib (100%) rename model_adapter.cpp => kcpp_src/model_adapter.cpp (99%) rename model_adapter.h => kcpp_src/model_adapter.h (99%) rename simplecpuinfo.cpp => kcpp_src/simplecpuinfo.cpp (93%) delete mode 100755 scripts/check-release-apiabi.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index c509f4782..21a6b9a66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,7 +607,7 @@ add_library(sdtype_adapter otherarch/sdcpp/src/core/backend_fit.cpp otherarch/sdcpp/src/core/layer_split_partition.cpp otherarch/sdcpp/src/core/ggml_extend_backend.cpp) -target_include_directories(sdtype_adapter PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/include ./otherarch/sdcpp/src ./otherarch/sdcpp/examples ./otherarch/sdcpp/thirdparty/oniguruma ./otherarch/sdcpp/thirdparty/utf8proc ./tools ./common) +target_include_directories(sdtype_adapter PUBLIC . ./kcpp_src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/include ./otherarch/sdcpp/src ./otherarch/sdcpp/examples ./otherarch/sdcpp/thirdparty/oniguruma ./otherarch/sdcpp/thirdparty/utf8proc ./tools ./common) target_compile_definitions(sdtype_adapter PRIVATE ONIG_STATIC UTF8PROC_STATIC) target_compile_features(sdtype_adapter PUBLIC cxx_std_17) # don't bump target_link_libraries(sdtype_adapter PRIVATE common2 ggml ${LLAMA_EXTRA_LIBS}) @@ -615,46 +615,46 @@ set_target_properties(sdtype_adapter PROPERTIES POSITION_INDEPENDENT_CODE ON) add_library(whisper_adapter otherarch/whispercpp/whisper_adapter.cpp) -target_include_directories(whisper_adapter PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/whispercpp ./tools ./common) +target_include_directories(whisper_adapter PUBLIC . ./kcpp_src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/whispercpp ./tools ./common) target_compile_features(whisper_adapter PUBLIC cxx_std_17) # don't bump target_link_libraries(whisper_adapter PRIVATE common2 ggml ${LLAMA_EXTRA_LIBS}) set_target_properties(whisper_adapter PROPERTIES POSITION_INDEPENDENT_CODE ON) add_library(music_adapter otherarch/acestep/music_adapter.cpp) -target_include_directories(music_adapter PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/acestep ./tools ./common) +target_include_directories(music_adapter PUBLIC . ./kcpp_src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/acestep ./tools ./common) target_compile_features(music_adapter PUBLIC cxx_std_17) # don't bump target_link_libraries(music_adapter PRIVATE common2 ggml ${LLAMA_EXTRA_LIBS}) set_target_properties(music_adapter PROPERTIES POSITION_INDEPENDENT_CODE ON) add_library(tts_adapter otherarch/tts_adapter.cpp) -target_include_directories(tts_adapter PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/ttscpp/include ./otherarch/ttscpp/src ./otherarch/qwen3tts ./tools ./common) +target_include_directories(tts_adapter PUBLIC . ./kcpp_src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/ttscpp/include ./otherarch/ttscpp/src ./otherarch/qwen3tts ./tools ./common) target_compile_features(tts_adapter PUBLIC cxx_std_17) # don't bump target_link_libraries(tts_adapter PRIVATE common2 ggml ${LLAMA_EXTRA_LIBS}) set_target_properties(tts_adapter PROPERTIES POSITION_INDEPENDENT_CODE ON) add_library(embeddings_adapter otherarch/embeddings_adapter.cpp) -target_include_directories(embeddings_adapter PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./tools ./common) +target_include_directories(embeddings_adapter PUBLIC . ./kcpp_src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./tools ./common) target_compile_features(embeddings_adapter PUBLIC cxx_std_17) # don't bump target_link_libraries(embeddings_adapter PRIVATE common2 ggml ${LLAMA_EXTRA_LIBS}) set_target_properties(embeddings_adapter PROPERTIES POSITION_INDEPENDENT_CODE ON) add_library(gpttype_adapter - gpttype_adapter.cpp + kcpp_src/gpttype_adapter.cpp src/llama.cpp common/chat.cpp src/llama-model.cpp) -target_include_directories(gpttype_adapter PUBLIC . ./src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/thirdparty ./tools ./common) +target_include_directories(gpttype_adapter PUBLIC . ./kcpp_src ./src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/thirdparty ./tools ./common) target_compile_features(gpttype_adapter PUBLIC cxx_std_17) # don't bump target_link_libraries(gpttype_adapter PRIVATE common2 ggml ggml_v1 ggml_v2 ggml_v3 ${LLAMA_EXTRA_LIBS}) set_target_properties(gpttype_adapter PROPERTIES POSITION_INDEPENDENT_CODE ON) if (LLAMA_CUBLAS) set(TARGET koboldcpp_cublas) - add_library(${TARGET} SHARED expose.cpp expose.h kcpp_backend.cpp kcpp_backend.h) - target_include_directories(${TARGET} PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/thirdparty ./tools ./common) + add_library(${TARGET} SHARED kcpp_src/expose.cpp kcpp_src/expose.h kcpp_src/kcpp_backend.cpp kcpp_src/kcpp_backend.h) + target_include_directories(${TARGET} PUBLIC . ./kcpp_src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/thirdparty ./tools ./common) target_compile_features(${TARGET} PUBLIC cxx_std_17) # don't bump set_target_properties(${TARGET} PROPERTIES PREFIX "") set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME "koboldcpp_cublas") @@ -673,8 +673,8 @@ endif() if (LLAMA_HIPBLAS) set(TARGET koboldcpp_hipblas) - add_library(${TARGET} SHARED expose.cpp expose.h kcpp_backend.cpp kcpp_backend.h) - target_include_directories(${TARGET} PUBLIC . ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/thirdparty ./tools ./common) + add_library(${TARGET} SHARED kcpp_src/expose.cpp kcpp_src/expose.h kcpp_src/kcpp_backend.cpp kcpp_src/kcpp_backend.h) + target_include_directories(${TARGET} PUBLIC . ./kcpp_src ./ggml/include ./ggml/src ./ggml/src/ggml-cpu ./include ./otherarch ./otherarch/tools ./vendor/stb ./vendor/nlohmann ./vendor ./otherarch/sdcpp ./otherarch/sdcpp/thirdparty ./tools ./common) target_compile_features(${TARGET} PUBLIC cxx_std_17) # don't bump set_target_properties(${TARGET} PROPERTIES PREFIX "") set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME "koboldcpp_hipblas") diff --git a/Makefile b/Makefile index 11c7b5313..0821885d8 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ CFLAGS += -fsanitize=undefined -fsanitize-undefined-trap-on-error CXXFLAGS += -fsanitize=undefined -fsanitize-undefined-trap-on-error endif CFLAGS += -I. -Iggml/include -Iggml/src -Iggml/src/ggml-cpu -Iinclude -Isrc -I./common -I./vendor -I./vendor/stb -I./include -I./otherarch -I./otherarch/tools -I./tools/mtmd -I./otherarch/sdcpp -I./otherarch/ttscpp/include -I./otherarch/ttscpp/src -I./otherarch/qwen3tts -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c11 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_CPU -DGGML_USE_CPU_REPACK -DGGML_USE_RPC -CXXFLAGS += -I. -Iggml/include -Iggml/src -Iggml/src/ggml-cpu -Iinclude -Isrc -I./common -I./vendor -I./vendor/stb -I./include -I./otherarch -I./otherarch/tools -I./tools/mtmd -I./otherarch/sdcpp -I./otherarch/ttscpp/include -I./otherarch/ttscpp/src -I./otherarch/qwen3tts -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c++17 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_CPU -DGGML_USE_CPU_REPACK -DGGML_USE_RPC +CXXFLAGS += -I. -I./kcpp_src -Iggml/include -Iggml/src -Iggml/src/ggml-cpu -Iinclude -Isrc -I./common -I./vendor -I./vendor/stb -I./include -I./otherarch -I./otherarch/tools -I./tools/mtmd -I./otherarch/sdcpp -I./otherarch/ttscpp/include -I./otherarch/ttscpp/src -I./otherarch/qwen3tts -I./otherarch/sdcpp/thirdparty -I./include/vulkan -O3 -fno-finite-math-only -std=c++17 -fPIC -DLOG_DISABLE_LOGS -D_GNU_SOURCE -DGGML_USE_CPU -DGGML_USE_CPU_REPACK -DGGML_USE_RPC ifndef KCPP_DEBUG CFLAGS += -DNDEBUG -s @@ -429,7 +429,7 @@ NOAVX2_BUILD = $(CXX) $(CXXFLAGS) $^ -shared -o $@.dll $(LDFLAGS) endif ifdef LLAMA_VULKAN -VULKAN_LIB = lib/vulkan-1.lib +VULKAN_LIB = kcpp_src/lib/vulkan-1.lib VULKAN_BUILD = $(CXX) $(CXXFLAGS) $^ $(VULKAN_LIB) -shared -o $@.dll $(LDFLAGS) endif @@ -596,7 +596,7 @@ mtmd-helper-gen.o: tools/mtmd/mtmd-helper-gen.cpp tools/mtmd/mtmd-helper-common. $(CXX) $(CXXFLAGS) -c $< -o $@ mtmd-image.o: tools/mtmd/mtmd-image.cpp tools/mtmd/mtmd-image.h $(CXX) $(CXXFLAGS) -c $< -o $@ -hash.o: hash.cpp vendor/hash/hash.cpp vendor/hash/hash.h vendor/hash/sha256/sha256.c vendor/hash/sha256/sha256.h vendor/hash/rotate-bits/rotate-bits.h +hash.o: kcpp_src/hash.cpp vendor/hash/hash.cpp vendor/hash/hash.h vendor/hash/sha256/sha256.c vendor/hash/sha256/sha256.h vendor/hash/rotate-bits/rotate-bits.h $(CXX) $(CXXFLAGS) -I./vendor/hash -c $< -o $@ unicode-common.o: common/unicode.cpp common/unicode.h $(CXX) $(CXXFLAGS) -c $< -o $@ @@ -694,7 +694,7 @@ sampling.o: common/sampling.cpp common/common.h common/sampling.h common/log.h $(CXX) $(CXXFLAGS) -c $< -o $@ console.o: common/console.cpp common/console.h $(CXX) $(CXXFLAGS) -c $< -o $@ -expose.o: expose.cpp expose.h model_adapter.cpp +expose.o: kcpp_src/expose.cpp kcpp_src/expose.h kcpp_src/model_adapter.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ llama-impl.o: src/llama-impl.cpp src/llama-impl.h $(CXX) $(CXXFLAGS) -c $< -o $@ @@ -732,7 +732,7 @@ otherarch/sdcpp/thirdparty/utf8proc/%.o: otherarch/sdcpp/thirdparty/utf8proc/%.c otherarch/sdcpp/examples/%.o: otherarch/sdcpp/examples/%.cpp $(CXX) -I./otherarch/sdcpp/include -I./otherarch/sdcpp/examples -I./vendor/nlohmann $(CXXFLAGS) -c $< -o $@ -otherarch/sdcpp/sdtype_adapter.o: otherarch/sdcpp/sdtype_adapter.cpp otherarch/sdcpp/include/stable-diffusion.h otherarch/sdcpp/src/kcpp_sd_extensions.h model_adapter.h otherarch/utils.h +otherarch/sdcpp/sdtype_adapter.o: otherarch/sdcpp/sdtype_adapter.cpp otherarch/sdcpp/include/stable-diffusion.h otherarch/sdcpp/src/kcpp_sd_extensions.h kcpp_src/model_adapter.h otherarch/utils.h $(CXX) -I./otherarch/sdcpp/include -I./otherarch/sdcpp/src $(CXXFLAGS) -c $< -o $@ otherarch/sdcpp/thirdparty/zip.o: otherarch/sdcpp/thirdparty/zip.c @@ -747,7 +747,7 @@ LLAMASERVER_CXXFLAGS := -I./tools/mtmd #whisper objects -whispercpp_default.o: otherarch/whispercpp/whisper_adapter.cpp otherarch/whispercpp/whisper.cpp kcpp_backend.h +whispercpp_default.o: otherarch/whispercpp/whisper_adapter.cpp otherarch/whispercpp/whisper.cpp kcpp_src/kcpp_backend.h $(CXX) $(CXXFLAGS) -c $< -o $@ #tts objects @@ -761,19 +761,19 @@ music_default.o: otherarch/acestep/music_adapter.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ # idiotic "for easier compilation" -GPTTYPE_ADAPTER = gpttype_adapter.cpp kcpp_backend.h model_adapter.h otherarch/otherarch.h include/llama.h otherarch/llama_v2.cpp otherarch/llama_v3.cpp otherarch/gptj_v1.cpp otherarch/gptj_v2.cpp otherarch/gptj_v3.cpp otherarch/gpt2_v1.cpp otherarch/gpt2_v2.cpp otherarch/gpt2_v3.cpp otherarch/rwkv_v2.cpp otherarch/rwkv_v3.cpp otherarch/neox_v2.cpp otherarch/neox_v3.cpp otherarch/mpt_v3.cpp +GPTTYPE_ADAPTER = kcpp_src/gpttype_adapter.cpp kcpp_src/kcpp_backend.h kcpp_src/model_adapter.h otherarch/otherarch.h include/llama.h otherarch/llama_v2.cpp otherarch/llama_v3.cpp otherarch/gptj_v1.cpp otherarch/gptj_v2.cpp otherarch/gptj_v3.cpp otherarch/gpt2_v1.cpp otherarch/gpt2_v2.cpp otherarch/gpt2_v3.cpp otherarch/rwkv_v2.cpp otherarch/rwkv_v3.cpp otherarch/neox_v2.cpp otherarch/neox_v3.cpp otherarch/mpt_v3.cpp gpttype_adapter_default.o: $(GPTTYPE_ADAPTER) $(CXX) $(CXXFLAGS) -c $< -o $@ -kcpp_backend_failsafe.o: kcpp_backend.cpp kcpp_backend.h +kcpp_backend_failsafe.o: kcpp_src/kcpp_backend.cpp kcpp_src/kcpp_backend.h $(CXX) $(CXXFLAGS) $(FAILSAFE_FLAGS) -c $< -o $@ -kcpp_backend_default.o: kcpp_backend.cpp kcpp_backend.h +kcpp_backend_default.o: kcpp_src/kcpp_backend.cpp kcpp_src/kcpp_backend.h $(CXX) $(CXXFLAGS) -c $< -o $@ -kcpp_backend_cublas.o: kcpp_backend.cpp kcpp_backend.h +kcpp_backend_cublas.o: kcpp_src/kcpp_backend.cpp kcpp_src/kcpp_backend.h $(CXX) $(CXXFLAGS) $(CUBLAS_FLAGS) $(HIPFLAGS) -c $< -o $@ -kcpp_backend_vulkan.o: kcpp_backend.cpp kcpp_backend.h +kcpp_backend_vulkan.o: kcpp_src/kcpp_backend.cpp kcpp_src/kcpp_backend.h $(CXX) $(CXXFLAGS) $(VULKAN_FLAGS) -c $< -o $@ -kcpp_backend_vulkan_noavx2.o: kcpp_backend.cpp kcpp_backend.h +kcpp_backend_vulkan_noavx2.o: kcpp_src/kcpp_backend.cpp kcpp_src/kcpp_backend.h $(CXX) $(CXXFLAGS) $(FAILSAFE_FLAGS) $(VULKAN_FLAGS) -c $< -o $@ clean: @@ -792,7 +792,7 @@ fitparams: tools/fit-params/main.cpp tools/fit-params/fit-params.cpp common/arg. $(CXX) $(CXXFLAGS) -DGGML_USE_VULKAN $(filter-out %.h,$^) $(VULKAN_LIB) -o $@ $(LDFLAGS) sdmain: $(OBJS_SDCOMMON) $(OBJS_SDMAIN) build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-iqp.o ggml-unops.o llama.o chat.o llama-model.o console.o clip_default.o mtmd.o mtmd-helper.o mtmd-helper-gen.o mtmd-image.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS) $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS) -whispermain: otherarch/whispercpp/main.cpp otherarch/whispercpp/whisper.cpp kcpp_backend.h kcpp_backend_default.o build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-iqp.o ggml-unops.o llama.o chat.o llama-model.o console.o clip_default.o mtmd.o mtmd-helper.o mtmd-helper-gen.o mtmd-image.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS) +whispermain: otherarch/whispercpp/main.cpp otherarch/whispercpp/whisper.cpp kcpp_src/kcpp_backend.h kcpp_backend_default.o build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-iqp.o ggml-unops.o llama.o chat.o llama-model.o console.o clip_default.o mtmd.o mtmd-helper.o mtmd-helper-gen.o mtmd-image.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS) $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS) ttsmain: tools/tts/tts.cpp common/arg.cpp common/preset.cpp $(COMMON_DOWNLOAD_SRCS) build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-iqp.o ggml-unops.o llama.o chat.o llama-model.o console.o clip_default.o mtmd.o mtmd-helper.o mtmd-helper-gen.o mtmd-image.o ggml-backend.o ggml-backend-meta.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS) $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS) @@ -993,7 +993,7 @@ quantize_ace: otherarch/acestep/quantize-acestep.cpp tools/mtmd/clip.cpp ggml_v3 #window simple clinfo -simplecpuinfo: simplecpuinfo.cpp +simplecpuinfo: kcpp_src/simplecpuinfo.cpp $(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS) build-info.h: diff --git a/README.md b/README.md index adf210b89..8abc71ad9 100644 --- a/README.md +++ b/README.md @@ -118,9 +118,9 @@ If you want to build a universal binary that works on other systems like the one - To make your build sharable and capable of working on other devices, you must use `LLAMA_PORTABLE=1` - If you want to generate the .exe file, make sure you have the python module PyInstaller installed with pip (`pip install PyInstaller`). Then run the script `make_pyinstaller.bat` - The koboldcpp.exe file will be at your dist folder. -- **Building with CUDA**: Visual Studio, CMake and CUDA Toolkit is required. Clone the repo, then open the CMake file and compile it in Visual Studio. Copy the `koboldcpp_cublas.dll` generated into the same directory as the `koboldcpp.py` file. If you are bundling executables, you may need to include CUDA dynamic libraries (such as `cublasLt64_11.dll` and `cublas64_11.dll`) in order for the executable to work correctly on a different PC. +- **Building with CUDA**: Visual Studio, CMake and CUDA Toolkit is required. Clone the repo, then open the CMake file and compile it in Visual Studio. Copy the `koboldcpp_cublas.dll` generated into the same directory as the `koboldcpp.py` file. Portable executables must include matching CUDA dynamic libraries: `cublas`, `cublasLt`, and `cudart` from the same CUDA toolkit family used for the build. - **Replacing Libraries (Not Recommended)**: If you wish to use your own version of the additional Windows libraries (Vulkan), you can do it with: - - Move the respectives .lib files to the /lib folder of your project, overwriting the older files. + - Move the respective `.lib` files to the `/kcpp_src/lib` folder of your project, overwriting the older files. - Also, replace the existing versions of the corresponding .dll files located in the project directory root. - Make the KoboldCpp project using the instructions above. diff --git a/hash.cpp b/hash.cpp deleted file mode 100644 index af1b3732c..000000000 --- a/hash.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "vendor/hash/hash.cpp" - -extern "C" { -#include "vendor/hash/sha256/sha256.c" -} diff --git a/kcpp_src/README.md b/kcpp_src/README.md new file mode 100644 index 000000000..a3aea52e3 --- /dev/null +++ b/kcpp_src/README.md @@ -0,0 +1,5 @@ +# KoboldCpp native sources + +This directory contains KoboldCpp-owned native integration code. Upstream-synced +llama.cpp and ggml sources remain in their original directories so upstream +updates can continue to be merged without path-only conflicts. diff --git a/expose.cpp b/kcpp_src/expose.cpp similarity index 99% rename from expose.cpp rename to kcpp_src/expose.cpp index 1b86e7985..7fbf66821 100644 --- a/expose.cpp +++ b/kcpp_src/expose.cpp @@ -17,8 +17,8 @@ #include #include #include -#include "expose.h" -#include "model_adapter.cpp" +#include "kcpp_src/expose.h" +#include "kcpp_src/model_adapter.cpp" extern "C" { diff --git a/expose.h b/kcpp_src/expose.h similarity index 99% rename from expose.h rename to kcpp_src/expose.h index eb421dece..124e9ff8b 100644 --- a/expose.h +++ b/kcpp_src/expose.h @@ -1,4 +1,5 @@ #pragma once + #include #include diff --git a/gpttype_adapter.cpp b/kcpp_src/gpttype_adapter.cpp similarity index 99% rename from gpttype_adapter.cpp rename to kcpp_src/gpttype_adapter.cpp index aea2b8331..ba6724ecf 100644 --- a/gpttype_adapter.cpp +++ b/kcpp_src/gpttype_adapter.cpp @@ -12,7 +12,7 @@ #include #include #include -#include "model_adapter.h" +#include "kcpp_src/model_adapter.h" #include "otherarch.h" #include "llama.h" #include @@ -33,7 +33,7 @@ #include "utils.h" #include "llmutils.h" -#include "kcpp_backend.h" +#include "kcpp_src/kcpp_backend.h" #include "llama_v2.cpp" #include "llama_v3.cpp" diff --git a/kcpp_src/hash.cpp b/kcpp_src/hash.cpp new file mode 100644 index 000000000..eaa4b5c32 --- /dev/null +++ b/kcpp_src/hash.cpp @@ -0,0 +1,5 @@ +#include "../vendor/hash/hash.cpp" + +extern "C" { +#include "../vendor/hash/sha256/sha256.c" +} diff --git a/kcpp_backend.cpp b/kcpp_src/kcpp_backend.cpp similarity index 99% rename from kcpp_backend.cpp rename to kcpp_src/kcpp_backend.cpp index ad89f80d0..a04d4c234 100644 --- a/kcpp_backend.cpp +++ b/kcpp_src/kcpp_backend.cpp @@ -1,4 +1,4 @@ -#include "kcpp_backend.h" +#include "kcpp_src/kcpp_backend.h" #include #include diff --git a/kcpp_backend.h b/kcpp_src/kcpp_backend.h similarity index 99% rename from kcpp_backend.h rename to kcpp_src/kcpp_backend.h index e95433ec7..043007c77 100644 --- a/kcpp_backend.h +++ b/kcpp_src/kcpp_backend.h @@ -1,5 +1,4 @@ #pragma once - #include "ggml-backend.h" #include "ggml_v2.h" #include "ggml_v3.h" diff --git a/lib/vulkan-1.lib b/kcpp_src/lib/vulkan-1.lib similarity index 100% rename from lib/vulkan-1.lib rename to kcpp_src/lib/vulkan-1.lib diff --git a/model_adapter.cpp b/kcpp_src/model_adapter.cpp similarity index 99% rename from model_adapter.cpp rename to kcpp_src/model_adapter.cpp index 34a11e2f1..b4631dfe4 100644 --- a/model_adapter.cpp +++ b/kcpp_src/model_adapter.cpp @@ -9,7 +9,7 @@ #include #include -#include "model_adapter.h" +#include "kcpp_src/model_adapter.h" #include "ggml.h" #include "ggml-cpu.h" #include "gguf.h" diff --git a/model_adapter.h b/kcpp_src/model_adapter.h similarity index 99% rename from model_adapter.h rename to kcpp_src/model_adapter.h index 3d0cdad69..ac8eb7462 100644 --- a/model_adapter.h +++ b/kcpp_src/model_adapter.h @@ -11,7 +11,7 @@ #include #include -#include "expose.h" +#include "kcpp_src/expose.h" #include "src/llama-arch.h" enum FileFormat diff --git a/simplecpuinfo.cpp b/kcpp_src/simplecpuinfo.cpp similarity index 93% rename from simplecpuinfo.cpp rename to kcpp_src/simplecpuinfo.cpp index 876e8275b..a143f2567 100644 --- a/simplecpuinfo.cpp +++ b/kcpp_src/simplecpuinfo.cpp @@ -1,4 +1,4 @@ -//a simple program that obtains AVX and AVX2 info, prints them out and exits +// A simple program that obtains AVX and AVX2 info, prints them out and exits. #include #if defined(_MSC_VER) #include @@ -40,4 +40,4 @@ int main() { printf("{\"avx\":%d, \"avx2\":%d}",avxSupported,avx2Supported); fflush(stdout); return 0; -} \ No newline at end of file +} diff --git a/scripts/check-release-apiabi.sh b/scripts/check-release-apiabi.sh deleted file mode 100755 index d31d24041..000000000 --- a/scripts/check-release-apiabi.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/bash -# Check API/ABI compatibility between the previous release tag and current HEAD. -# -# Finds the most recent vX.Y.Z tag, checks it out in a temporary git worktree, -# builds both versions with shared libs enabled, and uses check-apiabi-compat.sh -# to compare the results. -# -# Exit codes: -# 0: compatible, or check was skipped -# 1: backwards-incompatible changes found, or build failed -# -# Options: -# --tag : compare against this tag instead of the latest release -# -# Environment: -# SKIP_APIABI_CHECK: set to 1 or true to skip -# APIABI_COMPARE_TAG: equivalent to --tag (used by CI) - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" - -usage() { - echo "Usage: $0 [--tag ]" >&2 - echo " --tag Compare against this release tag (default: latest)" >&2 -} - -COMPARE_TAG="${APIABI_COMPARE_TAG:-}" -while [[ "$#" -gt 0 ]]; do - case "$1" in - --tag) - if [[ -z "${2:-}" ]]; then usage; exit 1; fi - COMPARE_TAG="$2" - shift 2 - ;; - --tag=*) - COMPARE_TAG="${1#*=}" - shift - ;; - -h | --help) - usage; exit 0 - ;; - *) - usage; exit 1 - ;; - esac -done - -if [[ "${SKIP_APIABI_CHECK:-}" == "1" || "${SKIP_APIABI_CHECK:-}" == "true" ]]; then - echo "SKIP_APIABI_CHECK is set - skipping API/ABI compatibility check" - exit 0 -fi - -if ! command -v abi-compliance-checker >/dev/null 2>&1 || ! command -v abidw >/dev/null 2>&1; then - echo "Warning: abi-compliance-checker or abigail-tools not installed - skipping API/ABI check" - exit 0 -fi - -discover_libs() { - local build_dir="$1" - local libs=() - for dir in "$build_dir/src" "$build_dir/bin"; do - [[ -d "$dir" ]] || continue - for f in "$dir"/lib*.so; do - [[ -f "$f" ]] && libs+=("$(basename "$f" .so)") - done - done - echo "${libs[@]}" -} - -if [[ -n "${COMPARE_TAG}" ]]; then - PREV_TAG="${COMPARE_TAG}" - if ! git -C "$REPO_ROOT" rev-parse --verify "${PREV_TAG}^{}" >/dev/null 2>&1; then - echo "Error: tag '${PREV_TAG}' not found in repository." >&2 - exit 1 - fi -else - PREV_TAG=$(git -C "$REPO_ROOT" tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true) - if [[ -z "${PREV_TAG}" ]]; then - echo "Warning: no previous release tag found - skipping API/ABI check" - exit 0 - fi -fi -OLD_VERSION="${PREV_TAG#v}" -OLD_MAJOR="${OLD_VERSION%%.*}" -OLD_MINOR="${OLD_VERSION#*.}"; OLD_MINOR="${OLD_MINOR%%.*}" - -NEW_MAJOR=$(grep "set(LLAMA_VERSION_MAJOR" "$REPO_ROOT/CMakeLists.txt" | sed 's/.*MAJOR \([0-9]*\).*/\1/') -NEW_MINOR=$(grep "set(LLAMA_VERSION_MINOR" "$REPO_ROOT/CMakeLists.txt" | sed 's/.*MINOR \([0-9]*\).*/\1/') - -if [[ "$NEW_MAJOR" -gt "$OLD_MAJOR" ]]; then - echo "Major version increment ($OLD_MAJOR -> $NEW_MAJOR): API/ABI breaking changes are expected, skipping compatibility check." - exit 0 -fi - -CHECK_FLAGS=() -if [[ "$NEW_MINOR" -eq "$OLD_MINOR" ]]; then - echo "Patch version bump detected: checking for any API/ABI changes (a minor bump is required if any are found)..." - CHECK_FLAGS+=(--strict) -else - echo "Minor version bump detected: checking for backwards-incompatible API/ABI changes..." -fi - -echo "Checking API/ABI compatibility against ${PREV_TAG}..." - -WORKTREE_DIR=$(mktemp -d) -BUILD_OLD=$(mktemp -d) -BUILD_NEW=$(mktemp -d) - -cleanup() { - git -C "$REPO_ROOT" worktree remove --force "$WORKTREE_DIR" 2>/dev/null || true - rm -rf "$WORKTREE_DIR" "$BUILD_OLD" "$BUILD_NEW" -} -trap cleanup EXIT - -git -C "$REPO_ROOT" worktree add "$WORKTREE_DIR" "$PREV_TAG" - -cmake -S "$WORKTREE_DIR" -B "$BUILD_OLD" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -cmake --build "$BUILD_OLD" --parallel "$(nproc)" -OLD_LIBS=($(discover_libs "$BUILD_OLD")) -echo "Libraries found in old build: ${OLD_LIBS[*]}" - -cmake -S "$REPO_ROOT" -B "$BUILD_NEW" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -cmake --build "$BUILD_NEW" --parallel "$(nproc)" -NEW_LIBS=($(discover_libs "$BUILD_NEW")) -echo "Libraries found in new build: ${NEW_LIBS[*]}" - -(cd "$WORKTREE_DIR" && "$SCRIPT_DIR/check-apiabi-compat.sh" --include-path ggml/include --generate "$BUILD_OLD" "${OLD_LIBS[@]}") -(cd "$REPO_ROOT" && "$SCRIPT_DIR/check-apiabi-compat.sh" --include-path ggml/include --generate "$BUILD_NEW" "${NEW_LIBS[@]}") -(cd "$REPO_ROOT" && "$SCRIPT_DIR/check-apiabi-compat.sh" "${CHECK_FLAGS[@]}" --check "$BUILD_OLD" "$BUILD_NEW")