diff --git a/.github/workflows/genai_package.yml b/.github/workflows/genai_package.yml
new file mode 100644
index 0000000000..b6f1647c7a
--- /dev/null
+++ b/.github/workflows/genai_package.yml
@@ -0,0 +1,47 @@
+name: genai_package
+on: pull_request
+jobs:
+ ubuntu_genai_package:
+ if: false
+ runs-on: ubuntu-20.04
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ submodules: recursive
+ - uses: actions/setup-python@v4
+ with:
+ python-version: 3.8
+ - run: mkdir ./ov/
+ - run: curl https://storage.openvinotoolkit.org/repositories/openvino/packages/2024.1/linux/l_openvino_toolkit_ubuntu20_2024.1.0.15008.f4afc983258_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz
+ - run: sudo ./ov/install_dependencies/install_openvino_dependencies.sh
+ - run: source ./ov/setupvars.sh && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
+ - run: source ./ov/setupvars.sh && cmake --build ./build/ --config Release --target package -j
+ - run: source ./ov/setupvars.sh && cmake --install ./build/ --config Release --prefix ov
+ - run: ov/samples/cpp/build_samples.sh -b "${{ github.workspace }}/s pace"
+ - run: source ./ov/setupvars.sh && python -m pip install --upgrade-strategy eager -r text_generation/causal_lm/cpp/requirements.txt
+ - run: source ./ov/setupvars.sh && python -m pip install ./thirdparty/openvino_tokenizers/[transformers]
+ - run: source ./ov/setupvars.sh && optimum-cli export openvino --trust-remote-code --weight-format fp16 --model TinyLlama/TinyLlama-1.1B-Chat-v1.0 TinyLlama-1.1B-Chat-v1.0
+ - run: source ./ov/setupvars.sh && timeout 50s "${{ github.workspace }}/s pace/intel64/Release/greedy_causal_lm" .\TinyLlama-1.1B-Chat-v1.0\ ""
+
+ windows_genai_package:
+ runs-on: windows-latest
+ defaults:
+ run:
+ shell: cmd
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ submodules: recursive
+ - uses: actions/setup-python@v4
+ with:
+ python-version: 3.8
+ - run: curl --output ov.zip https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.2.0-15349-765302e0de1/w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64.zip
+ - run: unzip ov.zip
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && cmake --build ./build/ --config Release --target package -j
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && cmake --install ./build/ --config Release --prefix w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\samples\cpp\build_samples_msvc.bat -b "${{ github.workspace }}/samples_build"
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && python -m pip install --upgrade-strategy eager -r text_generation/causal_lm/cpp/requirements.txt
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && python -m pip install ./thirdparty/openvino_tokenizers/[transformers]
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && optimum-cli export openvino --trust-remote-code --weight-format fp16 --model TinyLlama/TinyLlama-1.1B-Chat-v1.0 TinyLlama-1.1B-Chat-v1.0
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && "${{ github.workspace }}/samples_build/intel64/Release/greedy_causal_lm" .\TinyLlama-1.1B-Chat-v1.0\ ""
diff --git a/.github/workflows/genai_lib.yml b/.github/workflows/genai_python_lib.yml
similarity index 66%
rename from .github/workflows/genai_lib.yml
rename to .github/workflows/genai_python_lib.yml
index 5b8d6db3fe..e9cfefff31 100644
--- a/.github/workflows/genai_lib.yml
+++ b/.github/workflows/genai_python_lib.yml
@@ -1,7 +1,7 @@
-name: genai_lib
+name: genai_python_lib
on: pull_request
jobs:
- genai_lib_ubuntu:
+ ubuntu_genai_python_lib:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
@@ -15,12 +15,12 @@ jobs:
- run: sudo ./ov/install_dependencies/install_openvino_dependencies.sh
- run: source ./ov/setupvars.sh && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
- run: source ./ov/setupvars.sh && cmake --build ./build/ --config Release -j
- - run: python -m pip install openvino # Can't load CentOS libraries from the archive
+ - run: python -m pip install --pre openvino --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly # Can't load CentOS libraries from the archive
- run: PYTHONPATH=./src/python/ python -c "from openvino_genai.py_generate_pipeline import LLMPipeline"
- - run: source ./ov/setupvars.sh && python -m pip install --pre --upgrade . --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
+ - run: source ./ov/setupvars.sh && python -m pip install --pre . --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
- run: python -c "from openvino_genai.py_generate_pipeline import LLMPipeline"
- genai_lib_windows:
+ windows_genai_python_lib:
runs-on: windows-latest
defaults:
run:
@@ -32,11 +32,11 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.8
- - run: curl --output ov.zip https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.1.0-14645-e6dc0865128/w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64.zip
+ - run: curl --output ov.zip https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.2.0-15349-765302e0de1/w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64.zip
- run: unzip ov.zip
- - run: call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64\setupvars.bat && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
- - run: call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64\setupvars.bat && cmake --build ./build/ --config Release -j
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && cmake --build ./build/ --config Release -j
- run: python -m pip install "numpy<1.27"
- - run: set "PYTHONPATH=./src/python;" && call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64\setupvars.bat && python -c "from openvino_genai.py_generate_pipeline import LLMPipeline" # cmd evaluates variables in a different way. Setting PYTHONPATH before setupvars.bat instead of doing that after solves that.
- - run: call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64\setupvars.bat && python -m pip install .
+ - run: set "PYTHONPATH=./src/python;" && call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && python -c "from openvino_genai.py_generate_pipeline import LLMPipeline" # cmd evaluates variables in a different way. Setting PYTHONPATH before setupvars.bat instead of doing that after solves that.
+ - run: call w_openvino_toolkit_windows_2024.2.0.dev20240515_x86_64\setupvars.bat && python -m pip install .
- run: python -c "from openvino_genai.py_generate_pipeline import LLMPipeline"
diff --git a/.gitignore b/.gitignore
index 1546c18f71..fe5cf86f7b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
# They are copied to python folder during the build to allow skipping wheel installation
-src/python/openvino_genai/*generate_pipeline_lib*
+src/python/openvino_genai/*genai*
src/python/openvino_genai/py_generate_pipeline*
# build/artifact dirs
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 754752962a..809327095c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,13 @@ cmake_minimum_required(VERSION 3.15)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake build type")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithDebInfo" "MinSizeRel")
-project(openvino_genai)
+project(openvino_genai VERSION 2024.2.0.0)
add_subdirectory(./thirdparty/openvino_tokenizers/ "${CMAKE_CURRENT_BINARY_DIR}/openvino_tokenizers/")
add_subdirectory(src)
add_subdirectory(text_generation/causal_lm/cpp)
+
+install(DIRECTORY text_generation/causal_lm/cpp/ DESTINATION samples/cpp/causal_lm COMPONENT cpp_samples_genai)
+install(FILES LICENSE third-party-programs.txt DESTINATION licensing_genai COMPONENT licensing_genai) # TODO: how to merge with OPenvino
+set(CPACK_GENERATOR "ZIP")
+include(CPack)
diff --git a/pyproject.toml b/pyproject.toml
index 007dcb11f7..cb373e12c8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -22,8 +22,8 @@ dependencies = [
[tool.scikit-build]
cmake.source-dir = "./"
cmake.build-type = "Release"
-cmake.targets = ["py_generate_pipeline", "generate_pipeline_lib"]
-install.components = ["genai", "genai_python"]
+cmake.targets = ["py_generate_pipeline", "genai"]
+install.components = ["core_genai", "pygenai"]
sdist.cmake = true
wheel.packages = ["src/python/openvino_genai"]
wheel.install-dir = "openvino_genai"
diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
index d706d32356..ffe28a81df 100644
--- a/src/cpp/CMakeLists.txt
+++ b/src/cpp/CMakeLists.txt
@@ -44,13 +44,14 @@ ov_genai_build_jinja2cpp()
file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
-set(TARGET_NAME generate_pipeline_lib)
+set(TARGET_NAME genai)
add_library(${TARGET_NAME} SHARED ${SOURCE_FILES})
+add_library(openvino::${TARGET_NAME} ALIAS ${TARGET_NAME})
target_include_directories(${TARGET_NAME}
# TODO: remove it, because beam_search algo should not be exposed to end users
- PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../text_generation/causal_lm/cpp/
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
+ PRIVATE "$"
+ PUBLIC "$" "$")
target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime PRIVATE nlohmann_json::nlohmann_json jinja2cpp)
@@ -58,11 +59,47 @@ target_compile_definitions(${TARGET_NAME} PRIVATE OPENVINO_TOKENIZERS_PATH=\"$"
- "${CMAKE_CURRENT_SOURCE_DIR}/../python/openvino_genai/$"
- COMMENT "Copy generate_pipeline_lib to src/python/openvino_genai")
+ "$"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../python/openvino_genai/$"
+ COMMENT "Copy ${TARGET_NAME} to src/python/openvino_genai")
+
+install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION . COMPONENT core_genai RUNTIME DESTINATION . COMPONENT core_genai)
+
+# - Windows: `\runtime\bin\intel64\Release\`
+# - MacOS_x86: `/runtime/lib/intel64/Release`
+# - MacOS_arm64: `/runtime/lib/arm64/Release/`
+# - Linux_x86: `/runtime/lib/intel64/`
+# - Linux_arm64: `/runtime/lib/aarch64/`
+string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCH_DIR)
+if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
+ set(ARCH_DIR intel64)
+elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^(arm64.*|aarch64.*|AARCH64.*|ARM64.*)")
+ if(APPLE)
+ set(ARCH_DIR "arm64")
+ else()
+ set(ARCH_DIR "aarch64")
+ endif()
+elseif(ARCH_DIR STREQUAL "x86_64" OR ARCH_DIR STREQUAL "amd64" # Windows detects Intel's 64-bit CPU as AMD64
+ OR CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
+ set(ARCH_DIR intel64)
+endif()
+if(MSVC OR APPLE)
+ set(ARCH_DIR ${ARCH_DIR}/${CMAKE_BUILD_TYPE})
+endif()
+install(TARGETS ${TARGET_NAME} EXPORT openvino_genaiTargets
+ LIBRARY DESTINATION runtime/lib/${ARCH_DIR} COMPONENT core_genai_dev
+ ARCHIVE DESTINATION runtime/lib/${ARCH_DIR} COMPONENT core_genai_dev
+ RUNTIME DESTINATION runtime/bin/${ARCH_DIR} COMPONENT core_genai_dev
+ INCLUDES DESTINATION runtime/include)
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION runtime/include COMPONENT core_genai_dev)
+install(EXPORT openvino_genaiTargets FILE openvino_genaiTargets.cmake NAMESPACE openvino:: DESTINATION runtime/cmake)
+include(CMakePackageConfigHelpers)
+configure_package_config_file(openvino_genaiConfig.cmake.in "${CMAKE_BINARY_DIR}/openvino_genaiConfig.cmake" INSTALL_DESTINATION runtime/cmake)
+install(FILES "${CMAKE_BINARY_DIR}/openvino_genaiConfig.cmake" "${CMAKE_BINARY_DIR}/openvino_genaiConfigVersion.cmake" DESTINATION runtime/cmake COMPONENT core_genai_dev)
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file("${CMAKE_BINARY_DIR}/openvino_genaiConfigVersion.cmake" VERSION ${CMAKE_PROJECT_VERSION} COMPATIBILITY AnyNewerVersion)
+export(EXPORT openvino_genaiTargets FILE "${CMAKE_BINARY_DIR}/openvino_genaiTargets.cmake" NAMESPACE openvino::)
+# export(TARGETS ${TARGET_NAME} NAMESPACE openvino:: FILE "${CMAKE_BINARY_DIR}/openvino_genaiConfig.cmake") TODO
diff --git a/src/cpp/include/openvino/genai/visibility.hpp b/src/cpp/include/openvino/genai/visibility.hpp
index 3a143da92a..6a8cf756e0 100644
--- a/src/cpp/include/openvino/genai/visibility.hpp
+++ b/src/cpp/include/openvino/genai/visibility.hpp
@@ -3,8 +3,8 @@
#include "openvino/core/visibility.hpp"
-#ifdef generate_pipeline_lib_EXPORTS
+#ifdef genai_EXPORTS
# define OPENVINO_GENAI_EXPORTS OPENVINO_CORE_EXPORTS
#else
# define OPENVINO_GENAI_EXPORTS OPENVINO_CORE_IMPORTS
-#endif // generate_pipeline_lib_EXPORTS
+#endif // genai_EXPORTS
diff --git a/src/cpp/openvino_genaiConfig.cmake.in b/src/cpp/openvino_genaiConfig.cmake.in
new file mode 100644
index 0000000000..abfd33b524
--- /dev/null
+++ b/src/cpp/openvino_genaiConfig.cmake.in
@@ -0,0 +1,10 @@
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(OpenVINO COMPONENTS Runtime)
+
+if(NOT TARGET genai)
+ include("${CMAKE_CURRENT_LIST_DIR}/openvino_genaiTargets.cmake")
+endif()
+
+check_required_components(openvino_genai)
diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt
index b73950e828..62f26f3215 100644
--- a/src/python/CMakeLists.txt
+++ b/src/python/CMakeLists.txt
@@ -16,16 +16,16 @@ if(NOT pybind11_POPULATED)
endif()
pybind11_add_module(py_generate_pipeline py_generate_pipeline.cpp)
-target_link_libraries(py_generate_pipeline PRIVATE generate_pipeline_lib)
+target_link_libraries(py_generate_pipeline PRIVATE genai)
-install(TARGETS py_generate_pipeline LIBRARY DESTINATION . COMPONENT genai_python)
+install(TARGETS py_generate_pipeline LIBRARY DESTINATION . COMPONENT pygenai)
# setting RPATH / LC_RPATH depending on platform
if(LINUX)
- # to find libgenerate_pipeline_lib.so in the same folder
+ # to find libgenai.so in the same folder
set(rpaths "$ORIGIN")
elseif(APPLE)
- # to find libgenerate_pipeline_lib.dylib in the same folder
+ # to find libgenai.dylib in the same folder
set(rpaths "@loader_path")
if(DEFINED SKBUILD)
# in case we build pip package, we need to refer to libopenvino.dylib from 'openvino' package
@@ -37,9 +37,12 @@ if(rpaths)
set_target_properties(py_generate_pipeline PROPERTIES INSTALL_RPATH "${rpaths}")
endif()
-# Populate python with the libraries to allow skipping wheel installation
+# Copy the library to python to allow skipping wheel installation
add_custom_command(TARGET py_generate_pipeline POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$"
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/$"
COMMENT "Copy py_generate_pipeline to src/python/openvino_genai/")
+
+find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
+install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/ DESTINATION python/openvino_genai/ COMPONENT pygenai_${Python_VERSION_MAJOR}_${Python_VERSION_MINOR})
diff --git a/text_generation/causal_lm/cpp/CMakeLists.txt b/text_generation/causal_lm/cpp/CMakeLists.txt
index 8b6281f50e..07d91e6d3b 100644
--- a/text_generation/causal_lm/cpp/CMakeLists.txt
+++ b/text_generation/causal_lm/cpp/CMakeLists.txt
@@ -4,23 +4,30 @@
cmake_minimum_required(VERSION 3.15)
project(causal_lm)
-if(NOT TARGET openvino_tokenizers)
-add_subdirectory(../../../thirdparty/openvino_tokenizers/ "${CMAKE_CURRENT_BINARY_DIR}/openvino_tokenizers/")
+if(TARGET openvino_tokenizers)
+ set(OPENVINO_TOKENIZERS_PATH $)
+else()
+ set(OPENVINO_TOKENIZERS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../bin/openvino_tokenizers.dll) # TODO: I'll go away after the generate() gets a way to find openvino_tokenizers
endif()
+find_package(openvino_genai REQUIRED PATHS
+ "${CMAKE_BINARY_DIR}" # Reuse the package from the build.
+ ${OpenVINO_DIR} # GenAI may be installed alogside OpenVINO.
+)
+
add_executable(greedy_causal_lm greedy_causal_lm.cpp)
-target_compile_definitions(greedy_causal_lm PRIVATE OPENVINO_TOKENIZERS_PATH=\"$\")
-target_link_libraries(greedy_causal_lm PRIVATE generate_pipeline_lib)
+target_compile_definitions(greedy_causal_lm PRIVATE OPENVINO_TOKENIZERS_PATH="${OPENVINO_TOKENIZERS_PATH}")
+target_link_libraries(greedy_causal_lm PRIVATE openvino::genai)
set_target_properties(greedy_causal_lm PROPERTIES CXX_STANDARD 17)
set_target_properties(greedy_causal_lm PROPERTIES CXX_STANDARD_REQUIRED ON)
add_executable(beam_search_causal_lm beam_search_causal_lm.cpp)
-target_link_libraries(beam_search_causal_lm PRIVATE generate_pipeline_lib)
+target_link_libraries(beam_search_causal_lm PRIVATE openvino::genai)
set_target_properties(beam_search_causal_lm PROPERTIES CXX_STANDARD 17)
set_target_properties(beam_search_causal_lm PROPERTIES CXX_STANDARD_REQUIRED ON)
add_executable(speculative_decoding_lm speculative_decoding_lm.cpp)
-target_compile_definitions(speculative_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH=\"$\")
+target_compile_definitions(speculative_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH="${OPENVINO_TOKENIZERS_PATH}")
target_include_directories(speculative_decoding_lm PRIVATE ./)
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
target_link_libraries(speculative_decoding_lm PRIVATE openvino::runtime)
@@ -30,7 +37,7 @@ find_package(TBB REQUIRED COMPONENTS tbb)
target_link_libraries(speculative_decoding_lm PRIVATE TBB::tbb)
add_executable(prompt_lookup_decoding_lm prompt_lookup_decoding_lm.cpp)
-target_compile_definitions(prompt_lookup_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH=\"$\")
+target_compile_definitions(prompt_lookup_decoding_lm PRIVATE OPENVINO_TOKENIZERS_PATH="${OPENVINO_TOKENIZERS_PATH}")
target_include_directories(prompt_lookup_decoding_lm PRIVATE ./)
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
target_link_libraries(prompt_lookup_decoding_lm PRIVATE openvino::runtime)
@@ -40,13 +47,13 @@ find_package(TBB REQUIRED COMPONENTS tbb)
target_link_libraries(prompt_lookup_decoding_lm PRIVATE TBB::tbb)
add_executable(generate_sample generate_pipeline/generate_sample.cpp)
-target_link_libraries(generate_sample PRIVATE generate_pipeline_lib)
+target_link_libraries(generate_sample PRIVATE openvino::genai)
target_include_directories(generate_sample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
set_target_properties(generate_sample PROPERTIES CXX_STANDARD 17)
set_target_properties(generate_sample PROPERTIES CXX_STANDARD_REQUIRED ON)
add_executable(chat_sample generate_pipeline/chat_sample.cpp)
-target_link_libraries(chat_sample PRIVATE generate_pipeline_lib)
+target_link_libraries(chat_sample PRIVATE openvino::genai)
target_include_directories(chat_sample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
set_target_properties(chat_sample PROPERTIES CXX_STANDARD 17)
set_target_properties(chat_sample PROPERTIES CXX_STANDARD_REQUIRED ON)