Skip to content

Conversation

@mzegla
Copy link
Collaborator

@mzegla mzegla commented Jan 28, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 28, 2026 10:34
Copy link
Contributor

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 modifies the plugin configuration structure to support prefix caching for NPU devices by moving NPU-specific parameters into a nested DEVICE_PROPERTIES.NPU structure instead of keeping them at the top level.

Changes:

  • Updated C++ code to check for and add NPUW_LLM_ENABLE_PREFIX_CACHING within the nested DEVICE_PROPERTIES.NPU structure
  • Modified Python export script to create the nested structure for NPU-specific properties including MAX_PROMPT_LEN and NPUW_LLM_ENABLE_PREFIX_CACHING

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/graph_export/graph_export.cpp Enhanced conflict detection to search both top-level and nested structures, and changed the insertion logic to add prefix caching parameter within DEVICE_PROPERTIES.NPU
demos/common/export_models/export_model.py Removed top-level MAX_PROMPT_LEN assignment and consolidated NPU-specific properties into the nested DEVICE_PROPERTIES.NPU structure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +623 to +630
devicePropsItr = d.FindMember("DEVICE_PROPERTIES");
}

auto npuItr = devicePropsItr->value.FindMember("NPU");
if (npuItr == devicePropsItr->value.MemberEnd()) {
rapidjson::Value npuObj(rapidjson::kObjectType);
devicePropsItr->value.AddMember("NPU", npuObj, d.GetAllocator());
npuItr = devicePropsItr->value.FindMember("NPU");
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

After adding the member in line 621, the iterator lookup in line 622 is unnecessary. The AddMember operation returns void, but you can use the newly created deviceProps object directly or leverage the fact that the member was just added to avoid the redundant FindMember call. Consider storing a reference or iterator during creation to avoid this second lookup.

Suggested change
devicePropsItr = d.FindMember("DEVICE_PROPERTIES");
}
auto npuItr = devicePropsItr->value.FindMember("NPU");
if (npuItr == devicePropsItr->value.MemberEnd()) {
rapidjson::Value npuObj(rapidjson::kObjectType);
devicePropsItr->value.AddMember("NPU", npuObj, d.GetAllocator());
npuItr = devicePropsItr->value.FindMember("NPU");
devicePropsItr = d.MemberEnd();
--devicePropsItr;
}
auto npuItr = devicePropsItr->value.FindMember("NPU");
if (npuItr == devicePropsItr->value.MemberEnd()) {
rapidjson::Value npuObj(rapidjson::kObjectType);
devicePropsItr->value.AddMember("NPU", npuObj, d.GetAllocator());
npuItr = devicePropsItr->value.MemberEnd();
--npuItr;

Copilot uses AI. Check for mistakes.
Comment on lines +629 to +633
devicePropsItr->value.AddMember("NPU", npuObj, d.GetAllocator());
npuItr = devicePropsItr->value.FindMember("NPU");
}

npuItr->value.AddMember("NPUW_LLM_ENABLE_PREFIX_CACHING", value, d.GetAllocator());
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

Similar to the DEVICE_PROPERTIES creation, after adding the NPU member in line 628, the FindMember call in line 629 is redundant. Consider refactoring to avoid this unnecessary lookup.

Suggested change
devicePropsItr->value.AddMember("NPU", npuObj, d.GetAllocator());
npuItr = devicePropsItr->value.FindMember("NPU");
}
npuItr->value.AddMember("NPUW_LLM_ENABLE_PREFIX_CACHING", value, d.GetAllocator());
npuObj.AddMember("NPUW_LLM_ENABLE_PREFIX_CACHING", value, d.GetAllocator());
devicePropsItr->value.AddMember("NPU", npuObj, d.GetAllocator());
} else {
npuItr->value.AddMember("NPUW_LLM_ENABLE_PREFIX_CACHING", value, d.GetAllocator());
}

Copilot uses AI. Check for mistakes.
Comment on lines +468 to +469
device_properties = { "NPU": npu_properties }
plugin_config['DEVICE_PROPERTIES'] = device_properties
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The variable name 'device_properties' is ambiguous since it only contains NPU properties in this context. Consider renaming to 'npu_device_properties' or using a more descriptive name to clarify that this is specifically for NPU configuration.

Suggested change
device_properties = { "NPU": npu_properties }
plugin_config['DEVICE_PROPERTIES'] = device_properties
npu_device_properties = { "NPU": npu_properties }
plugin_config['DEVICE_PROPERTIES'] = npu_device_properties

Copilot uses AI. Check for mistakes.
npu_properties['NPUW_LLM_ENABLE_PREFIX_CACHING'] = True
device_properties = { "NPU": npu_properties }
plugin_config['DEVICE_PROPERTIES'] = device_properties

Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

There is an extra blank line here. Consider removing this trailing whitespace to maintain consistent code formatting.

Suggested change

Copilot uses AI. Check for mistakes.
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