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
Auto: MiniMax H3 Image first, where the GPU can take its lane
Adarshf84c1026d62d
diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex 4edb3e93..1d128058 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -69,7 +69,7 @@ Feed, Library, studios (React Query caches patched by id; polls every 10 s while| `studio-packs.generated.ts` | Round 4 part 5. The 14 Photodump / Instadump packs and the 6 Fashion Factory templates (name, photo or shot count, description). **Generated** by `scripts/gen-studio-packs.py` from the research in `parity-image-studios.json`. It replaces the retired provider's generated presets file, which went with its generated models file and their generators (see Retired models); the Soul preset fallback list and `presetPrompt` left `packs.ts` with it || `replaced.ts` | Round 4 part 5 (O7). What replaced each retired model, training target and lost operation, pure and browser-safe: `REPLACED_BY` (12 model ids → the model that does the job now, with `was`, the name it ran under, a `note`, and `original`, `ops`, `withReferences` and `director` where they apply), `TRAINING_REPLACED_BY`, `OPS_REPLACED_BY`, `replacedBy`, `currentModelId`, `replacementOf` and `migrateRequest` (see Retired models) || `models.ts` | Open-source models (ComfyUI workflow ids), fal utility models (Join clips, and the hidden Extract frame, Crop to size, Mix voice and music, Level audio, Forced Alignment), the browser-only models (`local` provider: Color Grade, Ad compositor) + the generated cloud lists (whose hidden chain helpers include Trim video, Add soundtrack, Voice timeline and Extract soundtrack). A launch price (`Pricing.promo`) stays beside the list price (see `promo.ts`): the catalog never reads the clock. Since round 4 part 3 `MODELS` starts with the Fuobe Originals: `original()` joins each one's ComfyUI routes to its generated cloud half. Since round 4 part 5 the cloud list is `CLOUD_MODELS` and the cloud tools only (no retired provider's models or routes are joined, and the hand-written `ai-influencer` is gone), and two hidden open models run Character Swap Studio's graphs: `oss-h3-swap-segment` (`video-swap` on `video-character-swap-h3-segment`) and `oss-h3-person-mask` (`bg-remove-video` on `video-mask-h3-relay`). Since round 5 part 1 `originals` holds the eight new Originals' GPU halves, `oss-video-depth-vda-large` joins the open list, the hidden `oss-face-mosaic` (`face-mosaic` on `image-face-mosaic-sam3`) is the face mosaic's GPU step, and `oss-tryon-klein` carries the try-on LoRA in `ModelOptions.loras`, so its switch governs it. Since round 5 part 2 the open list gains `oss-moss-image` (MOSS-Image, `t2i` on `moss-image-t2i`; layout `moss`; a Quality control whose values each stand for several settings through `controls[].sets`, `MOSS_QUALITY`: Standard 25 steps, CFG 2.5, `er_sde`; Best 50 steps, CFG 3, euler; Fast 8 steps, CFG 1 on the 8-step DMD file) and `oss-dbs-separate` (DBS, `separate-audio` on `separate-soundtrack-dbs`: `separationModel`, Fast or Best, with no default so the host picks, and `channels`), and the hidden `oss-uni3c-path` (Wan 2.1 + Uni3C, `camera-path` on `wan21-i2v-uni3c-path`, which needs the still and the path's render: `requires.video`). Round 5 part 3 adds 16 open models (Kandinsky 6.0, Kandinsky VSR and VRMBG 3.0 are also hosted, as separate cloud models; the cloud's Bria matte is VRMBG 3.0): `oss-kandinsky6` (`t2v` on `kandinsky6-t2av`, `i2v` on `kandinsky6-i2av`; 5 s at 480p with sound; Quality Lite or Pro sets the transformer file through `controls[].sets`; an opt-in Prompt helper), `oss-kandinsky6-vsr` (`upscale-video` on `video-upscale-kandinsky6-vsr`, 2x, 2.25x or 4x, `maxSourceSeconds` 5), the three NVIDIA RTX Video models of `rtx-video.ts`, `oss-video-key-corridorkey` (CorridorKey 2.0 on `video-key-corridorkey`, `greenScreen`: the cut-out, its mask or the clean foreground, as WebM, ProRes 4444 or EXR), `oss-video-matte-vrmbg3` (Bria VRMBG 3.0 on `video-matte-vrmbg3`, gated weights placed by hand), `oss-matte-feynobg` (FeyNoBg fine hair on `image-matte-feynobg`), `oss-auk` (Tencent AuK: `speech-edit` on `speech-edit-auk`, `tts` on `speech-tts-auk`), `oss-idol-mesh` (Idol 3D quick mesh, `image-to-3d` on `image-to-mesh-idol`) and six hidden helpers: `oss-hi3d-refine` (`refine-3d` on `mesh-refine-hi3d`), `oss-hy-nomas-world` (`world-turn` on `world-hy-nomas-turn`), `oss-person-mask` (SAM 3.1, `bg-remove` on `image-person-mask-sam3`), and `oss-worldcast`, `oss-depth-pro` and `oss-vggt-omega`, whose routes go to the `worldcast` provider (endpoints `cases`, `depth/depth-pro`, `depth/vggt-omega`) and whose licences are in `ModelDef.licence`. `oss-minimax-h3` gains a `ref2v` and an `avatar` route on `minimax-h3-flex-ref2va` (Pika H3 Flex), the Quality value `flex` (the 6-step Flex graphs), `maxImages` 9, `maxVideos` 3 and `maxAudios` 3, and `finishTiers: ["2K"]` only while Regenerate is offered (`REGEN_OFFERED`, false). `oss-pixal3d`, `oss-trellis2`, `oss-hunyuan3d-21`, `oss-trellis2-multi` and `oss-idol-mesh` carry the "Refine detail · Hi3D 1.0" control (`params.extra.hi3dRefine`) |-| `../auto-image.ts` | Auto (`oss-auto-image`), the Image studio's open default: a catalog entry whose routes are its picks' own (so the picker, the price and the GPU pre-flight read them), never run as itself. `autoCandidates` picks the model for a request (a picture to work from → the edit model for its operation; lettering → MOSS-Image, then Krea 2 Realism; a line of the owner's `autoImagePatterns` setting, and anything else → Krea 2 Realism, then MOSS-Image; never Ideogram 4 or FIBO 2 Dev for text to image), and `src/server/generations.ts` `autoRouted` plans the first that is switched on and keeps the pick in `GenerationRequest.auto`, so a run planned again goes to the same model (while it is one of Auto's models for the operation). When a text-to-image run of Auto fails on its model (a job failure, not reaching the GPU), `autoFails` hands it to `declinedAgain`, which makes it with Auto's next model (`autoNext`, each model at most once, `why: "fallback"`), on the same row, hold and admission. Ideogram 4 picked by name, when it declines a run (every picture its grey card), goes the same way through `DECLINED_FALLBACKS` (Krea 2 Realism, FIBO 2 Dev, MOSS-Image), each only after the one before fails (`declinedFails`). `autoLine` is the line the feed card, the run details, the Library and Accounts' runs show |+| `../auto-image.ts` | Auto (`oss-auto-image`), the Image studio's open default: a catalog entry whose routes are its picks' own (so the picker, the price and the GPU pre-flight read them), never run as itself. `autoCandidates` picks the model for a request (a picture to work from → the edit model for its operation; lettering → MiniMax H3 Image, then MOSS-Image, then Krea 2 Realism; a line of the owner's `autoImagePatterns` setting → Krea 2 Realism, then MiniMax H3 Image, then MOSS-Image; anything else → MiniMax H3 Image, then Krea 2 Realism, then MOSS-Image; never Ideogram 4 or FIBO 2 Dev for text to image), and `src/server/generations.ts` `autoRouted` plans the first that is switched on (a model in `AUTO_LARGE_MODELS`, MiniMax H3 Image, only where `src/server/auto-gpu.ts` `autoFitsHere` says the GPUs the run goes to take its lane: on the workers `poolTakes`, elsewhere the last GPU check reads its files and VRAM; no reading counts as yes) and keeps the pick in `GenerationRequest.auto`, so a run planned again goes to the same model (while it is one of Auto's models for the operation). When a text-to-image run of Auto fails on its model (a job failure, not reaching the GPU), `autoFails` hands it to `declinedAgain`, which makes it with Auto's next model (`autoNext`, each model at most once, `why: "fallback"`), on the same row, hold and admission. Ideogram 4 picked by name, when it declines a run (every picture its grey card), goes the same way through `DECLINED_FALLBACKS` (Krea 2 Realism, FIBO 2 Dev, MOSS-Image), each only after the one before fails (`declinedFails`). `autoLine` is the line the feed card, the run details, the Library and Accounts' runs show || `llm-models.ts` | `text-llm` (cloud: Claude, else a local model) and `oss-text-llm` (open: a local model only, never Claude, route endpoint `ollama`; since round 4 its translations run on ComfyUI's Qwen3.5 4B, `oss-qwen35-translate`, when no local model server is ready), kind `text`, ops `translate` and `write` || `elements.ts` | Elements (character / location / prop / style / voice), `@handle` parsing and `applyMentions`; since round 4 part 4 an element holds up to 80 photos (`MAX_ELEMENT_PHOTOS`) and a mention brings its trained LoRA to every model of the LoRA's family on either engine (`identityFor`); since round 4 part 5 an older Soul ID (the retired provider's `referenceId`) goes to no model; the element shows "Older Soul ID" with "Retrain for Fuobe Soul" (nothing retrains by itself) || `sketch.ts` | `applySketch` (masks and drawings → the right operation and inputs) |diff --git a/docs/FEATURES.md b/docs/FEATURES.mdindex eb030e86..b2bfb3e7 100644--- a/docs/FEATURES.md+++ b/docs/FEATURES.md@@ -61,7 +61,7 @@ Fuobe is a complete creative studio you can run yourself: 108 camera motions, 25- **MOSS-Image** (Image studio → model menu → MOSS-Image) — OpenMOSS's picture model, made for Chinese and English text in pictures. In the cloud it runs on fal at $0.05 per megapixel, up to 4 images (fal's safety checker returns a black image when it flags an output). On your GPU it is free, on ComfyUI's built-in nodes, with about 15 GB of files and 16 GB of VRAM (a guess); **Options → Quality** picks Standard (25 steps), Best (50), Fast (8 steps, an extra 5.4 GB file) or Base model (MOSS-Image Base, 50 steps, an extra 5.4 GB file). Its text encoder is the int8 Qwen3.5-9B: the w4a8 build in ComfyUI's template crashed the graphics driver on a test PC. The Image studio's controls chip now reads **Options** (it read "Director"). Text placed in boxes: the Image studio's Layout mode draws the boxes on the picture, and `src/lib/layout-prompt.ts` turns them into MOSS's prompt- **Film look** (Image studio and Canvas, MOSS-Image → Film look) — film and camera looks for MOSS-Image on both engines, in eight groups (colour film, slide, black and white, instant, motion picture, toy and odd cameras, grades, broken film), each with a thumbnail from its own test render. The server adds the picked look when the picture is made: the look's words before and after the prompt, and the look's opposite in the negative prompt beside MOSS-Image's own. A black-and-white look first takes the colour words out of the prompt (an LLM rewrite, then a word list; the word list alone when no LLM answers). The prompt box keeps the person's words, and Reuse applies the look again. Enhance, Assist (`film_look`) and the `moss-film-looks` skill write MOSS prompts by the same rules. Looks live in `src/lib/film-looks.ts`; a layout runs without a look- **The newest open image models, first on your GPU** — Ideogram 4, Qwen-Image 2.1 and its Turbo, Krea 2 (Realism, Turbo, Edit, Identity Edit, Image to image, Inpaint) and FIBO 2 (Dev, Edit Turbo), from the owner's ComfyUI workflows. On the open engine the Image studio opens on Auto (next item) and Edit and Inpaint on Qwen-Image 2.1; every model menu's "Best" list puts the new models first (text to image: Ideogram 4, Qwen-Image 2.1, Krea 2 Realism, MOSS-Image, then FIBO 2 Dev; edits: Qwen-Image 2.1, its Turbo, FIBO 2 Dev and Edit Turbo, then Krea 2 Edit), and so do apps, Layers, Canvas, Cinema stills, Photodump, Fashion Factory and Character swap's anchor. Apps and tools that run a LoRA trained on an older model keep it (Angles, Relight, Product shot, Try-On, Cinema's recompose). Ideogram 4 reads a JSON caption, which Fuobe writes from your words (with your local LLM, never a paid API; a plain caption without one) and keeps as the run's prompt. When Ideogram's safety filter sends its grey card for every picture of a run, the run is made once more with a new seed, then with Qwen-Image 2.1, before it fails and says what to try; the card is kept for the owner to look at. Soul Location doesn't offer Ideogram 4 (pictures of empty places hit that filter most), and a new Layers layer starts on Qwen-Image 2.1. Qwen-Image 2.1, FIBO 2 and Krea 2 Edit take up to 4 references (Krea 2 Edit 2) and leave out the ones you don't give; an edit keeps image 1's shape and size, so Edit and Inpaint show no aspect or size choice for them, and Qwen-Image 2.1's inpaint and expand take the picture alone. An app run made before an app moved to Qwen-Image 2.1 (a retry, Run again, Reuse) runs on Qwen-Image 2.1 and says so. About 92 GB of new files, 20–24 GB of VRAM (estimates), ComfyUI 0.42.0; Krea 2 runs Comfy-Org's fp8 Krea 2 Turbo, the file the owner's edit workflow loads. Krea 2 Inpaint also needs the ComfyUI-Krea2-Ostris-Edit node pack, so it isn't in Inpaint's "Best" list. Qwen-Image 2.1, Ideogram 4 and FIBO 2 weights are non-commercial. None of the 16 graphs has rendered through Fuobe yet-- **Auto, the Image studio's first pick on your GPU** — Auto picks the open model for each run, for everyone (the owner, accounts, and a guest's draft): a run with a picture to work from goes to the edit model for its operation (Qwen-Image 2.1), lettering, posters, logos and signs (real words asked for, such as a poster that says "OPEN") to MOSS-Image, which follows the words and draws them in place, then Krea 2 Realism; and every other prompt to Krea 2 Realism, then MOSS-Image. Auto never picks Ideogram 4 or FIBO 2 Dev for a picture from words; both stay in the model menus to pick by hand. A list the owner edits in Settings → Auto image model (one word, phrase or pattern per line; a built-in list to start with) also starts on Krea 2 Realism, and the run details name the line it matched. When Auto's first model is switched off or can't run there, the run is planned on the other; when it fails, the other one makes the same run, each model at most once; it is still one run for limits and billing, with nothing charged again. The tile, the run details and the Library say what made it ("Auto · made with Krea 2 Realism", or "Auto · made with MOSS-Image · Auto's next model" when the other one made it), and the price before Run is the picked model's. Picking a model by name always runs that model; when Ideogram 4 picked by name declines a run, Krea 2 Realism, FIBO 2 Dev, then MOSS-Image make it, and the owner sees the words it declined and "Add a pattern", which puts a line on that list+- **Auto, the Image studio's first pick on your GPU** — Auto picks the open model for each run, for everyone (the owner, accounts, and a guest's draft): a run with a picture to work from goes to the edit model for its operation (Qwen-Image 2.1), every prompt from words to MiniMax H3 Image first, where the GPU the run goes to has the VRAM its lane needs (about 32 GB) and its files; then lettering, posters, logos and signs (real words asked for, such as a poster that says "OPEN") to MOSS-Image, which follows the words and draws them in place, then Krea 2 Realism; and every other prompt to Krea 2 Realism, then MOSS-Image. On a smaller GPU, or one without MiniMax H3 Image's files, the run starts on the next model. Auto's 1K and 1.5K run at MiniMax H3 Image's 2K. Auto never picks Ideogram 4 or FIBO 2 Dev for a picture from words; both stay in the model menus to pick by hand. A list the owner edits in Settings → Auto image model (one word, phrase or pattern per line; a built-in list to start with) starts on Krea 2 Realism instead (then MiniMax H3 Image, then MOSS-Image), and the run details name the line it matched. When Auto's first model is switched off or can't run there, the run is planned on the next; when it fails, the next one makes the same run, each model at most once; it is still one run for limits and billing, with nothing charged again. The tile, the run details and the Library say what made it ("Auto · made with Krea 2 Realism", or "Auto · made with MOSS-Image · Auto's next model" when the other one made it), and the price before Run is the picked model's. Picking a model by name always runs that model; when Ideogram 4 picked by name declines a run, Krea 2 Realism, FIBO 2 Dev, then MOSS-Image make it, and the owner sees the words it declined and "Add a pattern", which puts a line on that list- **Kandinsky 6.0** (Video studio → model menu, both engines) — Kandinsky Lab's model makes 5 s clips at 480p with sound and lip-synced dialogue, from words or a first frame. Words in quotes are what someone says, and a closing `Sound:` line sets the sound. On your GPU it is free, on Kandinsky Lab's own node packs: **Options → Quality** picks Lite (10 steps, the default; about 24 GB of VRAM, an estimate) or Pro (about 80 GB, with an extra 60 GB file), and the Prompt helper (an extra 19 GB file) writes a fuller caption first. In the cloud it runs on fal: Pro or Lite at Fast, Standard or Best steps (Pro · Standard, the default, $0.56 a clip; Lite from $0.08; Pro · Best $1.35). Lipsync & avatars links a talking character from words to the Video studio on Kandinsky. **Kandinsky VSR** (Upscale → Video, both engines) upscales clips up to 5 s by 2x, 2.25x (the default, 480p to 1080p) or 4x, about $0.09 for 5 s of 480p to 1080p on fal- **Pika H3 Flex** (your GPU only) — Pika's add-on that makes MiniMax H3 clips in 6 steps. In the Video studio, MiniMax H3's Quality offers **Fast · Pika Flex (6 steps)** for words and first and last frames, and a **References** chip takes up to 9 images, 3 clips and 3 voice or music clips (Image N, Clip N and Voice N in the prompt). Cinema's reference takes and "Talk from a voice clip" in Lipsync & avatars use it too. 32 GB of VRAM recorded, not measured. No hosted service offers the add-on, so the cloud keeps hosted MiniMax H3 under its own name. MiniMax H3's other choices now read "Standard · 8 steps" and "Sharper · 20 steps"- **One sheet** (Storyboard) and **Re-render from layers** (Layers) — One sheet draws up to 8 panels on one picture with MOSS-Image (your GPU or fal), then cuts it into frames, each with Animate and Edit; it stays the owner's until a GPU test is recorded. Re-render from layers (desktop) repaints the layers as one picture, which lands as a new top layer: MOSS-Image on both engines, Ideogram 4.5 and FLUX.3 in the clouddiff --git a/src/components/settings-form.tsx b/src/components/settings-form.tsxindex 02cbeba3..cc9ad17d 100644--- a/src/components/settings-form.tsx+++ b/src/components/settings-form.tsx@@ -802,7 +802,7 @@ export function SettingsForm({ prices }: { prices?: string }) {<Sectionid="auto-image"title="Auto image model"- description="Auto is the Image studio's first pick on the open engine: Krea 2 Realism for every picture, MOSS-Image first for lettering, posters and logos, and Qwen-Image 2.1 for edits. When the first model is switched off, can't run or fails, the other one makes the same run, at no extra charge. Prompts that match the lines below start on Krea 2 Realism too, and their run details name the line."+ description="Auto is the Image studio's first pick on the open engine: MiniMax H3 Image first for every picture, then Krea 2 Realism, or MOSS-Image for lettering, posters and logos; Qwen-Image 2.1 for edits. MiniMax H3 Image runs where the GPU has about 32 GB and its files; elsewhere Auto starts on the next model. When a model is switched off, can't run or fails, the next one makes the same run, at no extra charge. Prompts that match the lines below start on Krea 2 Realism instead, and their run details name the line."inactive={mode === "cloud" ? "Not used in Paid APIs only mode" : undefined}><AutoPatternsSetting setting={get("autoImagePatterns")} saving={save.isPending} onSave={set("autoImagePatterns")} />diff --git a/src/lib/auto-image.ts b/src/lib/auto-image.tsindex db4f3661..d3e94bf5 100644--- a/src/lib/auto-image.ts+++ b/src/lib/auto-image.ts@@ -11,16 +11,28 @@ import type { AutoPick, AutoWhy, Operation } from "./catalog/types";export const AUTO_IMAGE = "oss-auto-image";export const AUTO_NAME = "Auto";-/** Every plain prompt, an account's, a guest's or the owner's: natural skin, light and faces. */+/**+ * Every plain prompt and every lettering prompt starts here, an account's, a guest's or the owner's: photoreal people and+ * products, painting, illustration and exact lettering. Its lane needs a large GPU (AUTO_LARGE_MODELS): where the GPUs a+ * run goes to can't take it, Auto starts on the next model.+ */+export const AUTO_LEAD_MODEL = "oss-minimax-h3-image";+/** Next for a plain prompt, and first for a prompt the setting's patterns match: natural skin, light and faces. */export const AUTO_PHOTO_MODEL = "oss-krea2-realism";-/** Lettering (posters, logos, signs, words in quotes): MOSS-Image follows the words and draws them in place. */+/** Next for lettering (posters, logos, signs, words in quotes): MOSS-Image follows the words and draws them in place. */export const AUTO_TEXT_MODEL = "oss-moss-image";/**- * Auto's text-to-image models, in order for a plain prompt; lettering takes them the other way round. When the first- * is switched off or can't run here, the run is planned on the other; when it fails, the other makes the same run- * (src/server/generations.ts autoFails), each model at most once.+ * Auto's text-to-image models, in order for a plain prompt (lettering takes MOSS-Image before Krea 2 Realism; a prompt the+ * patterns match starts on Krea 2 Realism). When one is switched off or can't run here, the run is planned on the next;+ * when it fails, the next makes the same run (src/server/generations.ts autoFails), each model at most once.*/-export const AUTO_T2I_MODELS = [AUTO_PHOTO_MODEL, AUTO_TEXT_MODEL] as const;+export const AUTO_T2I_MODELS = [AUTO_LEAD_MODEL, AUTO_PHOTO_MODEL, AUTO_TEXT_MODEL] as const;+/**+ * Auto's models whose lane needs a large GPU (MiniMax H3 Image: about 32 GB for its 21 GB model and 27 GB text encoder).+ * The server plans one only where the GPUs the run goes to can take that lane and hold its files (src/server/auto-gpu.ts);+ * elsewhere the run starts on the next model.+ */+export const AUTO_LARGE_MODELS: ReadonlySet<string> = new Set([AUTO_LEAD_MODEL]);/*** Ideogram 4 picked by name (Auto never plans it): when it declines a run (its grey "blocked" card for every picture),* the same run is made by these, in order, each only if the one before fails.@@ -43,16 +55,16 @@ export const autoModelsFor = (op: Operation): readonly string[] => (op === "t2i"export const AUTO_MODELS: ReadonlySet<string> = new Set([...AUTO_T2I_MODELS, ...Object.values(AUTO_EDIT_MODELS).flat()]);/**- * Prompts about lettering, which go to MOSS-Image first. Words in quotes count too ("a sign that says “OPEN”").+ * Prompts about lettering, which go to MOSS-Image right after MiniMax H3 Image. Words in quotes count too ("a sign that+ * says “OPEN”").*/const TEXT_WORDS =/\b(text|texts|typography|typographic|typeface|font|fonts|lettering|letters|logo|logos|logotype|wordmark|monogram|poster|posters|signage|signs?|billboard|banner|headline|caption|calligraphy|graffiti|label|labels|menu|book cover|album cover|magazine cover|infographic|says|that reads)\b/i;const QUOTED = /["“”«»][^"“”«»\n]{2,80}["“”«»]/;/**- * The setting's list (Settings → Auto image model): prompts Auto starts on Krea 2 Realism, the model every plain prompt- * starts on too, and whose run details name the line they matched. Lettering still goes to MOSS-Image first. One per- * line: a word or phrase matches as a whole word (a space or a hyphen matches either), any other line is a regular+ * The setting's list (Settings → Auto image model): prompts Auto starts on Krea 2 Realism (then MiniMax H3 Image, then+ * MOSS-Image), and whose run details name the line they matched. Lettering still follows its own order. One per line: a word or phrase matches as a whole word (a space or a hyphen matches either), any other line is a regular* expression, and a line that starts with "#" is a note; case never matters.*/export const DEFAULT_AUTO_PATTERNS: readonly string[] = [@@ -152,21 +164,37 @@ export interface AutoAsk {/*** The models Auto would plan a run on, best first, and why: a picture to work from → the studio's edit model for its- * operation; lettering → MOSS-Image, then Krea 2 Realism; a prompt the setting's patterns match, and anything else →- * Krea 2 Realism, then MOSS-Image. The same for the owner, an account and a guest. The server plans the first one that- * is switched on and runs the operation (src/server/generations.ts autoRouted), and the next one makes the run when it- * fails (autoNext).+ * operation; lettering → MiniMax H3 Image, then MOSS-Image, then Krea 2 Realism; a prompt the setting's patterns match →+ * Krea 2 Realism, then MiniMax H3 Image, then MOSS-Image; anything else → MiniMax H3 Image, then Krea 2 Realism, then+ * MOSS-Image. The same for the owner, an account and a guest. The server plans the first one that is switched on, runs+ * the operation and fits the GPUs the run goes to (src/server/generations.ts autoRouted), and the next one makes the run+ * when it fails (autoNext).*/export function autoCandidates(ask: AutoAsk, patterns: readonly { line: string; re: RegExp }[]): { models: string[]; why: AutoWhy; pattern?: string } {const op = ask.op && ask.op !== "t2i" ? ask.op : (ask.images ?? 0) > 0 ? "edit" : "t2i";if (op !== "t2i") return { models: [...(AUTO_EDIT_MODELS[op] ?? [])], why: "edit" };const words = ask.prompt ?? "";- if (asksForText(words)) return { models: [AUTO_TEXT_MODEL, AUTO_PHOTO_MODEL], why: "text" };+ if (asksForText(words)) return { models: [AUTO_LEAD_MODEL, AUTO_TEXT_MODEL, AUTO_PHOTO_MODEL], why: "text" };const pattern = matchedPattern(words, patterns);- if (pattern) return { models: [...AUTO_T2I_MODELS], why: "trigger", pattern };+ if (pattern) return { models: [AUTO_PHOTO_MODEL, AUTO_LEAD_MODEL, AUTO_TEXT_MODEL], why: "trigger", pattern };return { models: [...AUTO_T2I_MODELS], why: "plain" };}+/** A size tier's place in order ("1K" < "1.5K" < "2K" < "4K"); NaN for a size that isn't a tier. */+const tierOf = (r: string) => (/^\d+(\.\d+)?k$/i.test(r) ? parseFloat(r) : NaN);++/**+ * The size a run of Auto asks of the model it picks: as asked, unless every size that model makes is larger (MiniMax H3+ * Image makes 2K and 4K, so Auto's 1K and 1.5K run at its 2K default). A size that isn't a tier stays as it is.+ */+export function autoResolution(asked: string | undefined, model: { options: { resolutions?: readonly string[] }; defaults?: { resolution?: string } } | undefined): string | undefined {+ const sizes = model?.options.resolutions;+ const to = model?.defaults?.resolution;+ if (!asked || !sizes?.length || !to || sizes.includes(asked)) return asked;+ const t = tierOf(asked);+ return Number.isFinite(t) && sizes.every((s) => tierOf(s) > t) ? to : asked;+}+/** Auto's models left for a run, in its order, after the ones that tried it (each model makes a run at most once). */export const autoNext = (models: readonly string[], tried: readonly string[]): string[] => models.filter((m) => !tried.includes(m));diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.tsindex a3d966fa..9b8dfc33 100644--- a/src/lib/catalog/models.ts+++ b/src/lib/catalog/models.ts@@ -147,14 +147,15 @@ const open: ModelDef[] = [// A studio's "Best" list is its default, then the `top` models in this order (bestForStudio in src/lib/composer.ts).// Auto: the Image studio's default on the open engine. Not a model of its own: the server plans each run on the model it// picks (src/lib/auto-image.ts), and the run names that model. Its routes are its picks' own (Krea 2 Realism for words,- // Qwen-Image 2.1 for edits), so the picker, the price and the GPU pre-flight read them; it never runs as itself.+ // the lane every GPU Auto plans on can take, MiniMax H3 Image's needing a large one; Qwen-Image 2.1 for edits), so the+ // picker, the price and the GPU pre-flight read them; it never runs as itself.o({id: AUTO_IMAGE,name: AUTO_NAME,vendor: "Fuobe",family: "auto",kind: "image",- tagline: "Picks the model for you: Krea 2 Realism for most pictures, MOSS-Image for lettering, Qwen-Image 2.1 for edits",+ tagline: "Picks the model for you: MiniMax H3 Image first, then Krea 2 Realism, or MOSS-Image for lettering; Qwen-Image 2.1 for edits",routes: [comfy("t2i", "krea2-realism-t2i", "Auto picks the model before the run"), { ...comfy("edit", "qwen-image-21-edit", "Auto: Qwen-Image 2.1, up to 4 references"), unsized: true }],options: { aspectRatios: IMG_AR, resolutions: ["1K", "1.5K", "2K"], maxImages: 4, seed: true },defaults: { aspectRatio: "1:1", resolution: "1.5K" },diff --git a/src/lib/starter-prices.ts b/src/lib/starter-prices.tsindex 2a2f9c2c..3640502e 100644--- a/src/lib/starter-prices.ts+++ b/src/lib/starter-prices.ts@@ -1,3 +1,4 @@+import { AUTO_IMAGE, AUTO_LEAD_MODEL } from "@/lib/auto-image";import { getModel } from "@/lib/catalog";import { estimateCost } from "@/lib/catalog/plan";import type { StartQuote } from "@/lib/connections";@@ -33,9 +34,11 @@ export function startQuotes(): Record<"image" | "video" | "edit", StartQuote> {const usd = cloud ? estimateCost(cloud, { ...cloud.defaults }, 1, undefined, false, PRERENDER) : null;// The providers that host each model: a key for another one runs it as a demo.const providers = (m: NonNullable<typeof cloud>) => [...new Set(m.routes.map((r) => r.provider))];+ // Auto names the model it starts on ("Auto (MiniMax H3 Image first)"): a run goes there where the GPU can take it.+ const lead = open?.id === AUTO_IMAGE ? getModel(AUTO_LEAD_MODEL) : undefined;return {cloud: cloud ? { name: cloud.name, price: usd ? `about ${formatCost(usd)} ${what(cloud.defaults?.duration)}` : "priced by the provider", providers: providers(cloud) } : null,- open: open ? { name: open.name, providers: providers(open) } : null,+ open: open ? { name: lead ? `${open.name} (${lead.name} first)` : open.name, providers: providers(open) } : null,};};return {diff --git a/src/lib/studios.ts b/src/lib/studios.tsindex 16294123..b8955111 100644--- a/src/lib/studios.ts+++ b/src/lib/studios.ts@@ -22,8 +22,8 @@ export const IMAGE_STUDIO: StudioConfig = {slots: [],// Up to 10 references where the model takes them (FLUX 3 Klein); each model's own limit caps it (composer refMax).multiRef: { label: "Add ref", max: 10 },- // Auto picks the open model for each run (src/lib/auto-image.ts): Krea 2 Realism for most, MOSS-Image for lettering- // (each the other's fallback), Qwen-Image 2.1 for edits. The default for everyone: the owner, an account and a guest.+ // Auto picks the open model for each run (src/lib/auto-image.ts): MiniMax H3 Image first where the GPU can take it, then+ // Krea 2 Realism (MOSS-Image for lettering), Qwen-Image 2.1 for edits. The default for everyone: the owner, an account and a guest.defaultModels: { cloud: "nano-banana-pro", open: AUTO_IMAGE },// A model's own settings (MOSS-Image's Quality, Ideogram's speed) sit under "Options".controlsTitle: "Options",diff --git a/src/server/auto-gpu.ts b/src/server/auto-gpu.tsnew file mode 100644index 00000000..19d1b24e--- /dev/null+++ b/src/server/auto-gpu.ts@@ -0,0 +1,37 @@+import "server-only";+import { getModel } from "@/lib/catalog";+import type { Operation } from "@/lib/catalog/types";+import { workflowReadiness } from "@/lib/gpu/readiness";+import { loadIndex, preflightOn } from "./gpu/index-file";+import { contextFor } from "./gpu/readiness-service";+import { readSnapshot } from "./gpu/snapshots";+import { runTarget } from "./gpu/target";+import { poolOnWorkers, poolTakes } from "./hosted";+import { ownGpu } from "./providers/comfyui";++/**+ * Whether the GPUs a run in the current scope goes to can take a model's lane for this operation, for Auto's models whose+ * lane needs a large GPU (src/lib/auto-image.ts AUTO_LARGE_MODELS). Read where the run is planned, in the run's own scope+ * (the owner's, an account's own GPU, or this install's GPUs for an account or a guest):+ *+ * - This install's GPUs on the workers (no GPU of the run's own): a worker allowed the graph's lane holds its files and node+ * packs and has the VRAM the requirements index asks for it (hosted.ts poolTakes, the check a run there meets before Run).+ * - A ComfyUI the GPU check reads (this install's own server, an account's own GPU, a ComfyUI on a computer): its last check+ * reads the graph ready (its files, node packs and nodes) on a card with the VRAM it needs. A CPU never fits.+ * - No check to read (the pre-flight is off, or that ComfyUI hasn't been read yet): yes. The run is tried, and if its job+ * fails, Auto's next model makes it (src/server/generations.ts autoFails).+ */+export function autoFitsHere(modelId: string, op: Operation): boolean {+ const route = getModel(modelId)?.routes.find((r) => r.op === op && r.provider === "comfyui");+ if (!route) return true;+ const graph = route.endpoint;+ if (!ownGpu() && poolOnWorkers()) return poolTakes(graph);+ if (!preflightOn()) return true;+ const t = runTarget();+ const snap = t ? readSnapshot(t) : null;+ if (!t || !snap?.inventory.reachable) return true;+ const index = loadIndex();+ if (!index.workflows[graph]) return true;+ const r = workflowReadiness(graph, snap.inventory, index, contextFor(t));+ return r.state === "ready" && (r.vram.fit === "fits" || r.vram.fit === "any");+}diff --git a/src/server/generations.ts b/src/server/generations.tsindex 109476a4..90d006a4 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -37,7 +37,7 @@ import { finishSteps, mosaicPixels, unionMasks } from "@/lib/soul-post";import { ANGLES_ORIGINAL, MOSAIC_SCALE } from "@/lib/catalog/open-tools";import { computeDimensions } from "@/lib/comfy";import { captionFromWords, captionWords, parseCaption } from "@/lib/ideogram-caption";-import { AUTO_IMAGE, autoCandidates, autoModelsFor, autoNext, autoPatterns, nextDeclinedFallback } from "@/lib/auto-image";+import { AUTO_IMAGE, AUTO_LARGE_MODELS, autoCandidates, autoModelsFor, autoNext, autoPatterns, autoResolution, nextDeclinedFallback } from "@/lib/auto-image";import { h3Frames, h3Prompt, inH3Layout } from "@/lib/h3-prompt";import { h3ReferenceTags, h3TalkPrompt } from "@/lib/h3-references";import {@@ -66,6 +66,7 @@ import { listElements } from "./elements";import { markStale } from "./gpu/snapshots";import { loadIndex } from "./gpu/index-file";import { qwen21Gpu } from "./qwen21-gpu";+import { autoFitsHere } from "./auto-gpu";import { h3Gpu } from "./h3-gpu";import { H3_TIER_PARAM, H3_UNET_PARAM } from "@/lib/gpu/h3-tier";import { DETAILS_MAX_IMAGES, GPU_PARAM, QWEN21_SPEED, speedLora } from "@/lib/qwen21-speed";@@ -1444,16 +1445,23 @@ function autoPatternsNow(): ReturnType<typeof autoPatterns> {* A run of Auto (src/lib/auto-image.ts) as the model it picks runs it: the pick it carries (a run planned again: a resend,* a run that waited to enter the line, Auto's next model after the one before failed) while it is one of Auto's models* for the operation (an older run's Ideogram 4 or FIBO 2 Dev picture is planned again), else the first of its picks for these words- * and pictures that is switched on and runs the operation (Settings → Models & licences). A picture to work from makes it- * an edit. Any other request as it is.+ * and pictures that is switched on and runs the operation (Settings → Models & licences), passing over a model whose lane+ * needs a large GPU where the GPUs the run goes to can't take it (src/server/auto-gpu.ts; when no other is left, it is+ * planned all the same). A picture to work from makes it an edit. The picked model makes the run at the size asked, or at+ * its own default when it makes only larger sizes (autoResolution). Any other request as it is.*/function autoRouted(req: GenerationRequest): GenerationRequest {if (req.modelId !== AUTO_IMAGE) return req;const images = req.inputs?.images?.length ?? 0;+ const sized = (r: GenerationRequest, model: string): GenerationRequest => {+ const asked = r.params?.resolution;+ const to = autoResolution(asked, getModel(model));+ return to === asked ? r : { ...r, params: { ...r.params, resolution: to } };+ };if (req.auto) {const m = getModel(req.auto.model);const op = (req.op && m?.routes.some((r) => r.op === req.op) ? req.op : undefined) ?? (images ? "edit" : "t2i");- if (autoModelsFor(op).includes(req.auto.model)) return { ...req, modelId: req.auto.model, op };+ if (autoModelsFor(op).includes(req.auto.model)) return sized({ ...req, modelId: req.auto.model, op }, req.auto.model);}const c = autoCandidates({ prompt: req.prompt, op: req.op, images }, autoPatternsNow());const op: Operation = c.why === "edit" ? (req.op && req.op !== "t2i" ? req.op : "edit") : "t2i";@@ -1466,9 +1474,10 @@ function autoRouted(req: GenerationRequest): GenerationRequest {return false;}};- const model = c.models.find(runs);+ const fits = (id: string) => !AUTO_LARGE_MODELS.has(id) || autoFitsHere(id, op);+ const model = c.models.find((id) => runs(id) && fits(id)) ?? c.models.find(runs);if (!model) throw new Error(op === "t2i" ? "Auto has no image model switched on here. Pick a model" : "Auto has no edit model switched on here. Pick a model");- return { ...req, modelId: model, op, auto: { model, why: c.why } };+ return sized({ ...req, modelId: model, op, auto: { model, why: c.why } }, model);}/** The LoRA files a graph loads itself (not injected), so a run downloads the ones ComfyUI lacks before it starts. */@@ -3284,9 +3293,9 @@ function declinedFallback(stored: GenerationRequest, modelId: string): Generatio* An Ideogram 4 run whose every picture was its "blocked" card, or a run of Auto whose model failed (autoFails), is made* again in its place: the same run (its id, its place, its turn in the line, its billing hold), as the same job of its* batch, through the same submit as every run (this install's workers, the owner's ComfyUI, an account's own GPU), never- * by a model that tried it before. A run of Auto goes to Auto's models left in its order (src/lib/auto-image.ts: Krea 2- * Realism and MOSS-Image, never Ideogram 4), each at most once, and keeps Auto, its pick saying why (`why: "fallback"`,- * or "declined" after Ideogram 4 declined an older run); Ideogram 4 picked by name goes to DECLINED_FALLBACKS in order and+ * by a model that tried it before. A run of Auto goes to Auto's models left in its order (src/lib/auto-image.ts: MiniMax H3+ * Image where the GPUs can take it, Krea 2 Realism and MOSS-Image, never Ideogram 4), each at most once, and keeps Auto,+ * its pick saying why (`why: "fallback"`, or "declined" after Ideogram 4 declined an older run); Ideogram 4 picked by name goes to DECLINED_FALLBACKS in order and* names the model that made it (its model and its request's notice). Each next model is the first switched on that goes* where the run went, and only when the one before fails (declinedFails).* None is a new press of Run: no limit counts it again, and no new row or hold is made. The run's tile says which model@@ -3299,12 +3308,9 @@ function declinedAgain(r: Row, declined: DeclinedMeta, later = false): boolean {const auto = stored.modelId === AUTO_IMAGE;const account = stored.account;// Planned where the run went: this install's GPUs (its stamp: place, class, hold), the account's own, or the owner's.- const planned = (req: GenerationRequest) =>- account && stored.place === "pool"- ? runOnPool(account, () => withRunStamp(stampOf(stored), () => prepare(req)))- : account- ? asAccount(account, () => prepare(req))- : prepare(req);+ const there = <T,>(fn: () => T): T =>+ account && stored.place === "pool" ? runOnPool(account, () => withRunStamp(stampOf(stored), fn)) : account ? asAccount(account, fn) : fn();+ const planned = (req: GenerationRequest) => there(() => prepare(req));let asked = stored;let model: string | undefined;let p: ReturnType<typeof prepare> | undefined;@@ -3312,7 +3318,8 @@ function declinedAgain(r: Row, declined: DeclinedMeta, later = false): boolean {// fallbacks after the one that made it now (a legacy "retry" stage has no model: it starts at the first).const tried = auto ? [...new Set([...(declined.tried ?? []), r.model_id])] : undefined;const order: string[] = [];- if (tried) order.push(...autoNext(autoCandidates({ prompt: stored.prompt, op: "t2i" }, autoPatternsNow()).models, tried));+ // (A model whose lane needs a large GPU only where the GPUs the run went to can take it: src/server/auto-gpu.ts.)+ if (tried) order.push(...autoNext(autoCandidates({ prompt: stored.prompt, op: "t2i" }, autoPatternsNow()).models, tried).filter((m) => !AUTO_LARGE_MODELS.has(m) || there(() => autoFitsHere(m, "t2i"))));else for (let m = nextDeclinedFallback(declined.model); m; m = nextDeclinedFallback(m)) order.push(m);const why = declined.cause === "failed" ? "fallback" : "declined";for (const m of order) {@@ -3421,8 +3428,8 @@ const AUTO_NEXT_CAUSES: ReadonlySet<TroubleCause> = new Set<TroubleCause>([]);/**- * A text-to-image run of Auto whose model failed: the same run is made by Auto's next model (Krea 2 Realism, then- * MOSS-Image; lettering the other way round), as a run Ideogram 4 declined is (declinedAgain): the same row, hold and+ * A text-to-image run of Auto whose model failed: the same run is made by Auto's next model (after MiniMax H3 Image, Krea 2+ * Realism, then MOSS-Image; lettering takes MOSS-Image first), as a run Ideogram 4 declined is (declinedAgain): the same row, hold and* place in line, nothing charged again. False: it goes on; null: not such a run, or no model left, so it fails as any run.*/function autoFails(id: string, said: string, trouble?: Diagnosis): false | null {diff --git a/src/server/run-details.ts b/src/server/run-details.tsindex 4081b655..5d54148a 100644--- a/src/server/run-details.ts+++ b/src/server/run-details.ts@@ -2,7 +2,7 @@ import "server-only";import fs from "node:fs";import { getModel, getPreset } from "@/lib/catalog";import { presetRoutes } from "@/lib/catalog/preset-recipe-routes";-import { AUTO_IMAGE } from "@/lib/auto-image";+import { AUTO_IMAGE, AUTO_LEAD_MODEL } from "@/lib/auto-image";import { cleanNodeTimes, type NodeTime } from "@/lib/node-times";import type { AutoWhy, Engine, GenerationRequest, MediaKind } from "@/lib/catalog/types";import { madeOfRun } from "@/lib/catalog/fitted";@@ -505,13 +505,25 @@ export function surfaceOf(feature: string, stamp: GenerationRequest): RunSurface/** Why Auto picked its model, in words. */export const AUTO_WHY_WORDS: Record<AutoWhy, string> = {edit: "It had a picture to work from, so it went to the edit model",- text: "Its words ask for lettering, so it went to MOSS-Image first",+ text: "Its words ask for lettering, so it went to MiniMax H3 Image first",trigger: "Its words match a pattern in Settings → Auto image model, so it went to Krea 2 Realism first",- plain: "A plain prompt, so it went to Krea 2 Realism first",+ plain: "A plain prompt, so it went to MiniMax H3 Image first",fallback: "The model before it couldn't make it, so Auto's next model made it",declined: "Ideogram 4 declined it, so this model made it instead",};+/**+ * Why Auto picked the model it did, in words: AUTO_WHY_WORDS, and for a plain or lettering prompt that started on another+ * model than MiniMax H3 Image (its GPU couldn't take that lane or hold its files, or it was switched off), that one.+ */+function autoWhyWords(why: AutoWhy, model: string): string {+ if ((why === "plain" || why === "text") && model !== AUTO_LEAD_MODEL) {+ const name = getModel(model)?.name ?? model;+ return `${why === "text" ? "Its words ask for lettering" : "A plain prompt"}, and ${getModel(AUTO_LEAD_MODEL)?.name ?? AUTO_LEAD_MODEL} didn't fit the GPU it went to (or was switched off), so it went to ${name} first`;+ }+ return AUTO_WHY_WORDS[why] ?? why;+}+const DECLINED_STAGE_WORDS: Record<string, string> = {retry: "Ideogram 4 declined it and was asked again with a new seed",fallback: "Ideogram 4 declined it, so another model made it",@@ -543,7 +555,7 @@ export function madeByOf(run: AdminRun, meta: Record<string, unknown>): RunMadeB.map((n) => n?.trim()).filter((n): n is string => !!n);return {- ...(pick && { auto: { model: pick.model, name: getModel(pick.model)?.name ?? pick.model, why: pick.why, words: AUTO_WHY_WORDS[pick.why] ?? pick.why } }),+ ...(pick && { auto: { model: pick.model, name: getModel(pick.model)?.name ?? pick.model, why: pick.why, words: autoWhyWords(pick.why, pick.model) } }),...(declined && { declined }),notices,// Worked out here when the run doesn't carry it: the same rules the studios use before a run.diff --git a/src/server/settings.ts b/src/server/settings.tsindex 3665bfef..003188b7 100644--- a/src/server/settings.ts+++ b/src/server/settings.ts@@ -137,7 +137,7 @@ export const SETTINGS = {/** Tokens of context the local model gets (Ollama's num_ctx; LM Studio loads models with it). 0 = the server's own setting. */llmContext: { key: "llm.context", env: "FUOBE_LLM_CONTEXT", default: "16384" },/**- * Settings → Auto image model: prompts Auto starts on Krea 2 Realism (as it does every plain prompt), one pattern per+ * Settings → Auto image model: prompts Auto starts on Krea 2 Realism (a plain prompt starts on MiniMax H3 Image), one pattern per* line, whose run details name the line they matched (src/lib/auto-image.ts). Empty: the built-in list.*/autoImagePatterns: { key: "auto.imagePatterns", default: DEFAULT_AUTO_PATTERNS.join("\n") },diff --git a/tests/auto-image-gpu.test.ts b/tests/auto-image-gpu.test.tsnew file mode 100644index 00000000..e84c7bba--- /dev/null+++ b/tests/auto-image-gpu.test.ts@@ -0,0 +1,168 @@+import fs from "node:fs";+import path from "node:path";+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";+import type { Generation } from "@/lib/catalog/types";+import type { GpuInventory, RequirementIndex } from "@/lib/gpu/types";+import { tempDir } from "./helpers/temp-dir";++// Auto on a ComfyUI the GPU check reads (the owner's own server here; an account's own GPU and a computer read the same+// way): MiniMax H3 Image is planned only where the last check reads a card with the VRAM its lane needs (about 32 GB) and+// its files; elsewhere the run starts on the next model, and a later fallback never goes to it either. With no check to+// read, MiniMax H3 Image is tried, and its failure moves to the next model. This install's GPUs on the workers:+// tests/auto-image-pool.test.ts. Stand-ins only: nothing here reaches a GPU.+vi.setConfig({ testTimeout: 60_000 });+process.env.FUOBE_DATA_DIR = tempDir("fuobe-auto-image-gpu-");+process.env.COMFYUI_URL = "http://127.0.0.1:9"; // nothing listens here: runs fall back to the demo+process.env.OLLAMA_URL = "http://127.0.0.1:9";+delete process.env.ANTHROPIC_API_KEY;+delete process.env.FUOBE_GPU_PREFLIGHT;++const { setSetting } = await import("@/server/settings");+const { createGenerations, getGeneration, previewGeneration } = await import("@/server/generations");+const { mockProvider } = await import("@/server/providers/mock");+const { changeAccess } = await import("@/server/model-access");+const { writeSnapshot, dropSnapshots } = await import("@/server/gpu/snapshots");+const { autoFitsHere } = await import("@/server/auto-gpu");+const { AUTO_IMAGE } = await import("@/lib/auto-image");++const index = JSON.parse(fs.readFileSync(path.join(process.cwd(), "workflows/comfyui/requirements.json"), "utf8")) as RequirementIndex;+const H3 = "oss-minimax-h3-image";+const H3_FILES = index.workflows["minimax-h3-image-t2i"].files.map((k) => `${index.files[k].folder}/${index.files[k].file}`);+const GIB = 2 ** 30;+const INSTALL = { kind: "install", key: "install", via: "server" } as const;++/** The install's last GPU check: one graphics card of `gb` (none: a CPU), with these model files. */+function inventory(o: { gb?: number; files?: string[] }): GpuInventory {+ const at = Date.now();+ const models: GpuInventory["models"] = { diffusion_models: { have: {}, total: 0 }, text_encoders: { have: {}, total: 0 }, vae: { have: {}, total: 0 }, loras: { have: {}, total: 0 } };+ for (const key of o.files ?? []) {+ const [folder, file] = key.split("/");+ (models[folder] ??= { have: {}, total: 0 }).have[file] = null;+ }+ for (const m of Object.values(models)) m.total = Object.keys(m.have).length;+ return {+ v: 1,+ via: "server",+ checkedAt: at,+ tookMs: 5,+ reachable: true,+ comfy: { version: "0.45.0", os: "posix", torch: "2.12.0+cu130", embeddedPython: false, deployEnv: "local-git", flags: {} as never },+ devices: o.gb === undefined ? [] : [{ name: "cuda:0 NVIDIA GeForce RTX : cudaMallocAsync", type: "cuda", index: 0, vramTotal: o.gb * GIB, vramFree: o.gb * GIB }],+ manager: { api: "none" },+ nodes: { have: [], missing: [], total: 1, readAt: at, how: "object_info" },+ combos: {},+ packs: {},+ models,+ loras: {},+ fingerprint: "x",+ errors: [],+ } as never;+}+const checked = (o: Parameters<typeof inventory>[0]) => writeSnapshot(INSTALL, inventory(o));+const picked = (prompt: string) => previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt }).model.id;++let failing = new Set<string>();+let handed: string[] = [];+const submit = mockProvider.submit;+const poll = mockProvider.poll;++beforeAll(() => setSetting("demoMode", "auto"));+beforeEach(() => {+ setSetting("enhanceProvider", "none");+ setSetting("autoImagePatterns", "");+ changeAccess([{ kind: "reset" }]);+ dropSnapshots("install");+ failing = new Set();+ handed = [];+ mockProvider.submit = async (ctx) => {+ handed.push(ctx.model.id);+ return submit(ctx);+ };+ mockProvider.poll = async (ctx) => (failing.has(ctx.model.id) ? { state: "failed", error: "Out of memory on the GPU" } : poll(ctx));+});+afterEach(() => {+ mockProvider.submit = submit;+ mockProvider.poll = poll;+});++async function run(prompt: string): Promise<Generation> {+ const made = createGenerations({ feature: "image", modelId: AUTO_IMAGE, prompt });+ const end = Date.now() + 30_000;+ for (;;) {+ const g = getGeneration(made[0].id)!;+ if (["succeeded", "failed", "canceled"].includes(g.status)) return g;+ if (Date.now() > end) throw new Error(`${g.id} is still ${g.status}`);+ await new Promise((r) => setTimeout(r, 50));+ }+}++describe("Auto and the GPU's size and files", () => {+ it("a 32 GB card with MiniMax H3 Image's files: plain words and lettering start on it", () => {+ checked({ gb: 32, files: H3_FILES });+ expect(autoFitsHere(H3, "t2i")).toBe(true);+ expect(picked("a red fox in deep snow")).toBe(H3);+ expect(picked('a poster that says "GRAND OPENING"')).toBe(H3);+ // A prompt the patterns match keeps Krea 2 Realism first.+ expect(picked("editorial photo of a model in swimwear on a yacht")).toBe("oss-krea2-realism");+ // A larger card too.+ checked({ gb: 96, files: H3_FILES });+ expect(picked("a red fox in deep snow")).toBe(H3);+ });++ it("a smaller card: Krea 2 Realism for plain words, MOSS-Image for lettering", () => {+ for (const gb of [24, 16, 12]) {+ checked({ gb, files: H3_FILES });+ expect(autoFitsHere(H3, "t2i"), `${gb} GB`).toBe(false);+ expect(picked("a red fox in deep snow"), `${gb} GB`).toBe("oss-krea2-realism");+ expect(picked('a poster that says "GRAND OPENING"'), `${gb} GB`).toBe("oss-moss-image");+ }+ });++ it("a large card without MiniMax H3 Image's files, or with only some: the next model", () => {+ checked({ gb: 48 });+ expect(autoFitsHere(H3, "t2i")).toBe(false);+ expect(picked("a red fox in deep snow")).toBe("oss-krea2-realism");+ checked({ gb: 48, files: H3_FILES.slice(0, 1) });+ expect(picked("a red fox in deep snow")).toBe("oss-krea2-realism");+ expect(picked('a sign that says "OPEN"')).toBe("oss-moss-image");+ });++ it("a ComfyUI on its CPU: the next model", () => {+ checked({ files: H3_FILES });+ expect(autoFitsHere(H3, "t2i")).toBe(false);+ expect(picked("a red fox in deep snow")).toBe("oss-krea2-realism");+ });++ it("no check to read: MiniMax H3 Image is tried", () => {+ expect(autoFitsHere(H3, "t2i")).toBe(true);+ expect(picked("a red fox in deep snow")).toBe(H3);+ });++ it("only MiniMax H3 Image switched on: it is planned all the same, rather than no model", () => {+ checked({ gb: 16 });+ changeAccess([{ kind: "model", id: "oss-krea2-realism", on: false }, { kind: "model", id: "oss-moss-image", on: false }]);+ expect(picked("a red fox in deep snow")).toBe(H3);+ });++ it("on a smaller card, a fallback never goes to MiniMax H3 Image: Krea 2 Realism fails, MOSS-Image makes it", async () => {+ checked({ gb: 24, files: H3_FILES });+ failing = new Set(["oss-krea2-realism"]);+ const g = await run("a red fox in deep snow");+ expect(g.status, g.error ?? "").toBe("succeeded");+ expect(handed).toEqual(["oss-krea2-realism", "oss-moss-image"]);+ expect(g.request.auto).toEqual({ model: "oss-moss-image", why: "fallback" });+ });++ it("on a card that takes it, MiniMax H3 Image fails: Krea 2 Realism makes it; lettering goes to MOSS-Image", async () => {+ checked({ gb: 32, files: H3_FILES });+ failing = new Set([H3]);+ const g = await run("a red fox in deep snow");+ expect(g.status, g.error ?? "").toBe("succeeded");+ expect(handed).toEqual([H3, "oss-krea2-realism"]);+ handed = [];+ const t = await run('a poster that says "GRAND OPENING"');+ expect(t.status, t.error ?? "").toBe("succeeded");+ expect(handed).toEqual([H3, "oss-moss-image"]);+ expect(t.request.auto).toEqual({ model: "oss-moss-image", why: "fallback" });+ });+});diff --git a/tests/auto-image-pool.test.ts b/tests/auto-image-pool.test.tsindex bbe8c682..555e1f68 100644--- a/tests/auto-image-pool.test.ts+++ b/tests/auto-image-pool.test.ts@@ -5,10 +5,12 @@ import { startFakeBilling, FAKE_POLICY, type FakeBilling } from "./helpers/fake-import { tempDir } from "./helpers/temp-dir";/**- * An account's free run of Auto on this install's GPUs: Auto picks its model there as anywhere (Krea 2 Realism, or- * MOSS-Image for lettering), and when that model fails, the other one makes the same run on the same GPUs. One press of- * Run stays one run: the hourly count, the runs at once and the billing hold count it once; the account reads which- * model made its picture. The price before Run is the picked model's. (The owner's runs: tests/auto-image-runs.test.ts.)+ * An account's free run of Auto on this install's GPUs: Auto picks its model there as anywhere (MiniMax H3 Image, then+ * Krea 2 Realism, or MOSS-Image for lettering), MiniMax H3 Image only where a worker allowed its lane has its files and+ * the VRAM it needs; when a model fails, the next one makes the same run on the same GPUs. One press of Run stays one+ * run: the hourly count, the runs at once and the billing hold count it once; the account reads which model made its+ * picture. The price before Run is the picked model's. (The owner's runs: tests/auto-image-runs.test.ts; a GPU the check+ * reads: tests/auto-image-gpu.test.ts.)*/vi.mock("next/server", async (importOriginal) => ({ ...(await importOriginal<typeof import("next/server")>()), connection: async () => {} }));@@ -52,6 +54,7 @@ const { AUTO_IMAGE } = await import("@/lib/auto-image");const { autoLine } = await import("@/lib/auto-image");const { encodePng } = await import("@/server/png");+const H3 = "oss-minimax-h3-image";const HOST = "localhost:3000";const SITE_HEADERS = { host: HOST, "sec-fetch-site": "same-origin", origin: `http://${HOST}` };const sha = (s: string) => crypto.createHash("sha256").update(s).digest("hex");@@ -80,14 +83,20 @@ const post = async (body: Record<string, unknown>, cookie: string, preview = falreturn { status: r.status, body: (await r.json()) as { items?: { id: string }[]; code?: string; error?: string; modelId?: string; modelName?: string; place?: string; quote?: Record<string, unknown> } };};-/** A worker as the owner adds it, connected: the line is open for the account's runs. */-function standInWorker() {+/**+ * A worker as the owner adds it, connected: the line is open for the account's runs. `vramGb`: its card (96 GB by+ * default); `without`: workflows whose files it doesn't hold.+ */+function standInWorker(o: { vramGb?: number; without?: string[] } = {}) {const w = pool.addWorker(`stand-in-${++n}`);const lanes = allLanes(loadIndex(), sha);pool.patchWorker(w.id, { paused: false, hours: { always: true }, allow: Object.fromEntries(lanes.map((l) => [l.lane, { delayMs: 0 }])), claimAfterMs: 0 });+ const workflows = loadManifest()+ .workflows.map((x) => x.id)+ .filter((id) => !o.without?.includes(id));db().prepare("UPDATE relay_workers SET lanes_json = ?, facts_json = ?, catalog_version = ?, protocol = 3 WHERE id = ?")- .run(JSON.stringify({ lanes: lanes.map((l) => l.lane), workflows: loadManifest().workflows.map((x) => x.id) }), JSON.stringify({ vramBytes: 96 * 2 ** 30 }), catalogVersion(), w.id);+ .run(JSON.stringify({ lanes: lanes.map((l) => l.lane), workflows }), JSON.stringify({ vramBytes: (o.vramGb ?? 96) * 2 ** 30 }), catalogVersion(), w.id);db().prepare("UPDATE relay_workers SET seen_at = ?, paused_local = 0 WHERE id = ?").run(Date.now(), w.id);return w;}@@ -161,7 +170,7 @@ afterEach(() => {});describe("an account's free run of Auto on this install's GPUs", () => {- it("a plain prompt: Krea 2 Realism, with no Ideogram 4 or FIBO 2 Dev job", async () => {+ it("a plain prompt: MiniMax H3 Image, with no Ideogram 4 or FIBO 2 Dev job", async () => {const a = account();accountId = a.id;const r = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: "a red fox in deep snow", params: { aspectRatio: "4:5" } }, a.cookie);@@ -169,31 +178,31 @@ describe("an account's free run of Auto on this install's GPUs", () => {const g = await settled(r.body.items![0].id);expect(g.status, g.error ?? "").toBe("succeeded");expect(g.place).toBe("pool");- expect(sent.map((s) => s.model)).toEqual(["oss-krea2-realism"]);- expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "plain" });- expect(autoLine(g)).toBe("Auto · made with Krea 2 Realism");+ expect(sent.map((s) => s.model)).toEqual([H3]);+ expect(g.request.auto).toEqual({ model: H3, why: "plain" });+ expect(autoLine(g)).toBe("Auto · made with MiniMax H3 Image");});- it("Krea 2 Realism fails: MOSS-Image makes it there at once, and it counts as one run", async () => {+ it("MiniMax H3 Image fails: Krea 2 Realism makes it there at once, and it counts as one run", async () => {const a = account();accountId = a.id;- failing = new Set(["oss-krea2-realism"]);+ failing = new Set([H3]);const r = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: "a red fox in deep snow", params: { aspectRatio: "4:5" } }, a.cookie);expect(r.status, JSON.stringify(r.body)).toBe(201);const id = r.body.items![0].id;const g = await settled(id);expect(g.status, g.error ?? "").toBe("succeeded");expect(g.place).toBe("pool");- expect(g.modelId).toBe("oss-moss-image");+ expect(g.modelId).toBe("oss-krea2-realism");expect(g.request.modelId).toBe(AUTO_IMAGE);- expect(g.request.auto).toEqual({ model: "oss-moss-image", why: "fallback" });- expect(autoLine(g)).toBe("Auto · made with MOSS-Image · Auto's next model");+ expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "fallback" });+ expect(autoLine(g)).toBe("Auto · made with Krea 2 Realism · Auto's next model");expect(sent.map((s) => [s.model, s.id])).toEqual([+ [H3, id],["oss-krea2-realism", id],- ["oss-moss-image", id],]);expect(sent[1].tile.status).toBe("running");- expect(sent[1].tile.message).toBe("Making it with MOSS-Image");+ expect(sent[1].tile.message).toBe("Making it with Krea 2 Realism");expect(sent[1].tile.queue).toBeUndefined();expect(sent.map((s) => s.going)).toEqual([1, 1]);expect(sent.map((s) => s.hourly)).toEqual([1, 1]);@@ -201,36 +210,65 @@ describe("an account's free run of Auto on this install's GPUs", () => {expect(rowsOf(a.id)).toBe(1);});- it("lettering: MOSS-Image first, then Krea 2 Realism when it fails, still one run", async () => {+ it("lettering: MiniMax H3 Image first, then MOSS-Image when it fails, still one run", async () => {const a = account();accountId = a.id;- failing = new Set(["oss-moss-image"]);+ failing = new Set([H3]);const r = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: 'a sign that says "LIGHTHOUSE" at dusk' }, a.cookie);expect(r.status, JSON.stringify(r.body)).toBe(201);const g = await settled(r.body.items![0].id);expect(g.status, g.error ?? "").toBe("succeeded");- expect(sent.map((s) => s.model)).toEqual(["oss-moss-image", "oss-krea2-realism"]);- expect(g.modelId).toBe("oss-krea2-realism");- expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "fallback" });+ expect(sent.map((s) => s.model)).toEqual([H3, "oss-moss-image"]);+ expect(g.modelId).toBe("oss-moss-image");+ expect(g.request.auto).toEqual({ model: "oss-moss-image", why: "fallback" });expect(sent.map((s) => s.hourly)).toEqual([1, 1]);expect(admitted(a.id)).toBe(1);expect(rowsOf(a.id)).toBe(1);});- it("both fail: each tried once, then the run fails once, as one run", async () => {+ it("all fail: each tried once, then the run fails once, as one run", async () => {const a = account();accountId = a.id;- failing = new Set(["oss-krea2-realism", "oss-moss-image"]);+ failing = new Set([H3, "oss-krea2-realism", "oss-moss-image"]);const r = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: "a lighthouse at dusk" }, a.cookie);expect(r.status, JSON.stringify(r.body)).toBe(201);const g = await settled(r.body.items![0].id);expect(g.status).toBe("failed");- expect(sent.map((s) => s.model)).toEqual(["oss-krea2-realism", "oss-moss-image"]);+ expect(sent.map((s) => s.model)).toEqual([H3, "oss-krea2-realism", "oss-moss-image"]);expect(admitted(a.id)).toBe(1);expect(rowsOf(a.id)).toBe(1);});- it("a prompt the patterns match goes to Krea 2 Realism, and so does a plain one; the price before Run is that model's", async () => {+ it("workers whose cards are too small for MiniMax H3 Image's lane: Krea 2 Realism, or MOSS-Image for lettering, priced as that", async () => {+ db().prepare("DELETE FROM relay_workers").run();+ standInWorker({ vramGb: 24 });+ const a = account();+ accountId = a.id;+ const price = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" }, a.cookie, true);+ expect(price.body).toMatchObject({ place: "pool", modelId: "oss-krea2-realism", quote: { allowed: true } });+ const words = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: 'a sign that says "OPEN"' }, a.cookie, true);+ expect(words.body).toMatchObject({ place: "pool", modelId: "oss-moss-image" });+ // When Krea 2 Realism fails there, MOSS-Image makes it: MiniMax H3 Image is never sent to a card that can't take it.+ failing = new Set(["oss-krea2-realism"]);+ const r = await post({ feature: "image", modelId: AUTO_IMAGE, prompt: "a red fox in deep snow" }, a.cookie);+ expect(r.status, JSON.stringify(r.body)).toBe(201);+ const g = await settled(r.body.items![0].id);+ expect(g.status, g.error ?? "").toBe("succeeded");+ expect(sent.map((s) => s.model)).toEqual(["oss-krea2-realism", "oss-moss-image"]);+ });++ it("workers without MiniMax H3 Image's files: the next model; one worker with them is enough", async () => {+ db().prepare("DELETE FROM relay_workers").run();+ standInWorker({ without: ["minimax-h3-image-t2i", "minimax-h3-image-edit"] });+ const a = account();+ accountId = a.id;+ const plain = { feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" };+ expect((await post(plain, a.cookie, true)).body).toMatchObject({ place: "pool", modelId: "oss-krea2-realism" });+ standInWorker({ vramGb: 32 });+ expect((await post(plain, a.cookie, true)).body).toMatchObject({ place: "pool", modelId: H3, modelName: "MiniMax H3 Image" });+ });++ it("a prompt the patterns match goes to Krea 2 Realism, a plain one to MiniMax H3 Image; the price before Run is that model's", async () => {const a = account();accountId = a.id;const cat = { feature: "image", modelId: AUTO_IMAGE, prompt: "a cat in an antique-gold paillette gown, her hair lifting in the wind" };@@ -238,7 +276,7 @@ describe("an account's free run of Auto on this install's GPUs", () => {expect(price.status, JSON.stringify(price.body)).toBe(200);expect(price.body).toMatchObject({ place: "pool", modelId: "oss-krea2-realism", modelName: "Krea 2 Realism", quote: { allowed: true } });const plain = await post({ ...cat, prompt: "a koi pond at night" }, a.cookie, true);- expect(plain.body).toMatchObject({ place: "pool", modelId: "oss-krea2-realism", quote: { allowed: true } });+ expect(plain.body).toMatchObject({ place: "pool", modelId: H3, modelName: "MiniMax H3 Image", quote: { allowed: true } });const r = await post(cat, a.cookie);expect(r.status, JSON.stringify(r.body)).toBe(201);const g = await settled(r.body.items![0].id);diff --git a/tests/auto-image-runs.test.ts b/tests/auto-image-runs.test.tsindex cae4c139..ccfa04ed 100644--- a/tests/auto-image-runs.test.ts+++ b/tests/auto-image-runs.test.ts@@ -3,10 +3,11 @@ import { renderToStaticMarkup } from "react-dom/server";import type { GenInput, Generation } from "@/lib/catalog/types";import { tempDir } from "./helpers/temp-dir";-// Auto's runs: each is planned on the model Auto picks (Krea 2 Realism, MOSS-Image for lettering, Qwen-Image 2.1 for an-// edit; never Ideogram 4 or FIBO 2 Dev for a picture from words) and keeps Auto with its pick. When its text-to-image-// model fails, the other one makes the same run, each at most once, and only then does it fail. Ideogram 4 picked by name-// still takes its own fallbacks when it declines (tests/ideogram-declined.test.ts). Its rules alone: tests/auto-image.test.ts.+// Auto's runs: each is planned on the model Auto picks (MiniMax H3 Image, then Krea 2 Realism, or MOSS-Image for+// lettering; Qwen-Image 2.1 for an edit; never Ideogram 4 or FIBO 2 Dev for a picture from words) and keeps Auto with its+// pick. When its text-to-image model fails, the next one makes the same run, each at most once, and only then does it+// fail. Ideogram 4 picked by name still takes its own fallbacks when it declines (tests/ideogram-declined.test.ts). Its+// rules alone: tests/auto-image.test.ts; by the GPU's size and files: tests/auto-image-gpu.test.ts.vi.setConfig({ testTimeout: 60_000 });const dir = tempDir("fuobe-auto-image-runs-");process.env.FUOBE_DATA_DIR = dir;@@ -43,6 +44,7 @@ const poll = mockProvider.poll;const answers = new Map<string, Buffer[]>();const CAT = "a cat in an antique-gold paillette gown, studio light, her hair lifting in the wind";+const H3 = "oss-minimax-h3-image";beforeAll(() => setSetting("demoMode", "auto"));beforeEach(() => {@@ -91,25 +93,28 @@ const rowsSince = (id: string) => db().prepare("SELECT COUNT(*) FROM generationsconst line = (g: Generation) => renderToStaticMarkup(MadeNote({ g })!);describe("what Auto runs on", () => {- it("plain words: Krea 2 Realism, and the run keeps Auto with its pick", async () => {- const g = await run("a red fox in deep snow", { params: { aspectRatio: "16:9" } });+ it("plain words: MiniMax H3 Image at its 2K, and the run keeps Auto with its pick", async () => {+ const g = await run("a red fox in deep snow", { params: { aspectRatio: "16:9", resolution: "1.5K" } });expect(g.status, g.error ?? "").toBe("succeeded");- expect(handed.map((h) => h.model)).toEqual(["oss-krea2-realism"]);- expect(g.modelId).toBe("oss-krea2-realism");+ expect(handed.map((h) => h.model)).toEqual([H3]);+ expect(g.modelId).toBe(H3);expect(g.request.modelId).toBe(AUTO_IMAGE);- expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "plain" });+ expect(g.request.auto).toEqual({ model: H3, why: "plain" });expect(handed[0].input.aspectRatio).toBe("16:9");- expect(line(g)).toContain("Auto · made with Krea 2 Realism");+ // Auto's 1.5K is below what MiniMax H3 Image makes: it makes the run at its own 2K. The request keeps what was asked.+ expect(handed[0].input.resolution).toBe("2K");+ expect(g.request.params?.resolution).toBe("1.5K");+ expect(line(g)).toContain("Auto · made with MiniMax H3 Image");expect(line(g)).not.toContain("next model");expect(g.request.notice).toBeUndefined();});- it("lettering: MOSS-Image", async () => {+ it("lettering: MiniMax H3 Image first too", async () => {const g = await run('a poster that says "GRAND OPENING" in gold letters');expect(g.status, g.error ?? "").toBe("succeeded");- expect(handed.map((h) => h.model)).toEqual(["oss-moss-image"]);- expect(g.request.auto).toEqual({ model: "oss-moss-image", why: "text" });- expect(line(g)).toContain("Auto · made with MOSS-Image");+ expect(handed.map((h) => h.model)).toEqual([H3]);+ expect(g.request.auto).toEqual({ model: H3, why: "text" });+ expect(line(g)).toContain("Auto · made with MiniMax H3 Image");});it("a prompt the patterns match: Krea 2 Realism, naming the pattern", async () => {@@ -139,29 +144,34 @@ describe("what Auto runs on", () => {it("Ideogram 4 and FIBO 2 Dev are never planned for a picture from words, whatever the words or the switches", () => {const words = ["a koi pond at night", 'a poster that says "OPEN"', CAT, "a neon sign above a bar", "a woman in a red evening gown"];- for (const prompt of words) expect(["oss-krea2-realism", "oss-moss-image"], prompt).toContain(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt }).model.id);+ for (const prompt of words) expect([H3, "oss-krea2-realism", "oss-moss-image"], prompt).toContain(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt }).model.id);+ changeAccess([{ kind: "model", id: H3, on: false }]);+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" }).model.id).toBe("oss-krea2-realism");+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: 'a poster that says "OPEN"' }).model.id).toBe("oss-moss-image");changeAccess([{ kind: "model", id: "oss-krea2-realism", on: false }]);for (const prompt of words) expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt }).model.id, prompt).toBe("oss-moss-image");changeAccess([{ kind: "model", id: "oss-moss-image", on: false }]);- // Neither is on: Auto asks for a model rather than reaching for Ideogram 4 or FIBO 2 Dev.+ // None is on: Auto asks for a model rather than reaching for Ideogram 4 or FIBO 2 Dev.expect(() => previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" })).toThrow(/Auto has no image model switched on here/);});it("the owner's own patterns still route, and a model switched off is passed over", async () => {setSetting("autoImagePatterns", "koi");expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" }).model.id).toBe("oss-krea2-realism");- expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT }).model.id).toBe("oss-krea2-realism");+ // The built-in lines are gone with that list: a prompt only they matched is a plain one now.+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT }).model.id).toBe(H3);setSetting("autoImagePatterns", "");+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT }).model.id).toBe("oss-krea2-realism");expect(getSetting("autoImagePatterns")).toBe(DEFAULT_AUTO_PATTERNS.join("\n"));- changeAccess([{ kind: "model", id: "oss-moss-image", on: false }]);+ changeAccess([{ kind: "model", id: H3, on: false }, { kind: "model", id: "oss-moss-image", on: false }]);expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: 'a poster that says "OPEN"' }).model.id).toBe("oss-krea2-realism");});it("is priced before Run as the model it would pick (free on a GPU), and a pick it carries stays while it is one of Auto's", () => {const p = previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: "a koi pond at night" });- expect(p.model.id).toBe("oss-krea2-realism");+ expect(p.model.id).toBe(H3);expect(p.costUsd).toBe(0);- expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: 'a sign that says "OPEN"' }).model.id).toBe("oss-moss-image");+ expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: 'a sign that says "OPEN"' }).model.id).toBe(H3);// A run planned again (a resend, a run that waited to enter the line) keeps the model it was made with.expect(previewGeneration({ feature: "image", modelId: AUTO_IMAGE, prompt: CAT, auto: { model: "oss-moss-image", why: "fallback" } }).model.id).toBe("oss-moss-image");// An older run's Ideogram 4 or FIBO 2 Dev pick, or a pick that isn't one of Auto's, is planned again.@@ -181,52 +191,78 @@ describe("what Auto runs on", () => {});describe("Auto's next model when one fails", () => {- it("Krea 2 Realism fails: MOSS-Image makes the same run at once, and the run says so", async () => {- failing = new Set(["oss-krea2-realism"]);+ it("MiniMax H3 Image fails: Krea 2 Realism makes the same run at once, at the size asked, and the run says so", async () => {+ failing = new Set([H3]);const g = await run("a red fox in deep snow", { params: { aspectRatio: "4:5", resolution: "1K" } });expect(g.status, g.error ?? "").toBe("succeeded");- expect(handed.map((h) => h.model)).toEqual(["oss-krea2-realism", "oss-moss-image"]);- expect(g.modelId).toBe("oss-moss-image");+ expect(handed.map((h) => h.model)).toEqual([H3, "oss-krea2-realism"]);+ expect(g.modelId).toBe("oss-krea2-realism");expect(g.request.modelId).toBe(AUTO_IMAGE);- expect(g.request.auto).toEqual({ model: "oss-moss-image", why: "fallback" });+ expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "fallback" });expect(g.request.notice).toBeUndefined();expect(g.outputs).toHaveLength(1);- // The same words, the shape and size asked; Working, saying which model makes it.+ // The same words and shape; MiniMax H3 Image at its 2K, Krea 2 Realism at the 1K asked; Working, saying which model makes it.+ expect(handed[0].input.resolution).toBe("2K");expect(handed[1].input.prompt).toBe("a red fox in deep snow");expect(handed[1].input.aspectRatio).toBe("4:5");+ expect(handed[1].input.resolution).toBe("1K");expect(handed[1].run.status).toBe("running");- expect(handed[1].run.message).toBe("Making it with MOSS-Image");+ expect(handed[1].run.message).toBe("Making it with Krea 2 Realism");expect(rowsSince(g.id)).toBe(1);- expect(line(g)).toContain("Auto · made with MOSS-Image · Auto's next model");+ expect(line(g)).toContain("Auto · made with Krea 2 Realism · Auto's next model");expect(line(g)).not.toContain("declined");expect(g.declinedCards).toBeUndefined();});- it("lettering: MOSS-Image fails, Krea 2 Realism makes it", async () => {- failing = new Set(["oss-moss-image"]);+ it("MiniMax H3 Image and Krea 2 Realism fail: MOSS-Image makes it", async () => {+ failing = new Set([H3, "oss-krea2-realism"]);+ const g = await run("a red fox in deep snow");+ expect(g.status, g.error ?? "").toBe("succeeded");+ expect(handed.map((h) => h.model)).toEqual([H3, "oss-krea2-realism", "oss-moss-image"]);+ expect(g.request.auto).toEqual({ model: "oss-moss-image", why: "fallback" });+ expect(rowsSince(g.id)).toBe(1);+ });++ it("lettering: MiniMax H3 Image fails, MOSS-Image makes it; MOSS-Image fails too, Krea 2 Realism", async () => {+ failing = new Set([H3]);const g = await run('a storefront with "OPEN LATE" painted on the glass');expect(g.status, g.error ?? "").toBe("succeeded");- expect(handed.map((h) => h.model)).toEqual(["oss-moss-image", "oss-krea2-realism"]);- expect(g.request.auto).toEqual({ model: "oss-krea2-realism", why: "fallback" });+ expect(handed.map((h) => h.model)).toEqual([H3, "oss-moss-image"]);+ expect(g.request.auto).toEqual({ model: "oss-moss-image", why: "fallback" });expect(rowsSince(g.id)).toBe(1);++ handed = [];+ failing = new Set([H3, "oss-moss-image"]);+ const k = await run('a neon sign that says "LATE"');+ expect(k.status, k.error ?? "").toBe("succeeded");+ expect(handed.map((h) => h.model)).toEqual([H3, "oss-moss-image", "oss-krea2-realism"]);+ expect(k.request.auto).toEqual({ model: "oss-krea2-realism", why: "fallback" });+ });++ it("a prompt the patterns match: Krea 2 Realism first, then MiniMax H3 Image", async () => {+ failing = new Set(["oss-krea2-realism"]);+ const g = await run(CAT);+ expect(g.status, g.error ?? "").toBe("succeeded");+ expect(handed.map((h) => h.model)).toEqual(["oss-krea2-realism", H3]);+ expect(g.request.auto).toEqual({ model: H3, why: "fallback" });});- it("when both fail, each was tried once, never Ideogram 4 or FIBO 2 Dev, and the run fails once as one run", async () => {- failing = new Set(["oss-krea2-realism", "oss-moss-image", "oss-fibo2-dev", "oss-ideogram-4"]);+ it("when all fail, each was tried once, never Ideogram 4 or FIBO 2 Dev, and the run fails once as one run", async () => {+ failing = new Set([H3, "oss-krea2-realism", "oss-moss-image", "oss-fibo2-dev", "oss-ideogram-4"]);const g = await run("a red fox in deep snow");expect(g.status).toBe("failed");expect(g.error).toMatch(/Out of memory/);- expect(handed.map((h) => h.model)).toEqual(["oss-krea2-realism", "oss-moss-image"]);+ expect(handed.map((h) => h.model)).toEqual([H3, "oss-krea2-realism", "oss-moss-image"]);expect(g.request.modelId).toBe(AUTO_IMAGE);expect(rowsSince(g.id)).toBe(1);});- it("the next model switched off: the run fails as its first model did", async () => {- changeAccess([{ kind: "model", id: "oss-moss-image", on: false }]);- failing = new Set(["oss-krea2-realism"]);+ it("the next models switched off: the run fails as its first model did", async () => {+ changeAccess([{ kind: "model", id: "oss-krea2-realism", on: false }, { kind: "model", id: "oss-moss-image", on: false }]);+ failing = new Set([H3]);const g = await run("a red fox in deep snow");expect(g.status).toBe("failed");- expect(handed.map((h) => h.model)).toEqual(["oss-krea2-realism"]);+ expect(handed.map((h) => h.model)).toEqual([H3]);});});diff --git a/tests/auto-image.test.ts b/tests/auto-image.test.tsindex a5962a2a..e36c5a3a 100644--- a/tests/auto-image.test.ts+++ b/tests/auto-image.test.ts@@ -5,6 +5,7 @@ import { planGeneration, estimateCost } from "@/lib/catalog/plan";import { getPreset } from "@/lib/catalog";import {AUTO_IMAGE,+ AUTO_LARGE_MODELS,AUTO_MODELS,AUTO_T2I_MODELS,autoCandidates,@@ -13,6 +14,7 @@ import {autoNext,autoPatterns,autoPatternsProblems,+ autoResolution,DECLINED_FALLBACKS,DEFAULT_AUTO_PATTERNS,matchedPattern,@@ -29,8 +31,10 @@ import type { Generation } from "@/lib/catalog/types";const defaults = autoPatterns(DEFAULT_AUTO_PATTERNS.join("\n"));const pick = (prompt: string, more: { op?: "t2i" | "edit" | "inpaint" | "outpaint"; images?: number } = {}) => autoCandidates({ prompt, ...more }, defaults);-const KREA_FIRST = ["oss-krea2-realism", "oss-moss-image"];-const MOSS_FIRST = ["oss-moss-image", "oss-krea2-realism"];+const H3 = "oss-minimax-h3-image";+const PLAIN = [H3, "oss-krea2-realism", "oss-moss-image"];+const LETTERING = [H3, "oss-moss-image", "oss-krea2-realism"];+const KREA_FIRST = ["oss-krea2-realism", H3, "oss-moss-image"];describe("Auto in the catalog", () => {it("is an open image choice named Auto, next to the models it picks, which keep their names", () => {@@ -38,6 +42,7 @@ describe("Auto in the catalog", () => {expect(m).toMatchObject({ name: "Auto", engine: "open", kind: "image" });expect(m.routes.map((r) => r.op)).toEqual(["t2i", "edit"]);for (const [id, name] of [+ [H3, "MiniMax H3 Image"],["oss-ideogram-4", "Ideogram 4"],["oss-krea2-realism", "Krea 2 Realism"],["oss-fibo2-dev", "FIBO 2 Dev"],@@ -48,16 +53,20 @@ describe("Auto in the catalog", () => {// Every model it may pick is in the catalog, as an open image model.for (const id of AUTO_MODELS) expect(getModel(id), id).toMatchObject({ engine: "open", kind: "image" });expect(MODELS.filter((x) => x.name === "Auto")).toHaveLength(1);- // Its text-to-image route is Krea 2 Realism's (the GPU pre-flight reads it), and it says what it picks.+ // Its text-to-image route is Krea 2 Realism's (the lane every GPU Auto plans on can take; the GPU pre-flight reads it),+ // and it says what it picks, MiniMax H3 Image first.expect(m.routes.find((r) => r.op === "t2i")?.endpoint).toBe(getModel("oss-krea2-realism")!.routes[0].endpoint);+ expect(m.tagline).toMatch(/^Picks the model for you: MiniMax H3 Image first/);expect(m.tagline).toMatch(/Krea 2 Realism/);expect(m.tagline).toMatch(/MOSS-Image/);expect(m.tagline).not.toMatch(/Ideogram|FIBO/);});it("never plans a picture from words on Ideogram 4 or FIBO 2 Dev; both stay in the catalog to pick by hand", () => {- expect(AUTO_T2I_MODELS).toEqual(KREA_FIRST);- expect(autoModelsFor("t2i")).toEqual(KREA_FIRST);+ expect(AUTO_T2I_MODELS).toEqual(PLAIN);+ expect(autoModelsFor("t2i")).toEqual(PLAIN);+ // MiniMax H3 Image's lane needs a large GPU: the server plans it only where the GPUs can take it.+ expect([...AUTO_LARGE_MODELS]).toEqual([H3]);for (const id of ["oss-ideogram-4", "oss-fibo2-dev"]) {expect(autoModelsFor("t2i")).not.toContain(id);expect(getModel(id)).toMatchObject({ engine: "open", kind: "image" });@@ -90,7 +99,7 @@ describe("what Auto picks", () => {for (const words of ["put the logo on the poster", "a cat in a gown"]) expect(pick(words, { images: 1 }).models).not.toContain("oss-ideogram-4");});- it("lettering, posters, logos, signs and words in quotes: MOSS-Image, then Krea 2 Realism", () => {+ it("lettering, posters, logos, signs and words in quotes: MiniMax H3 Image, then MOSS-Image, then Krea 2 Realism", () => {for (const words of ["a film poster for a heist movie","a minimal logo for a coffee roaster",@@ -101,10 +110,10 @@ describe("what Auto picks", () => {// Lettering wins over a pattern."a poster of a model in a bikini",])- expect(pick(words), words).toEqual({ models: MOSS_FIRST, why: "text" });+ expect(pick(words), words).toEqual({ models: LETTERING, why: "text" });});- it("a prompt the setting's patterns match: Krea 2 Realism, then MOSS-Image, naming the line", () => {+ it("a prompt the setting's patterns match: Krea 2 Realism, then MiniMax H3 Image, then MOSS-Image, naming the line", () => {for (const words of ["a cat in an antique-gold paillette gown, studio light, her hair lifting in the wind","a fox wearing a tailored velvet suit at a gala",@@ -120,9 +129,21 @@ describe("what Auto picks", () => {expect(pick("a cat in an antique-gold paillette gown").pattern).toMatch(/gowns/);});- it("everything else: Krea 2 Realism, then MOSS-Image", () => {+ it("everything else: MiniMax H3 Image, then Krea 2 Realism, then MOSS-Image", () => {for (const words of ["a koi pond at night, neon rain", "a cat asleep on a windowsill", "a dog running on a beach", "a woman in a red evening gown on a staircase", "sheerness of the cliffs", "a swimmer at dawn"])- expect(pick(words), words).toEqual({ models: KREA_FIRST, why: "plain" });+ expect(pick(words), words).toEqual({ models: PLAIN, why: "plain" });+ });++ it("asks MiniMax H3 Image for its 2K where Auto's size is below what it makes; other picks keep the size asked", () => {+ const h3 = getModel(H3)!;+ expect(h3.options.resolutions).toEqual(["2K", "4K"]);+ expect(autoResolution("1K", h3)).toBe("2K");+ expect(autoResolution("1.5K", h3)).toBe("2K");+ expect(autoResolution("2K", h3)).toBe("2K");+ expect(autoResolution(undefined, h3)).toBeUndefined();+ // Krea 2 Realism makes every size Auto offers; MOSS-Image's largest is below Auto's 2K, which it keeps as it did.+ for (const r of ["1K", "1.5K", "2K"]) expect(autoResolution(r, getModel("oss-krea2-realism"))).toBe(r);+ expect(autoResolution("2K", getModel("oss-moss-image"))).toBe("2K");});it("lettering a prompt only rules out doesn't count as asking for it", () => {@@ -133,7 +154,7 @@ describe("what Auto picks", () => {"a clean product shot, text-free, logo-free","a misty forest, avoid text and labels",])- expect(pick(words), words).toEqual({ models: KREA_FIRST, why: "plain" });+ expect(pick(words), words).toEqual({ models: PLAIN, why: "plain" });// A prompt that rules some lettering out and asks for other lettering still asks for it.for (const words of ['a poster that says "OPEN", no watermark', "a neon sign above a bar, no logos", "no text on the shirt, a logo on the cap"])expect(pick(words), words).toMatchObject({ why: "text" });@@ -144,16 +165,19 @@ describe("what Auto picks", () => {const c = pick(words);expect(c.models, words).not.toContain("oss-ideogram-4");expect(c.models, words).not.toContain("oss-fibo2-dev");- expect([...c.models].sort(), words).toEqual([...KREA_FIRST].sort());+ expect([...c.models].sort(), words).toEqual([...PLAIN].sort());}});- it("the next model after one fails: the other of the two, each at most once, then none", () => {- expect(autoNext(KREA_FIRST, ["oss-krea2-realism"])).toEqual(["oss-moss-image"]);- expect(autoNext(MOSS_FIRST, ["oss-moss-image"])).toEqual(["oss-krea2-realism"]);- expect(autoNext(KREA_FIRST, ["oss-krea2-realism", "oss-moss-image"])).toEqual([]);- // An older run that started on Ideogram 4: both are left, in order.- expect(autoNext(KREA_FIRST, ["oss-ideogram-4"])).toEqual(KREA_FIRST);+ it("the next model after one fails: the next in order, each at most once, then none", () => {+ expect(autoNext(PLAIN, [H3])).toEqual(["oss-krea2-realism", "oss-moss-image"]);+ expect(autoNext(PLAIN, [H3, "oss-krea2-realism"])).toEqual(["oss-moss-image"]);+ expect(autoNext(LETTERING, [H3])).toEqual(["oss-moss-image", "oss-krea2-realism"]);+ expect(autoNext(LETTERING, [H3, "oss-moss-image"])).toEqual(["oss-krea2-realism"]);+ expect(autoNext(KREA_FIRST, ["oss-krea2-realism"])).toEqual([H3, "oss-moss-image"]);+ expect(autoNext(PLAIN, PLAIN)).toEqual([]);+ // An older run that started on Ideogram 4: all are left, in order.+ expect(autoNext(PLAIN, ["oss-ideogram-4"])).toEqual(PLAIN);});it("Ideogram 4 picked by name, after it declines: Krea 2 Realism, FIBO 2 Dev, MOSS-Image, then none", () => {