{"record":{"id":"4eac246131db848b","repo":"moeru-ai/airi","slug":"kokoro-worker-failed-with-dtype-attempt-dtype","errorCode":null,"errorMessage":"[Kokoro Worker] Failed with dtype=${attempt.dtype} device=${attempt.device}, trying next fallback...","messagePattern":"\\[Kokoro Worker\\] Failed with dtype=(.+?) device=(.+?), trying next fallback\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui/src/workers/kokoro/worker.ts","lineNumber":206,"sourceCode":"          return\n        }\n        const ready: ModelReadyResponse = {\n          type: 'model-ready',\n          requestId,\n          modelId: MODEL_NAMES.KOKORO,\n          device: attempt.device as 'webgpu' | 'wasm' | 'cpu',\n          metadata: {\n            voices: ttsModel.voices,\n            actualDtype: attempt.dtype,\n            actualDevice: attempt.device,\n          },\n        }\n        globalThis.postMessage(ready)\n        return\n      }\n      catch (error) {\n        lastError = error\n        console.warn(\n          `[Kokoro Worker] Failed with dtype=${attempt.dtype} device=${attempt.device}, trying next fallback...`,\n          errorMessageFromValue(error),\n        )\n      }\n    }\n\n    // All attempts exhausted\n    if (isCancelled(requestId))\n      clearCancelled(requestId)\n    else\n      sendError(requestId, lastError ?? new Error('All dtype/device combinations failed'), 'load')\n  }\n  catch (error) {\n    if (isCancelled(requestId))\n      clearCancelled(requestId)\n    else\n      sendError(requestId, error, 'load')\n  }","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui/src/workers/kokoro/worker.ts#L188-L224","documentation":"Inside the Kokoro TTS worker, one dtype/device load attempt (e.g. fp32 on webgpu) failed; the loop moves to the next fallback combination and logs the pair that failed. If every combination fails, the worker posts a sendError(requestId, lastError, 'load') message. On success, the ready message reports actualDtype/actualDevice of the winning attempt, so callers can see what was actually used.","triggerScenarios":"No WebGPU adapter (older browser, VM, Linux without GPU, flags disabled) so webgpu pairs fail; fp16 unsupported on the GPU; out-of-memory under wasm; model shard fetch failing for one dtype but not another.","commonSituations":"Running in a VM or on Linux without GPU drivers; older Safari; memory-constrained devices where even wasm OOMs; corporate proxy blocking some model downloads.","solutions":["Use a WebGPU-capable browser (recent Chrome/Edge with WebGPU enabled) for GPU inference","Let the fallback chain reach wasm/cpu — slower but works everywhere","Free memory (close tabs, reduce parallel loads) if wasm attempts OOM","Verify network access to the model host when a specific dtype's shards fail to fetch","If all combos fail, read the worker's sendError 'load' payload: lastError holds the root cause"],"exampleFix":"// before\nfor (const attempt of attempts) {\n  try { /* load with attempt.dtype / attempt.device */ }\n  catch (error) {\n    console.warn(`[Kokoro Worker] Failed with dtype=${attempt.dtype} device=${attempt.device}, trying next fallback...`)\n  }\n}\n\n// after: skip doomed webgpu attempts before paying the load cost\nconst viable = attempts.filter(a => a.device !== 'webgpu' || (typeof navigator !== 'undefined' && 'gpu' in navigator))\nfor (const attempt of viable) { /* ... */ }","handlingStrategy":"fallback","validationCode":"const supportsWebGPU = typeof navigator !== 'undefined' && 'gpu' in navigator\n// skip webgpu dtype/device attempts up front when the adapter is missing","typeGuard":"function supportsWebGPU(): boolean {\n  return typeof navigator !== 'undefined' && 'gpu' in navigator\n}","tryCatchPattern":"for (const attempt of attempts) {\n  try {\n    /* load model with attempt.dtype / attempt.device */\n  }\n  catch (error) {\n    lastError = error\n    console.warn(`[Kokoro Worker] Failed with dtype=${attempt.dtype} device=${attempt.device}, trying next fallback...`, errorMessageFromValue(error))\n  }\n}\n// exhausted: sendError(requestId, lastError ?? new Error('All dtype/device combinations failed'), 'load')","preventionTips":["Feature-detect navigator.gpu before trying webgpu dtype/device pairs","Keep the wasm fallback path exercised in CI so it is known-good","Read the final sendError 'load' payload: lastError names the root cause after all combos fail","Free GPU memory and reduce parallel loads when wasm attempts OOM"],"tags":["kokoro","tts","webgpu","wasm","dtype-fallback","worker"],"backgroundTag":"webgpu-adapter-unavailable","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}