@@ -321,9 +321,39 @@ def test_optim_config_writes_valid_json(
321321 data = json .loads (cfg_path .read_text (encoding = "utf-8" ))
322322 assert isinstance (data , dict )
323323
324- def test_default_device_is_npu (self , onnx_model_path : Path , rules_dir : Path ) -> None :
325- """Omitting ``--device`` should use NPU as documented in --help."""
324+ def test_default_device_auto_filters_local_devices_by_ep_support (
325+ self ,
326+ onnx_model_path : Path ,
327+ rules_dir : Path ,
328+ monkeypatch : pytest .MonkeyPatch ,
329+ ) -> None :
330+ """Omitting ``--device`` uses ``auto`` and filters local devices by
331+ ``EP_SUPPORTED_DEVICES``. For pinned ``qnn`` and local CPU/GPU/NPU,
332+ execution targets are ``(qnn, GPU)`` and ``(qnn, NPU)``.
333+
334+ The test is hardware-agnostic (AMD/Intel included): local availability
335+ is controlled via monkeypatch rather than real machine capabilities.
336+
337+ This setup distinguishes auto-device behavior from an NPU-only default:
338+ NPU is supported while GPU is intentionally unsupported, so running both
339+ targets must return partial support (exit code 1).
340+ """
341+ monkeypatch .setattr (
342+ "winml.modelkit.sysinfo.device._get_available_devices" ,
343+ lambda : ["CPU" , "GPU" , "NPU" ],
344+ )
345+ monkeypatch .setattr (
346+ "winml.modelkit.commands.analyze._get_local_ep_device_pairs" ,
347+ lambda : [
348+ ("QNNExecutionProvider" , "NPU" ),
349+ ("QNNExecutionProvider" , "GPU" ),
350+ ("QNNExecutionProvider" , "CPU" ),
351+ ("DmlExecutionProvider" , "GPU" ),
352+ ("CPUExecutionProvider" , "CPU" ),
353+ ],
354+ )
326355 _write_supported_rule (rules_dir , "QNNExecutionProvider" , "NPU" )
356+ _write_supported_rule (rules_dir , "QNNExecutionProvider" , "GPU" )
327357 result = _invoke (["-m" , str (onnx_model_path ), "--ep" , "qnn" , "--quiet" ])
328358 assert result .exit_code == 0
329359
@@ -522,8 +552,7 @@ def test_dml_with_cpu_device_rejected(self, onnx_model_path: Path, rules_dir: Pa
522552 ]
523553 )
524554 assert result .exit_code == 2
525- assert "only supports" in result .output .lower ()
526- assert "gpu" in result .output .lower ()
555+ assert "no ep/device combination matched" in result .output .lower ()
527556
528557 def test_cpu_ep_with_npu_device_rejected (self , onnx_model_path : Path , rules_dir : Path ) -> None :
529558 """CPUExecutionProvider only supports CPU; --device NPU must fail."""
@@ -539,8 +568,7 @@ def test_cpu_ep_with_npu_device_rejected(self, onnx_model_path: Path, rules_dir:
539568 ]
540569 )
541570 assert result .exit_code == 2
542- assert "only supports" in result .output .lower ()
543- assert "cpu" in result .output .lower ()
571+ assert "no ep/device combination matched" in result .output .lower ()
544572
545573 def test_invalid_onnx_file_exits_two_without_traceback (
546574 self , tmp_path : Path , rules_dir : Path
0 commit comments