Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: size auto-quantised text encoders at the hosted file in the image picker (#14735)
Daniel Hanf27fd4ebacfb
diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.pyindex 5f4910990a4..f87abe84ef9 100644--- a/studio/backend/core/inference/diffusion.py+++ b/studio/backend/core/inference/diffusion.py@@ -7331,10 +7331,13 @@ class DiffusionBackend:# its dense size): out of both the share and the hosted bytes.te4_in_table = "text_encoder_4" in sourcesshare = table_priced / max(1, len(sources) - (1 if te4_in_table else 0))- # MPS only takes the int8 ConvRot file, smaller than the fp8 one.+ # MPS and an automatic int8 pick only take the int8 ConvRot file, smaller than the fp8 one.+ from .diffusion_te_prequant import auto_int8_takes_file_only+scale = (te_int8_convrot_budget_scale(fam)if int8_convrot_te_runs_on(target)+ or auto_int8_takes_file_only(text_encoder_quant)else TE_PREQUANT_BUDGET_SCALE)from .diffusion_te_prequant import _TE_DENSE_SIBLING_GBdiff --git a/studio/backend/core/inference/diffusion_te_prequant.py b/studio/backend/core/inference/diffusion_te_prequant.pyindex 4716164c0a2..d48d5050227 100644--- a/studio/backend/core/inference/diffusion_te_prequant.py+++ b/studio/backend/core/inference/diffusion_te_prequant.py@@ -349,7 +349,7 @@ def te_prequant_budget_scale(return 1.0scale = (te_int8_convrot_budget_scale(fam)- if _int8_convrot_only(te_quant_mode, target)+ if _int8_convrot_only(te_quant_mode, target) or auto_int8_takes_file_only(te_quant_mode)else TE_PREQUANT_BUDGET_SCALE)return _with_dense_siblings(fam, base, te_quant_mode, scale)@@ -532,6 +532,18 @@ def te_prequant_sources_confirmed(return confirmed+def auto_int8_takes_file_only(te_quant_mode: Any) -> bool:+ """Whether this pick is an AUTOMATIC int8 one, which loads the hosted int8 ConvRot file or the dense encoder and+ never the fp8 file behind it (``te_prequant_sources`` drops it). Its pre-cast budget is the int8 file's own+ fraction, not ``TE_PREQUANT_BUDGET_SCALE``: that ceiling covers an fp8 file this pick never opens, and pricing it+ oversized every auto load by up to 1.6 GB (Qwen-Image-2.1: 0.65 against the file's 0.533 of 17.5 GB)."""+ try:+ from .diffusion_precision import TE_QUANT_INT8, normalize_te_quant+ return normalize_te_quant(te_quant_mode) == TE_QUANT_INT8 and _auto_pick(te_quant_mode)+ except Exception: # noqa: BLE001+ return False++def _int8_convrot_only(te_quant_mode: Optional[str], target: Any) -> bool:"""Whether this pick can ONLY take the int8 ConvRot file (no fp8 fallback): Apple Silicon."""try:diff --git a/studio/backend/tests/test_diffusion_image_te_default.py b/studio/backend/tests/test_diffusion_image_te_default.pyindex dc23f9abf23..6cad97a90a6 100644--- a/studio/backend/tests/test_diffusion_image_te_default.py+++ b/studio/backend/tests/test_diffusion_image_te_default.py@@ -414,7 +414,9 @@ def test_automatic_default_budgets_dense_when_the_hub_cannot_answer(monkeypatch)def test_automatic_default_budgets_int8_once_the_hub_lists_the_file(monkeypatch):scale, _ = _budget(monkeypatch, _auto_int8(), listed = (_QWEN25VL_INT8[1],))explicit, _ = _budget(monkeypatch, "int8")- assert scale == explicit < 1.0+ # The automatic pick takes the int8 file only, so it is priced at that file; an explicit int8 keeps the fp8+ # ceiling of the file it may fall back to.+ assert scale == tpq.te_int8_convrot_budget_scale(_fam("qwen-image")) < explicit < 1.0def test_automatic_default_budgets_int8_when_the_file_is_cached_without_asking_the_hub(monkeypatch):diff --git a/studio/backend/tests/test_diffusion_te_auto_int8_budget.py b/studio/backend/tests/test_diffusion_te_auto_int8_budget.pynew file mode 100644index 00000000000..9c7610a576e--- /dev/null+++ b/studio/backend/tests/test_diffusion_te_auto_int8_budget.py@@ -0,0 +1,121 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""An automatic int8 text-encoder pick is budgeted at its hosted int8 ConvRot file, not the fp8 ceiling.++The auto pick loads the int8 file or the dense encoder, never the fp8 file (``te_prequant_sources`` drops it), so+``TE_PREQUANT_BUDGET_SCALE`` (the fp8 files' 0.65 ceiling) over-stated every auto load on CUDA. The Studio picker+sizes the same file (model-catalog.ts ``autoQuantTextEncoderGb``), so the two now agree.+"""++from __future__ import annotations++import types++import pytest++torch = pytest.importorskip("torch")++import core.inference.diffusion_te_prequant as tpq # noqa: E402+from core.inference.diffusion_families import _FAMILIES # noqa: E402+from core.inference.diffusion_precision import resolve_te_quant_request # noqa: E402++CUDA_BF16 = types.SimpleNamespace(device = "cuda", dtype = torch.bfloat16)++# family -> (bf16 encoder bytes, hosted int8 ConvRot file bytes), from the Hub listing of the family's FP8 repo.+_HOSTED_INT8 = {+ "flux.3-klein": (8_875_719_344, 5_247_076_320),+ "flux.3-klein-base": (8_875_719_344, 5_247_076_320),+ "qwen-image-2.1": (17_534_340_584, 9_349_769_248),+}+++def _fam(name):+ return next(f for f in _FAMILIES if f.name == name)+++def cuda_env(monkeypatch):+ import core.inference.diffusion as D+ import core.inference.diffusion_precision as prec+ from core.inference.diffusion_text_encoder_trim import KEEP_LM_HEAD_ENV++ monkeypatch.delenv(KEEP_LM_HEAD_ENV, raising = False)+ supported = lambda target, mode: getattr(target, "device", None) == "cuda"+ monkeypatch.setattr(prec, "te_quant_supported", supported)+ monkeypatch.setattr(D, "te_quant_supported", supported, raising = False)+ monkeypatch.setattr(tpq, "te_prequant_sources_confirmed", lambda sources, **k: True)+ return CUDA_BF16+++def _auto_mode(fam):+ mode, auto = resolve_te_quant_request(None, fam.te_quant_auto)+ assert auto and mode == "int8", fam.name+ return mode++[email protected]("name", sorted(_HOSTED_INT8))+def test_auto_int8_budgets_the_int8_file(name, cuda_env):+ fam = _fam(name)+ scale = tpq.te_prequant_budget_scale(+ fam, te_quant_mode = _auto_mode(fam), target = cuda_env, base = fam.base_repo+ )+ assert scale == tpq.te_int8_convrot_budget_scale(fam)+ assert scale < tpq.TE_PREQUANT_BUDGET_SCALE+ dense, hosted = _HOSTED_INT8[name]+ # Never below the file it loads: an under-estimate lets an oversized load through.+ assert scale >= hosted / dense++[email protected]("name", sorted(_HOSTED_INT8))+def test_explicit_int8_keeps_the_fp8_fallback_budget(name, cuda_env):+ # An explicit int8 may fall back to the fp8 file, so it keeps the fp8 ceiling.+ fam = _fam(name)+ scale = tpq.te_prequant_budget_scale(+ fam, te_quant_mode = "int8", target = cuda_env, base = fam.base_repo+ )+ assert scale == tpq.TE_PREQUANT_BUDGET_SCALE+++def test_auto_fp8_pick_is_unchanged(cuda_env):+ fam = _fam("flux.1-kontext")+ mode, auto = resolve_te_quant_request(None, fam.te_quant_auto)+ assert auto and mode == "fp8"+ explicit = tpq.te_prequant_budget_scale(+ fam, te_quant_mode = "fp8", target = cuda_env, base = fam.base_repo+ )+ scale = tpq.te_prequant_budget_scale(+ fam, te_quant_mode = mode, target = cuda_env, base = fam.base_repo+ )+ assert explicit == tpq.TE_PREQUANT_BUDGET_SCALE+ # Only the CLIP-L sibling stays dense; the hosted T5 share is still priced at the fp8 ceiling.+ assert tpq.TE_PREQUANT_BUDGET_SCALE < scale < 1.0+++def test_an_unconfirmed_auto_int8_file_still_budgets_dense(cuda_env, monkeypatch):+ monkeypatch.setattr(tpq, "te_prequant_sources_confirmed", lambda sources, **k: False)+ fam = _fam("qwen-image-2.1")+ scale = tpq.te_prequant_budget_scale(+ fam, te_quant_mode = _auto_mode(fam), target = cuda_env, base = fam.base_repo+ )+ assert scale == 1.0+++def test_the_uncached_precast_price_of_an_auto_int8_pick_is_the_int8_file(cuda_env, monkeypatch):+ from core.inference import diffusion_prequant as pq+ from core.inference.diffusion import DiffusionBackend+ from core.inference.diffusion_auto_policy import family_bf16_components_gb++ monkeypatch.setattr(pq, "prefer_cached_pickle_twins", lambda repo, names, **k: names)+ monkeypatch.setattr(pq, "first_cached_as_resolved", lambda *a, **k: None)+ fam = _fam("qwen-image-2.1")+ mib, _components, exact = DiffusionBackend._precast_text_encoder_mib(+ fam, fam.base_repo, cuda_env, _auto_mode(fam)+ )+ encoders = family_bf16_components_gb(fam, fam.base_repo)[1]+ assert not exact+ assert mib == int(encoders * 1000**3 * tpq.te_int8_convrot_budget_scale(fam)) // (1024 * 1024)+ explicit, _c, _e = DiffusionBackend._precast_text_encoder_mib(+ fam, fam.base_repo, cuda_env, "int8"+ )+ assert explicit == int(encoders * 1000**3 * tpq.TE_PREQUANT_BUDGET_SCALE) // (1024 * 1024)diff --git a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.tsindex 4dab3abbe4e..00152a94a0f 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts+++ b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts@@ -56,6 +56,11 @@ export interface ModelArtifact {prequantRepo?: string;/** Size (GB) per scheme; int8 stores scales fp8 does not. TRANSFORMER ONLY. */prequantSizeGb?: Readonly<Partial<Record<DenseQuantScheme, number>>>;+ /** The quantised text-encoder companion an AUTO load takes in place of the bf16 encoder: the family's+ * `te_quant_auto` resolved by `diffusion_te_prequant.te_prequant_sources` to a hosted file. `denseGb` is the bf16+ * encoder `approxSizeGb` counts, `quantisedGb` the hosted file the backend loads instead (GiB, Hub file sizes).+ * Absent = an auto load keeps the bf16 encoder (no `te_quant_auto`, ComfyUI's bf16 choice, or no hosted file). */+ autoQuantTextEncoderGb?: Readonly<{ denseGb: number; quantisedGb: number }>;/** Curated resident-size estimate for routing. Omitted = unknown: never auto-picked unless* downloaded. GGUF omits it too, since its quant ladder self-fits via pickDefaultQuant. */approxSizeGb?: number;@@ -218,6 +223,16 @@ const audioGgufGroups = (tasks: readonly AudioCppTask[]): CatalogGroup[] =>// Sizes are steady resident estimates (GB) used only for routing; missing = never auto-pick// unless downloaded. GGUF entries carry none: pickDefaultQuant sizes the .gguf files.+// The text encoders an auto load quantises (diffusion_families `te_quant_auto` with a hosted file the backend+// confirms), in GiB from the Hub file sizes. FLUX.3 Klein and its base share one Qwen3-VL-4B: 8,875,719,344 bytes+// bf16 against the 5,247,076,320-byte int8 ConvRot file. Qwen-Image 2.1 and its Turbo share one Qwen3-VL-8B:+// 17,534,340,584 bf16 against 9,349,769,248 int8 ConvRot. FLUX.1 Kontext's auto pick is fp8 on T5-XXL only+// (CLIP-L stays bf16): 9,524,648,584 against 6,163,991,880. Families whose auto int8 file is not hosted+// (Qwen-Image, Qwen-Image-Edit, HunyuanImage 2.1, Krea 2) load the dense encoder, so they carry none.+const FLUX3_KLEIN_AUTO_TE = { denseGb: 8.27, quantisedGb: 4.89 } as const;+const QWEN_IMAGE_21_AUTO_TE = { denseGb: 16.33, quantisedGb: 8.71 } as const;+const FLUX1_KONTEXT_AUTO_TE = { denseGb: 8.87, quantisedGb: 5.74 } as const;+export const IMAGE_CATALOG: CatalogGroup[] = [{canonicalId: "unsloth/Z-Image-Turbo",@@ -264,6 +279,7 @@ export const IMAGE_CATALOG: CatalogGroup[] = [prequantRepo: "unsloth/flux-3-image-klein-FP8",fetchedFrom: "unsloth/flux-3-image-klein-FP8",prequantSizeGb: { fp8: 6.0, int8: 6.0 },+ autoQuantTextEncoderGb: FLUX3_KLEIN_AUTO_TE,}),gguf("unsloth/flux-3-image-klein-GGUF"),],@@ -283,6 +299,7 @@ export const IMAGE_CATALOG: CatalogGroup[] = [fetchedFrom: "unsloth/flux-3-image-klein-base-FP8",// The INT8 file is BFL's own int8_convrot denoiser, smaller than the FP8.prequantSizeGb: { fp8: 5.98, int8: 5.41 },+ autoQuantTextEncoderGb: FLUX3_KLEIN_AUTO_TE,}),gguf("unsloth/flux-3-image-klein-base-GGUF"),],@@ -302,6 +319,7 @@ export const IMAGE_CATALOG: CatalogGroup[] = [totalParams: 7115124736,prequantRepo: "unsloth/Qwen-Image-2.1-FP8",prequantSizeGb: { fp8: 7.12, int8: 7.26 },+ autoQuantTextEncoderGb: QWEN_IMAGE_21_AUTO_TE,}),gguf("unsloth/Qwen-Image-2.1-GGUF"),],@@ -322,6 +340,7 @@ export const IMAGE_CATALOG: CatalogGroup[] = [totalParams: 7115124736,prequantRepo: "unsloth/Qwen-Image-2.1-Turbo-FP8",prequantSizeGb: { fp8: 7.12, int8: 7.26 },+ autoQuantTextEncoderGb: QWEN_IMAGE_21_AUTO_TE,}),gguf("unsloth/Qwen-Image-2.1-Turbo-GGUF"),],@@ -426,7 +445,10 @@ export const IMAGE_CATALOG: CatalogGroup[] = [description: "Image editing",scope: "image",artifacts: [- bf16Mirror("black-forest-labs/FLUX.1-Kontext-dev", 32, { totalParams: 11901408320 }),+ bf16Mirror("black-forest-labs/FLUX.1-Kontext-dev", 32, {+ totalParams: 11901408320,+ autoQuantTextEncoderGb: FLUX1_KONTEXT_AUTO_TE,+ }),gguf("unsloth/FLUX.1-Kontext-dev-GGUF"),],},@@ -1482,8 +1504,15 @@ const FORMAT_QUALITY: Record<ArtifactFormat, number> = {const BF16_BYTES_PER_PARAM = 2;+/** GiB an auto load saves by taking the hosted quantised text encoder instead of the bf16 one. */+function autoQuantTextEncoderSavingGb(artifact: ModelArtifact): number {+ const te = artifact.autoQuantTextEncoderGb;+ return te ? Math.max(0, te.denseGb - te.quantisedGb) : 0;+}+/** What a row is sized by here: the pre-quantised transformer plus the companions, which are- * `approxSizeGb` minus the bf16 transformer. Clamped to the dense figure.+ * `approxSizeGb` minus the bf16 transformer, with the text encoder at the quantised size an auto load really+ * takes (`autoQuantTextEncoderGb`). Clamped to the dense figure.** The reported schemes are a LADDER: `_pipeline_planned_denoiser_scheme` walks every rung below* its winner and seeds the first whose hosted artifact stays resident, so the first rung fitting@@ -1503,16 +1532,23 @@ function residentSizeGb(const denseTransformerGb = artifact.totalParams? (artifact.totalParams * BF16_BYTES_PER_PARAM) / BYTES_PER_GB: 0;- const companionsGb = Math.max(0, dense - denseTransformerGb);+ // The host runs a dense scheme, so it is a CUDA bf16 card, which is also where the backend's auto text-encoder+ // pick loads its hosted file (te_prequant_sources needs fp8 to run). Anywhere else the encoder stays bf16.+ const teSavingGb = autoQuantTextEncoderSavingGb(artifact);+ const denseResidentGb = Math.max(0, dense - teSavingGb);+ const companionsGb = Math.max(+ 0,+ Math.max(0, dense - denseTransformerGb) - teSavingGb,+ );let firstHosted: number | undefined;for (const scheme of schemes) {const quantised = artifact.prequantSizeGb?.[scheme as DenseQuantScheme];if (quantised === undefined) continue;- const sizeGb = Math.min(dense, quantised + companionsGb);+ const sizeGb = Math.min(denseResidentGb, quantised + companionsGb);if (firstHosted === undefined) firstHosted = sizeGb;if (allowanceGb === undefined || sizeGb <= allowanceGb) return sizeGb;}- return firstHosted ?? dense;+ return firstHosted ?? denseResidentGb;}function fitsArtifactBudget(diff --git a/studio/frontend/tests/dense-quant-prequant-routing.test.ts b/studio/frontend/tests/dense-quant-prequant-routing.test.tsindex 5f673d2fe33..f7cca67d29a 100644--- a/studio/frontend/tests/dense-quant-prequant-routing.test.ts+++ b/studio/frontend/tests/dense-quant-prequant-routing.test.ts@@ -277,7 +277,8 @@ test("Qwen-Image-2.1 is badged with the size its verdict used", () => {const card = onCard(22.49, ["int8", "fp8"]);const fit = curatedArtifactFit(QWEN_21, IMAGE_CATALOG, card);assert.ok(fit?.sizeGb !== undefined);- assert.ok(Math.abs(fit.sizeGb - 27.01) < 0.01, String(fit.sizeGb));+ // int8 DiT 7.26 + the companions with the Qwen3-VL-8B at its hosted int8 ConvRot size (8.71, not 16.33 bf16).+ assert.ok(Math.abs(fit.sizeGb - 19.39) < 0.01, String(fit.sizeGb));assert.equal(fit.allowanceGb, 22.49 * 0.7);assert.equal(fit.fits, false);assert.equal(curatedArtifactFitsDevice(QWEN_21, IMAGE_CATALOG, card), fit.fits);@@ -321,11 +322,11 @@ test("the over-budget text never shows the size below the budget it exceeds", ());assert.equal(text(QWEN_21, 22.49),- "Needs ~27GB for weights (budget: ~15.7GB, 70% of a 22.49GB GPU)",+ "Needs ~19GB for weights (budget: ~15.7GB, 70% of a 22.49GB GPU)",);});-test("Qwen-Image-2.1 routes every card as on main", () => {+test("Qwen-Image-2.1 routes by the int8 text encoder an auto load takes", () => {const group = groupForRepoId(QWEN_21, IMAGE_CATALOG);assert.ok(group);const pick = (gpuGb: number) =>@@ -333,10 +334,11 @@ test("Qwen-Image-2.1 routes every card as on main", () => {...onCard(gpuGb, ["int8"]),isDownloaded: notDownloaded,}).repoId;- // 36 sits just below the existing routing threshold.+ // 19.39 GiB resident against the 70% rule: the dense row from a 27.7 GiB card up, the GGUF below.assert.equal(pick(24), "unsloth/Qwen-Image-2.1-GGUF");- assert.equal(pick(31.84), "unsloth/Qwen-Image-2.1-GGUF");- assert.equal(pick(36), "unsloth/Qwen-Image-2.1-GGUF");+ assert.equal(pick(27.6), "unsloth/Qwen-Image-2.1-GGUF");+ assert.equal(pick(27.8), QWEN_21);+ assert.equal(pick(31.84), QWEN_21);assert.equal(pick(39.5), QWEN_21);});diff --git a/studio/frontend/tests/picker-auto-quant-text-encoder.test.ts b/studio/frontend/tests/picker-auto-quant-text-encoder.test.tsnew file mode 100644index 00000000000..b828230cc0a--- /dev/null+++ b/studio/frontend/tests/picker-auto-quant-text-encoder.test.ts@@ -0,0 +1,116 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test from "node:test";++import {+ IMAGE_CATALOG,+ artifactForRepoId,+ catalogGroupFitsDevice,+ curatedArtifactFit,+ groupForRepoId,+ pickDefaultArtifact,+} from "../src/features/model-picker/components/model-selector/model-catalog.ts";++const KLEIN = "black-forest-labs/flux-3-image-klein";+const KLEIN_BASE = "black-forest-labs/flux-3-image-klein-base";+const QWEN_21 = "unsloth/Qwen-Image-2.1";+const QWEN_21_TURBO = "Qwen/Qwen-Image-2.1-Turbo";+const KONTEXT = "unsloth/FLUX.1-Kontext-dev";+const notDownloaded = () => false;+const GIB = 1024 ** 3;++const card = (gpuGb: number, denseQuantSchemes: readonly string[] = ["int8", "fp8"]) => ({+ gpuGb,+ systemRamGb: 64,+ denseQuantSchemes,+});++const pick = (id: string, gpuGb: number, schemes?: readonly string[]) => {+ const group = groupForRepoId(id, IMAGE_CATALOG);+ assert.ok(group, id);+ return pickDefaultArtifact(group, { ...card(gpuGb, schemes), isDownloaded: notDownloaded }).label;+};++const sizeOf = (id: string, gpuGb: number, schemes?: readonly string[]) => {+ const fit = curatedArtifactFit(id, IMAGE_CATALOG, card(gpuGb, schemes));+ assert.ok(fit?.sizeGb !== undefined, id);+ return fit.sizeGb;+};++test("each auto-quantised row states the hosted encoder file the backend loads", () => {+ // Hub file sizes (bytes): the bf16 encoder shards against the file te_prequant_sources resolves for the+ // family's te_quant_auto on a CUDA bf16 host.+ for (const [id, dense, quantised] of [+ [KLEIN, 8_875_719_344, 5_247_076_320],+ [KLEIN_BASE, 8_875_719_344, 5_247_076_320],+ [QWEN_21, 17_534_340_584, 9_349_769_248],+ [QWEN_21_TURBO, 17_534_340_584, 9_349_769_248],+ [KONTEXT, 9_524_648_584, 6_163_991_880],+ ] as const) {+ const te = artifactForRepoId(id, IMAGE_CATALOG)?.artifact.autoQuantTextEncoderGb;+ assert.ok(te, id);+ assert.ok(Math.abs(te.denseGb - dense / GIB) < 0.01, `${id} dense`);+ assert.ok(Math.abs(te.quantisedGb - quantised / GIB) < 0.01, `${id} quantised`);+ }+});++test("rows whose encoder an auto load keeps bf16 carry no quantised companion", () => {+ // No te_quant_auto (ComfyUI keeps the encoder bf16), or an auto int8 file that is not hosted, so the backend+ // loads the dense encoder.+ for (const id of [+ "unsloth/Z-Image-Turbo",+ "unsloth/FLUX.1-schnell",+ "unsloth/FLUX.1-dev",+ "black-forest-labs/FLUX.1-Krea-dev",+ "unsloth/Qwen-Image",+ "unsloth/Qwen-Image-2512",+ "unsloth/Qwen-Image-Edit-2511",+ "krea/Krea-2-Turbo",+ "Alpha-VLLM/Lumina-Image-2.0",+ "hunyuanvideo-community/HunyuanImage-2.1-Diffusers",+ "HiDream-ai/HiDream-I1-Full",+ ]) {+ assert.equal(+ artifactForRepoId(id, IMAGE_CATALOG)?.artifact.autoQuantTextEncoderGb,+ undefined,+ id,+ );+ }+});++test("the dense row is sized with the quantised encoder, not the bf16 one", () => {+ // Klein: 6.0 int8 DiT + (18.92 - 10.33 bf16 DiT) companions, less the 3.38 GiB the int8 encoder saves.+ assert.ok(Math.abs(sizeOf(KLEIN, 24) - 11.2) < 0.02, String(sizeOf(KLEIN, 24)));+ assert.ok(Math.abs(sizeOf(KLEIN_BASE, 24) - 10.61) < 0.02, String(sizeOf(KLEIN_BASE, 24)));+ assert.ok(Math.abs(sizeOf(QWEN_21, 32) - 19.39) < 0.02, String(sizeOf(QWEN_21, 32)));+ assert.ok(Math.abs(sizeOf(QWEN_21_TURBO, 32) - 19.39) < 0.02);+ // Kontext has no hosted DiT, so the bf16 DiT stays and only T5-XXL drops to fp8: 32 - 3.13.+ assert.ok(Math.abs(sizeOf(KONTEXT, 32) - 28.87) < 0.02, String(sizeOf(KONTEXT, 32)));+});++test("a card the dense row fits with its quantised encoder picks it over the GGUF", () => {+ assert.equal(pick(KLEIN_BASE, 16), "BF16");+ assert.equal(pick(KLEIN_BASE, 16, ["fp8", "int8"]), "BF16");+ assert.equal(pick(QWEN_21, 32), "BF16");+ assert.equal(pick(QWEN_21_TURBO, 32), "BF16");+ // Still too big: unchanged.+ assert.equal(pick(QWEN_21, 24), "GGUF");+ assert.equal(pick(KLEIN, 12), "GGUF");+ const kleinBase = groupForRepoId(KLEIN_BASE, IMAGE_CATALOG);+ assert.ok(kleinBase);+ assert.equal(catalogGroupFitsDevice(kleinBase, card(16), notDownloaded), true);+});++test("a host that reports no dense scheme keeps the bf16 sizing", () => {+ // No dense scheme = not a CUDA bf16 card the backend's encoder cast runs on, so nothing is assumed.+ for (const [id, dense] of [+ [KLEIN, 18.92],+ [QWEN_21, 33],+ [KONTEXT, 32],+ ] as const) {+ assert.equal(curatedArtifactFit(id, IMAGE_CATALOG, card(80, []))?.sizeGb, dense, id);+ }+ assert.equal(pick(QWEN_21, 32, []), "GGUF");+});