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.

Hosted runs: MiniMax H3 at 2K says its setup label before Run, and Run opens that setup

Adarsh53bbc4c3b467
diff --git a/src/app/api/generations/route.ts b/src/app/api/generations/route.ts
index 57efad4b..41b71ddf 100644
--- a/src/app/api/generations/route.ts
+++ b/src/app/api/generations/route.ts
@@ -144,7 +144,9 @@ export async function POST(request: Request) {
// quote (its words for Run) and where it would stand in line. Off, or a run on its own GPU or key: priced as before.
// (The client's address is read only for a policy that counts runs per address.)
const pool = viewer.kind !== "owner" ? await poolQuote(account, req, wish, { addr: () => clientAddress(request) }) : null;
- if (pool) {
+ // A mode that runs on the visitor's own setup only has no plan here: its label, which Run opens.
+ if (pool && !pool.planned) return Response.json({ modelId: req.modelId, place: "pool", quote: pool.quote, line: pool.line });
+ if (pool?.planned) {
const { model, ...p } = pool.planned;
return Response.json({ ...p, modelId: model.id, modelName: model.name, engine: model.engine, kind: outputKind(p.op, model), opLabel: OPERATION_LABELS[p.op] ?? p.op, place: "pool", quote: pool.quote, line: pool.line });
}
diff --git a/src/server/hosted-run.ts b/src/server/hosted-run.ts
index 30045244..c16993df 100644
--- a/src/server/hosted-run.ts
+++ b/src/server/hosted-run.ts
@@ -25,7 +25,7 @@ import {
} from "./billing";
import { getModel } from "@/lib/catalog";
import { PLACE_ASK_HEADER, RUN_PLACE_HEADER, RUN_SHOWN_HEADER } from "@/lib/guest-access";
-import { createGenerations, outputKind, plannedSteps, previewChained, previewGeneration, type PlannedStep } from "./generations";
+import { AccountRunError, createGenerations, outputKind, plannedSteps, previewChained, previewGeneration, type PlannedStep } from "./generations";
import { loadIndex } from "./gpu/index-file";
import { poolLane } from "./computer/pool";
import { HOSTED_GUEST_WORDS, HOSTED_WORDS, inputCounts, poolAllows, poolAllowsRun, poolOnWorkers, poolReady, poolRunsProvider, poolTakes, poolUploads, POOL_LANE, queueFacts, runFacts, runOnPool, workflowPicks } from "./hosted";
@@ -91,6 +91,18 @@ const billingRefusal = (code: RefuseCode | "price-changed", text: string, extra:
type Planned = ReturnType<typeof previewGeneration>;
+/**
+ * Planning a run on this install's GPUs was refused for a mode or option that runs on a visitor's own setup only (MiniMax
+ * H3 at 2K, Kandinsky 6.0 Pro: their check refuses them there before poolGate is asked): that setup, so the run and its
+ * price check say its label as poolGate would. Null for any other refusal (a cloud model without the visitor's key
+ * keeps today's answer: it never runs here).
+ */
+function refusedForOwnSetup(e: unknown, req: GenerationRequest): OwnSetup | null {
+ if (!(e instanceof AccountRunError) || req.engine === "cloud") return null;
+ const own = requestOwnSetup({ ...req, engine: "open" });
+ return own?.need === "gpu" ? own : null;
+}
+
/**
* The decision for an account's run: its own GPU or key as today, this install's GPUs, or a refusal. On this install's
* GPUs: the request as it runs there (`req`, `capped` when the policy cut its outputs), its plan, its policy, the steps
@@ -340,7 +352,10 @@ export async function decidePlace(account: Account, asked: GenerationRequest, wi
let planned: Planned;
try {
planned = runOnPool(account.id, () => previewGeneration(asked));
- } catch {
+ } catch (e) {
+ // A mode that runs on the visitor's own setup only: its own GPU when it has one, else refused in its label's words.
+ const own = refusedForOwnSetup(e, asked);
+ if (own && !accountGpu(account.id)) return gateRefusal({ ok: false, reason: "ownSetup", setup: own });
// A paid model, a model switched off, a request with something wrong: today's path says what.
return OWN;
}
@@ -524,7 +539,7 @@ export async function poolQuote(
asked: GenerationRequest,
wish: PlaceWish,
o: { addr?: () => string | null } = {},
-): Promise<{ planned: Planned; quote: Quote; line: PoolLine } | null> {
+): Promise<{ planned: Planned | null; quote: Quote; line: PoolLine } | null> {
if (!hostedRunsOn() || wish === "own" || !poolReady()) return null;
// A guest is priced under the billing service's policy for guests (none set: as an account would be, once signed up).
const p = await billingPolicy(account?.id ?? null);
@@ -533,7 +548,11 @@ export async function poolQuote(
let planned: Planned;
try {
planned = runOnPool(account?.id ?? null, () => previewGeneration(req));
- } catch {
+ } catch (e) {
+ // A mode that runs on the visitor's own setup only, for a viewer with no GPU of its own: Run says its label and opens
+ // that setup (no plan to show: it never runs here).
+ const own = refusedForOwnSetup(e, req);
+ if (own && !(account && accountGpu(account.id)) && !(p && !p.hosted)) return { planned: null, quote: gateQuote({ ok: false, reason: "ownSetup", setup: own }, !account), line: { place: 1, etaSeconds: null } };
return null;
}
if (planned.route.provider !== "comfyui") return null;
diff --git a/tests/hosted-runs-kandinsky6.test.ts b/tests/hosted-runs-kandinsky6.test.ts
index 85c760f3..f7b2aa5f 100644
--- a/tests/hosted-runs-kandinsky6.test.ts
+++ b/tests/hosted-runs-kandinsky6.test.ts
@@ -55,8 +55,8 @@ describe("Kandinsky 6.0 on this install's GPUs", () => {
const before = fake.calls_of("/v1/quote").length;
const q = await poolQuote(account, t2v, undefined);
expect(q).not.toBeNull();
- expect(q!.planned.model.id).toBe("oss-kandinsky6");
- expect(q!.planned.route).toMatchObject({ provider: "comfyui", endpoint: "kandinsky6-t2av" });
+ expect(q!.planned!.model.id).toBe("oss-kandinsky6");
+ expect(q!.planned!.route).toMatchObject({ provider: "comfyui", endpoint: "kandinsky6-t2av" });
expect(q!.quote).toMatchObject({ amount: 7, priceVersion: "v7" });
const sent = fake.calls_of("/v1/quote").slice(before);
expect(sent).toHaveLength(1);
diff --git a/tests/hosted-runs-voice-design.test.ts b/tests/hosted-runs-voice-design.test.ts
index 8c1e220a..b0336dc8 100644
--- a/tests/hosted-runs-voice-design.test.ts
+++ b/tests/hosted-runs-voice-design.test.ts
@@ -55,9 +55,9 @@ describe("Design a voice on this install's GPUs", () => {
const before = fake.calls_of("/v1/quote").length;
const q = await poolQuote(account, design(modelId), undefined);
expect(q, modelId).not.toBeNull();
- expect(q!.planned.model.id).toBe(modelId);
- expect(q!.planned.op).toBe("voice-design");
- expect(q!.planned.route.provider).toBe("comfyui");
+ expect(q!.planned!.model.id).toBe(modelId);
+ expect(q!.planned!.op).toBe("voice-design");
+ expect(q!.planned!.route.provider).toBe("comfyui");
expect(q!.quote).toMatchObject({ amount: 7, priceVersion: "v7" });
const sent = fake.calls_of("/v1/quote").slice(before);
expect(sent).toHaveLength(1);
diff --git a/tests/hosted-runs.test.ts b/tests/hosted-runs.test.ts
index 36628409..340048fe 100644
--- a/tests/hosted-runs.test.ts
+++ b/tests/hosted-runs.test.ts
@@ -150,7 +150,7 @@ describe("hosted runs on", () => {
expect(place.planned.model.id).toBe(QMA_MODEL);
expect(place.planned.route.provider).toBe("comfyui");
const quoted = await poolQuote(auth.accountById(a)!, req, undefined);
- expect(quoted?.planned.model.id).toBe(QMA_MODEL);
+ expect(quoted?.planned?.model.id).toBe(QMA_MODEL);
expect(quoted?.quote).toBeTruthy();
});
diff --git a/tests/regenerate-more-hosted.test.ts b/tests/regenerate-more-hosted.test.ts
index 1f7e4b4c..000213fd 100644
--- a/tests/regenerate-more-hosted.test.ts
+++ b/tests/regenerate-more-hosted.test.ts
@@ -33,6 +33,8 @@ const { resetRates } = await import("@/server/rate");
const { decidePlace, poolQuote } = await import("@/server/hosted-run");
const R = await import("@/lib/catalog/regenerate");
const { ownSetupLabel, ownSetupOnly } = await import("@/lib/own-setup");
+const generationsRoute = await import("@/app/api/generations/route");
+const { poolRunState } = await import("@/lib/hosted");
let fake: FakeBilling;
let a = "";
@@ -74,6 +76,24 @@ describe("MiniMax H3 at 2K on this install's GPUs", () => {
expect((await decidePlace(auth.accountById(a)!, twoK("768p"), undefined)).kind).toBe("pool");
});
+ it("the price check before Run answers 2K with its label, which Run opens; never a refusal's words", async () => {
+ const setup = ownSetupOnly("regenerate:h3-2k")!;
+ const text = JSON.stringify({ ...twoK(), place: "pool" });
+ const r = await generationsRoute.POST(
+ new Request("http://localhost:3000/api/generations?preview=1", {
+ method: "POST",
+ headers: { host: "localhost:3000", "content-type": "application/json", "content-length": String(Buffer.byteLength(text)), cookie: `${auth.SESSION_COOKIE}=${auth.createSession(a).value}` },
+ body: text,
+ }),
+ );
+ expect(r.status).toBe(200);
+ const body = (await r.json()) as Parameters<typeof poolRunState>[0];
+ expect(body?.place).toBe("pool");
+ const state = poolRunState(body);
+ expect(state).toMatchObject({ refused: true, text: ownSetupLabel(setup), setup });
+ expect(state?.text).not.toMatch(/worker|comfy|pool|vram|held|isn['’]t|can['’]t|not available/i);
+ });
+
it("a policy that keeps Open-H3 Regenerate off these GPUs changes nothing for 768p", async () => {
fake.policy = { ...fake.policy, pool: { deny: [R.REGEN_MODEL] } };
// Said before Run (Run is off), in the words the run itself gets, and never priced.