Skip to content

armgit / fuobe

Public Imported from GitHub
0

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.

GPU pre-flight: Options → Decoder as the composer sends it asks for the decoder file it loads

Claude63cbfe899126
diff --git a/src/server/gpu/gate.ts b/src/server/gpu/gate.ts
index 7d9609c4..12cab752 100644
--- a/src/server/gpu/gate.ts
+++ b/src/server/gpu/gate.ts
@@ -1,12 +1,14 @@
import "server-only";
import crypto from "node:crypto";
+import { getModel } from "@/lib/catalog";
+import { controlSets } from "@/lib/catalog/plan";
import { resolveWorkflowId } from "@/lib/comfy-variants";
import { fixPlan } from "@/lib/gpu/plan";
import { CLEAN_VAE, DECODER_PARAM, GPU_PARAM } from "@/lib/qwen21-speed";
import { H3_TIER_PARAM, H3_UNET_PARAM, withTierFile } from "@/lib/gpu/h3-tier";
import { deviceLabel, needTargets, toolReadiness } from "@/lib/gpu/readiness";
import type { FileKey, FixPlan, ToolReadiness, ToolRef } from "@/lib/gpu/types";
-import type { GenerationRequest } from "@/lib/catalog/types";
+import type { GenerationRequest, GenParams } from "@/lib/catalog/types";
import { authEnabled, crossSite, hostAllowed, validToken } from "../auth";
import { loadIndex, preflightOn } from "./index-file";
import { contextFor } from "./readiness-service";
@@ -43,6 +45,13 @@ const sha256 = (s: string) => crypto.createHash("sha256").update(s).digest("hex"
/** Needs that stop a run (a licence comes with its download; VRAM is never a need). */
const blocks = (r: ToolReadiness) => r.state === "unsupported" || r.needs.some((n) => n.kind !== "hf-licence");
+/** The decoder file a run's options pick (Options → Decoder through the model's own control sets), or one the request names. */
+export function pickedDecoder(modelId: string, extra: Record<string, unknown>): unknown {
+ const model = getModel(modelId);
+ const decoded = model ? controlSets(model, { extra } as GenParams).extra : undefined;
+ return decoded?.vae ?? (extra[DECODER_PARAM] === "clean" ? CLEAN_VAE : extra.vae);
+}
+
export async function gateGeneration(t: GpuTarget, g: GateInput): Promise<GateResult> {
if (!preflightOn() || g.skip || g.route.provider !== "comfyui" || t.kind === "none") return { ok: true };
let idx = loadIndex();
@@ -64,8 +73,9 @@ export async function gateGeneration(t: GpuTarget, g: GateInput): Promise<GateRe
});
if (!has(id)) return { ok: true };
// A decoder an option picks (Qwen-Image 2.1's "Clean" Texture-Fix VAE, MiniMax H3's Fast decode) is an optional file of the
- // graph: this run needs it.
- const picked = extra[DECODER_PARAM] === "clean" ? CLEAN_VAE : extra.vae;
+ // graph: this run needs it. The request carries the option's value ({ decoder: "clean" }); the model's control turns it into
+ // the file the run loads, as the plan does (controlSets), so the gate checks the same file.
+ const picked = pickedDecoder(g.modelId, extra);
const vae: FileKey | undefined = typeof picked === "string" ? `vae/${picked}` : undefined;
if (vae && idx.files[vae] && idx.workflows[id].optional.includes(vae) && !idx.workflows[id].files.includes(vae)) {
idx = { ...idx, workflows: { ...idx.workflows, [id]: { ...idx.workflows[id], files: [...idx.workflows[id].files, vae] } } };
diff --git a/tests/h3-any-gpu.test.ts b/tests/h3-any-gpu.test.ts
index aae86bac..a12ba2a8 100644
--- a/tests/h3-any-gpu.test.ts
+++ b/tests/h3-any-gpu.test.ts
@@ -253,6 +253,9 @@ describe("the GPU pre-flight", () => {
try {
expect(await gate({}, { gpuTier: "standard" })).toEqual({ ok: true });
expect(await gate({ vae: T.SOL_VAE }, { gpuTier: "standard" })).toMatchObject({ ok: true, warning: expect.stringMatching(/1 more thing/) });
+ // Options → Decoder as the composer sends it: the option's value, which the model's control turns into Sol's file.
+ expect(await gate({ decoder: "fast" }, { gpuTier: "standard" })).toMatchObject({ ok: true, warning: expect.stringMatching(/1 more thing/) });
+ expect(await gate({ decoder: "standard" }, { gpuTier: "standard" })).toEqual({ ok: true });
} finally {
dropSnapshots("install");
}