Fix: ensure bitnet-lut-kernels.h prepared before llama.cpp build#449
Fix: ensure bitnet-lut-kernels.h prepared before llama.cpp build#449shivansh31414 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
@shivansh31414 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
This PR fixes clean CMake configure/build failures by ensuring include/bitnet-lut-kernels.h is present before 3rdparty/llama.cpp / ggml is configured, using either a user-provided header path or a preset-kernel header selected by model + architecture.
Changes:
- Adds CMake cache variables
BITNET_PRESET_KERNEL_MODELandBITNET_LUT_KERNELS_FILEto control howbitnet-lut-kernels.his prepared. - Implements configure-time logic to copy a provided header or a preset header into
include/bitnet-lut-kernels.hbefore adding llama.cpp. - Adds a clearer fatal error when no suitable preset header can be found.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| set(BITNET_LUT_KERNELS_DST "${CMAKE_CURRENT_SOURCE_DIR}/include/bitnet-lut-kernels.h") | ||
| if (NOT EXISTS "${BITNET_LUT_KERNELS_DST}") | ||
| file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include") | ||
|
|
||
| if (BITNET_LUT_KERNELS_FILE) | ||
| if (NOT EXISTS "${BITNET_LUT_KERNELS_FILE}") | ||
| message(FATAL_ERROR "BITNET_LUT_KERNELS_FILE does not exist: ${BITNET_LUT_KERNELS_FILE}") | ||
| endif() | ||
| configure_file("${BITNET_LUT_KERNELS_FILE}" "${BITNET_LUT_KERNELS_DST}" COPYONLY) | ||
| message(STATUS "Prepared bitnet-lut-kernels.h from BITNET_LUT_KERNELS_FILE=${BITNET_LUT_KERNELS_FILE}") |
| add_compile_options(-fpermissive) | ||
| endif() | ||
|
|
||
| set(BITNET_LUT_KERNELS_DST "${CMAKE_CURRENT_SOURCE_DIR}/include/bitnet-lut-kernels.h") |
| set(BITNET_LUT_KERNEL_VARIANT "tl1") | ||
| elseif (GGML_BITNET_X86_TL2) | ||
| set(BITNET_LUT_KERNEL_VARIANT "tl2") | ||
| elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)") |
Title: Fix CMake build: ensure
bitnet-lut-kernels.hprepared before llama.cppSummary
The CMake build currently fails because
include/bitnet-lut-kernels.his required at configure time but is not tracked in the source tree. This header is produced by setup scripts (setup_env.py, codegen utilities) and not by CMake itself, which breaks a cleancmake .. && makeworkflow.Problem
bitnet-lut-kernels.his missing during CMake configure.add_subdirectory(3rdparty/llama.cpp).Fix Implemented
fixes: #378
CMakeLists.txtto ensureinclude/bitnet-lut-kernels.hexists before llama.cpp is added.BITNET_PRESET_KERNEL_MODEL(default:bitnet_b1_58-3B)BITNET_LUT_KERNELS_FILE(optional explicit header path)BITNET_LUT_KERNELS_FILEis set → copy that file.preset_kernels/<model>/bitnet-lut-kernels-{tl1|tl2}.hbased on architecture.