Skip to content
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
35 changes: 34 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,40 @@ and the OpenVINO runtime baseline evolve independently:
- **OpenVINO compatibility** changes to the pinned runtime and header
baseline.

## Unreleased
## 0.2.2

Release focused on the optional OpenVINO GenAI C API and remaining correctness
fixes.

### Nim API

- Added 150 fixed-signature raw declarations from the OpenVINO GenAI
`2026.4.1.0` C headers, tracked all 153 C symbols, and added a managed API
for LLM text and chat generation, VLM, Whisper, generation settings,
JSON/chat containers, results, synchronous streaming callbacks and
performance metrics. Raw declarations are available from
`openvino/raw/genai`; importing `openvino` does not load the optional GenAI
library.
- Added a private C adapter for the three variadic pipeline constructors. It
forwards at most 16 string property pairs without a Nim C-varargs ABI.
- Added GenAI loader configuration, runtime and model setup documentation, and
real-model LLM and Whisper integration checks under ORC and ARC.
- Reject embedded NUL characters in GenAI model paths, device names, prompts,
JSON, settings and pipeline properties before passing strings to C.
- Clear an empty stop-string list through a non-null sentinel pointer required
by the upstream C implementation.
- Report request-returned tensor storage ownership as unknown rather than
incorrectly claiming OpenVINO owns a potentially caller-provided buffer.
`storageOwnership` distinguishes unknown, OpenVINO-owned and caller-owned;
`ownsStorage` returns true only when ownership is known.

### OpenVINO compatibility

- GenAI declarations target OpenVINO GenAI `2026.4.1.0`, paired with Runtime
`2026.4.1`. Real LLM and Whisper generation was verified on Linux x86_64
with CPU; VLM, Windows/macOS, GPU and NPU GenAI execution remain unverified.
- The scope is the complete pinned GenAI C API. C++-only image/video
generation, speech generation, embeddings and reranking are not exposed.

## 0.2.1

Expand Down
17 changes: 12 additions & 5 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ e213a14). The SHA-256 of all 18 headers is recorded in docs/c-api-coverage.md an
docs/resonance-audit.md, and tests/abi compares the declarations against headers
compiled by a C compiler rather than against a transcription.

The optional modules under src/openvino/raw/genai were written by hand against
the OpenVINO GenAI C headers from tag 2026.4.1.0, commit
ab01d1771e4adaa0e1e08e9d630def170572506c. Their eight functional header
SHA-256 digests and the 153-symbol coverage contract are recorded in
docs/c-api-coverage.md. The generated C bridge for the three variadic pipeline
constructors is original adapter code; no upstream source file is copied.

Whether that requires attribution here was considered rather than assumed. The
conclusion, recorded so that a reader need not repeat the reasoning:

Expand All @@ -38,11 +45,11 @@ conclusion, recorded so that a reader need not repeat the reasoning:
upstream work has one whose contents are attributable. This file therefore
states the relationship and the provenance rather than copying anything.

No third-party source code is bundled. The package depends on the OpenVINO
runtime at run time only, loads it by name through the dynamic loader, and never
ships or installs it. The only third-party artefact this repository references is
the pinned OpenVINO wheel that CI downloads by URL and sha256, which is recorded
in ci/install-openvino.py and is not redistributed.
No third-party source code or native library is bundled. The package depends on
OpenVINO Runtime at run time and optionally on matching GenAI and Tokenizers
libraries; it loads them through the dynamic loader and never ships or installs
them. CI downloads the pinned OpenVINO wheel by URL and SHA-256, as recorded in
ci/install-openvino.py; that artifact is not redistributed.


