From 0beaeab414a74f2a9c003740dbd4c8d569c23d1d Mon Sep 17 00:00:00 2001 From: techjarves Date: Sat, 13 Jun 2026 15:45:16 +0530 Subject: [PATCH] fix: resolve OpenVINO NPU and GPU backend switching/loading transition issues --- app/frontend/src/components/Generator.jsx | 2 +- .../src/components/ImageConstraints.jsx | 11 +++++------ app/frontend/src/components/ModelManager.jsx | 6 ++++-- .../openvino_npu_worker.cpython-313.pyc | Bin 12022 -> 12022 bytes 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/frontend/src/components/Generator.jsx b/app/frontend/src/components/Generator.jsx index 8fc9048..c1b2811 100644 --- a/app/frontend/src/components/Generator.jsx +++ b/app/frontend/src/components/Generator.jsx @@ -139,7 +139,7 @@ function Generator({ crashError = status.error; break; } - if (!status.running && i > 3) { + if (!status.running && !status.loading?.active && i > 3) { crashError = "The backend process terminated immediately on startup."; break; } diff --git a/app/frontend/src/components/ImageConstraints.jsx b/app/frontend/src/components/ImageConstraints.jsx index 5f23b0d..ecb9ce9 100644 --- a/app/frontend/src/components/ImageConstraints.jsx +++ b/app/frontend/src/components/ImageConstraints.jsx @@ -86,18 +86,17 @@ function ImageConstraints({ const currentBackend = constraints.backendType || "cpu"; if (backendType === currentBackend) return; - const isGpuBackend = (type) => !["cpu", "openvino-npu"].includes(type); const switchesAccelerator = - (currentBackend === "openvino-npu" && isGpuBackend(backendType)) || - (isGpuBackend(currentBackend) && backendType === "openvino-npu"); + (currentBackend === "openvino-npu" && backendType !== "openvino-npu") || + (currentBackend !== "openvino-npu" && backendType === "openvino-npu"); if (serverRunning && switchesAccelerator) { const leavingNpu = currentBackend === "openvino-npu"; const confirmed = await showConfirm({ - title: leavingNpu ? "Unload NPU Model?" : "Unload GPU Model?", + title: leavingNpu ? "Unload NPU Model?" : "Unload Model?", message: leavingNpu - ? "The OpenVINO NPU model must be unloaded before switching to the GPU backend." - : "The GPU model must be unloaded before switching to the OpenVINO NPU backend.", + ? "The OpenVINO NPU model must be unloaded before switching to the standard backend." + : "The active model must be unloaded before switching to the OpenVINO NPU backend.", confirmLabel: "Unload", cancelLabel: "Cancel", danger: true, diff --git a/app/frontend/src/components/ModelManager.jsx b/app/frontend/src/components/ModelManager.jsx index bb78cc1..179de5b 100644 --- a/app/frontend/src/components/ModelManager.jsx +++ b/app/frontend/src/components/ModelManager.jsx @@ -332,7 +332,9 @@ function ModelManager({ activeModel, setActiveModel, serverRunning, setServerRun let isReady = false; let crashError = null; - for (let i = 0; i < 240; i++) { // Poll for up to 120 seconds (240 * 500ms) + const isOpenVinoModel = modelInfo?.backendType === "openvino-npu"; + const maxStartupPolls = isOpenVinoModel ? 1200 : 240; + for (let i = 0; i < maxStartupPolls; i++) { const status = await getBackendStatus(); if (status.loading) { setModelLoadProgress({ @@ -355,7 +357,7 @@ function ModelManager({ activeModel, setActiveModel, serverRunning, setServerRun crashError = status.error; break; } - if (!status.running && i > 3) { + if (!status.running && !status.loading?.active && i > 3) { crashError = "The backend process terminated immediately on startup."; break; } diff --git a/scripts/__pycache__/openvino_npu_worker.cpython-313.pyc b/scripts/__pycache__/openvino_npu_worker.cpython-313.pyc index 4ca397fd11e61ed30690c4a1619fbd5210c8cf94..0d8ccd3e0d2d901e1c5bfbc4d9864deb539f07cc 100644 GIT binary patch delta 22 ccmews`z@CDGcPX}0}$xz=w_vCl*b%7