BitNet
BitNet copied to clipboard
`include/bitnet-lut-kernels.h` missing from repository, build fails
I've been following gpt4.1 instructions to build BitNet from source, but I'm unable to proceed because include/bitnet-lut-kernels.h is missing from both the main repository and my local clone.
The build fails with the following error:
\BitNet\build>cmake .. -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
-- The C compiler identification is Clang 20.1.3 with GNU-like command-line
-- The CXX compiler identification is Clang 20.1.3 with GNU-like command-line
...
CMake Error at 3rdparty/llama.cpp/ggml/src/CMakeLists.txt:1324 (add_library):
Cannot find source file:
../../../../include/bitnet-lut-kernels.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
.ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
.f95 .f03 .hip .ispc
CMake Error at 3rdparty/llama.cpp/ggml/src/CMakeLists.txt:1324 (add_library):
No SOURCES given to target: ggml
CMake Generate step failed. Build files cannot be regenerated correctly.
I've already initialized submodules and checked the official repo for the missing file. In Cursor, gpt-4.1 advised me to open an issue and said it was a packaging issue? Please advise if this file was intentionally removed, or if it will be restored? Is there a workaround for building the project in the meantime?
Thank you!
same issue for me as well, any idea
-- Warning: ccache not found - consider installing it for faster compilation or disable this warning with GGML_CCACHE=OFF
-- CMAKE_SYSTEM_PROCESSOR: aarch64
-- ARM detected
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E
-- Performing Test COMPILER_SUPPORTS_FP16_FORMAT_I3E - Failed
-- Configuring done (2.6s)
CMake Error at 3rdparty/llama.cpp/ggml/src/CMakeLists.txt:1324 (add_library):
Cannot find source file:
../../../../include/bitnet-lut-kernels.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
.ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
.f95 .f03 .hip .ispc
CMake Error at 3rdparty/llama.cpp/ggml/src/CMakeLists.txt:1324 (add_library):
No SOURCES given to target: ggml
I had the same. Termux. Solved it by:
~/downloads $ cd BitNet ~/downloads/BitNet $ ls 3rdparty logs assets Makefile bin media build preset_kernels cmake_install.cmake README.md CMakeCache.txt requirements.txt
CMakeFiles run_inference.py CMakeLists.txt SECURITY.md
CODE_OF_CONDUCT.md setup_env.py compile_commands.json src docs utils include LICENSE llama.h
LlamaConfigVersion.cmake
~/downloads/BitNet $ cd 3rdparty/
~/.../BitNet/3rdparty $ ls
llama.cpp llama.cpp.1
~/.../BitNet/3rdparty $ mv llama.cpp llama.cpp.3
and git cloning as per: https://github.com/ggml-org/llama.cpp/blob/master/docs/build.md
Make worked then.
I had another missing file error during the make install stage:
-- Installing: /data/data/com.termux/files/usr/lib/libllama.so
-- Set non-toolchain portion of runtime path of "/data/data/com.termux/files/usr/lib/libllama.so" to ""
CMake Error at cmake_install.cmake:86 (file):
file INSTALL cannot find "/data/data/com.termux/files/home/downloads/BitNet/llama.h": No such file or directory.
- solved by a hack:
locate llama.h /data/data/com.termux/files/home/downloads/BitNet/3rdparty/llama.cpp/include/llama.h
/data/data/com.termux/files/home/downloads/BitNet/3rdparty/llama.cpp/spm-headers/llama.h
so:
cp ../3rdparty/llama.cpp/include/llama.h "/data/data/com.termux/files/home/downloads/BitNet/"
Ugly, but works. In short, anything that be missing: try to git clone, locate and move to the installation, that is the current folder, for quick fixes.
I trashed my clone & rebuilt successfully by simply following the README instructions...
I feel stupid😭... I had to edit code, adding #include <chrono> in 3rdparty\llama.cpp\common\common.cpp and 3rdparty\llama.cpp\common\log.cpp. Also, I had to change all instances of std::chrono::high_resolution_clock to std::chrono::steady_clock throughout the codebase. After making these changes, the project built and ran as expected.
These errors were happening when I was running python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s, but the changes I described allowed me to continue with the build. Hope this helps anyone else running into similar issues!
I trashed my clone & rebuilt successfully by simply following the README instructions...
I feel stupid😭... I had to edit code, adding
#include <chrono>in3rdparty\llama.cpp\common\common.cppand3rdparty\llama.cpp\common\log.cpp. Also, I had to change all instances ofstd::chrono::high_resolution_clocktostd::chrono::steady_clockthroughout the codebase. After making these changes, the project built and ran as expected.These errors were happening when I was running
python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s, but the changes I described allowed me to continue with the build. Hope this helps anyone else running into similar issues!
Thanks for the info. We know this issue but had to add the fix to readme instead of directly fix it in the code, so that we could keep sync with llama.cpp. Hopefully someone will fix this issue in the llama.cpp repo directly.
FYI, it has compiled fine (after my 'hack') from the beginning (maybe because I have somewhat bespoke Termux setup, installed most of the libs and some more), but when running it:
Successfully installed gguf-0.16.0
~/downloads/BitNet $ gguf-dump models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf | head -n 20
INFO:gguf-dump:* Loading: models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf
Traceback (most recent call last): File "/data/data/com.termux/files/usr/bin/gguf-dump", line 8, in <module> sys.exit(gguf_dump_entrypoint())
^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/gguf/scripts/gguf_dump.py", line 439, in main
reader = GGUFReader(args.model, 'r') ^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/gguf/gguf_reader.py", line 182, in __init__ self._build_tensors(offs, tensors_fields)
File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/gguf/gguf_reader.py", line 325, in _build_tensors ggml_type = GGMLQuantizationType(raw_dtype[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.12/enum.py", line 751, in __call__ return cls.__new__(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.12/enum.py", line 1170, in __new__ raise ve_exc
ValueError: np.uint32(36) is not a valid GGMLQuantizationType
~/downloads/BitNet $
plus:
python run_inference.py -m models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf -p "You are a helpful assistant" -cnv warning: no usable GPU found, --gpu-layers option will be ignored
warning: one possible reason is that llama.cpp was compiled without GPU support warning: consult docs/build.md for compilation instructions build: 5162 (2016f07b) with clang version 20.1.3 for aarch64-unknown-linux-android24 main: llama backend init
main: load the model and apply lora adapter, if any
gguf_init_from_file_impl: tensor 'blk.0.ffn_down.weight' of type 36 (TYPE_IQ4_NL_4_4 REMOVED, use IQ4_NL with runtime repacking) has 6912 elements per row, not a multiple of block size (0)
gguf_init_from_file_impl: failed to read tensor info
llama_model_load: error loading model: llama_model_loader: failed to load model from models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf
llama_model_load_from_file_impl: failed to load model
common_init_from_params: failed to load model 'models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf'
main: error: unable to load model Error occurred while running command: Command '['build/bin/llama-cli', '-m', 'models/BitNet-b1.58-2B-4T/ggml-model-i2_s.gguf', '-n', '128', '-t', '2', '-p', 'You are a helpful assistant', '-ngl', '0', '-c', '2048', '--temp', '0.8', '-b', '1', '-cnv']' returned non-zero exit status 1.
Quick diagnosis: this seems to happen mostly due to the almost empty bin folder after the "default" compile:
ls build/bin/
libggml-base.so libggml.so libggml-cpu.so libllama.so
~/downloads/BitNet $
After moving the necessary llama-cli thereto, to make it run:
ls build/bin/
libggml-base.so libggml.so llama-cli libggml-cpu.so libllama.so
~/downloads/BitNet $
the error above appears. Probably the llama-cli incompatibilities due to it being a newish model:
llama-cli --version version: 5162 (2016f07b)
built with clang version 20.1.3 for aarch64-unknown-linux-android24
Seems also I need to RTFM later on myself and do some A/B version testing ...
Still freezes at cmake step for half a day (even with -v to debug, no output) or is incompatible after basic hacks in Droid, see: https://github.com/microsoft/BitNet/issues/210