Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Select Minimax weights by VRAM

Bitti753d40aeeb65
diff --git a/docs/generator-weights.md b/docs/generator-weights.md
index 8ba029d..2b16ae3 100644
--- a/docs/generator-weights.md
+++ b/docs/generator-weights.md
@@ -2,7 +2,12 @@
In Settings → Generator, edit a template and enter local paths or HTTP/HTTPS
download URLs. Hugging Face `blob` links are converted to direct file downloads.
-The bundled **Minimax H3 Original** template contains the four supplied model URLs.
+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
+and the original INT8 model above 20 GB; unknown hardware uses the W4A8 fallback.
+Existing local weights and customized download variants are preserved.
Templates awaiting downloads appear under **Download**. Once their
weights are downloaded, they move into **Generators**. Removing or losing their
diff --git a/src/components/SettingsView.downloads.test.tsx b/src/components/SettingsView.downloads.test.tsx
index 6c7083b..8d5f89c 100644
--- a/src/components/SettingsView.downloads.test.tsx
+++ b/src/components/SettingsView.downloads.test.tsx
@@ -118,19 +118,19 @@ it("stores multiple variants and their GPU and VRAM criteria in the editor", asy
fireEvent.click(advanced);
const weight = screen.getByLabelText("Transformer weights").closest(".settings-path")!;
const details = weight.querySelector("details")!;
- fireEvent.click(within(weight as HTMLElement).getByText("Download variants (1)"));
+ fireEvent.click(within(weight as HTMLElement).getByText("Download variants (2)"));
details.open = true;
fireEvent.change(screen.getByLabelText("Add Transformer weights download URL"), { target: { value: "https://example.com/larger.safetensors" } });
fireEvent.click(within(weight as HTMLElement).getByRole("button", { name: "Add URL" }));
- const gpu = screen.getByLabelText("Transformer weights variant 2 GPU model");
+ const gpu = screen.getByLabelText("Transformer weights variant 3 GPU model");
fireEvent.change(gpu, { target: { value: "RTX 5090" } });
fireEvent.blur(gpu);
- fireEvent.change(screen.getByLabelText("Transformer weights variant 2 minimum VRAM"), { target: { value: "32" } });
- await waitFor(() => expect(loadGeneratorTemplateSettings().templates.find((template) => template.id === "minimax-h3-original")?.sources?.transformer?.[1]).toMatchObject({ url: "https://example.com/larger.safetensors", gpuModel: "RTX 5090", minVramGb: 32 }));
+ fireEvent.change(screen.getByLabelText("Transformer weights variant 3 minimum VRAM"), { target: { value: "32" } });
+ await waitFor(() => expect(loadGeneratorTemplateSettings().templates.find((template) => template.id === "minimax-h3-original")?.sources?.transformer?.[2]).toMatchObject({ url: "https://example.com/larger.safetensors", gpuModel: "RTX 5090", minVramGb: 32 }));
fireEvent.click(advanced);
expect(screen.queryByText(/Download variants/)).toBeNull();
fireEvent.click(advanced);
- expect(screen.getByLabelText("Transformer weights variant 2 GPU model")).toHaveValue("RTX 5090");
+ expect(screen.getByLabelText("Transformer weights variant 3 GPU model")).toHaveValue("RTX 5090");
fireEvent.click(screen.getByRole("button", { name: "Generators" }));
fireEvent.click(screen.getByRole("button", { name: "Edit Default generator" }));
expect(screen.getByRole("checkbox", { name: "Show advanced options" })).not.toBeChecked();
diff --git a/src/lib/settings.test.ts b/src/lib/settings.test.ts
index 6328e11..1342137 100644
--- a/src/lib/settings.test.ts
+++ b/src/lib/settings.test.ts
@@ -11,6 +11,7 @@ import {
loadAgentEndpointSettings,
loadEngineSettings,
loadGeneratorTemplateSettings,
+ minimaxOriginalTemplate,
saveAgentEndpointSettings,
saveGeneratorTemplateSettings,
} from "./settings";
@@ -42,6 +43,33 @@ describe("generator templates", () => {
}
});
+ it.each(["textEncoder", "transformer"] as const)("upgrades saved Minimax %s variants once and preserves downloaded weights", (field) => {
+ const template = minimaxOriginalTemplate();
+ const downloadedPath = "D:/Models/encoder.safetensors";
+ template.sources![field] = [{ url: template.paths[field], gpuModel: "", minVramGb: 0, downloadedPath }];
+ 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.templates[0].paths[field]).toBe(downloadedPath);
+ expect(settings.templates[0].sources![field]).toEqual([
+ { ...minimaxOriginalTemplate().sources![field]![0], downloadedPath },
+ minimaxOriginalTemplate().sources![field]![1],
+ ]);
+ expect(loadGeneratorTemplateSettings()).toEqual(settings);
+ });
+
+ it.each(["textEncoder", "transformer"] as const)("preserves custom Minimax %s variants and does not restore a removed catalog template", (field) => {
+ const template = minimaxOriginalTemplate();
+ template.paths[field] = "https://example.com/custom.safetensors";
+ template.sources![field] = [{ url: template.paths[field], gpuModel: "", minVramGb: 0 }];
+ localStorage.setItem("slopus.generator-templates.v1", JSON.stringify({ templates: [template], catalogVersion: 1 }));
+ expect(loadGeneratorTemplateSettings().templates[0].sources![field]).toEqual(template.sources![field]);
+ const custom = createGeneratorTemplate();
+ localStorage.setItem("slopus.generator-templates.v1", JSON.stringify({ templates: [custom], catalogVersion: 1 }));
+ expect(loadGeneratorTemplateSettings().templates.map(({ id }) => id)).toEqual([custom.id]);
+ });
+
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.ts
index c057b46..62f71eb 100644
--- a/src/lib/settings.ts
+++ b/src/lib/settings.ts
@@ -157,14 +157,22 @@ export function minimaxOriginalTemplate(): GeneratorTemplate {
videoVae: `${root}vae/minimax_h3_video_vae_fp16.safetensors`,
audioVae: `${root}vae/minimax_h3_audio_vae_fp32.safetensors`, tokenizer: "",
};
- return { id: "minimax-h3-original", name: "Minimax H3 Original", defaultSteps: 20, attention: "sage2", paths,
- sources: Object.fromEntries(ENGINE_PATH_FIELDS.filter(({ id }) => paths[id]).map(({ id }) => [id, [{ url: paths[id], gpuModel: "", minVramGb: 0 }]])) };
+ const sources: GeneratorTemplate["sources"] = Object.fromEntries(ENGINE_PATH_FIELDS.filter(({ id }) => paths[id]).map(({ id }) => [id, [{ url: paths[id], gpuModel: "", minVramGb: 0 }]]));
+ sources.transformer = [
+ { 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: 1,
+ catalogVersion: 2,
});
const normalizeTemplateSettings = (value: unknown): GeneratorTemplateSettings | null => {
@@ -209,7 +217,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 === 1 ? 1 : 0,
+ catalogVersion: record.catalogVersion === 2 ? 2 : record.catalogVersion === 1 ? 1 : 0,
};
};
@@ -222,9 +230,20 @@ export function loadGeneratorTemplateSettings(): GeneratorTemplateSettings {
if (stored) {
const normalized = normalizeTemplateSettings(JSON.parse(stored));
if (normalized) {
- if (!normalized.catalogVersion) {
- if (!normalized.templates.some((template) => template.id === "minimax-h3-original")) normalized.templates.push(minimaxOriginalTemplate());
- normalized.catalogVersion = 1;
+ if ((normalized.catalogVersion ?? 0) < 2) {
+ const bundled = minimaxOriginalTemplate();
+ 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) {
+ const variants = existing?.sources?.[field];
+ const defaults = bundled.sources![field]!;
+ if (variants?.length === 1 && variants[0].url === bundled.paths[field]
+ && !variants[0].gpuModel.trim() && variants[0].minVramGb === 0) {
+ existing!.sources![field] = [{ ...variants[0], minVramGb: defaults[0].minVramGb }, { ...defaults[1] }];
+ }
+ }
+ normalized.catalogVersion = 2;
localStorage.setItem(GENERATOR_TEMPLATES_KEY, JSON.stringify(normalized));
}
return normalized;
diff --git a/src/lib/weightDownloads.test.ts b/src/lib/weightDownloads.test.ts
index 40078b2..cf99ced 100644
--- a/src/lib/weightDownloads.test.ts
+++ b/src/lib/weightDownloads.test.ts
@@ -54,7 +54,29 @@ it("preserves the sample links and prevents an unfinished template from being th
expect(templateNeedsDownload(saved())).toBe(true);
expect(loadGeneratorTemplateSettings().defaultTemplateId).toBe("");
expect(defaultGeneratorTemplate().id).toBe("");
- expect(Object.values(saved().sources ?? {}).flat()).toHaveLength(4);
+ expect(Object.values(saved().sources ?? {}).flat()).toHaveLength(6);
+});
+
+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) => {
+ const original = vi.mocked(invoke).getMockImplementation()!;
+ vi.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";
+ 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,
+ }));
+ 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}`);
+ expect(invoke).toHaveBeenCalledWith("download_weight", expect.objectContaining({
+ url: vram <= 20
+ ? "https://huggingface.co/koongrizzly/MiniMax_H3_int4_W4A8_ConvRot_Pruned/resolve/main/diffusion_models/minimax_h3_ref2va_hybrid_b20-49_pruned_w4a8_mixed.safetensors"
+ : minimaxOriginalTemplate().paths.transformer,
+ }));
});
it("replaces a URL being typed instead of accumulating partial download sources", () => {