Test fixtures
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
[![Nim](https://img.shields.io/badge/Nim-%E2%89%A52.0.0-yellow.svg)](https://nim-lang.org/)
[![OpenVINO](https://img.shields.io/badge/OpenVINO-2026.4.x-6b4fbb.svg)](https://docs.openvino.ai/)
[![Latest release](https://img.shields.io/badge/latest%20release-v0.2.1-brightgreen.svg)](https://github.com/AbyssGG/OpenVINO-Nim-API/releases/tag/v0.2.1)
[![Status](https://img.shields.io/badge/status-v0.2.2-brightgreen.svg)](https://github.com/AbyssGG/OpenVINO-Nim-API/releases/tag/v0.2.2)

**English** | [简体中文](README_zh-CN.md)

Nim bindings for the [OpenVINO](https://docs.openvino.ai/) Runtime C API.
Nim bindings for the [OpenVINO](https://docs.openvino.ai/) Runtime and GenAI C APIs.

OpenVINO Nim API provides two layers. The managed API is idiomatic Nim with
private native handles, Nim exceptions and documented ownership rules. The
Expand All @@ -21,6 +21,12 @@ Corporation.** OpenVINO is a trademark of Intel Corporation.

## Status

Version `0.2.2` adds the optional OpenVINO GenAI C API for text/chat, visual
language and Whisper workloads, and fixes remaining correctness issues. See
the [release notes](RELEASE_NOTES.md) and [GenAI guide](docs/genai.md). GenAI
uses separately installed matching native libraries; only Linux x86_64 CPU
LLM and Whisper execution has been verified so far.

Version `0.2.1` was released on 2026-11-15 with correctness and memory safety fixes. See the
[GitHub Release](https://github.com/AbyssGG/OpenVINO-Nim-API/releases/tag/v0.2.1) and [release notes](RELEASE_NOTES.md).

Expand Down Expand Up @@ -66,17 +72,18 @@ already works unless it says so.

## Feature overview

| Capability | 0.2.0 status | Notes |
| Capability | 0.2.2 status | Notes |
|---|---|---|
| Managed Nim API | Available | `Core`, `Model`, `CompiledModel`, `InferRequest`, `Tensor`, shapes and properties |
| Raw C ABI layer | Available | Import it explicitly with `openvino/raw`; pinned to OpenVINO `2026.4.1` headers |
| Raw C ABI layers | Available | Import `openvino/raw` for Runtime `2026.4.1` or `openvino/raw/genai` for GenAI `2026.4.1.0` headers |
| Synchronous CPU inference | Available | Windows and Linux x86_64 are verified in CI and on clean hosts |
| Synchronous GPU & NPU inference | Available (Windows x86_64) | Verified on Intel iGPU (`GPU.0`), NVIDIA dGPU (`GPU.1`) and Intel AI Boost (`NPU`) via `nimble testHardware` |
| Runtime discovery and diagnostics | Available | Version, device listing, symbol checks and actionable loader errors |
| Profiling and explicit blob I/O | Available | Verified on CPU, GPU and NPU; no implicit cache directory or device policy is added |
| Asynchronous inference | Available (new in 0.2.0) | `startAsync`, `wait`, `waitFor`, `cancel` and `CompletionQueue`; no Nim code runs on OpenVINO threads, so user callbacks are deliberately not offered |
| Dynamic shapes and reshape | Available (new in 0.2.0) | `PartialShape`, `Port.partialShape` and `Model.reshape`; the NPU plugin needs bounded or static shapes |
| Layout and preprocessing | Available (new in 0.2.0) | `Layout` and a declarative `PreprocessPlan` applied in one call |
| Optional OpenVINO GenAI C API | Available (new in 0.2.2) | All 153 pinned C symbols represented by 150 raw declarations and a C adapter for three variadic constructors; managed LLM/chat, VLM and Whisper APIs; real-model CPU checks cover LLM and Whisper on Linux x86_64 |
| Request pools, remote contexts | Roadmap | See [the roadmap](docs/roadmap.md) |

The roadmap is deliberately explicit about what is not implemented. See
Expand Down
8 changes: 7 additions & 1 deletion README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

[English](README.md) | **简体中文**

OpenVINO Runtime C API 的 Nim 绑定。项目主文档以英文维护,本页提供中文
OpenVINO Runtime 与 GenAI C API 的 Nim 绑定。项目主文档以英文维护,本页提供中文
入口和关键说明;API 名称、代码示例和兼容性结论以英文文档为准。

**本项目由社区维护,不是 Intel 或 OpenVINO 官方项目,也没有得到 Intel
Corporation 的认可或附属关系。** OpenVINO 是 Intel Corporation 的商标。

## 项目状态

版本 `0.2.2` 增加可选的 OpenVINO GenAI C API,覆盖文本/聊天生成、视觉语言生成和
Whisper,并修复剩余正确性问题。详见[发布说明](RELEASE_NOTES.md)和
[GenAI 指南](docs/genai.md)。GenAI 需要单独安装匹配的本机库;目前仅在 Linux
x86_64 CPU 上对真实 LLM 和 Whisper 模型完成验证。

版本 `0.2.1` 已于 2026-11-15 发布,包含正确性和内存安全修复,详见[GitHub Release](https://github.com/AbyssGG/OpenVINO-Nim-API/releases/tag/v0.2.1) 和[发布说明](RELEASE_NOTES.md)。

版本 `0.2.0` 已于 2026-10-18 发布([GitHub Release](https://github.com/AbyssGG/OpenVINO-Nim-API/releases/tag/v0.2.0)),新增异步推理(`startAsync`、`wait`、
Expand Down Expand Up @@ -102,6 +107,7 @@ Nimble 官方包索引条目已提交([nim-lang/packages #3578](https://github
- [英文入门指南](docs/getting-started.md)
- [英文 API overview](docs/api-overview.md)
- [英文 C API coverage](docs/c-api-coverage.md)
- [英文 GenAI guide](docs/genai.md)
- [英文 compatibility matrix](docs/compatibility.md)
- [英文 troubleshooting](docs/troubleshooting.md)
- [贡献指南](CONTRIBUTING.md)
Expand Down
42 changes: 30 additions & 12 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
# OpenVINO Nim API 0.2.1
# OpenVINO Nim API 0.2.2

This patch release fixes correctness and memory safety issues in the
community-maintained Nim bindings for the OpenVINO Runtime C API.
This release adds optional GenAI support and fixes correctness issues in the
community-maintained Nim bindings for the OpenVINO Runtime and GenAI C APIs.

## Added

- Raw declarations for all 150 fixed-signature functions in OpenVINO GenAI
`2026.4.1.0` C headers, tracking of all 153 C symbols, and a C adapter for
the three variadic pipeline constructors.
- Managed LLM text/chat generation, synchronous streaming, VLM generation,
Whisper transcription, generation settings, JSON/chat history, results and
performance metrics.
- Lazy GenAI library loading and a C adapter for its variadic pipeline
constructors. Core `import openvino` continues to work without GenAI installed.
- Real-model integration tests for LLM and Whisper under ORC and ARC.
- Correct handling of an empty stop-string list and embedded NUL strings.

## Fixes

- Reject tensor byte copies of Nim types containing managed references.
- Validate every shape dimension even when a zero dimension is present.
- Reject embedded NUL characters in C-bound names, properties, devices and
file paths rather than silently truncating them.
- Avoid overflowing a completion queue's deadline for very long timeouts.
- Report request-returned tensor storage ownership as unknown unless the
runtime contract guarantees ownership.
- Reject embedded NUL characters across GenAI inputs instead of silently
truncating strings at the C boundary.
- Carry forward the 0.2.1 fixes: reject tensor byte copies containing Nim
references, validate negative shape dimensions even with zero dimensions,
reject embedded NUL in existing C-bound strings, and guard long timeout
deadline arithmetic.

## Compatibility

The package targets OpenVINO `2026.4.1` and requires Nim `2.0.0` or newer.
The changes reject inputs that could previously cause incorrect behaviour.
The 0.2.1 changes have not been tested on GPU or NPU hardware.
See [the compatibility matrix](docs/compatibility.md) for previous releases.
The package targets OpenVINO Runtime `2026.4.1` and GenAI `2026.4.1.0`, and
requires Nim `2.0.0` or newer. Real GenAI execution was tested on Linux x86_64
CPU for LLM and Whisper. VLM, Windows/macOS, GPU and NPU GenAI remain unverified.
This release covers the upstream GenAI **C API**; C++-only image/video
generation, speech generation, embeddings and reranking are outside its scope.
See [the compatibility matrix](docs/compatibility.md) and [GenAI guide](docs/genai.md).

For the complete change list, see [CHANGELOG.md](CHANGELOG.md).
6 changes: 4 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ provides a bilingual entry point.
|---|---|
| I am new to the project | [Getting started](getting-started.md) |
| I need the public types and functions | [API overview](api-overview.md) |
| I need optional text, vision or speech generation | [GenAI guide](genai.md) |
| I need the generated symbol pages | [API index](api-index.html) after `nimble docs` |
| I need to know what really works | [Compatibility](compatibility.md) |
| I need to diagnose a loader or runtime failure | [Troubleshooting](troubleshooting.md) |
Expand All @@ -27,8 +28,9 @@ From the repository root:
nimble docs
```

The task generates a page for every public managed module, the explicit raw
entry point, and a merged symbol index under `build/docs`. The output is an
The task generates a page for every public managed module, including optional
GenAI, both explicit raw entry points, and a merged symbol index under
`build/docs`. The output is an
artifact in CI and can also be opened locally at `build/docs/index.html`.

## Optional GitHub Pages deployment
Expand Down
23 changes: 19 additions & 4 deletions docs/api-overview.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# API overview

OpenVINO Nim API has a small managed surface and an explicit raw C layer. The
managed surface is the compatibility target for application code; raw modules
mirror the pinned OpenVINO 2026.4 C headers and are intentionally less safe.
OpenVINO Nim API has a managed surface and explicit raw C layers. The managed
surface is the compatibility target for application code; raw modules mirror
the pinned OpenVINO Runtime 2026.4 and GenAI 2026.4.1.0 C headers and are
intentionally less safe.

## Managed modules

| Module | Main symbols | Responsibility |
|---|---|---|
| `openvino` | `newCore`, `RuntimeVersion`, exceptions | Stable import root; raw declarations are not re-exported |
| `openvino` | `newCore`, `RuntimeVersion`, exceptions, GenAI API | Stable import root; raw declarations are not re-exported |
| `openvino/core` | `Core`, `runtimeVersion`, `availableDevices` | Runtime loading, model reading, compiling and import |
| `openvino/model` | `Model`, `inputCount`, `outputCount`, `reshape` | Model metadata, const ports and reshaping |
| `openvino/node` | `Port`, `name`, `elementType`, `shape`, `partialShape`, `isDynamic` | Read-only input and output port metadata |
Expand All @@ -21,6 +22,7 @@ mirror the pinned OpenVINO 2026.4 C headers and are intentionally less safe.
| `openvino/properties` | `Property`, `enableProfiling`, `cacheDirectory` | Safe string-valued runtime properties |
| `openvino/errors` | `OpenVinoError`, `OpenVinoBusyError`, `OpenVinoCancelledError`, `OpenVinoArgumentError`, `OpenVinoLibraryError`, `OpenVinoVersionError` | Runtime, busy, cancelled, argument, loader and version failures |
| `openvino/version` | `PackageVersion`, `TargetOpenVinoVersion` | Package metadata and the pinned runtime baseline |
| `openvino/genai` | `LlmPipeline`, `VlmPipeline`, `WhisperPipeline`, configs, results | Optional managed GenAI C API; loaded only when used |

All managed handles have an idempotent `close()` and a destructor backstop.
Copying a managed value shares the native handle and closed state; it does not
Expand Down Expand Up @@ -124,6 +126,14 @@ as the request exists, and its function must not allocate, raise or touch Nim
memory. The exact symbol list and header checksums are in
[C API coverage](c-api-coverage.md).

The managed GenAI API covers the pinned GenAI C functions for text generation
and chat, visual-language generation, Whisper transcription, JSON containers,
generation settings, results and metrics. It is optional: importing
`openvino` does not load GenAI, and the GenAI C library plus its matching
Runtime and Tokenizers components are required only when a GenAI operation is
called. Streaming handlers run synchronously on the calling thread. See the
[GenAI guide](genai.md) for installation, examples and the C++-only boundary.

## Typical call sequence

1. Create a `Core` with `newCore()`.
Expand All @@ -148,6 +158,11 @@ checks element width and size, but does not convert data or distinguish
integer and floating-point types of the same width.
Match the Nim data type to the model's declared element type.

`storageOwnership` reports `soOpenVinoOwned`, `soCallerOwned` or `soUnknown`.
Request-returned tensors have unknown storage ownership: keep any external
buffer alive until all uses of the bound tensor have finished. `ownsStorage`
returns true only for known OpenVINO-owned storage.

For repeated inference, keep the compiled model and request, update input
storage with `copyFrom`, and call `infer()` again. `copyFrom` requires exactly
the tensor's element count. Read or copy each output before the next inference
Expand Down
Loading