{"record":{"id":"92df9a5882c6da62","repo":"moeru-ai/airi","slug":"whisper-worker-fp16-encoder-failed-falling-back","errorCode":null,"errorMessage":"[Whisper Worker] fp16 encoder failed, falling back to fp32:","messagePattern":"\\[Whisper Worker\\] fp16 encoder failed, falling back to fp32:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui/src/libs/workers/worker.ts","lineNumber":135,"sourceCode":"      progress_callback,\n    })\n\n    // NOTICE: fp16 encoder may fail on some devices/browsers. Fall back to fp32\n    // if the initial load fails. Decoder fp16 is known broken (see Issue #989).\n    // https://github.com/huggingface/transformers.js/issues/989\n    this.model ??= (async () => {\n      try {\n        return await WhisperForConditionalGeneration.from_pretrained(this.model_id!, {\n          dtype: {\n            encoder_model: 'fp16',\n            decoder_model_merged: 'q4',\n          },\n          device: actualDevice,\n          progress_callback,\n        })\n      }\n      catch (error) {\n        console.warn(\n          '[Whisper Worker] fp16 encoder failed, falling back to fp32:',\n          errorMessageFromValue(error),\n        )\n        return await WhisperForConditionalGeneration.from_pretrained(this.model_id!, {\n          dtype: {\n            encoder_model: 'fp32',\n            decoder_model_merged: 'q4',\n          },\n          device: actualDevice,\n          progress_callback,\n        })\n      }\n    })()\n\n    return Promise.all([this.tokenizer, this.processor, this.model])\n  }\n}\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui/src/libs/workers/worker.ts#L117-L153","documentation":"The Whisper web worker (transformers.js WhisperForConditionalGeneration) first tries to load the model with dtype fp16 encoder + q4 decoder; if that load fails it warns and retries with an fp32 encoder. fp16 failures are typical on devices/WebGPU adapters without shader-f16 support or on WASM fallback paths where fp16 weights cannot be decoded — the fp32 retry trades download size/speed for compatibility.","triggerScenarios":"Loading the whisper model in a browser whose WebGPU adapter lacks 'shader-f16' feature, or where WebGPU is unavailable and the WASM/device backend cannot handle fp16 encoder weights; also transient model-file fetch corruption.","commonSituations":"Older GPUs/drivers, VMs, remote desktops, some Linux Mesa setups; browser without WebGPU enabled falling back to WASM; first-run download interrupted, leaving a corrupt fp16 weight shard in cache.","solutions":["Accept the fallback — fp32 works everywhere; it just downloads more bytes and runs slower.","Check navigator.gpu && adapter.features.has('shader-f16') before expecting fp16 to work.","Clear the transformers.js model cache and retry if the fp16 error looks like a corrupt download (fetch/CRC errors rather than dtype errors).","Update GPU drivers / use a Chromium build with WebGPU to get fp16 back."],"exampleFix":"// before\ndtype: { encoder_model: 'fp16', decoder_model_merged: 'q4' }\n\n// after — pick dtype from adapter capability\nconst wantsFp16 = adapter?.features?.has('shader-f16') ?? false\ndtype: { encoder_model: wantsFp16 ? 'fp16' : 'fp32', decoder_model_merged: 'q4' }","handlingStrategy":"fallback","validationCode":"async function supportsShaderFp16(): Promise<boolean> {\n  const gpu = (navigator as any).gpu\n  if (!gpu) return false\n  const adapter = await gpu.requestAdapter()\n  return !!adapter?.features?.has('shader-f16')\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await WhisperForConditionalGeneration.from_pretrained(id, { dtype: { encoder_model: 'fp16', decoder_model_merged: 'q4' }, device })\n}\ncatch {\n  return await WhisperForConditionalGeneration.from_pretrained(id, { dtype: { encoder_model: 'fp32', decoder_model_merged: 'q4' }, device })\n}","preventionTips":["Probe adapter.features.has('shader-f16') up front and choose dtype accordingly.","Clear the model cache on suspicious fetch/decode errors before retrying.","Keep the fp32 fallback path (already present) so unsupported GPUs still work."],"tags":["transformers-js","whisper","webgpu","dtype","fallback"],"backgroundTag":"model-dtype-unsupported","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}