-
Notifications
You must be signed in to change notification settings - Fork 426
Project#15: GGUF Reader in OpenVINO for direct GGUF Execution (Prototype) #3449
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
Closed
shahkarnav115-beep
wants to merge
6
commits into
openvinotoolkit:master
from
shahkarnav115-beep:ggufreaderv2-gsoc26-warmup
Closed
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
824f3d8
Initial work for gsoc 2026 on project#15
shahkarnav115-beep 36b9f7a
integrate llama.cpp static dependency and isolate legacy gguf backend
shahkarnav115-beep fbdfd2d
Temporary work for the proof of concept
shahkarnav115-beep 024cd2b
verified math parity
shahkarnav115-beep 521550f
Merge branch 'master' into ggufreaderv2-gsoc26-warmup
shahkarnav115-beep ed8335d
Merge branch 'master' into ggufreaderv2-gsoc26-warmup
shahkarnav115-beep 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 |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| [submodule "thirdparty/openvino_tokenizers"] | ||
| path = thirdparty/openvino_tokenizers | ||
| url = https://github.com/openvinotoolkit/openvino_tokenizers.git | ||
| [submodule "thirdparty/llama.cpp"] | ||
| path = thirdparty/llama.cpp | ||
| url = https://github.com/ravi9/llama.cpp.git | ||
| branch = dev_backend_openvino |
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 |
|---|---|---|
|
|
@@ -181,6 +181,14 @@ if(NOT ENABLE_GGUF) | |
| list(REMOVE_ITEM SOURCE_FILES ${GGUF_SOURCES}) | ||
| endif() | ||
|
|
||
| if(BUILD_LLAMA_CPP) | ||
| list(REMOVE_ITEM SOURCE_FILES | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_quants.cpp" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_modeling.cpp" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/building_blocks.cpp" | ||
| ) | ||
| endif() | ||
|
|
||
| set(TARGET_NAME openvino_genai) | ||
| set(TARGET_NAME_OBJ ${TARGET_NAME}_obj) | ||
|
|
||
|
|
@@ -195,9 +203,8 @@ if(ENABLE_XGRAMMAR) | |
| target_link_libraries(${TARGET_NAME_OBJ} PRIVATE xgrammar) | ||
| endif() | ||
|
|
||
| if(ENABLE_GGUF) | ||
| target_link_libraries(${TARGET_NAME_OBJ} PRIVATE gguflib) | ||
| target_compile_definitions(${TARGET_NAME_OBJ} PRIVATE ENABLE_GGUF) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why have you removed this line? |
||
| if(ENABLE_GGUF AND NOT BUILD_LLAMA_CPP) | ||
| target_link_libraries(${TARGET_NAME} PRIVATE gguflib) | ||
| endif() | ||
|
|
||
| target_include_directories(${TARGET_NAME_OBJ} SYSTEM PRIVATE "${safetensors.h_SOURCE_DIR}") | ||
|
|
@@ -261,8 +268,65 @@ if(ENABLE_XGRAMMAR) | |
| target_link_libraries(${TARGET_NAME} PRIVATE xgrammar) | ||
| endif() | ||
|
|
||
| if(ENABLE_GGUF) | ||
| target_link_libraries(${TARGET_NAME} PRIVATE gguflib) | ||
| if(ENABLE_GGUF AND NOT BUILD_LLAMA_CPP) | ||
| FetchContent_Declare( | ||
| gguflib | ||
| URL https://github.com/Lourdle/gguf-tools/archive/bac796ada809ac293e685db59b075971181cb008.zip | ||
| URL_HASH SHA256=4d6eab5055468d222833f3f83fe2f7909ccd06114278c2c0b468570ef002c22d) | ||
| FetchContent_MakeAvailable(gguflib) | ||
| set_target_properties(gguf-tools PROPERTIES EXCLUDE_FROM_ALL ON) | ||
|
|
||
| add_library(gguflib STATIC ${gguflib_SOURCE_DIR}/fp16.c ${gguflib_SOURCE_DIR}/gguflib.c) | ||
| set_target_properties(gguflib PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
| target_include_directories(gguflib PUBLIC "${gguflib_SOURCE_DIR}") | ||
| endif() | ||
|
|
||
| if(BUILD_LLAMA_CPP) | ||
| target_compile_definitions(${TARGET_NAME_OBJ} PUBLIC HAS_LLAMA_CPP) | ||
|
|
||
| target_include_directories(${TARGET_NAME_OBJ} PRIVATE | ||
| "${OpenVINOGenAI_SOURCE_DIR}/thirdparty/llama.cpp/include" | ||
| "${OpenVINOGenAI_SOURCE_DIR}/thirdparty/llama.cpp/ggml/include" | ||
| "${OpenVINOGenAI_SOURCE_DIR}/thirdparty/llama.cpp/ggml/src" | ||
| ) | ||
|
|
||
| find_package(OpenCL QUIET) | ||
| if(OpenCL_FOUND) | ||
| target_include_directories(${TARGET_NAME_OBJ} PRIVATE ${OpenCL_INCLUDE_DIRS}) | ||
| endif() | ||
|
|
||
| if(TARGET llama) | ||
| target_link_libraries(${TARGET_NAME} PRIVATE llama) | ||
| add_dependencies(${TARGET_NAME} llama) | ||
|
|
||
| if(TARGET ggml-openvino) | ||
| target_link_libraries(${TARGET_NAME} PRIVATE ggml-openvino) | ||
| endif() | ||
|
|
||
| endif() | ||
|
|
||
| foreach(_tgt llama ggml ggml-base ggml-cpu ggml-openvino) | ||
| if(TARGET ${_tgt}) | ||
| get_target_property(_inc_dirs ${_tgt} INTERFACE_INCLUDE_DIRECTORIES) | ||
| if(_inc_dirs) | ||
| set(_new_inc_dirs "") | ||
| foreach(_dir IN LISTS _inc_dirs) | ||
| if(IS_ABSOLUTE "${_dir}") | ||
| list(APPEND _new_inc_dirs "$<BUILD_INTERFACE:${_dir}>") | ||
| else() | ||
| list(APPEND _new_inc_dirs "${_dir}") | ||
| endif() | ||
| endforeach() | ||
| set_target_properties(${_tgt} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${_new_inc_dirs}") | ||
| endif() | ||
|
|
||
| install(TARGETS ${_tgt} EXPORT OpenVINOGenAITargets | ||
| LIBRARY DESTINATION ${LIBRARY_DESTINATION} COMPONENT core_genai | ||
| RUNTIME DESTINATION ${RUNTIME_DESTINATION} COMPONENT core_genai | ||
| ARCHIVE DESTINATION ${ARCHIVE_DESTINATION} COMPONENT core_genai | ||
| ) | ||
| endif() | ||
| endforeach() | ||
| endif() | ||
|
|
||
| target_compile_features(${TARGET_NAME} INTERFACE cxx_std_17) | ||
|
|
@@ -317,11 +381,12 @@ if(rpaths) | |
| endif() | ||
|
|
||
| install(TARGETS ${TARGET_NAME} EXPORT OpenVINOGenAITargets | ||
| LIBRARY DESTINATION ${LIBRARY_DESTINATION} COMPONENT core_genai | ||
| NAMELINK_COMPONENT core_genai_dev | ||
| ARCHIVE DESTINATION ${ARCHIVE_DESTINATION} COMPONENT core_genai_dev | ||
| RUNTIME DESTINATION ${RUNTIME_DESTINATION} COMPONENT core_genai | ||
| INCLUDES DESTINATION runtime/include) | ||
| LIBRARY DESTINATION ${LIBRARY_DESTINATION} COMPONENT core_genai | ||
| NAMELINK_COMPONENT core_genai_dev | ||
| ARCHIVE DESTINATION ${ARCHIVE_DESTINATION} COMPONENT core_genai_dev | ||
| RUNTIME DESTINATION ${RUNTIME_DESTINATION} COMPONENT core_genai | ||
| INCLUDES DESTINATION runtime/include | ||
| ) | ||
|
|
||
| # development files do not need to be built for NPM package | ||
| if(CPACK_GENERATOR STREQUAL "NPM") | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed