Skip to content
1 min read · 145 words

Function: isGpuOutOfMemoryError()

ts
function isGpuOutOfMemoryError(message: string): boolean;

Defined in: src/batteries/llm/chat_common/gpu_budget.ts:62

Detect the WebGPU "out of memory / failed to allocate" family of errors from a message string.

Parameters

ParameterTypeDescription
messagestringThe error message (or any stringifiable value's String(...) form).

Returns

boolean

true when the message matches a known GPU-exhaustion signature.

Remarks

ORT-web surfaces GPU exhaustion through several non-obvious signatures depending on where the allocation failed (buffer mapping, device loss, unaligned-access fallback, Dawn validation). This matcher is the single source of truth both on-device batteries use to translate a raw provider throw into a typed, catchable E_*_GPU_OUT_OF_MEMORY. Substring/case-insensitive; intentionally broad on the well-known phrases but anchored enough not to swallow unrelated errors. Verified against the signatures observed in the flagship agent's WebGPU OOM repro (Apple Metal, 4 GiB budget).