Skip to content

Commit f36ecf3

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 f36ecf3

File tree

124 files changed

+32129
-1231
lines changed

Some content is hidden

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

124 files changed

+32129
-1231
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: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#
44

55
file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
6+
file(GLOB modeling_tests_src "${CMAKE_CURRENT_SOURCE_DIR}/src/modeling/tests/*.cpp")
7+
file(GLOB modeling_samples_src "${CMAKE_CURRENT_SOURCE_DIR}/src/modeling/samples/*.cpp")
8+
list(REMOVE_ITEM SOURCE_FILES ${modeling_tests_src})
9+
list(REMOVE_ITEM SOURCE_FILES ${modeling_samples_src})
610
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")
711

812
# Dependencies
@@ -101,6 +105,8 @@ FetchContent_Declare(safetensors.h
101105
URL_HASH SHA256=9aaf5961609601cf9aaa96582a207bce7c6e5fbf57ed2cc669bb7bde6a937d4b)
102106
FetchContent_MakeAvailable(safetensors.h)
103107

108+
add_subdirectory(src/modeling)
109+
104110
if(ENABLE_GGUF)
105111
FetchContent_Declare(
106112
gguflib
@@ -177,10 +183,50 @@ if(NOT ENABLE_GGUF)
177183
set(GGUF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf.cpp
178184
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_quants.cpp
179185
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_modeling.cpp
186+
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_weight_finalizer.cpp
187+
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/gguf_weight_source.cpp
180188
${CMAKE_CURRENT_SOURCE_DIR}/src/gguf_utils/building_blocks.cpp)
181189
list(REMOVE_ITEM SOURCE_FILES ${GGUF_SOURCES})
182190
endif()
183191

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

@@ -200,9 +246,14 @@ if(ENABLE_GGUF)
200246
target_compile_definitions(${TARGET_NAME_OBJ} PRIVATE ENABLE_GGUF)
201247
endif()
202248

249+
if(ENABLE_GGUF AND ENABLE_SAFETENSORS)
250+
target_compile_definitions(${TARGET_NAME_OBJ} PRIVATE ENABLE_SAFETENSORS)
251+
endif()
252+
253+
203254
target_include_directories(${TARGET_NAME_OBJ} SYSTEM PRIVATE "${safetensors.h_SOURCE_DIR}")
204255

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

207258
# Add OpenCL support if enabled via OpenVINO configuration
208259
if(ENABLE_SYSTEM_OPENCL AND TARGET OpenCL::OpenCL AND (DEFINED OpenCL_HPP_INCLUDE_DIR OR DEFINED CL2_HPP_INCLUDE_DIR))
@@ -224,8 +275,8 @@ endif()
224275
# Add native CPU optimization for SIMD instructions
225276
if (ARCH_DIR STREQUAL "intel64")
226277
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")
278+
# Force AVX2 + F16C (disable AVX512). F16C is needed for _mm256_cvtph_ps in rtn_quantize.hpp
279+
target_compile_options(${TARGET_NAME_OBJ} PRIVATE "-mavx2" "-mf16c" "-mno-avx512f")
229280
message(STATUS "Enable SIMD compilation for ${TARGET_NAME_OBJ}")
230281
elseif(MSVC)
231282
target_compile_options(${TARGET_NAME_OBJ} PRIVATE "/arch:AVX2")
@@ -316,6 +367,7 @@ if(rpaths)
316367
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "${rpaths}")
317368
endif()
318369

370+
319371
install(TARGETS ${TARGET_NAME} EXPORT OpenVINOGenAITargets
320372
LIBRARY DESTINATION ${LIBRARY_DESTINATION} COMPONENT core_genai
321373
NAMELINK_COMPONENT core_genai_dev

0 commit comments

Comments
 (0)