{"record":{"id":"602ec1d32ca81630","repo":"moeru-ai/airi","slug":"gpu-memory-pressure-level-math-round-usa","errorCode":null,"errorMessage":"[GPU] Memory pressure: ${level} — ${Math.round(usage.allocated / 1024 / 1024)}MB / ${Math.round(usage.budget / 1024 / 1024)}MB (models: ${usage.models.join(', ')})","messagePattern":"\\[GPU\\] Memory pressure: (.+?) — (.+?)MB / (.+?)MB \\(models: (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui/src/libs/inference/coordinator.ts","lineNumber":34,"sourceCode":"import { createLoadQueue } from './load-queue'\n\nlet coordinator: GPUResourceCoordinator | null = null\nlet loadQueue: LoadQueue | null = null\n\n/**\n * Get the global GPU resource coordinator.\n * Initializes lazily from cached WebGPU capabilities.\n */\nexport function getGPUCoordinator(): GPUResourceCoordinator {\n  if (!coordinator) {\n    const capabilities = getCachedWebGPUCapabilities()\n    const estimatedVRAM = capabilities?.estimatedVRAM ?? 0\n    coordinator = createGPUResourceCoordinator(estimatedVRAM)\n\n    // Log memory pressure events\n    coordinator.onMemoryPressure((level) => {\n      const usage = coordinator!.getUsage()\n      console.warn(\n        `[GPU] Memory pressure: ${level} — `\n        + `${Math.round(usage.allocated / 1024 / 1024)}MB / ${Math.round(usage.budget / 1024 / 1024)}MB `\n        + `(models: ${usage.models.join(', ')})`,\n      )\n    })\n  }\n\n  return coordinator\n}\n\n/**\n * Get the global model load queue.\n * Ensures only one model loads at a time to prevent\n * bandwidth competition and GPU memory spikes.\n */\nexport function getLoadQueue(): LoadQueue {\n  if (!loadQueue) {\n    loadQueue = createLoadQueue()","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui/src/libs/inference/coordinator.ts#L16-L52","documentation":"The global GPU resource coordinator tracks allocated bytes per loaded model against an estimated VRAM budget (from cached WebGPU capabilities; 0 when unavailable). When allocation crosses a pressure level it emits a memory-pressure event, and getGPUCoordinator() logs this warn with allocated/budget MB and the model list. It is an advisory signal to free models or stop loading, not an error — but ignoring it usually precedes real device-lost failures.","triggerScenarios":"Loading multiple inference models concurrently (e.g. whisper + kokoro) plus renderer work on a GPU whose estimatedVRAM is small or was cached as 0/unknown; high quantization choices inflating allocations.","commonSituations":"Low-VRAM integrated GPUs; browsers where capabilities estimation fails so budget defaults to 0; users enabling every model in settings at once.","solutions":["Unload models you are not actively using via the coordinator instead of keeping all loaded.","Prefer smaller quantizations/dtypes on devices with low estimatedVRAM.","Serialize loads through the model load queue (getModelLoadQueue) so peak allocation stays under budget.","If capabilities caching returned 0, refresh it in a supported browser so the budget is realistic."],"exampleFix":"// before\nawait kokoro.load(); await whisper.load() // both resident, pressure warn\n\n// after\nconst c = getGPUCoordinator()\nif (c.getUsage().allocated + estimate > c.getUsage().budget) {\n  await c.release('kokoro') // free before loading the next model\n}\nawait whisper.load()","handlingStrategy":"validation","validationCode":"const usage = getGPUCoordinator().getUsage()\nif (usage.allocated + incomingModelBytes > usage.budget) {\n  // release or queue instead of loading now\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Route all model loads through the coordinator/load queue so allocations are checked centrally.","Release models on feature exit instead of keeping everything resident.","Re-estimate VRAM capabilities per device and prefer smaller quantizations on low budgets."],"tags":["gpu","vram","memory-pressure","inference","coordinator"],"backgroundTag":"vram-budget-exceeded","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}