Skip to content

Commit 79d7b5a

Browse files
committed
Merge branch '2025.4-new-arch' into master_tr_module_genai
Signed-off-by: Zhang, Xiaolin <xiaolin.zhang@intel.com>
2 parents f8e400e + 9114927 commit 79d7b5a

File tree

115 files changed

+31930
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+31930
-29
lines changed

cmake/features.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ option(ENABLE_SAMPLES "Enable samples build" ON)
99
option(ENABLE_TESTS "Enable tests build" ON)
1010
option(ENABLE_TOOLS "Enable tools build" ON)
1111
option(ENABLE_GGUF "Enable support for GGUF format" ON)
12+
option(ENABLE_SAFETENSORS "Enable support for Safetensors format" ON)
1213
option(ENABLE_XGRAMMAR "Enable support for structured output generation with xgrammar backend" ON)
1314

1415
# Disable building samples for NPM package

src/cpp/CMakeLists.txt

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#
44

55
file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
6+
file(GLOB modeling_samples_src "${CMAKE_CURRENT_SOURCE_DIR}/src/modeling/samples/*.cpp")
7+
list(REMOVE_ITEM SOURCE_FILES ${modeling_samples_src})
68
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")
79

810
# Dependencies
@@ -101,6 +103,8 @@ FetchContent_Declare(safetensors.h
101103
URL_HASH SHA256=9aaf5961609601cf9aaa96582a207bce7c6e5fbf57ed2cc669bb7bde6a937d4b)
102104
FetchContent_MakeAvailable(safetensors.h)
103105

