The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Docs: the computed streaming rule, workflows that never stream, and the fallback after running out of memory
Adarshf1fd236ed38a
diff --git a/docs/adding-a-model.md b/docs/adding-a-model.mdindex 31dab439..7ec7800b 100644--- a/docs/adding-a-model.md+++ b/docs/adding-a-model.md@@ -185,10 +185,25 @@ in system RAM and stream them to the card at each step (dynamic VRAM loading). Twith enough RAM can run the workflow. How workers and a person's own GPU use it is in[Workers: Streaming from RAM](gpu-workers.md#streaming-from-ram).+A new workflow needs nothing here to stream: the computed rule reads the size of its model files from+`requirements.json`. Two cases need `workflows/comfyui/stream-needs.json`:++- **The workflow can't stream.** Its node pack loads its models itself, outside ComfyUI's model management (a wrapper+ pack with its own loader nodes and its own offloading), so dynamic VRAM loading can't move its weights. Add the pack+ to `noStream.packs`, or the workflow to `noStream.workflows`. Isolated workflows never stream, with nothing to add.++ ```json+ {+ "streams": [],+ "noStream": { "packs": ["ComfyUI-WanVideoWrapper"], "workflows": [] }+ }+ ```++- **You measured what it needs.** A measured need replaces the computed rule for that workflow. Follow these steps:+1. Measure it first: run the workflow on a card smaller than its `vramGb`, with ComfyUI's dynamic VRAM on, and note theVRAM and the RAM the run needed.-2. Add the workflow to `workflows/comfyui/stream-needs.json`, the one list of streaming needs. Workflows with the same- need share an entry:+2. Add the workflow to `streams` in `workflows/comfyui/stream-needs.json`. Workflows with the same need share an entry:```json{@@ -202,9 +217,11 @@ with enough RAM can run the workflow. How workers and a person's own GPU use it- `ramGb`: the system RAM it needs then, in GB.- A workflow is in one entry at most. The need applies to whichever file set a GPU runs (its own files or avariant's).-3. Run `node scripts/comfy/build-requirements.mjs`. It writes each need into `requirements.json` (`stream`) and stops- when a number isn't above 0, when `vramGb` isn't below the workflow's own, when a workflow isn't in the manifest or- is named twice, or when an entry has a field it doesn't know.+3. Run `node scripts/comfy/build-requirements.mjs`. It writes each need into `requirements.json` (`stream`), and+ `stream: false` for each workflow that never streams. It stops when a number isn't above 0, when `vramGb` isn't+ below the workflow's own, when a workflow isn't in the manifest or is named twice, when a pack in `noStream` isn't+ in `packs.json`, when a workflow has a streaming need and never streams, or when an entry has a field it doesn't+ know.Like every file of the catalog, a change to `stream-needs.json` (and so to `requirements.json`) changes the catalogversion, so the workers update to it.diff --git a/docs/admin-api.md b/docs/admin-api.mdindex edb7ce6d..84edefc9 100644--- a/docs/admin-api.md+++ b/docs/admin-api.md@@ -129,10 +129,10 @@ Times are epoch milliseconds and sizes are bytes. Every answer is `Cache-Control| `PATCH /api/admin/site/uploads` | any of the five, each `true` or `false` | `{ switches }`; 400 with the reason for an unknown switch or a value that isn't a boolean. A switch that is off leaves that kind of file as it is: the tool says why it can't take it, and the server's checks apply. Browsers pick it up when they next load a page || `GET /api/admin/site/runs` | | `{ failureDetail }`: what a person reads when a run of theirs on this install's GPUs fails. `full`: the plain sentence and, under it, the cleaned technical reason (ComfyUI's own: no folders, addresses, keys or prompt text); `friendly`: the plain sentence only. Settings → Failed runs is the same choice. A new install starts with `full`; an install that had runs or settings before this choice existed keeps `friendly` || `PATCH /api/admin/site/runs` | `{ "failureDetail": "full" \| "friendly" }` | `{ failureDetail }`; 400 for any other body. Runs read it the next time they are shown. A person only ever sees the details of their own runs |-| `GET /api/admin/workers` | | `{ workers, lanes }`. Each worker adds `pickOrder`, `asked: { at, words }` or null, `jobs` (each job it holds: `{ taskId, generationId, slot, lane, laneLabel, stage, state, claimedAt, startedAt, progress, progressAt, movedAt, gpuBusy, stallMs, doing, typicalMs, etaS, owners, feature?, modelName?, op?, kind? }`: `doing` is what its ComfyUI runs now (`{ node, nodeClass, nodeTitle, value?, max?, pass? }`, or null), for the owner only; `movedAt` is when the worker last saw the job move, on the site clock, or null from an older worker; `gpuBusy` is its GPU use from 0 to 100, or null; past `stallMs` without a move the worker gives the job back; `etaS` is more than 0 or null, never 0 for a running job) and `lastEvent: { at, kind, event, words }` or null |+| `GET /api/admin/workers` | | `{ workers, lanes }`. Each worker adds `pickOrder`, `noStream` (the workflows it takes only with every weight on its card, newest first: `[{ workflowId, at }]`, [gpu-workers.md](gpu-workers.md#streaming-from-ram)), `asked: { at, words }` or null, `jobs` (each job it holds: `{ taskId, generationId, slot, lane, laneLabel, stage, state, claimedAt, startedAt, progress, progressAt, movedAt, gpuBusy, stallMs, doing, typicalMs, etaS, owners, feature?, modelName?, op?, kind? }`: `doing` is what its ComfyUI runs now (`{ node, nodeClass, nodeTitle, value?, max?, pass? }`, or null), for the owner only; `movedAt` is when the worker last saw the job move, on the site clock, or null from an older worker; `gpuBusy` is its GPU use from 0 to 100, or null; past `stallMs` without a move the worker gives the job back; `etaS` is more than 0 or null, never 0 for a running job) and `lastEvent: { at, kind, event, words }` or null || `POST /api/admin/workers` | `{ name, pool? }` | 201 `{ id, token }`: the worker's token, once || `POST /api/admin/workers/{id}/update` | none | `{ worker }`: its next beat answer asks it to update now. It looks for new code at once and restarts on it after the job in hand (a person's job is never cut off). Each worker in `GET /api/admin/workers` has `update`: `state` (`current`, `updating` while behind the site's version for under 3 minutes, `behind` after), `since`, `behindMs`, `site`, `worker`, `commit` (first 12 hex), `peopleHeld`, `peopleWaiting`, `askedAt`, `words` and `needsOwner` |-| `PATCH /api/admin/workers/{id}` | any of `paused`, `pauseNow`, `drain`, `autoResume`, `hours`, `allow`, `claimAfterMs`, `switchAfterMs`, `pickOrder` (a whole number from -100 to 100, 0 by default: a free worker with a higher one gets first pick, [gpu-workers.md](gpu-workers.md#who-picks-first)), `rotate` (needs `workers:tokens`), `revoke` | `{ worker, token? }`: a new worker token after `rotate`, once. 400 with the reason for a value that isn't allowed |+| `PATCH /api/admin/workers/{id}` | any of `paused`, `pauseNow`, `drain`, `autoResume`, `hours`, `allow`, `claimAfterMs`, `switchAfterMs`, `pickOrder` (a whole number from -100 to 100, 0 by default: a free worker with a higher one gets first pick, [gpu-workers.md](gpu-workers.md#who-picks-first)), `clearNoStream` (`true` for its whole `noStream` list, or a list of workflow ids: it may stream them from RAM again), `rotate` (needs `workers:tokens`), `revoke` | `{ worker, token? }`: a new worker token after `rotate`, once. 400 with the reason for a value that isn't allowed || `GET /api/admin/workers/jobs` | `before`, `limit` (1 to 200, 50), `worker`, `generation` | `{ items, next }`: the workers' log, newest first. Each item: `{ id, at, event, workerId, workerName, taskId, generationId, principal, lane, execMs, device }` ([gpu-workers.md](gpu-workers.md)) || `GET /api/admin/workers/events` | `worker`, `kinds` (a comma list of `state`, `job`, `stage`, `looking`, `admin`, `version`, `log`; all when not given), `before`, `after`, `generation`, `limit` (1 to 500, 100) | `{ items, next, latest }`: the workers' timeline, newest first. Each item: `{ id, at, workerId, workerName, kind, event, words, taskId, generationId, lane, laneLabel, state, detail }`. `next` pages back (as `before`); `latest` is the newest row id (as `after`, for new rows only) ([gpu-workers.md](gpu-workers.md)) || `GET /api/admin/audit` | `before` (the last page's `next`), `limit` (1 to 200, default 50), `actor` (`owner`, `token` or `system`), `token` (a token id), `action`, `changes=1` (changes only: no reads, file views or refusals) | `{ items, next }` |diff --git a/docs/gpu-workers.md b/docs/gpu-workers.mdindex abee2293..eedda1d2 100644--- a/docs/gpu-workers.md+++ b/docs/gpu-workers.md@@ -439,7 +439,7 @@ A worker gets a job only when all of these are true, all in one SQLite transacti- it has the workflow's files and packs (from its inventory) and enough memory. The files are the workflow's own, orevery file of one of its model variants (see "Model variants" below), and the VRAM is that of the files it would run.A workflow's need is its whole GB less 3%, because a card reports a little less than its size (a 32 GB card shows- about 31.8 GiB). A workflow with a streaming need also runs on a smaller card with enough system RAM (see+ about 31.8 GiB). Most workflows also run on a smaller card with enough system RAM, with their weights streamed (see"Streaming from RAM" below);- it verified every run-time file the job loads (see "Run-time files" below);- the retry rule allows it: a worker that lost or failed the job gets it again only when no other worker that can run@@ -696,25 +696,57 @@ the same model in another format.### Streaming from RAMA workflow's VRAM need is for every model weight on the card. ComfyUI can keep part of the weights in system RAM and-stream them to the card at each step (dynamic VRAM loading): slower, but a smaller card runs it. A workflow may have a-streaming need, `{ vramGb, ramGb }` (`workflows/comfyui/stream-needs.json`, built into `requirements.json`;-[adding-a-model.md](adding-a-model.md#streaming-from-ram) says how to add one).--- **Which workers qualify.** A worker has the memory for a workflow when its VRAM covers the workflow's VRAM need (as- always), or when the workflow has a streaming need and the worker's VRAM covers the need's `vramGb` and its RAM covers- the need's `ramGb`. Both have the same 3% allowance as the VRAM need: a PC with 32 GB of RAM reports about 31.9 GiB.- The RAM is the one its ComfyUI reports (`ramBytes` in its facts, once its ComfyUI has started). A worker whose RAM- isn't known yet, or whose ComfyUI runs with dynamic VRAM off (`--disable-dynamic-vram`, `--highvram`, `--gpu-only`,- `--novram` or `--cpu`; `dynamicVramOff` in its facts), qualifies on VRAM only.+stream them to the card at each step (dynamic VRAM loading): slower, but a smaller card runs it.+`workflows/comfyui/stream-needs.json` (built into `requirements.json` as each workflow's `stream`;+[adding-a-model.md](adding-a-model.md#streaming-from-ram) says how to change it) holds two things:++- `streams`: measured streaming needs, `{ vramGb, ramGb }`. A workflow with one streams only when the GPU meets it.+- `noStream`: the node packs and the workflows that never stream, because their models are loaded outside ComfyUI's+ model management (a pack's own loader nodes and offloading). These workflows get `stream: false`. Isolated workflows+ never stream either. The list starts with ComfyUI-WanVideoWrapper, ComfyUI-HunyuanVideo-Foley, ComfyUI-MMAudio,+ ComfyUI-ThinkSound_Wrapper, ComfyUI-LatentSyncWrapper and kandinsky6-sr: in `requirements.json`, their model files+ are read only by the pack's own loader nodes.++Every other workflow streams by the computed rule.++- **Which workers qualify.** A worker has the memory for a workflow when one of these is true:+ 1. Its VRAM covers the workflow's VRAM need (as always).+ 2. The workflow has a measured streaming need, and the worker's VRAM covers the need's `vramGb` and its RAM covers+ the need's `ramGb`. A measured need decides alone: the computed rule doesn't apply to that workflow.+ 3. The computed rule. The workflow has no measured need and isn't `stream: false`, and all of these are true:+ - The worker's card has 8 GB or more.+ - Its VRAM covers the part of the workflow's VRAM need that isn't model files: activations, working buffers, and+ any weights the catalog doesn't list, such as files a pack downloads itself.+ - The model files it would load, plus the run-time files the run adds, plus a 2 GiB reserve, fit in its VRAM and+ its RAM together. The files are the set the worker runs: the workflow's own, or a model variant's, with sizes+ from `requirements.json`.++ The reserve comes from measured runs on a 10 GB card with 32 GB of RAM (the card reports about 10 GiB, the RAM about+ 31.9 GiB). Workflows whose model files totalled 38.4 to 39.5 GiB ran with their weights streamed: the RAM was near+ full, and the page file covered a few GB at the peak. 39.5 GiB plus the 2 GiB reserve is just under 10 + 31.9 GiB, so+ those runs qualify, and anything larger doesn't. Each VRAM and RAM figure has the same 3% allowance as the VRAM need.+ The RAM is the one the worker's ComfyUI reports (`ramBytes` in its facts, once its ComfyUI has started). A worker whose+ RAM or VRAM isn't known yet, or whose ComfyUI runs with dynamic VRAM off (`--disable-dynamic-vram`, `--highvram`,+ `--gpu-only`, `--novram` or `--cpu`; `dynamicVramOff` in its facts), qualifies on VRAM only.- **The same rule everywhere.** The claim, the check that some worker could ever run a run before it is queued, and thechoice of a model variant's files all read it (`memoryFit` and `streamFits` in `src/lib/lanes.ts`). A variant's own- VRAM need counts as the VRAM need; the workflow's streaming need applies to whichever file set the worker runs.+ VRAM need counts as the VRAM need, and its own files count for the computed rule.+- **When a streamed job runs out of memory.** The claim notes on the task that the worker took it by streaming. If that+ job then fails because it ran out of memory, the worker no longer takes that workflow by streaming. Out of memory+ means CUDA out of memory, "Allocation on device", "The paging file is too small", Python's `MemoryError` or "not+ enough memory", in the failed entry's execution error or the worker's reason. The workflow goes on the worker's list+ (`no_stream_json` on the worker, with the time; `noStream` in `GET /api/admin/workers`). If another worker can run+ the job, it goes back in line with its place kept, as a try that costs the run nothing. Its error doesn't show. With+ no other worker for it, or for a job taken with every weight on the card, or for any other error, the job fails as+ before. The worker still takes the workflow with every weight on its card. Settings → Workers shows the list on the+ worker's card, and the owner clears one entry or all of them (`PATCH /api/admin/workers/{id}` with `clearNoStream`).- **Times.** A worker that streams runs slower. Its run limits come from its own measured runs in the lane (above), sothey stay right for it.-A person's own GPU (Fuobe Connect) reads the same rule from its check: a card short of the VRAM need, whose VRAM and RAM-cover the streaming need with dynamic VRAM on, is ready, and its line says "Ready · uses system RAM, slower". A check-that didn't read the RAM counts the VRAM need only.+A person's own GPU (Fuobe Connect) reads the same rule from its check. A card short of the VRAM need, whose VRAM and RAM+meet the measured need or the computed rule with dynamic VRAM on, is ready, and its line says "Ready · uses system RAM,+slower". A check that didn't read the RAM counts the VRAM need only. A person's own GPU has no list of its own: a run+there that runs out of memory fails as before.### What the worker checks itself@@ -1206,10 +1238,14 @@ routes.`tests/worker-runner.test.ts`, `tests/worker-recovery.test.ts`, `tests/worker-parts.test.ts`,`tests/worker-turns.test.ts`, `tests/worker-turns-run.test.ts`, `tests/worker-update.test.ts`, `tests/cpu-slot.test.ts`,`tests/worker-cpu-slot.test.ts`, `tests/fuobe-connect-nodes.test.ts`, `tests/model-variants.test.ts`,- `tests/pool-model-variants.test.ts`, `tests/stream-needs.test.ts`, `tests/pool-first-pick.test.ts`). The model variant+ `tests/pool-model-variants.test.ts`, `tests/stream-needs.test.ts`, `tests/stream-oom-fallback.test.ts`,+ `tests/pool-first-pick.test.ts`, `tests/worker-build-loads.test.ts`). The model varianttests check the build's refusals, which files a worker gets by its card and its files, the swapped graph and ticket,and an older worker program. The streaming tests check the build's refusals, the memory rule (VRAM only, VRAM and- RAM, unknown RAM, dynamic VRAM off, the 3% allowance) on the claim and on a person's own GPU. The first-pick tests+ RAM, unknown RAM, dynamic VRAM off, the 3% allowance, the computed rule and its reserve, the workflows that never+ stream) on the claim and on a person's own GPU, and a streamed job that runs out of memory going to another worker.+ The worker build test builds the worker's parts into a new folder and imports every built module with Node, as+ `scripts/check-worker-build.mjs` does in the deploy workflow before each build. The first-pick testscheck that a job is left for a free worker that picks first, and taken at once when that worker is busy, paused,silent, outside its hours or can't run it, or after the grace. The CPU slot tests run a CPU task while a GPU job runs, refuse a GLB that namesan outside file on the worker, bring a turntable back with its GLB, check that an account's picture reaches its