{"record":{"id":"b9a57b10500bb7bd","repo":"moeru-ai/airi","slug":"whisperadapter-devicelosscount-device-loss-ev","errorCode":null,"errorMessage":"[WhisperAdapter] ${deviceLossCount} device-loss events recorded, promoting load from webgpu to wasm.","messagePattern":"\\[WhisperAdapter\\] (.+?) device-loss events recorded, promoting load from webgpu to wasm\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui/src/libs/inference/adapters/whisper.ts","lineNumber":310,"sourceCode":"          w.postMessage({ type: 'cancel', requestId: createRequestId(), targetRequestId: requestId })\n          const reason = signal.reason\n          reject(reason instanceof Error ? reason : new InferenceAbortError(typeof reason === 'string' ? reason : undefined))\n        }\n        signal.addEventListener('abort', abortListener)\n      }\n    })\n  }\n\n  async function load(\n    onProgress?: (p: ProgressPayload) => void,\n    options?: { signal?: AbortSignal },\n  ): Promise<void> {\n    // NOTICE: Proactive WASM promotion after repeated device-loss events.\n    // See kokoro.ts for rationale. Whisper always requests 'webgpu' from the\n    // caller today, so we only check the promotion threshold.\n    const requestedDevice = deviceLossCount >= DEVICE_LOSS_WASM_THRESHOLD ? 'wasm' : 'webgpu'\n    if (requestedDevice === 'wasm') {\n      console.warn(\n        `[WhisperAdapter] ${deviceLossCount} device-loss events recorded, `\n        + `promoting load from webgpu to wasm.`,\n      )\n    }\n    throwIfAborted(options?.signal)\n    return operationMutex.runExclusive(async () => {\n      throwIfAborted(options?.signal)\n      state = 'loading'\n      updateInferenceStatus(MODEL_NAMES.WHISPER, { state: 'downloading', device: requestedDevice as any })\n\n      return getLoadQueue().enqueue(MODEL_NAMES.WHISPER, LOAD_PRIORITY.ASR, async () => {\n        throwIfAborted(options?.signal)\n        const w = ensureWorker()\n        const requestId = createRequestId()\n\n        const readyPromise = waitForMessage(w, requestId, 'model-ready', LOAD_TIMEOUT, (data) => {\n          if (data.type === 'progress' && onProgress) {\n            const payload = data.payload","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui/src/libs/inference/adapters/whisper.ts#L292-L328","documentation":"WhisperAdapter.load() checks the shared device-loss counter; when deviceLossCount >= DEVICE_LOSS_WASM_THRESHOLD it requests 'wasm' instead of the usual 'webgpu' and warns about the promotion. Rationale mirrors kokoro.ts: after repeated WebGPU device-loss events on this device, webgpu is treated as persistently unreliable and the adapter proactively falls back to the slower-but-stable wasm backend.","triggerScenarios":"Whisper load following one or more WebGPU device-loss events earlier in the session (possibly from another model's run); drivers/browsers with flaky WebGPU compute for conv nets.","commonSituations":"Same-machine sessions where kokoro already lost the device; hybrid-GPU laptops; long-running sessions after a driver reset.","solutions":["Accept the wasm fallback for ASR (latency rises, correctness unchanged).","Update browser/drivers to reduce device-loss frequency so the threshold is never reached.","If reproducible on your hardware, file the device-loss pattern against the browser's WebGPU tracker.","To avoid the warn in kiosks, pre-select wasm for whisper on known-bad devices."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const requested = adapterHasDeviceLosses(deviceLossCount) ? 'wasm' : 'webgpu'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Share the device-loss counter concept across adapters so one model's crashes protect the others.","Surface backend selection in diagnostics UI so users understand the speed change.","Test the wasm path for whisper regularly, since promotion can silently engage."],"tags":["whisper","asr","webgpu","device-lost","wasm-fallback"],"backgroundTag":"webgpu-device-lost","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}