106+
add_subdirectory(src/modeling)
107+
104108
if(ENABLE_GGUF)
105109
FetchContent_Declare(
106110
gguflib
@@ -177,10 +181,50 @@ if(NOT ENABLE_GGUF)
177181
set(GGUF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf.cpp
178182
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_quants.cpp
179183
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_modeling.cpp
184+
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_weight_finalizer.cpp
185+
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_weight_source.cpp
180186
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/building_blocks.cpp)
181187
list(REMOVE_ITEM SOURCE_FILES ${GGUF_SOURCES})
182188
endif()
183189

190+
# Safetensors support - requires ENABLE_GGUF for building_blocks
191+
if(NOT ENABLE_GGUF OR NOT ENABLE_SAFETENSORS)
192+
set(SAFETENSORS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/safetensors_utils/hf_config.cpp
193+
${CMAKE_CURRENT_SOURCE_DIR}/src/safetensors_utils/safetensors_loader.cpp
194+
${CMAKE_CURRENT_SOURCE_DIR}/src/safetensors_utils/safetensors_modeling.cpp
195+
${CMAKE_CURRENT_SOURCE_DIR}/src/safetensors_utils/safetensors_weight_source.cpp
196+
${CMAKE_CURRENT_SOURCE_DIR}/src/safetensors_utils/safetensors_weight_finalizer.cpp)
197+
list(REMOVE_ITEM SOURCE_FILES ${SAFETENSORS_SOURCES})
198+
endif()
199+
200+
# New multi-format loaders - conditional compilation
201+
if(NOT ENABLE_GGUF)
202+
set(GGUF_LOADER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/loaders/gguf/gguf_loader.cpp)
203+
list(REMOVE_ITEM SOURCE_FILES ${GGUF_LOADER_SOURCES})
204+
endif()
205+
206+
if(NOT ENABLE_GGUF OR NOT ENABLE_SAFETENSORS)
207+
set(SAFETENSORS_LOADER_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/loaders/safetensors/safetensors_loader.cpp)
208+
list(REMOVE_ITEM SOURCE_FILES ${SAFETENSORS_LOADER_SOURCES})
209+
endif()
210+
211+
# Exclude sources requiring new-arch OpenVINO operations (LinearAttention, MOE, FusedMLP, PlaceholderExtension)
212+
file(GLOB_RECURSE NEW_ARCH_MODEL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/modeling/models/*.cpp")
213+
list(REMOVE_ITEM SOURCE_FILES ${NEW_ARCH_MODEL_SOURCES})
214+
list(REMOVE_ITEM SOURCE_FILES
215+
"${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/building_blocks.cpp"
216+
"${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_modeling.cpp"
217+
"${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_weight_finalizer.cpp"
218+
"${CMAKE_CURRENT_SOURCE_DIR}/src/safetensors_utils/safetensors_modeling.cpp"
219+
"${CMAKE_CURRENT_SOURCE_DIR}/src/loaders/gguf/gguf_loader.cpp")
220+
221+
# Re-add qwen3_omni, qwen3_tts, and qwen3_vl model sources needed by always-built sample targets
222+
file(GLOB QWEN3_OMNI_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/modeling/models/qwen3_omni/*.cpp")
223+
file(GLOB QWEN3_TTS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/modeling/models/qwen3_tts/*.cpp")
224+
list(APPEND SOURCE_FILES ${QWEN3_OMNI_SOURCES} ${QWEN3_TTS_SOURCES})
225+
list(APPEND SOURCE_FILES
226+
"${CMAKE_CURRENT_SOURCE_DIR}/src/modeling/models/qwen3_vl/processing_qwen3_vl.cpp")
227+
184228
set(TARGET_NAME openvino_genai)
185229
set(TARGET_NAME_OBJ ${TARGET_NAME}_obj)
186230

@@ -200,9 +244,14 @@ if(ENABLE_GGUF)
200244
target_compile_definitions(${TARGET_NAME_OBJ} PRIVATE ENABLE_GGUF)
201245
endif()
202246

247+
if(ENABLE_GGUF AND ENABLE_SAFETENSORS)
248+
target_compile_definitions(${TARGET_NAME_OBJ} PRIVATE ENABLE_SAFETENSORS)
249+
endif()
250+
251+
203252
target_include_directories(${TARGET_NAME_OBJ} SYSTEM PRIVATE "${safetensors.h_SOURCE_DIR}")
204253

205-
target_link_libraries(${TARGET_NAME_OBJ} PRIVATE openvino::runtime openvino::threading nlohmann_json::nlohmann_json minja)
254+
target_link_libraries(${TARGET_NAME_OBJ} PRIVATE openvino::runtime openvino::core::dev openvino::threading nlohmann_json::nlohmann_json minja)
206255

207256
# Add OpenCL support if enabled via OpenVINO configuration
208257
if(ENABLE_SYSTEM_OPENCL AND TARGET OpenCL::OpenCL AND (DEFINED OpenCL_HPP_INCLUDE_DIR OR DEFINED CL2_HPP_INCLUDE_DIR))
@@ -224,8 +273,8 @@ endif()
224273
# Add native CPU optimization for SIMD instructions
225274
if (ARCH_DIR STREQUAL "intel64")
226275
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
227-
# Force AVX2 only (disable AVX512)
228-
target_compile_options(${TARGET_NAME_OBJ} PRIVATE "-mavx2" "-mno-avx512f")
276+
# Force AVX2 + F16C (disable AVX512). F16C is needed for _mm256_cvtph_ps in rtn_quantize.hpp
277+
target_compile_options(${TARGET_NAME_OBJ} PRIVATE "-mavx2" "-mf16c" "-mno-avx512f")
229278
message(STATUS "Enable SIMD compilation for ${TARGET_NAME_OBJ}")
230279
elseif(MSVC)
231280
target_compile_options(${TARGET_NAME_OBJ} PRIVATE "/arch:AVX2")
@@ -316,6 +365,7 @@ if(rpaths)
316365
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "${rpaths}")
317366
endif()
318367

368+
319369
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOGenAITargets
320370
LIBRARY DESTINATION ${LIBRARY_DESTINATION} COMPONENT core_genai
321371
NAMELINK_COMPONENT core_genai_dev

0 commit comments

Comments
 (0)