Skip to content

fix(session): suppress VerifyEachNodeIsAssignedToAnEp warning for explicit EP#571

Open
DingmaomaoBJTU wants to merge 1 commit into
mainfrom
qiowu/adjust_claudemd
Open

fix(session): suppress VerifyEachNodeIsAssignedToAnEp warning for explicit EP#571
DingmaomaoBJTU wants to merge 1 commit into
mainfrom
qiowu/adjust_claudemd

Conversation

@DingmaomaoBJTU
Copy link
Copy Markdown
Collaborator

Problem

winml perf -m microsoft/resnet-50 --device npu --iterations 100 emits a yellow ORT warning:

[W:onnxruntime:, session_state.cc:1316 onnxruntime::VerifyEachNodeIsAssignedToAnEp] Some nodes were not
assigned to the preferred execution providers which may or may not have an negative impact on performance.

Root cause

Two issues introduced in #404 and #440:

Issue 1 — no-ep discovery path used add_provider_for_devices.
When no --ep flag is given, ef2db0b added an EP discovery step that called add_provider_for_devices([matched]) with a single EP device. Any node that couldn't run on that EP (e.g. shape ops on NPU) fell back to CPU without CPU being a registered provider, triggering VerifyEachNodeIsAssignedToAnEp.

Issue 2 — explicit EP path registers only one provider.
When --device npu is used, the build config always sets resolved_ep="qnn", so the session always hits the explicit EP path. 6b8b004 correctly narrowed _find_ep_device to return QNN-on-NPU (instead of QNN-on-CPU as before). But with only QNN-on-NPU registered, shape ops have no registered home when they fall back to CPU → warning fires.

Fix

  1. Remove no-ep discovery block. Without --ep, fall straight to set_provider_selection_policy(PREFER_*). This is the correct abstraction when the user's intent is "prefer this device", not "use this exact EP".

  2. Register CPU as explicit fallback in the explicit EP path. After registering the primary EP via add_provider_for_devices, also register CPUExecutionProvider. Shape-related ops assigned to CPU now have a valid registered provider, silencing the warning without touching log severity levels.

Note

TODO: re-verify once zheng's PR is merged — upstream ORT changes may affect how add_provider_for_devices interacts with CPU fallback registration.

…licit EP

Two changes to _build_session_options:

1. Remove no-ep discovery path (added in ef2db0b). When no --ep is
   given, the intent is "prefer this device" — policy-based selection
   (set_provider_selection_policy) is the right abstraction. Using
   add_provider_for_devices in this path triggered
   VerifyEachNodeIsAssignedToAnEp because shape ops fell back to CPU
   without CPU being a registered provider.

2. For the explicit EP path, register CPUExecutionProvider as a second
   provider after the primary EP. Shape-related ops are intentionally
   assigned to CPU by ORT even when targeting NPU/GPU; registering CPU
   explicitly gives those nodes a valid home and silences the warning
   without suppressing ORT logs globally.

Also removes test_device_only from TestFindEpDevice — the device-only
call path (_find_ep_device with ep_name=None and a concrete device) no
longer has a production caller after the no-ep discovery block is
removed.

TODO: re-verify once zheng's PR is merged, in case upstream ORT changes
affect how add_provider_for_devices interacts with CPU fallback.
@DingmaomaoBJTU DingmaomaoBJTU marked this pull request as ready for review May 15, 2026 08:53
@DingmaomaoBJTU DingmaomaoBJTU requested a review from a team as a code owner May 15, 2026 08:53
_eps_initialized: bool = False

# EP short name -> ORT full provider name (for add_provider_for_devices matching)
_EP_NAME_MAP: ClassVar[dict[str, str]] = {
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.

use definition from constant.py

# Register CPU as explicit fallback so shape-related ops
# have a registered home and VerifyEachNodeIsAssignedToAnEp
# does not warn about unassigned nodes.
cpu_dev = self._find_ep_device(ep_name="CPUExecutionProvider", device="cpu")
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.

maybe only change this line only

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.

2 participants