AI media harness for planning, generating, and editing locally
TypeScript
Remove incompatible Minimax text encoder
Bitticb3ab0ee120f
diff --git a/docs/generator-weights.md b/docs/generator-weights.mdindex 2b16ae3..3d5e70a 100644--- a/docs/generator-weights.md+++ b/docs/generator-weights.md@@ -3,11 +3,13 @@In Settings → Generator, edit a template and enter local paths or HTTP/HTTPSdownload URLs. Hugging Face `blob` links are converted to direct file downloads.The bundled **Minimax H3 Original** template downloads four model files.-Its text encoder download uses Qwen3-VL 4B INT4 ConvRot for GPUs with 12 GB of-VRAM or less, and the original 32B encoder above 12 GB. Unknown hardware uses-the 4B fallback. Its transformer uses the hybrid W4A8 model at 20 GB or less+Its text encoder download uses the original Qwen3-VL 32B encoder on all GPUs.+The incompatible 4B INT4 ConvRot option is removed from saved Minimax templates;+templates using its downloaded file switch back to the original encoder, which+may need downloading. The old file is left on disk.+Its transformer uses the hybrid W4A8 model at 20 GB or lessand the original INT8 model above 20 GB; unknown hardware uses the W4A8 fallback.-Existing local weights and customized download variants are preserved.+Other local weights and customized download variants are preserved.Templates awaiting downloads appear under **Download**. Once theirweights are downloaded, they move into **Generators**. Removing or losing theirdiff --git a/src/lib/settings.test.ts b/src/lib/settings.test.tsindex 1342137..cbe842f 100644--- a/src/lib/settings.test.ts+++ b/src/lib/settings.test.ts@@ -12,6 +12,7 @@ import {loadEngineSettings,loadGeneratorTemplateSettings,minimaxOriginalTemplate,+ templateNeedsDownload,saveAgentEndpointSettings,saveGeneratorTemplateSettings,} from "./settings";@@ -50,12 +51,10 @@ describe("generator templates", () => {template.paths[field] = downloadedPath;localStorage.setItem("slopus.generator-templates.v1", JSON.stringify({ templates: [template], catalogVersion: 1 }));const settings = loadGeneratorTemplateSettings();- expect(settings.catalogVersion).toBe(2);+ expect(settings.catalogVersion).toBe(3);expect(settings.templates[0].paths[field]).toBe(downloadedPath);- expect(settings.templates[0].sources![field]).toEqual([- { ...minimaxOriginalTemplate().sources![field]![0], downloadedPath },- minimaxOriginalTemplate().sources![field]![1],- ]);+ expect(settings.templates[0].sources![field]).toEqual(minimaxOriginalTemplate().sources![field]!.map((source, index) =>+ index === 0 ? { ...source, downloadedPath } : source));expect(loadGeneratorTemplateSettings()).toEqual(settings);});@@ -70,6 +69,46 @@ describe("generator templates", () => {expect(loadGeneratorTemplateSettings().templates.map(({ id }) => id)).toEqual([custom.id]);});+ it.each(["url", "downloaded", "original", "custom", "cached original"])("removes the incompatible encoder from saved templates using %s", (selection) => {+ const template = minimaxOriginalTemplate();+ const originalUrl = template.paths.textEncoder;+ const removedUrl = "https://huggingface.co/Merserk/qwen3vl-4b-int4-convrot/resolve/main/qwen3vl_4b_int4_convrot.safetensors";+ const downloadedPath = "D:/Models/qwen3vl_4b_int4_convrot.safetensors";+ const cachedOriginal = "D:/Models/original.safetensors";+ const custom = { url: "https://example.com/custom.safetensors", gpuModel: "RTX", minVramGb: 8 };+ template.sources!.textEncoder = [+ { url: originalUrl, gpuModel: "", minVramGb: 13, ...(selection === "cached original" ? { downloadedPath: cachedOriginal } : {}) },+ { url: removedUrl, gpuModel: "", minVramGb: 0, downloadedPath },+ custom,+ ];+ template.paths = { transformer: "transformer", videoVae: "video", audioVae: "audio", tokenizer: "",+ textEncoder: selection === "url" ? removedUrl : selection === "original" ? cachedOriginal : selection === "custom" ? "D:/Models/custom.safetensors" : downloadedPath };+ localStorage.setItem("slopus.generator-templates.v1", JSON.stringify({ templates: [template], defaultTemplateId: template.id, catalogVersion: 2 }));+ const settings = loadGeneratorTemplateSettings();+ const migrated = settings.templates[0];+ expect(settings.catalogVersion).toBe(3);+ expect(migrated.sources!.textEncoder).toEqual([+ { url: originalUrl, gpuModel: "", minVramGb: 0, ...(selection === "cached original" ? { downloadedPath: cachedOriginal } : {}) },+ custom,+ ]);+ expect(migrated.paths.textEncoder).toBe(selection === "url" || selection === "downloaded" ? originalUrl+ : selection === "custom" ? "D:/Models/custom.safetensors" : cachedOriginal);+ expect(templateNeedsDownload(migrated)).toBe(selection === "url" || selection === "downloaded");+ expect(settings.defaultTemplateId).toBe(templateNeedsDownload(migrated) ? "" : template.id);+ expect(loadGeneratorTemplateSettings()).toEqual(settings);+ });++ it("restores the original encoder when only the removed URL was saved", () => {+ const template = minimaxOriginalTemplate();+ const originalUrl = template.paths.textEncoder;+ template.paths.textEncoder = "https://huggingface.co/Merserk/qwen3vl-4b-int4-convrot/resolve/main/qwen3vl_4b_int4_convrot.safetensors";+ delete template.sources!.textEncoder;+ localStorage.setItem("slopus.generator-templates.v1", JSON.stringify({ templates: [template], catalogVersion: 2 }));+ const migrated = loadGeneratorTemplateSettings().templates[0];+ expect(migrated.paths.textEncoder).toBe(originalUrl);+ expect(migrated.sources!.textEncoder).toEqual(minimaxOriginalTemplate().sources!.textEncoder);+ });+it("passes the default generator's attention and machine backend to the engine", () => {const template = createGeneratorTemplate();expect(template.attention).toBe("sage2");diff --git a/src/lib/settings.ts b/src/lib/settings.tsindex 62f71eb..dc243bb 100644--- a/src/lib/settings.ts+++ b/src/lib/settings.ts@@ -162,17 +162,13 @@ export function minimaxOriginalTemplate(): GeneratorTemplate {{ url: paths.transformer, gpuModel: "", minVramGb: 21 },{ url: "https://huggingface.co/koongrizzly/MiniMax_H3_int4_W4A8_ConvRot_Pruned/resolve/main/diffusion_models/minimax_h3_ref2va_hybrid_b20-49_pruned_w4a8_mixed.safetensors", gpuModel: "", minVramGb: 0 },];- sources.textEncoder = [- { url: paths.textEncoder, gpuModel: "", minVramGb: 13 },- { url: "https://huggingface.co/Merserk/qwen3vl-4b-int4-convrot/resolve/main/qwen3vl_4b_int4_convrot.safetensors", gpuModel: "", minVramGb: 0 },- ];return { id: "minimax-h3-original", name: "Minimax H3 Original", defaultSteps: 20, attention: "sage2", paths, sources };}const initialTemplateSettings = (paths = EMPTY_ENGINE_SETTINGS): GeneratorTemplateSettings => ({templates: [{ id: "default", name: "Default", defaultSteps: DEFAULT_GENERATION_STEPS, attention: "sage2", paths: copyPaths(paths) }, minimaxOriginalTemplate()],defaultTemplateId: "default",- catalogVersion: 2,+ catalogVersion: 3,});const normalizeTemplateSettings = (value: unknown): GeneratorTemplateSettings | null => {@@ -217,7 +213,7 @@ const normalizeTemplateSettings = (value: unknown): GeneratorTemplateSettings |templates,defaultTemplateId: templates.find((template) => template.id === requestedDefault && !templateNeedsDownload(template))?.id?? templates.find((template) => !templateNeedsDownload(template))?.id ?? "",- catalogVersion: record.catalogVersion === 2 ? 2 : record.catalogVersion === 1 ? 1 : 0,+ catalogVersion: record.catalogVersion === 3 ? 3 : record.catalogVersion === 2 ? 2 : record.catalogVersion === 1 ? 1 : 0,};};@@ -235,7 +231,7 @@ export function loadGeneratorTemplateSettings(): GeneratorTemplateSettings {const existing = normalized.templates.find((template) => template.id === bundled.id);if (!normalized.catalogVersion && !existing) normalized.templates.push(bundled);// Upgrade the original catalog entry without replacing custom variants or local paths.- for (const field of ["transformer", "textEncoder"] as const) {+ for (const field of ["transformer"] as const) {const variants = existing?.sources?.[field];const defaults = bundled.sources![field]!;if (variants?.length === 1 && variants[0].url === bundled.paths[field]@@ -246,6 +242,31 @@ export function loadGeneratorTemplateSettings(): GeneratorTemplateSettings {normalized.catalogVersion = 2;localStorage.setItem(GENERATOR_TEMPLATES_KEY, JSON.stringify(normalized));}+ if ((normalized.catalogVersion ?? 0) < 3) {+ const bundled = minimaxOriginalTemplate();+ const existing = normalized.templates.find((template) => template.id === bundled.id);+ const removedUrl = "https://huggingface.co/Merserk/qwen3vl-4b-int4-convrot/resolve/main/qwen3vl_4b_int4_convrot.safetensors";+ const encoders = existing?.sources?.textEncoder;+ if (existing && encoders) {+ const removed = encoders.filter((source) => source.url === removedUrl);+ const retained = encoders.filter((source) => source.url !== removedUrl).map((source) =>+ source.url === bundled.paths.textEncoder && !source.gpuModel.trim() && source.minVramGb === 13+ ? { ...source, minVramGb: 0 } : source);+ if (removed.length && !retained.some((source) => source.url === bundled.paths.textEncoder)) {+ retained.push({ ...bundled.sources!.textEncoder![0] });+ }+ if (existing.paths.textEncoder.trim() === removedUrl+ || removed.some((source) => source.downloadedPath && source.downloadedPath === existing.paths.textEncoder)) {+ const original = retained.find((source) => source.url === bundled.paths.textEncoder)!;+ existing.paths.textEncoder = original.downloadedPath || original.url;+ }+ existing.sources!.textEncoder = retained;+ }+ // A replaced local encoder may now need downloading and cannot remain the default.+ const migrated = normalizeTemplateSettings({ ...normalized, catalogVersion: 3 })!;+ localStorage.setItem(GENERATOR_TEMPLATES_KEY, JSON.stringify(migrated));+ return migrated;+ }return normalized;}}diff --git a/src/lib/weightDownloads.test.ts b/src/lib/weightDownloads.test.tsindex cf99ced..6d72791 100644--- a/src/lib/weightDownloads.test.ts+++ b/src/lib/weightDownloads.test.ts@@ -54,7 +54,7 @@ it("preserves the sample links and prevents an unfinished template from being thexpect(templateNeedsDownload(saved())).toBe(true);expect(loadGeneratorTemplateSettings().defaultTemplateId).toBe("");expect(defaultGeneratorTemplate().id).toBe("");- expect(Object.values(saved().sources ?? {}).flat()).toHaveLength(6);+ expect(Object.values(saved().sources ?? {}).flat()).toHaveLength(5);});it.each([8, 11.4, 12, 12.01, 16, 19.4, 20, 20.01, 24, 32])("selects the Minimax weights for %s GiB of VRAM", async (vram) => {@@ -62,13 +62,11 @@ it.each([8, 11.4, 12, 12.01, 16, 19.4, 20, 20.01, 24, 32])("selects the Minimaxvi.mocked(invoke).mockImplementation(async (command, args) => command === "weight_download_hardware"? [{ name: "GPU", memoryBytes: vram * 1024 ** 3 }] : original(command, args));await downloadTemplateWeights("minimax-h3-original");- const filename = vram <= 12 ? "qwen3vl_4b_int4_convrot.safetensors" : "qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors";+ const filename = "qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors";expect(getWeightDownloadState()).toMatchObject({ active: false, completed: 4, error: null });expect(saved().paths.textEncoder).toBe(`C:/Slopus/weights/${filename}`);expect(invoke).toHaveBeenCalledWith("download_weight", expect.objectContaining({- url: vram <= 12- ? "https://huggingface.co/Merserk/qwen3vl-4b-int4-convrot/resolve/main/qwen3vl_4b_int4_convrot.safetensors"- : minimaxOriginalTemplate().paths.textEncoder,+ url: minimaxOriginalTemplate().paths.textEncoder,}));const transformer = vram <= 20 ? "minimax_h3_ref2va_hybrid_b20-49_pruned_w4a8_mixed.safetensors" : "minimax_h3_fl2va_pruned_int8_convrot.safetensors";expect(saved().paths.transformer).toBe(`C:/Slopus/weights/${transformer}`);