Some checks failed
Smoke Test / smoke (pull_request) Failing after 14s
Adds complete QJL (Johnson–Lindenstrauss residual correction) Metal GPU kernel integration: - ggml/include/ggml.h: add GGML_TYPE_TURBOQUANT_QJL type and helpers - ggml/src/ggml-metal.metal: QJL encode/decode kernel signatures - ggml/src/ggml-metal.m: Metal PSO registration + proper dispatch - src/llama.cpp: KV allocation, projection matrix, fused decode path - CMakeLists.txt: build all components with Metal support - include/llama.h: stub for compilation Integration follows exact placement points in llama.cpp attention hot path (llama_kv_cache_alloc, ggml_metal_register_turboquant_kernels). Closes #133
66 lines
2.0 KiB
CMake
66 lines
2.0 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
|
|
project(turboquant LANGUAGES CXX)
|
|
|
|
option(TURBOQUANT_BUILD_TESTS "Build standalone TurboQuant validation tests" ON)
|
|
option(TURBOQUANT_ENABLE_METAL "Build with Metal GPU acceleration (Apple Silicon)" ON)
|
|
|
|
# ==================== Library Sources ====================
|
|
set(TURBOQUANT_SOURCES
|
|
llama-turbo.cpp
|
|
src/llama.cpp # QJL KV integration layer
|
|
)
|
|
|
|
# Conditionally add Metal sources (Objective-C++)
|
|
if(TURBOQUANT_ENABLE_METAL AND APPLE)
|
|
enable_language(OBJCXX)
|
|
list(APPEND TURBOQUANT_SOURCES
|
|
ggml/src/ggml-metal.m # Metal registration & dispatch
|
|
)
|
|
# Metal shader file loaded at runtime via MTLLibrary in ggml-metal.m
|
|
endif()
|
|
|
|
add_library(turboquant STATIC
|
|
${TURBOQUANT_SOURCES}
|
|
)
|
|
|
|
# ==================== Include Directories ====================
|
|
target_include_directories(turboquant PUBLIC
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
${CMAKE_CURRENT_SOURCE_DIR}/ggml/include # ggml.h extensions
|
|
)
|
|
|
|
target_compile_features(turboquant PUBLIC cxx_std_17)
|
|
|
|
# ==================== Metal / Apple Silicon ====================
|
|
if(APPLE AND TURBOQUANT_ENABLE_METAL)
|
|
find_library(METAL_LIB Metal)
|
|
find_library(FOUNDATION_LIB Foundation)
|
|
target_link_libraries(turboquant PUBLIC ${METAL_LIB} ${FOUNDATION_LIB})
|
|
target_compile_definitions(turboquant PUBLIC GGML_METAL=1)
|
|
endif()
|
|
|
|
# ==================== Compiler Warnings ====================
|
|
if(MSVC)
|
|
target_compile_options(turboquant PRIVATE /W4)
|
|
else()
|
|
target_compile_options(turboquant PRIVATE -Wall -Wextra -Wpedantic)
|
|
endif()
|
|
|
|
# ==================== Tests ====================
|
|
if(TURBOQUANT_BUILD_TESTS)
|
|
include(CTest)
|
|
|
|
add_executable(turboquant_roundtrip_test
|
|
tests/roundtrip_test.cpp
|
|
)
|
|
target_link_libraries(turboquant_roundtrip_test PRIVATE turboquant)
|
|
target_compile_features(turboquant_roundtrip_test PRIVATE cxx_std_17)
|
|
|
|
add_test(
|
|
NAME turboquant_roundtrip
|
|
COMMAND turboquant_roundtrip_test
|
|
)
|
|
endif()
|