Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

feat(models): every local bundle states its graphics memory need as numbers

purple26f62e836c0e
diff --git a/README.md b/README.md
index 4d9b18f7..7ae46938 100644
--- a/README.md
+++ b/README.md
@@ -149,7 +149,7 @@ GLM 5.3 is in the catalog too, but its smallest local quant is 217 GB, so on a d
| DreamShaper XL Turbo V2 | 6-8 GB | Anime and stylized. |
| FLUX.1 schnell or dev | 8-10 GB | Fast, or slower and better. |
| FLUX 2 Klein 4B | 8-10 GB | The newest FLUX, and the quickest of them. |
-| Z-Image Turbo | 10-16 GB | Unfiltered, 8 to 15 seconds per image. |
+| Z-Image Turbo | 10-16 GB | Unfiltered. Loads slowly below 16 GB. |
| Qwen-Image 2.1 | 16-24 GB | Generates and edits in one model. Needs ComfyUI 0.37.0. Research license, non-commercial. |
| ERNIE-Image Turbo | 24 GB | Baidu DiT, eight steps. |
diff --git a/src/api/__tests__/download-integrity.test.ts b/src/api/__tests__/download-integrity.test.ts
index 1e3f0a5e..556bd313 100644
--- a/src/api/__tests__/download-integrity.test.ts
+++ b/src/api/__tests__/download-integrity.test.ts
@@ -33,6 +33,8 @@ function bundle(files: Array<Partial<DiscoverModel>>, totalSizeGB = 0): ModelBun
tags: [],
totalSizeGB,
vramRequired: '8 GB',
+ vramMinGB: 8,
+ vramComfortGB: 8,
workflow: 'wan',
tier: 'standard',
files: files.map(f => ({
diff --git a/src/api/model-bundles.ts b/src/api/model-bundles.ts
index 5752d63e..298fd538 100644
--- a/src/api/model-bundles.ts
+++ b/src/api/model-bundles.ts
@@ -1,7 +1,8 @@
/**
* Der Download-Katalog: welche Dateien es gibt, wie groß sie sind und in
* welchen ComfyUI-Ordner sie gehören. Reine Daten plus die Formen, die sie
- * beschreiben — dieses Modul importiert außer einem Typ nichts.
+ * beschreiben. Dieses Modul importiert außer einem Typ nur die reine
+ * Grafikspeicher-Regel aus lib/vram-fit, die selbst nichts importiert.
*
* Audit W-T2: Der Katalog stand in api/discover.ts, dem Modul, das Downloads
* anstößt und ComfyUI nach installierten Dateien fragt. api/comfyui.ts braucht
@@ -21,6 +22,7 @@
import type { ProviderId } from './providers/types'
import type { ModelTier } from '../lib/render/model-tier'
+import { withVramNeed } from '../lib/vram-fit'
export interface DiscoverModel {
name: string
@@ -87,7 +89,7 @@ export interface DiscoverModel {
// ─── Image Model Bundles ───
export function getImageBundles(): ModelBundle[] {
- return [
+ return withVramNeed([
{
name: 'Juggernaut XL V9 (Photorealistic)',
description: 'Best photorealistic SDXL checkpoint. All in one. Just install and generate.',
@@ -285,7 +287,7 @@ export function getImageBundles(): ModelBundle[] {
},
{
name: 'Z-Image Turbo (Unfiltered, Fast)',
- description: 'Explicitly unfiltered image model. 8 to 15 seconds per image. No safety filters. Text to Image and Image to Image.',
+ description: 'Explicitly unfiltered image model. No safety filters. Text to Image and Image to Image.',
tags: ['Z-Image', 'Unfiltered', 'Fast', '1024px'],
uncensored: true,
verified: true,
@@ -613,7 +615,7 @@ export function getImageBundles(): ModelBundle[] {
},
],
},
- ]
+ ])
}
// Flat list for backwards compat
@@ -713,6 +715,15 @@ export interface ModelBundle {
tags: string[]
totalSizeGB: number
vramRequired: string
+ /**
+ * The same requirement as numbers, stamped on every entry by the one rule in
+ * lib/vram-fit (never written by hand, so no entry can disagree with its own
+ * text): from `vramMinGB` the model runs, from `vramComfortGB` it runs
+ * without moving weights out of graphics memory. Null when the text names no
+ * number, which is the companion files whose need is the checkpoint's.
+ */
+ vramMinGB: number | null
+ vramComfortGB: number | null
workflow: string
/**
* How the pickers order this bundle (Oct 2026, David). 'best' is today's open
@@ -767,7 +778,7 @@ export function getLoraAddonBundles(): ModelBundle[] {
}
export function getVideoBundles(): ModelBundle[] {
- return [
+ return withVramNeed([
{
name: 'Wan 2.1 · 1.3B (Lightweight)',
description: 'Best for 8 to 10 GB VRAM GPUs. Generates 480p video. Fast and lightweight.',
@@ -1441,7 +1452,7 @@ export function getVideoBundles(): ModelBundle[] {
},
],
},
- ]
+ ])
}
// ─── 2.5.8 specialized local-lane bundles (music / talking character / motion) ───
@@ -1453,7 +1464,7 @@ export function getVideoBundles(): ModelBundle[] {
// video list above (real uncensored finetunes) instead.
export function getAudioBundles(): ModelBundle[] {
- return [
+ return withVramNeed([
{
name: 'ACE Step 1.5 Turbo (Music)',
description: 'Newest full song generator, MIT licensed. Vocals, lyrics and instruments from a text description. One file.',
@@ -1518,7 +1529,7 @@ export function getAudioBundles(): ModelBundle[] {
},
],
},
- ]
+ ])
}
export function getLipsyncBundles(): ModelBundle[] {
@@ -1546,10 +1557,10 @@ export function getLipsyncBundles(): ModelBundle[] {
filename: 'wav2vec2_large_english_fp16.safetensors', subfolder: 'audio_encoders', sizeGB: 0.59,
},
]
- return [
+ return withVramNeed([
{
name: 'Wan 2.2 S2V Q4 (Talking Character, GGUF)',
- description: 'A portrait plus any voice becomes a talking video. Q4 quant, the comfortable pick for 12 GB cards.',
+ description: 'A portrait plus any voice becomes a talking video. Q4 quant, the pick for 12 GB cards.',
tags: ['Wan 2.2', 'S2V', 'GGUF'],
totalSizeGB: 20.0,
vramRequired: '10-12 GB',
@@ -1588,7 +1599,7 @@ export function getLipsyncBundles(): ModelBundle[] {
...s2vSupport,
],
},
- ]
+ ])
}
export function getMotionBundles(): ModelBundle[] {
@@ -1608,7 +1619,7 @@ export function getMotionBundles(): ModelBundle[] {
filename: 'wan_2.1_vae.safetensors', subfolder: 'vae', sizeGB: 0.24,
},
]
- return [
+ return withVramNeed([
{
name: 'Wan VACE 1.3B (Motion Control, light)',
description: 'Your character copies the moves from any dance or pose video. The light pick, runs from 8 GB VRAM.',
@@ -1651,5 +1662,5 @@ export function getMotionBundles(): ModelBundle[] {
...wanSupport,
],
},
- ]
+ ])
}
diff --git a/src/lib/__tests__/vram-fit.test.ts b/src/lib/__tests__/vram-fit.test.ts
new file mode 100644
index 00000000..5334e16a
--- /dev/null
+++ b/src/lib/__tests__/vram-fit.test.ts
@@ -0,0 +1,246 @@
+import { describe, it, expect } from 'vitest'
+import {
+ deriveVramNeed, vramFit, fileVramFit, vramFitLabel, vramFitLine, vramNeedTitle, slowLoadHint, cardGb,
+ withVramNeed, largestWeightGb, needForInstalledFile, VRAM_WORKING_GB, SLOW_LOAD_HINT_AFTER_MS,
+} from '../vram-fit'
+import {
+ getImageBundles, getVideoBundles, getAudioBundles, getLipsyncBundles, getMotionBundles, getLoraAddonBundles,
+} from '../../api/model-bundles'
+
+// The owner's test box, October 2026: RTX 3060 with 12 GB, Z-Image
+// (z_image_bf16 at 11.5 GB beside a 7.5 GB text encoder) sat more than 300 s in
+// "Loading the model into memory" while the catalogue said "10-16 GB" and
+// nothing else. These cases pin the one rule that now reads that text for
+// every bundle, and the words it turns into.
+
+const allBundles = () => [
+ ...getImageBundles(), ...getVideoBundles(), ...getAudioBundles(), ...getLipsyncBundles(), ...getMotionBundles(),
+]
+
+describe('deriveVramNeed: what the catalogue text and the file sizes say', () => {
+ it('a span is minimum and comfortable value', () => {
+ expect(deriveVramNeed({ vramRequired: '6-8 GB', files: [{ sizeGB: 6.5 }] })).toEqual({ vramMinGB: 6, vramComfortGB: 8 })
+ expect(deriveVramNeed({ vramRequired: '10-16 GB', files: [{ sizeGB: 11.5 }, { sizeGB: 7.5 }] })).toEqual({ vramMinGB: 10, vramComfortGB: 16 })
+ })
+
+ it('a single number or a plus is both ends, nothing is added to it', () => {
+ expect(deriveVramNeed({ vramRequired: '16 GB', files: [{ sizeGB: 8.82 }] })).toEqual({ vramMinGB: 16, vramComfortGB: 16 })
+ expect(deriveVramNeed({ vramRequired: '24+ GB', files: [{ sizeGB: 21 }] })).toEqual({ vramMinGB: 24, vramComfortGB: 24 })
+ })
+
+ it('the largest single weight plus working memory lifts the comfortable value', () => {
+ expect(VRAM_WORKING_GB).toBe(1.5)
+ // FLUX.1 FP8: "8-10 GB" beside a 16.1 GB diffusion model.
+ expect(deriveVramNeed({ vramRequired: '8-10 GB', files: [{ sizeGB: 16.1 }, { sizeGB: 4.6 }] })).toEqual({ vramMinGB: 8, vramComfortGB: 17.6 })
+ expect(deriveVramNeed({ vramRequired: '12+ GB', files: [{ sizeGB: 14 }, { sizeGB: 6.3 }] })).toEqual({ vramMinGB: 12, vramComfortGB: 15.5 })
+ // The weights load one after the other, so they are not added up.
+ expect(deriveVramNeed({ vramRequired: '10-16 GB', files: [{ sizeGB: 7 }, { sizeGB: 7 }, { sizeGB: 7 }] })!.vramComfortGB).toBe(16)
+ expect(largestWeightGb([{ sizeGB: 2 }, {}, { sizeGB: 9.3 }])).toBe(9.3)
+ expect(largestWeightGb()).toBe(0)
+ })
+
+ it('"best" names the comfortable value and no floor', () => {
+ expect(deriveVramNeed({ vramRequired: '16 GB best, offloads on less', files: [{ sizeGB: 15.27 }] })).toEqual({ vramMinGB: 0, vramComfortGB: 16.8 })
+ })
+
+ it('"any" has no floor and is as big as its file', () => {
+ expect(deriveVramNeed({ vramRequired: 'any', files: [{ sizeGB: 0.17 }] })).toEqual({ vramMinGB: 0, vramComfortGB: 1.7 })
+ })
+
+ it('a text without a number gets no verdict instead of a guessed one', () => {
+ expect(deriveVramNeed({ vramRequired: 'depends on the checkpoint', files: [{ sizeGB: 4.9 }] })).toBeNull()
+ expect(deriveVramNeed({})).toBeNull()
+ expect(withVramNeed([{ vramRequired: '' }])[0]).toMatchObject({ vramMinGB: null, vramComfortGB: null })
+ })
+})
+
+describe('vramFit: where a bundle stands on a card', () => {
+ const zimage = { vramMinGB: 10, vramComfortGB: 16 }
+
+ it('below the minimum needs more, from the comfortable value fits, between is tight', () => {
+ expect(vramFit(zimage, 8)).toBe('big')
+ expect(vramFit(zimage, 10)).toBe('tight')
+ expect(vramFit(zimage, 12)).toBe('tight')
+ expect(vramFit(zimage, 16)).toBe('fits')
+ expect(vramFit(zimage, 24)).toBe('fits')
+ })
+
+ it('a card that reports a hair under its size counts as that size', () => {
+ expect(cardGb(11.99)).toBe(12)
+ expect(vramFit({ vramMinGB: 12, vramComfortGB: 12 }, 11.99)).toBe('fits')
+ })
+
+ it('no card or no stated need is unknown, never a verdict', () => {
+ expect(vramFit(zimage, null)).toBe('unknown')
+ expect(vramFit(zimage, 0)).toBe('unknown')
+ expect(vramFit({ vramMinGB: null, vramComfortGB: null }, 12)).toBe('unknown')
+ expect(vramFit({}, 12)).toBe('unknown')
+ })
+
+ it('a file no bundle names is judged by its size, and never "needs more"', () => {
+ expect(fileVramFit(6.5, 12)).toBe('fits')
+ expect(fileVramFit(10.5, 12)).toBe('fits')
+ expect(fileVramFit(11.5, 12)).toBe('tight')
+ expect(fileVramFit(40, 12)).toBe('tight')
+ expect(fileVramFit(undefined, 12)).toBe('unknown')
+ expect(fileVramFit(6.5, null)).toBe('unknown')
+ })
+})
+
+describe('needForInstalledFile: what the catalogue knows about a file on the disk', () => {
+ it('finds the bundle that lists the file, whatever folder or case it comes in', () => {
+ const all = allBundles()
+ expect(needForInstalledFile('z_image_turbo_bf16.safetensors', all)).toEqual({ vramMinGB: 10, vramComfortGB: 16 })
+ expect(needForInstalledFile('zimage\\Z_Image_Turbo_BF16.safetensors', all)).toEqual({ vramMinGB: 10, vramComfortGB: 16 })
+ expect(needForInstalledFile('Juggernaut-XL_v9.safetensors', all)).toEqual({ vramMinGB: 6, vramComfortGB: 8 })
+ })
+
+ it('answers null for a file no bundle names, so its size decides', () => {
+ expect(needForInstalledFile('some_civitai_merge.safetensors', allBundles())).toBeNull()
+ expect(needForInstalledFile('', allBundles())).toBeNull()
+ })
+
+ it('answers null when two bundles list the file and disagree, or the bundle names no number', () => {
+ const a = { vramMinGB: 6, vramComfortGB: 8, files: [{ filename: 'shared.safetensors' }] }
+ const b = { vramMinGB: 10, vramComfortGB: 12, files: [{ filename: 'shared.safetensors' }] }
+ expect(needForInstalledFile('shared.safetensors', [a, { ...a }])).toEqual({ vramMinGB: 6, vramComfortGB: 8 })
+ expect(needForInstalledFile('shared.safetensors', [a, b])).toBeNull()
+ expect(needForInstalledFile('x.safetensors', [{ vramMinGB: null, vramComfortGB: null, files: [{ filename: 'x.safetensors' }] }])).toBeNull()
+ })
+})
+
+describe('the words', () => {
+ it('names the card in all three states', () => {
+ expect(vramFitLabel('fits', 12)).toBe('Fits your 12 GB card')
+ expect(vramFitLabel('tight', 12)).toBe('Tight on your 12 GB card')
+ expect(vramFitLabel('big', 12)).toBe('Needs more than your 12 GB card')
+ expect(vramFitLine('fits', 12)).toBe('Fits your 12 GB card')
+ expect(vramFitLine('tight', 12)).toBe('Tight on your 12 GB card: runs, but loading takes minutes')
+ expect(vramFitLine('big', 12)).toBe('Needs more than your 12 GB card')
+ })
+
+ it('says nothing without a card or a verdict', () => {
+ expect(vramFitLabel('fits', null)).toBe('')
+ expect(vramFitLabel('unknown', 12)).toBe('')
+ expect(vramFitLine('tight', null)).toBe('')
+ })
+
+ it('the tooltip states the two numbers the verdict rests on', () => {
+ expect(vramNeedTitle({ vramMinGB: 10, vramComfortGB: 16 })).toBe('Runs from 10 GB. Loads fully into graphics memory from 16 GB.')
+ expect(vramNeedTitle({ vramMinGB: 0, vramComfortGB: 1.7 })).toBe('Loads fully into graphics memory from 1.7 GB.')
+ expect(vramNeedTitle({ vramMinGB: null, vramComfortGB: null })).toBe('')
+ })
+
+ it('the waiting area speaks after a minute, and only for a model that is not a fit', () => {
+ expect(SLOW_LOAD_HINT_AFTER_MS).toBe(60_000)
+ expect(slowLoadHint('tight', 59_000)).toBe('')
+ expect(slowLoadHint('tight', 60_000)).toBe('This model is a tight fit for your graphics memory, so loading is slow.')
+ expect(slowLoadHint('big', 300_000)).toBe('This model is larger than your graphics memory, so loading is slow.')
+ expect(slowLoadHint('fits', 300_000)).toBe('')
+ expect(slowLoadHint('unknown', 300_000)).toBe('')
+ expect(slowLoadHint('big', Number.NaN)).toBe('')
+ })
+
+ it('no line carries a dash', () => {
+ const lines = [
+ vramFitLine('fits', 12), vramFitLine('tight', 12), vramFitLine('big', 12),
+ vramNeedTitle({ vramMinGB: 10, vramComfortGB: 16 }), slowLoadHint('tight', 60_000), slowLoadHint('big', 60_000),
+ ]
+ for (const line of lines) expect(line).not.toMatch(/[\u2013\u2014]/)
+ })
+})
+
+describe('every bundle in the catalogue carries the two numbers', () => {
+ /** The one entry whose text names no number: its need is the checkpoint's. */
+ const NO_NUMBER = ['Krea 2 Companion Files (Text Encoder + VAE)']
+
+ it('as the rule derives them, from its own text and files', () => {
+ const all = allBundles()
+ expect(all.length).toBeGreaterThan(30)
+ for (const b of all) {
+ const need = deriveVramNeed(b)
+ if (NO_NUMBER.includes(b.name)) {
+ expect(need, b.name).toBeNull()
+ expect([b.vramMinGB, b.vramComfortGB], b.name).toEqual([null, null])
+ continue
+ }
+ expect(need, b.name).not.toBeNull()
+ expect(b.vramMinGB, b.name).toBe(need!.vramMinGB)
+ expect(b.vramComfortGB, b.name).toBe(need!.vramComfortGB)
+ expect(Number.isFinite(b.vramComfortGB), b.name).toBe(true)
+ expect(b.vramComfortGB!, b.name).toBeGreaterThanOrEqual(b.vramMinGB!)
+ expect(b.vramComfortGB!, b.name).toBeGreaterThan(0)
+ expect(b.vramComfortGB!, b.name).toBeLessThan(99)
+ }
+ for (const b of getLoraAddonBundles()) expect(typeof b.vramComfortGB, b.name).toBe('number')
+ })
+
+ // Minimum, comfortable value, verdict on an 8, 12, 16 and 24 GB card. Written
+ // out so a changed text or file size in the catalogue shows up here as a
+ // changed verdict, and not only on somebody's card.
+ const TABLE: Array<[string, number, number, string]> = [
+ ['Juggernaut XL V9 (Photorealistic)', 6, 8, 'fits fits fits fits'],
+ ['RealVisXL V5 (Photorealistic)', 6, 8, 'fits fits fits fits'],
+ ['FLUX.1 [schnell] FP8 (Fast & Modern)', 8, 17.6, 'tight tight tight fits'],
+ ['FLUX.1 [dev] FP8 (High Quality)', 8, 17.6, 'tight tight tight fits'],
+ ['FLUX 2 Klein 4B (Next Gen)', 8, 10, 'tight fits fits fits'],
+ ['Z-Image Turbo (Unfiltered, Fast)', 10, 16, 'big tight fits fits'],
+ ['Z-Image Base (Unfiltered, Quality)', 10, 16, 'big tight fits fits'],
+ ['Qwen-Image 2.1 (Generate and Edit)', 16, 24, 'big big tight fits'],
+ ['Qwen-Image 2.1 Prompt Enhancer (Official)', 16, 16, 'big big fits fits'],
+ ['Qwen-Image 2.1 Prompt Enhancer (No Refusals)', 16, 16, 'big big fits fits'],
+ ['DreamShaper XL Turbo V2 (Anime/Stylized)', 6, 8, 'fits fits fits fits'],
+ ['ERNIE-Image Turbo', 24, 24, 'big big big fits'],
+ ['ERNIE-Image Base', 24, 24, 'big big big fits'],
+ ['SDXL VAE (fp16-fix) · addon', 0, 1.8, 'fits fits fits fits'],
+ ['Pixel Art XL · SDXL LoRA', 0, 1.7, 'fits fits fits fits'],
+ ['Wan 2.1 · 1.3B (Lightweight)', 8, 10, 'tight fits fits fits'],
+ ['Wan 2.1 · 14B FP8 (High Quality)', 12, 15.5, 'big tight fits fits'],
+ ['Wan 2.2 · TI2V 5B (Image + Text to Video)', 12, 12, 'big fits fits fits'],
+ ['HunyuanVideo 1.5 T2V FP8 (High Quality)', 12, 12, 'big fits fits fits'],
+ ['LTX Video 2.3 · 22B FP8', 16, 29, 'big big tight tight'],
+ ['MiniMax H3 · Video with Sound', 24, 24, 'big big big fits'],
+ ['MiniMax H3 Turbo LoRA · 8 Steps', 24, 24, 'big big big fits'],
+ ['FastH3 · MiniMax H3 in 8 Steps', 24, 24, 'big big big fits'],
+ ['LTX 2.5 · Video with Sound', 24, 24, 'big big big fits'],
+ ['LTX 2.5 · Small (GGUF Q4)', 16, 16, 'big big fits fits'],
+ ['AnimateDiff Lightning', 6, 8, 'fits fits fits fits'],
+ ['AnimateDiff v3', 6, 8, 'fits fits fits fits'],
+ ['FramePack F1 (Image to Video)', 6, 16.8, 'tight tight tight fits'],
+ ['SVD-XT 1.1 (Image to Video)', 12, 12, 'big fits fits fits'],
+ ['Mochi 1 Preview (FP8)', 16, 16, 'big big fits fits'],
+ ['NVIDIA Cosmos 7B', 24, 24, 'big big big fits'],
+ ['NSFW Wan 14B (Uncensored, GGUF)', 10, 12, 'big fits fits fits'],
+ ['Wan 2.2 Rapid AIO (Uncensored I2V, GGUF)', 10, 12, 'big fits fits fits'],
+ ['ACE Step 1.5 Turbo (Music)', 6, 10.8, 'tight fits fits fits'],
+ ['YuE2 (Songs from Style and Lyrics)', 6, 8, 'fits fits fits fits'],
+ ['ACE Step v1 3.5B (Music, lighter)', 4, 8.7, 'tight fits fits fits'],
+ ['Wan 2.2 S2V Q4 (Talking Character, GGUF)', 10, 14.4, 'big tight fits fits'],
+ ['Wan 2.2 S2V FP8 (Talking Character)', 0, 16.8, 'tight tight tight fits'],
+ ['Wan VACE 1.3B (Motion Control, light)', 8, 10, 'tight fits fits fits'],
+ ['Wan 2.2 Animate Q4 (Motion Control, GGUF)', 10, 12.2, 'big tight fits fits'],
+ ]
+
+ it('and the table of all of them holds', () => {
+ const all = allBundles()
+ expect(all.filter((b) => !NO_NUMBER.includes(b.name)).map((b) => b.name)).toEqual(TABLE.map((row) => row[0]))
+ for (const [name, min, comfort, verdicts] of TABLE) {
+ const b = all.find((x) => x.name === name)!
+ expect([b.vramMinGB, b.vramComfortGB], name).toEqual([min, comfort])
+ expect([8, 12, 16, 24].map((card) => vramFit(b, card)).join(' '), name).toBe(verdicts)
+ }
+ })
+
+ it('the box that raised it: Z-Image is tight on 12 GB, the add-ons fit every card', () => {
+ const image = getImageBundles()
+ expect(vramFitLine(vramFit(image.find((b) => b.name.startsWith('Z-Image Turbo'))!, 12), 12))
+ .toBe('Tight on your 12 GB card: runs, but loading takes minutes')
+ // Counter-check 2026-08-29: the old reader answered 99 GB to "any" and
+ // stamped a 0.17 GB LoRA "Too big for your GPU".
+ for (const name of ['SDXL VAE (fp16-fix) · addon', 'Pixel Art XL · SDXL LoRA']) {
+ const b = image.find((x) => x.name === name)!
+ expect(vramFit(b, 12), name).toBe('fits')
+ expect(vramFit(b, 4), name).toBe('fits')
+ }
+ })
+})
diff --git a/src/lib/vram-fit.ts b/src/lib/vram-fit.ts
new file mode 100644
index 00000000..1afb3912
--- /dev/null
+++ b/src/lib/vram-fit.ts
@@ -0,0 +1,197 @@
+/**
+ * How a local media model compares with the user's graphics card.
+ *
+ * The owner's test box (RTX 3060, 12 GB, October 2026) sat more than 300 s in
+ * "Loading the model into memory" on Z-Image: an 11.5 GB diffusion model next
+ * to a 7.5 GB text encoder. The catalogue said "10-16 GB" and the card was
+ * inside that span, so nothing warned him. The span was honest, it just was not
+ * read: its lower end is where the model starts to run at all, its upper end is
+ * where it runs without moving weights out of graphics memory.
+ *
+ * This file is that reading, once, for every bundle:
+ *
+ * - `vramMinGB` is the lower end of the catalogue's own text.
+ * - `vramComfortGB` is its upper end, and never less than the largest single
+ * weight plus working memory. Text encoder and diffusion model load one
+ * after the other, so the largest one is what has to fit, and a sampler
+ * needs room next to its weights.
+ * - A card below the minimum needs more, a card from the comfortable value
+ * up fits, everything between is tight: it runs, and it loads slowly.
+ *
+ * Nothing here is a measurement. Every number comes out of the catalogue's
+ * `vramRequired` text and its file sizes. A text that names no number at all
+ * ("depends on the checkpoint") gets no verdict instead of a guessed one.
+ *
+ * Pure and without imports, so api/model-bundles can stamp its entries with it
+ * and no import cycle can form.
+ */
+
+/** Room a model needs in graphics memory beside its largest weight, in GB. */
+export const VRAM_WORKING_GB = 1.5
+
+/** How long a load may run before a tight model gets its own sentence. */
+export const SLOW_LOAD_HINT_AFTER_MS = 60_000
+
+export interface VramNeed {
+ /** From this much graphics memory the model runs at all. 0: the catalogue names no floor. */
+ vramMinGB: number
+ /** From this much it runs without moving weights out of graphics memory. */
+ vramComfortGB: number
+}
+
+/** The two fields as a bundle carries them. Null: the catalogue's text names no number. */
+export interface VramNeedFields {
+ vramMinGB: number | null
+ vramComfortGB: number | null
+}
+
+export type VramFit = 'fits' | 'tight' | 'big' | 'unknown'
+
+interface NeedSource {
+ vramRequired?: string
+ files?: readonly { sizeGB?: number }[]
+}
+
+function round1(n: number): number {
+ return Math.round(n * 10) / 10
+}
+
+/** The largest single file of a bundle in GB, 0 when it lists none. */
+export function largestWeightGb(files: readonly { sizeGB?: number }[] = []): number {
+ return files.reduce((max, f) => Math.max(max, f.sizeGB ?? 0), 0)
+}
+
+/**
+ * What the catalogue's text and file sizes say a bundle needs.
+ *
+ * "10-16 GB" from 10, comfortable from 16
+ * "12+ GB", "16 GB" from that number, comfortable from it too
+ * "16 GB best, offloads on less" no floor, comfortable from 16
+ * "any" no floor, comfortable from the file size up
+ * anything without a number null, no verdict
+ *
+ * In every case the comfortable value is raised to the largest weight plus
+ * working memory, so a span whose upper end is below its own diffusion model
+ * (FLUX.1 FP8: "8-10 GB" beside a 16.1 GB file) cannot call a 12 GB card a fit.
+ */
+export function deriveVramNeed(source: NeedSource): VramNeed | null {
+ const text = (source.vramRequired ?? '').trim()
+ let min: number
+ let top: number
+ const span = text.match(/(\d+)\s*-\s*(\d+)/)
+ const best = text.match(/(\d+)\s*GB\s+best/i)
+ const single = text.match(/(\d+)/)
+ if (span) {
+ min = parseInt(span[1], 10)
+ top = parseInt(span[2], 10)
+ } else if (best) {
+ min = 0
+ top = parseInt(best[1], 10)
+ } else if (single) {
+ min = parseInt(single[1], 10)
+ top = min
+ } else if (/^any$/i.test(text)) {
+ min = 0
+ top = 0
+ } else {
+ return null
+ }
+ const largest = largestWeightGb(source.files)
+ const weight = largest > 0 ? round1(largest + VRAM_WORKING_GB) : 0
+ return { vramMinGB: min, vramComfortGB: Math.max(top, weight) }
+}
+
+/** Stamps a list of catalogue entries with the two fields. */
+export function withVramNeed<T extends NeedSource>(bundles: readonly T[]): (T & VramNeedFields)[] {
+ return bundles.map((b) => {
+ const need = deriveVramNeed(b)
+ return { ...b, vramMinGB: need?.vramMinGB ?? null, vramComfortGB: need?.vramComfortGB ?? null }
+ })
+}
+
+/** The card size the verdict and the wording use: whole GB, null when none was detected. */
+export function cardGb(vramGb: number | null | undefined): number | null {
+ if (typeof vramGb !== 'number' || !Number.isFinite(vramGb) || vramGb <= 0) return null
+ return Math.max(1, Math.round(vramGb))
+}
+
+/** Where a bundle stands on a card. Unknown without a card or without a stated need. */
+export function vramFit(need: Partial<VramNeedFields>, vramGb: number | null | undefined): VramFit {
+ const card = cardGb(vramGb)
+ if (card === null) return 'unknown'
+ if (typeof need.vramMinGB !== 'number' || typeof need.vramComfortGB !== 'number') return 'unknown'
+ if (card < need.vramMinGB) return 'big'
+ if (card < need.vramComfortGB) return 'tight'
+ return 'fits'
+}
+
+/**
+ * The same question for a file no bundle names (a CivitAI download): only its
+ * size is known, so the answer is fit or tight and never "needs more". A file
+ * size states no minimum.
+ */
+export function fileVramFit(sizeGB: number | null | undefined, vramGb: number | null | undefined): VramFit {
+ const card = cardGb(vramGb)
+ if (card === null || typeof sizeGB !== 'number' || !Number.isFinite(sizeGB) || sizeGB <= 0) return 'unknown'
+ return sizeGB + VRAM_WORKING_GB > card ? 'tight' : 'fits'
+}
+
+/** The short line: on a Model Manager card and on a row of the model picker. */
+export function vramFitLabel(fit: VramFit, vramGb: number | null | undefined): string {
+ const card = cardGb(vramGb)
+ if (card === null) return ''
+ if (fit === 'fits') return `Fits your ${card} GB card`
+ if (fit === 'tight') return `Tight on your ${card} GB card`
+ if (fit === 'big') return `Needs more than your ${card} GB card`
+ return ''
+}
+
+/** The line on a Model Manager card, where there is room to say what tight means. */
+export function vramFitLine(fit: VramFit, vramGb: number | null | undefined): string {
+ const label = vramFitLabel(fit, vramGb)
+ return fit === 'tight' && label ? `${label}: runs, but loading takes minutes` : label
+}
+
+/** What the card's verdict rests on, for the tooltip. */
+export function vramNeedTitle(need: Partial<VramNeedFields>): string {
+ if (typeof need.vramMinGB !== 'number' || typeof need.vramComfortGB !== 'number') return ''
+ const comfort = `Loads fully into graphics memory from ${need.vramComfortGB} GB.`
+ return need.vramMinGB > 0 ? `Runs from ${need.vramMinGB} GB. ${comfort}` : comfort
+}
+
+/**
+ * The sentence the waiting area adds once a load has run for a minute on a
+ * model that does not sit comfortably on the card. '' in every other case, so
+ * a model that fits, an undetected card and a short load all stay silent.
+ */
+export function slowLoadHint(fit: VramFit, elapsedMs: number, afterMs: number = SLOW_LOAD_HINT_AFTER_MS): string {
+ if (!Number.isFinite(elapsedMs) || elapsedMs < afterMs) return ''
+ if (fit === 'big') return 'This model is larger than your graphics memory, so loading is slow.'
+ if (fit === 'tight') return 'This model is a tight fit for your graphics memory, so loading is slow.'
+ return ''
+}
+
+interface CatalogueEntry extends VramNeedFields {
+ files: readonly { filename?: string }[]
+}
+
+/**
+ * What the catalogue says about a file on the disk, or null when it cannot say.
+ *
+ * An installed model is a file name, and the catalogue knows a file name only
+ * when a bundle lists it. Null when no bundle does (a CivitAI download), when
+ * the bundle names no number, or when two bundles list the file and disagree:
+ * in each of those cases the caller falls back to the file's own size.
+ */
+export function needForInstalledFile(filename: string, bundles: readonly CatalogueEntry[]): VramNeed | null {
+ const base = (filename.split(/[\\/]/).pop() ?? '').toLowerCase()
+ if (!base) return null
+ let found: VramNeed | null = null
+ for (const b of bundles) {
+ if (!b.files.some((f) => f.filename?.toLowerCase() === base)) continue
+ if (typeof b.vramMinGB !== 'number' || typeof b.vramComfortGB !== 'number') return null
+ if (found && (found.vramMinGB !== b.vramMinGB || found.vramComfortGB !== b.vramComfortGB)) return null
+ found = { vramMinGB: b.vramMinGB, vramComfortGB: b.vramComfortGB }
+ }
+ return found
+}