Skip to content

Conversation

yatarkan
Copy link
Contributor

@yatarkan yatarkan commented Oct 2, 2025

Description

transformers library starting from version 4.55 saves preprocessor_config.json a bit differently during model exporting with optimum-intel - they add some fields with null values (e.g. "crop_size" in Qwen/Qwen2.5-VL-3B-Instruct case).
GenAI is checking if the config contains specific keys (depending on the model), and if so it extracts values by the key or nested keys. Having params in json config with null values causing the error RuntimeError: [json.exception.type_error.304] cannot use at() with null.
This PR provides safe json config parsing by using read_json_param() utility function.

Ticket: 174249

Checklist:

  • Tests have been updated or added to cover the new code - N/A
  • This patch fully addresses the ticket.
  • I have made corresponding changes to the documentation - N/A

Copy link
Contributor

@Copilot Copilot AI left a comment

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 addresses a JSON config parsing issue in the VLM (Visual Language Model) processing where transformers library v4.55+ exports configs with null values that cause runtime errors. The solution replaces manual JSON key checking with the safer read_json_param() utility function across VLM configuration parsing.

  • Replaced manual contains() checks and direct at() access with read_json_param() calls
  • Added null-safety checks for array parameters in phi3_v and phi4mm models
  • Enhanced read_json_param() to support nested key paths and std::array types

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/cpp/src/visual_language/vlm_config.cpp Updated VLM config parsing to use safe read_json_param() with nested keys and added array type checks
src/cpp/src/visual_language/processor_config.cpp Replaced all manual JSON parsing with read_json_param() calls for safer config loading
src/cpp/src/json_utils.hpp Added std::array type trait and support for array types in read_json_param()

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +28 to +29
if (data[name].is_number() || data[name].is_boolean() || data[name].is_string() || data[name].is_object()
|| (is_std_array<T> && data[name].is_array())
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

[nitpick] The condition logic could be simplified and made more readable by extracting the array condition into a separate variable or reorganizing the boolean expressions for better clarity.

Suggested change
if (data[name].is_number() || data[name].is_boolean() || data[name].is_string() || data[name].is_object()
|| (is_std_array<T> && data[name].is_array())
bool is_compatible_array = is_std_array<T> && data[name].is_array();
if (data[name].is_number() || data[name].is_boolean() || data[name].is_string() || data[name].is_object()
|| is_compatible_array

Copilot uses AI. Check for mistakes.

@yatarkan yatarkan added this pull request to the merge queue Oct 6, 2025
Merged via the queue into openvinotoolkit:master with commit 5ee23bb Oct 6, 2025
142 of 148 checks passed
@yatarkan yatarkan deleted the yt/fix-null-config-params branch October 6, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants