Skip to content
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

Add complete version information #1500

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/genai-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
with:
platform: ubuntu22
commit_packages_to_provide: wheels
revision: latest_available_commit
revision: 345163f87953fb0dd8dd590257eb7fc84378da8e

llm_bench:
name: 'LLM bench tests'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
with:
platform: ubuntu22
commit_packages_to_provide: wheels
revision: latest_available_commit
revision: 345163f87953fb0dd8dd590257eb7fc84378da8e

- name: Clone docker tag from OpenVINO repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stable_diffusion_1_5_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
with:
platform: ubuntu22
commit_packages_to_provide: wheels
revision: latest_available_commit
revision: 345163f87953fb0dd8dd590257eb7fc84378da8e

openvino_download_windows:
name: Download OpenVINO for Windows
Expand All @@ -71,7 +71,7 @@ jobs:
with:
platform: windows
commit_packages_to_provide: wheels
revision: latest_available_commit
revision: 345163f87953fb0dd8dd590257eb7fc84378da8e

stable_diffusion_1_5_cpp-linux:
runs-on: ubuntu-22.04-8-cores
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ if(NOT OpenVINODeveloperPackage_FOUND)
endif()

include(cmake/features.cmake)
include(cmake/version.cmake)

if(ENABLE_PYTHON)
# the following two calls are required for cross-compilation
Expand Down
5 changes: 0 additions & 5 deletions cmake/templates/__version__.py.in

This file was deleted.

19 changes: 19 additions & 0 deletions cmake/templates/version.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2023-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "openvino/genai/version.hpp"

namespace ov {
namespace genai {

const Version get_version() {
const static Version version = {
"@OpenVINOGenAI_FULL_VERSION@",
"OpenVINO GenAI version",
};

return version;
}

} // namespace genai
} // namespace ov
34 changes: 34 additions & 0 deletions cmake/templates/version.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (C) 2023-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#pragma once

#include "openvino/core/version.hpp"
#include "openvino/genai/visibility.hpp"

/**
* OpenVINO GenAI major version
*/
#define OPENVINO_GENAI_VERSION_MAJOR @OpenVINOGenAI_VERSION_MAJOR@

/**
* OpenVINO GenAI minor version
*/
#define OPENVINO_GENAI_VERSION_MINOR @OpenVINOGenAI_VERSION_MINOR@

/**
* OpenVINO GenAI patch version
*/
#define OPENVINO_GENAI_VERSION_PATCH @OpenVINOGenAI_VERSION_PATCH@

namespace ov {
namespace genai {

/**
* Returns OpenVINO GenAI full version including git commit and hash information in form of:
* <MAJOR>.<MINOR>.<PATCH>.<REVISION>-<COMMIT NUMBER>-<COMMIT HASH>[-<BRANCH SUFFIX>]
*/
OPENVINO_EXTERN_C OPENVINO_GENAI_EXPORTS const ov::Version OPENVINO_CDECL get_version();

} // namespace genai
} // namespace ov
72 changes: 72 additions & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

find_package(Git QUIET)

function(ov_genai_branch_name VAR)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${OpenVINOGenAI_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
RESULT_VARIABLE EXIT_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(EXIT_CODE EQUAL 0)
set(${VAR} ${GIT_BRANCH} PARENT_SCOPE)
endif()
endif()
endfunction()

function(ov_genai_commit_hash VAR)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short=11 HEAD
WORKING_DIRECTORY ${OpenVINOGenAI_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
RESULT_VARIABLE EXIT_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(EXIT_CODE EQUAL 0)
set(${VAR} ${GIT_COMMIT_HASH} PARENT_SCOPE)
endif()
endif()
endfunction()

function(ov_genai_commit_number VAR)
set(GIT_COMMIT_NUMBER_FOUND OFF)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-list --count HEAD
WORKING_DIRECTORY ${OpenVINOGenAI_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_NUMBER
RESULT_VARIABLE EXIT_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(EXIT_CODE EQUAL 0)
set(GIT_COMMIT_NUMBER_FOUND ON)
set(${VAR} ${GIT_COMMIT_NUMBER} PARENT_SCOPE)
endif()
endif()
if(NOT GIT_COMMIT_NUMBER_FOUND)
# set zeros since git is not available
set(${VAR} "000" PARENT_SCOPE)
endif()
endfunction()

function(ov_genai_full_version full_version)
if(GIT_FOUND)
ov_genai_branch_name(GIT_BRANCH)
ov_genai_commit_hash(GIT_COMMIT_HASH)
ov_genai_commit_number(GIT_COMMIT_NUMBER)

if(NOT GIT_BRANCH MATCHES "^(master|HEAD)$")
set(GIT_BRANCH_POSTFIX "-${GIT_BRANCH}")
endif()

set(${full_version} "${OpenVINOGenAI_VERSION}-${GIT_COMMIT_NUMBER}-${GIT_COMMIT_HASH}${GIT_BRANCH_POSTFIX}" PARENT_SCOPE)
else()
set(${full_version} "${OpenVINOGenAI_VERSION}" PARENT_SCOPE)
endif()
endfunction()

ov_genai_full_version(OpenVINOGenAI_FULL_VERSION)
message(STATUS "OpenVINO GenAI full version: ${OpenVINOGenAI_FULL_VERSION}")
16 changes: 15 additions & 1 deletion src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ FetchContent_MakeAvailable(safetensors.h)

ov_genai_build_jinja2cpp()

# generate version files

configure_file("${OpenVINOGenAI_SOURCE_DIR}/cmake/templates/version.hpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/openvino/genai/version.hpp" @ONLY)

configure_file("${OpenVINOGenAI_SOURCE_DIR}/cmake/templates/version.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/version.cpp" @ONLY)

# Library

file(GLOB_RECURSE SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
list(APPEND SOURCE_FILES "${CMAKE_CURRENT_BINARY_DIR}/version.cpp")

set(TARGET_NAME openvino_genai)

Expand All @@ -68,7 +77,9 @@ if(TARGET openvino_tokenizers)
endif()

target_include_directories(${TARGET_NAME}
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" "$<INSTALL_INTERFACE:runtime/include>"
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:runtime/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")

target_include_directories(${TARGET_NAME} SYSTEM PRIVATE "${safetensors.h_SOURCE_DIR}")
Expand Down Expand Up @@ -145,6 +156,9 @@ install(TARGETS ${TARGET_NAME} EXPORT OpenVINOGenAITargets

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION runtime/include COMPONENT core_genai_dev)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvino/genai/version.hpp
DESTINATION runtime/include/openvino/genai COMPONENT core_genai_dev)

install(EXPORT OpenVINOGenAITargets FILE OpenVINOGenAITargets.cmake
NAMESPACE openvino:: DESTINATION runtime/cmake
COMPONENT core_genai_dev)
Expand Down
16 changes: 6 additions & 10 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/py_openvino_genai.pyi"
DESTINATION "${CMAKE_BINARY_DIR}/openvino_genai/")

configure_file("${OpenVINOGenAI_SOURCE_DIR}/cmake/templates/__version__.py.in"
"${CMAKE_BINARY_DIR}/openvino_genai/__version__.py" @ONLY)

if(OpenVINODeveloperPackage_FOUND)
# TODO: commit changes separately
# ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
Expand Down Expand Up @@ -69,18 +66,12 @@ endif()
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.pyi"
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/py_openvino_genai.pyi"
"${CMAKE_BINARY_DIR}/openvino_genai/__version__.py"
DESTINATION python/openvino_genai
COMPONENT pygenai_${Python3_VERSION_MAJOR}_${Python3_VERSION_MINOR})
install(TARGETS ${TARGET_NAME}
LIBRARY DESTINATION python/openvino_genai
COMPONENT pygenai_${Python3_VERSION_MAJOR}_${Python3_VERSION_MINOR})

install(FILES "${CMAKE_BINARY_DIR}/openvino_genai/__version__.py"
DESTINATION openvino_genai
COMPONENT wheel_genai
EXCLUDE_FROM_ALL)

install(FILES "${OpenVINOGenAI_SOURCE_DIR}/LICENSE"
"${OpenVINOGenAI_SOURCE_DIR}/third-party-programs.txt"
"${OpenVINOGenAI_SOURCE_DIR}/SECURITY.md"
Expand Down Expand Up @@ -154,7 +145,8 @@ if(pybind11_stubgen_AVAILABLE)
endif()

set(stub_files_location "${OpenVINOGenAI_BINARY_DIR}/src/python")
set(generated_files ${stub_files_location}/openvino_genai/__init__.pyi
set(init_pyi_file "${stub_files_location}/openvino_genai/__init__.pyi")
set(generated_files ${init_pyi_file}
${stub_files_location}/openvino_genai/py_openvino_genai.pyi)
set_source_files_properties(${generated_files} PROPERTIES GENERATED ON)

Expand Down Expand Up @@ -184,6 +176,9 @@ if(pybind11_stubgen_AVAILABLE)
"${CMAKE_BINARY_DIR}/openvino_genai/py_openvino_genai.pyi"
COMMAND "${CMAKE_COMMAND}" -E env PYTHONPATH=${CMAKE_BINARY_DIR}:${openvino_pythonpath}:$ENV{PYTHONPATH}
${pybind11_stubgen} --output-dir ${stub_files_location} openvino_genai
COMMAND "${CMAKE_COMMAND}"
-D init_pyi_file=${init_pyi_file}
-P "${CMAKE_CURRENT_SOURCE_DIR}/clean_version.cmake"
${validation_command}
${copy_to_source_command}
COMMAND "${CMAKE_COMMAND}" -E copy ${generated_files} "${CMAKE_BINARY_DIR}/openvino_genai/"
Expand All @@ -192,6 +187,7 @@ if(pybind11_stubgen_AVAILABLE)
${python_sources}
${validation_dependencies}
"${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/clean_version.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/compare_pyi.cmake"
COMMENT "[${pybind11_stubgen_dep}] Generate .pyi files"
VERBATIM)
Expand Down
21 changes: 21 additions & 0 deletions src/python/clean_version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

foreach(var IN ITEMS init_pyi_file)
if(NOT DEFINED ${var})
message(FATAL_ERROR "Variable ${var} is not defined")
endif()
endforeach()

file(STRINGS ${init_pyi_file} file_lines)

foreach(file_line IN LISTS file_lines)
if(file_line MATCHES "^__version__.*")
set(file_line "__version__: str")
endif()

set(file_content "${file_content}${file_line}\n")
endforeach()

file(WRITE ${init_pyi_file} ${file_content})
5 changes: 3 additions & 2 deletions src/python/openvino_genai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

import openvino # add_dll_directory for openvino lib
import os
from .__version__ import __version__


if hasattr(os, "add_dll_directory"):
os.add_dll_directory(os.path.dirname(__file__))
Expand All @@ -17,8 +15,11 @@
RawPerfMetrics,
PerfMetrics,
StreamerBase,
get_version,
)

__version__ = get_version()

# VLM pipeline

from .py_openvino_genai import (
Expand Down
5 changes: 3 additions & 2 deletions src/python/openvino_genai/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ from openvino_genai.py_openvino_genai import WhisperPerfMetrics
from openvino_genai.py_openvino_genai import WhisperPipeline
from openvino_genai.py_openvino_genai import WhisperRawPerfMetrics
from openvino_genai.py_openvino_genai import draft_model
from openvino_genai.py_openvino_genai import get_version
import os as os
from . import py_openvino_genai
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationResult', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'PerfMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMPipeline', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model', 'openvino', 'os', 'py_openvino_genai']
__version__: str = '2025.0.0.0'
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationResult', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'PerfMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMPipeline', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model', 'get_version', 'openvino', 'os', 'py_openvino_genai']
__version__: str
6 changes: 5 additions & 1 deletion src/python/openvino_genai/py_openvino_genai.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from __future__ import annotations
import openvino._pyopenvino
import os
import typing
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedGenerationResult', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationFinishReason', 'GenerationHandle', 'GenerationOutput', 'GenerationResult', 'GenerationStatus', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'MeanStdPair', 'PerfMetrics', 'PipelineMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMDecodedResults', 'VLMPerfMetrics', 'VLMPipeline', 'VLMRawPerfMetrics', 'WhisperDecodedResultChunk', 'WhisperDecodedResults', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model']
__all__ = ['Adapter', 'AdapterConfig', 'AggregationMode', 'AutoencoderKL', 'CLIPTextModel', 'CLIPTextModelWithProjection', 'CacheEvictionConfig', 'ChunkStreamerBase', 'ContinuousBatchingPipeline', 'CppStdGenerator', 'DecodedResults', 'EncodedGenerationResult', 'EncodedResults', 'FluxTransformer2DModel', 'GenerationConfig', 'GenerationFinishReason', 'GenerationHandle', 'GenerationOutput', 'GenerationResult', 'GenerationStatus', 'Generator', 'Image2ImagePipeline', 'ImageGenerationConfig', 'InpaintingPipeline', 'LLMPipeline', 'MeanStdPair', 'PerfMetrics', 'PipelineMetrics', 'RawPerfMetrics', 'SD3Transformer2DModel', 'Scheduler', 'SchedulerConfig', 'StopCriteria', 'StreamerBase', 'T5EncoderModel', 'Text2ImagePipeline', 'TokenizedInputs', 'Tokenizer', 'TorchGenerator', 'UNet2DConditionModel', 'VLMDecodedResults', 'VLMPerfMetrics', 'VLMPipeline', 'VLMRawPerfMetrics', 'WhisperDecodedResultChunk', 'WhisperDecodedResults', 'WhisperGenerationConfig', 'WhisperPerfMetrics', 'WhisperPipeline', 'WhisperRawPerfMetrics', 'draft_model', 'get_version']
class Adapter:
"""
Immutable LoRA Adapter that carries the adaptation matrices and serves as unique adapter identifier.
Expand Down Expand Up @@ -2204,3 +2204,7 @@ def draft_model(models_path: os.PathLike, device: str = '', **kwargs) -> openvin
"""
device on which inference will be performed
"""
def get_version() -> str:
"""
OpenVINO GenAI version
"""
7 changes: 7 additions & 0 deletions src/python/py_openvino_genai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <pybind11/typing.h>

#include "openvino/genai/llm_pipeline.hpp"
#include "openvino/genai/version.hpp"

#include "py_utils.hpp"

Expand All @@ -21,6 +22,7 @@ using ov::genai::DecodedResults;
using ov::genai::EncodedResults;
using ov::genai::StreamerBase;
using ov::genai::StringInputs;
using ov::genai::get_version;

void init_lora_adapter(py::module_& m);
void init_perf_metrics(py::module_& m);
Expand Down Expand Up @@ -82,7 +84,12 @@ class ConstructableStreamer: public StreamerBase {
PYBIND11_MODULE(py_openvino_genai, m) {
m.doc() = "Pybind11 binding for OpenVINO GenAI library";

m.def("get_version", [] () -> py::str {
return get_version().buildNumber;
}, get_version().description);

init_perf_metrics(m);

py::class_<DecodedResults>(m, "DecodedResults", decoded_results_docstring)
.def(py::init<>())
.def_property_readonly("texts", [](const DecodedResults &dr) -> py::typing::List<py::str> { return pyutils::handle_utf8((std::vector<std::string>)dr); })
Expand Down
Loading