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
Workers: a run's camera path is always drawn on a worker's CPU slot
Adarshcbe5a975d770
diff --git a/docs/gpu-workers.md b/docs/gpu-workers.mdindex db63c656..89072d6b 100644--- a/docs/gpu-workers.md+++ b/docs/gpu-workers.md@@ -626,7 +626,16 @@ billing policy's `kinds.model3d` says, as for any other kind.A finishing job is queued once for its run (and step), even when two app processes ask at the same time, and itsresults are stored once. It waits for a CPU slot as long as its run may wait in line. If no CPU slot takes it by then,a 3D model keeps its raw GLB and a camera path's step ends with one plain sentence. While it waits, the run's place in-line is the finishing job's. When the run is canceled or deleted, its finishing jobs end too: one in line at once,+line is the finishing job's. A camera path for a run on the workers is always queued for a CPU slot, even while no+worker with one is about, and is never drawn on the studio's server. (A run on the install's own ComfyUI, on the+studio's machine, has its path drawn there, as the install's own runs do.)++A chain's later step (sent once the steps before it are done) keeps its run's class and place in line: the place of+the first job a step of the same run had on the workers, or else the time the run was made. Once a worker took any of+the run's jobs, the step has no wait limit, since the wait limit applies only before the run's first start. Only steps+of the same press of Run count (the same billing hold; with none, the same batch). A result kept from an earlier run+gives a new step neither that run's place nor its start. When two app processes run on one database (a deploy's+overlap), only the one that takes a step's turn sends it, so each step is sent once. When the run is canceled or deleted, its finishing jobs end too: one in line at once,with its files, and one that a CPU slot runs at its next progress report (the worker sends one at least every 10seconds). A 3D model finished this way waits for the output check when the run asked for one, as any run's outputs do.The time a CPU task runs is never counted as GPU time.diff --git a/src/server/generations.ts b/src/server/generations.tsindex 4a3f74dc..0651467a 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -117,7 +117,7 @@ import { renderPathVideo } from "./path-render";import { songFormat, songToolProblem } from "@/lib/lyrics";import { hostedUntested } from "@/lib/catalog/hosted-untested";import { modelToFinish, startModelFinish, startTurntable, stopModelFinish, type OutputStore } from "./model3d-finish";-import { finishTask, pathOnWorker, poolFinishes3d, startWorkerModelFinish, stopWorkerFinish, workersFinish } from "./computer/finish";+import { finishTask, pathOnWorker, poolFinishes3d, startWorkerModelFinish, stopWorkerFinish } from "./computer/finish";import { PATH_FPS, PATH_FRAMES } from "@/lib/camera-path";import { cropPicture, isCropWindow } from "./crop-picture";import { convertMask, decodePng, encodePng } from "./png";@@ -1717,9 +1717,11 @@ async function advanceDependents(): Promise<void> {const photo = withChainInputs({ ...request, chain: slots }, values as string[]).inputs?.images?.[0];const keys = request.params?.cameraPath ?? [];if (deps[i]!.provider === "mock" || !photo) values[i] = placeholderFor(slots[i]);- else if (account && stored.place === "pool" && (workersFinish("path") || finishTask(r.id, "path", i))) {- // A run on this install's GPUs: the path is drawn on a worker's CPU slot (computer/finish.ts), never here. The- // step waits for it, sweep by sweep (once queued, it stays the worker's even while no CPU slot is about).+ else if (account && stored.place === "pool" && (poolOnWorkers() || finishTask(r.id, "path", i))) {+ // A run on this install's GPUs (the workers): the path is drawn on a worker's CPU slot (computer/finish.ts),+ // never here, whether or not one is about right now. The step waits for it, sweep by sweep, in the run's place+ // in line; one no CPU slot took within the run's wait fails in plain words. (A run on this install's own+ // ComfyUI, on this machine, has its path drawn here, as the install's own runs do.)const depth = values[i]!;const got = await asRun(() => pathOnWorker(r.id, i, { photo, depth, keys, frames: PATH_FRAMES, fps: PATH_FPS }));if (got.state === "failed") throw new Error(got.error);diff --git a/tests/cpu-slot.test.ts b/tests/cpu-slot.test.tsindex e962ed36..25d112c8 100644--- a/tests/cpu-slot.test.ts+++ b/tests/cpu-slot.test.ts@@ -542,6 +542,50 @@ describe("finishing jobs and their run", () => {expect(row(id)).toMatchObject({ class: "paid", rank_at: rankAt, slot: "cpu" });});+ it("a camera-path step of an account's run on the workers is queued for a CPU slot even with none about, and never drawn here", async () => {+ const generations = await import("@/server/generations");+ const { saveFile } = await import("@/server/storage");+ const { runnerByHand, tick } = await import("./helpers/app-process");+ // A worker with no CPU slot: no worker draws camera paths right now.+ const w = addWorker();+ beat(w, { cpuSlot: null });+ expect(finish.workersFinish("path")).toBe(false);+ const still = saveFile({ data: smallPng(), contentType: "image/png", name: "still.png", source: "upload", accountId });+ const depth = saveFile({ data: smallPng(), contentType: "image/png", name: "depth.png", source: "derived", accountId });+ // The run's scene step is done (its depth picture); its next step films along the path drawn through it.+ const scene = generation(accountId, "scene");+ db().prepare("UPDATE generations SET status = 'succeeded', outputs_json = ?, completed_at = ? WHERE id = ?").run(JSON.stringify([{ url: depth.url, kind: "image" }]), Date.now(), scene);+ const step = `cpu-slot-path-step-${++gens}`;+ const now = Date.now();+ const request = {+ feature: "canvas",+ modelId: "oss-uni3c-path",+ op: "camera-path",+ prompt: "The camera flies around the subject",+ inputs: { images: [still.url] },+ chain: [{ slot: "video", render: "path" }],+ params: { numOutputs: 1, cameraPath: [{ t: 0, azimuth: 0, elevation: 0, distance: 1 }, { t: 1, azimuth: 30, elevation: 4, distance: 0.9 }] },+ account: accountId,+ place: "pool",+ };+ db()+ .prepare("INSERT INTO generations (id, feature, model_id, engine, provider, op, kind, status, request_json, outputs_json, created_at, updated_at, depends_on) VALUES (?, 'canvas', 'oss-uni3c-path', 'open', 'comfyui', 'camera-path', 'video', 'queued', ?, '[]', ?, ?, ?)")+ .run(step, JSON.stringify(request), now, now, scene);+ generations.ensureRunner();+ runnerByHand();+ await tick();+ const t = finish.finishTask(step, "path");+ expect(t, "its camera path, queued on the workers").toMatchObject({ slot: "cpu", state: "waiting", account: accountId });+ const g = generations.getGeneration(step)!;+ expect(g.status).toBe("queued");+ expect(g.message).not.toBe("Rendering the camera path");+ // Turned again, it still waits for a CPU slot: the same job, and nothing drawn on this server.+ await tick();+ expect(finish.finishTask(step, "path")!.id).toBe(t!.id);+ expect(db().prepare("SELECT COUNT(*) FROM assets WHERE generation_id = ? AND name = 'path-render.mp4'").pluck().get(step)).toBe(0);+ await generations.cancelGeneration(step);+ });+it("are queued once for a run (and step), however often they are asked", () => {const gid = generation(accountId, "image-to-3d");const queue = () => finish.queueFinish({ kind: "model3d", generationId: gid, account: accountId, inputs: [{ slot: "model", data: Buffer.from("glTF fake model bytes"), contentType: "model/gltf-binary", name: "model.glb" }], settings: { material: "auto", turntable: true } });