Skip to content

OpenVINOEncapsulation: map float16/bfloat16/bool (char) OV dtypes#2559

Merged
xiaoyu-work merged 1 commit into
mainfrom
fix/openvino-encapsulation-fp16-bool-dtypes
Jul 3, 2026
Merged

OpenVINOEncapsulation: map float16/bfloat16/bool (char) OV dtypes#2559
xiaoyu-work merged 1 commit into
mainfrom
fix/openvino-encapsulation-fp16-bool-dtypes

Conversation

@justinchuby

Copy link
Copy Markdown
Contributor

Problem

OpenVINOEncapsulation builds the EPContext ONNX by mapping each OpenVINO model input/output element type to an ONNX TensorProto dtype via openvino_to_onnx_dtype[str(element_type)...]. The map was missing the OpenVINO string spellings for several common types:

  • fp16 stringifies as float16 (only f16 was mapped)
  • bf16 as bfloat16 (only bf16)
  • ONNX BOOL round-trips through OpenVINO as char

As a result, encapsulating an fp16 model (e.g. an LLM decoder) or any model with a boolean mask input crashes:

File ".../openvino/encapsulation.py", line 181, in _run_single_target
    inputs.append(helper.make_tensor_value_info(name, onnx_dtype, shape_list))
TypeError: 'NoneType' object cannot be interpreted as an integer

(onnx_dtype is None because the lookup missed.)

Fix

Add the missing aliases: float16FLOAT16, bfloat16BFLOAT16, charBOOL.

Validation

With this fix, OpenVINOConversionOpenVINOEncapsulation successfully produces EPContext ONNX models for all four components of a multimodal fp16 INT4 decoder+encoders package (Gemma 4 E2B, built via MobiusBuilderOnnxKQuantQuantizationMatMulNBitsToQDQ → OpenVINO 2026.3), including the audio encoder's boolean input_features_mask. Before the fix, fp16 inputs failed immediately and the boolean-mask encoder failed with the same NoneType error.

OpenVINOEncapsulation builds the EPContext ONNX by mapping each OV model
input/output element type (via str(element_type)) to an ONNX TensorProto
dtype. The map was missing the OpenVINO spellings for a few common types:
- fp16 stringifies as 'float16' (only 'f16' was mapped),
- bf16 as 'bfloat16' (only 'bf16'),
- ONNX BOOL round-trips through OpenVINO as 'char'.

Encapsulating an fp16 model (e.g. an LLM decoder) or any model with a boolean
mask input therefore crashed with 'NoneType object cannot be interpreted as
an integer' when make_tensor_value_info received a None dtype. Add the missing
aliases.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 3, 2026 05:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves OpenVINOEncapsulation’s robustness when generating EPContext ONNX models by extending the OpenVINO element-type-string → ONNX TensorProto dtype mapping so common OpenVINO spellings don’t miss the lookup (which previously led to onnx_dtype=None and a downstream crash).

Changes:

  • Add missing FP16 alias mapping: float16TensorProto.FLOAT16
  • Add missing BF16 alias mapping: bfloat16TensorProto.BFLOAT16
  • Add alias for OpenVINO boolean round-trip spelling: charTensorProto.BOOL

Comment on lines 31 to 54
@@ -48,6 +50,7 @@ class OpenVINOEncapsulation(Pass):
"uint64_t": TensorProto.UINT64,
"bool": TensorProto.BOOL,
"boolean": TensorProto.BOOL,
"char": TensorProto.BOOL,
# Add more if needed
@xiaoyu-work xiaoyu-work merged commit d9cc5e6 into main Jul 3, 2026
13 checks passed
@xiaoyu-work xiaoyu-work deleted the fix/openvino-encapsulation-fp16-bool-dtypes branch July 3, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants