Skip to content

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.

Studio: take the hosted pre-cast fp8 text encoder by default on Qwen-Image-2.1 (#11539)

Daniel Han0fb5edc9591b
diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.py
index 19a09ca0823..0fe7b08e94d 100644
--- a/studio/backend/core/inference/diffusion.py
+++ b/studio/backend/core/inference/diffusion.py
@@ -154,6 +154,7 @@ from .diffusion_precision import (
effective_te_quant,
normalize_te_quant,
quantize_text_encoders,
+ resolve_te_quant_request,
te_quant_needs_resident_weights,
te_quant_supported,
torchao_quantize_importable,
@@ -870,6 +871,28 @@ def _assert_base_repo_accessible(
return None
+def _te_quant_reason(
+ outcome: Any, engaged: Optional[str], *, auto: bool, family: Optional[str]
+) -> str:
+ """The status line for the text-encoder precision control.
+
+ ``quantize_text_encoders`` fills a reason on every path it takes, so the fallbacks here cover
+ only the case where it returns an empty one. An AUTO pick is annotated rather than described
+ differently: the reason still has to say what happened to the weights, and the annotation says
+ nobody asked for it, which is what tells a reader the encoder can be pinned back to bf16.
+ """
+ reason = getattr(outcome, "reason", None) or (
+ "dense bf16 text encoder(s) loaded"
+ if engaged is None
+ else "dense text encoder(s) quantised in place"
+ )
+ if auto and engaged is not None:
+ reason = f"{reason}; selected automatically for {family} (no text_encoder_quant requested)"
+ elif auto:
+ reason = f"{reason}; the automatic '{family}' encoder scheme did not engage"
+ return reason
+
+
@dataclass(frozen = True)
class _LoadState:
"""Everything about the currently-loaded pipeline, swapped as one unit."""
@@ -2392,10 +2415,16 @@ class DiffusionBackend:
kwargs["repo_id"], kwargs.get("base_repo"), fam, kwargs.get("hf_token")
)
kwargs["base_repo"] = base
- # The pre-cast encoder replaces these weights, so skip their dense shards. Same resolver as the injection.
+ # The pre-cast encoder replaces these weights, so skip their dense shards. Same resolver as the injection,
+ # and the same tri-state: a family whose UNSET request resolves to a hosted scheme must not stage the dense
+ # encoder the load is about to not open. kwargs keep the RAW request, which stays the single source of
+ # truth; the loader re-resolves it for itself and is what reports the choice.
+ te_quant_planned, _ = resolve_te_quant_request(
+ kwargs.get("text_encoder_quant"), getattr(fam, "te_quant_auto", None)
+ )
te_prequant_files = self._te_prequant_plan_files(
fam,
- kwargs.get("text_encoder_quant"),
+ te_quant_planned,
kwargs.get("hf_token"),
kwargs.get("gpu_ordinal"),
local_files_only = local_files_only,
@@ -3306,10 +3335,15 @@ class DiffusionBackend:
fam, repo_id, gguf_filename, base, hf_token
) or speech_pick_refusal(repo_id, gguf_filename, hf_token)
# Only a checkpoint that really resolves on the Hub earns the right to drop dense shards
+ # Resolved through the same tri-state the loader uses, so the size the picker SHOWS is the size the load will
+ # actually move on a family whose unset request takes a hosted encoder.
+ te_quant_planned, _ = resolve_te_quant_request(
+ text_encoder_quant, getattr(fam, "te_quant_auto", None)
+ )
te_files = (
self._te_prequant_plan_files(
fam,
- text_encoder_quant,
+ te_quant_planned,
hf_token,
load_kwargs.get("gpu_ordinal"),
base_repo = base,
@@ -4065,7 +4099,20 @@ class DiffusionBackend:
normalize_speed_mode(speed_mode)
normalize_attention_backend(attention_backend)
normalize_transformer_cache(transformer_cache)
- normalize_te_quant(text_encoder_quant)
+ # Text-encoder tri-state, resolved HERE so every consumer below (the memory plan, the download plan, the
+ # pre-cast injection, the dense cast) sees one decision. unset/"auto" -> the family's ``te_quant_auto``;
+ # "none"/"off" -> the released bf16 encoder; an explicit scheme pins itself. Also validates the raw request,
+ # which is why it runs before this load evicts the previous pipeline.
+ text_encoder_quant_requested = text_encoder_quant
+ text_encoder_quant, text_encoder_quant_auto = resolve_te_quant_request(
+ text_encoder_quant, getattr(fam, "te_quant_auto", None)
+ )
+ if text_encoder_quant_auto:
+ logger.info(
+ "diffusion.text_encoder_quant: '%s' selected automatically for %s (unset request)",
+ text_encoder_quant,
+ fam.name,
+ )
# A full pipeline is its own base; single-file kinds resolve the companion base repo.
base = (
repo_id if kind == "pipeline" else _resolve_base_repo(repo_id, base_repo, fam, hf_token)
@@ -5441,15 +5488,19 @@ class DiffusionBackend:
# engaged NOTHING leaves a dense bf16 encoder the caller did not ask for, and a PARTIAL cast
# leaves a pipeline conditioning off a mixture of quantised and dense encoders. A mode that
# engaged something ELSE (int8 -> fp8) is reported by the badge instead.
+ # The RAW request, not the resolved one: an AUTO-selected scheme that engaged nothing is a dense
+ # bf16 encoder nobody asked to avoid, so it falls back quietly. Refusing there would turn a load
+ # that works today into an error the caller cannot even attribute to a choice they made.
if (
(te_quant is None or te_outcome.partial)
- and normalize_te_quant(text_encoder_quant) is not None
+ and not text_encoder_quant_auto
+ and normalize_te_quant(text_encoder_quant_requested) is not None
and not precision_fallback_allowed()
):
raise RuntimeError(
precision_refusal_message(
"text_encoder_quant",
- normalize_te_quant(text_encoder_quant) or "",
+ normalize_te_quant(text_encoder_quant_requested) or "",
te_outcome.reason or "no text encoder could be cast",
off_label = "leave it unset to keep the dense bf16 encoder",
auto_available = False,
@@ -5544,13 +5595,15 @@ class DiffusionBackend:
else transformer_quant_decline_status,
),
"text_encoder_quant": (
- text_encoder_quant,
+ # The RAW request, for the same reason as the transformer above: the badge must not
+ # show a scheme the caller never typed as though they had pinned it.
+ text_encoder_quant_requested,
te_quant or "off",
- te_outcome.reason
- or (
- "dense bf16 text encoder(s) loaded"
- if te_quant is None
- else "dense text encoder(s) quantised in place"
+ _te_quant_reason(
+ te_outcome,
+ te_quant,
+ auto = text_encoder_quant_auto,
+ family = fam.name,
),
te_outcome.status,
),
diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.py
index feaf33715f3..2b6cd356019 100644
--- a/studio/backend/core/inference/diffusion_families.py
+++ b/studio/backend/core/inference/diffusion_families.py
@@ -128,6 +128,12 @@ class DiffusionFamily:
# Hosted PRE-CAST text-encoder checkpoints as (scheme, component, repo_id). Layerwise-fp8 only: the cast is
# deterministic, so the artifact is bit-identical while skipping the dense TE download.
te_prequant_repos: tuple[tuple[str, str, str], ...] = field(default_factory = tuple)
+ # The text-encoder scheme an UNSET request resolves to on this family, or None to keep the released bf16 encoder.
+ # Opt-in per family rather than implied by ``te_prequant_repos``, because hosting an artifact says the cast is
+ # reproducible, not that its conditioning is good enough to hand someone who asked for nothing. These encoders are
+ # different models (T5, CLIP, Qwen3-VL, Gemma) and fp8 tolerance does not transfer between them, so a family joins
+ # this list only once the fp8-vs-bf16 delta has been measured on it.
+ te_quant_auto: Optional[str] = None
# Native (sd.cpp) single-file assets, used only on the no-GPU sd.cpp engine. The transformer GGUF is shared with
# diffusers; sd-cli also needs a (repo_id, filename) VAE + text encoder(s), each with a trailing SdCppModelFiles
# field name.
@@ -375,6 +381,11 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (
),
# Qwen3-VL 8B, pre-cast. Independent of the DiT scheme, as on every other family.
te_prequant_repos = (("fp8", "text_encoder", "unsloth/Qwen-Image-2.1-FP8"),),
+ # The encoder is the BIG component here, not the denoiser: Qwen3-VL-8B is 16.33 GiB dense against 6.76 GiB for
+ # the INT8 transformer, so a quantised denoiser alone still costs ~26 GB and the hosted pre-cast encoder is
+ # what makes the family fit a 24 GB card. Measured on this family at 1024/40 steps: 23.74 -> 16.16 GiB resident
+ # and 11.6 -> 1.5 s to load the encoder, with per-image render time unchanged.
+ te_quant_auto = "fp8",
cfg_kwarg = "true_cfg_scale",
# 2.1 is UNIFIED: one pipeline, and QwenImage21Pipeline.__call__ takes ``image`` as condition
# images alongside the prompt, so this is the FLUX.2 shape rather than the Qwen-Image-Edit
diff --git a/studio/backend/core/inference/diffusion_precision.py b/studio/backend/core/inference/diffusion_precision.py
index c83b02a1218..d017be23f56 100644
--- a/studio/backend/core/inference/diffusion_precision.py
+++ b/studio/backend/core/inference/diffusion_precision.py
@@ -82,6 +82,41 @@ def normalize_te_quant(value: Optional[str]) -> Optional[str]:
return normalized
+def te_quant_is_auto(value: Optional[str]) -> bool:
+ """Whether ``value`` is the UNSET side of the text-encoder tri-state (unset / "" / "auto").
+
+ ``normalize_te_quant`` folds "none" and "off" into the same None, which is right for every
+ caller that only needs a scheme, and wrong for the one that has to tell "choose for me" from
+ "leave it alone". Reads the raw request, so it must run before normalising.
+ """
+ if value is None:
+ return True
+ normalized = str(value).strip().lower().replace("-", "_")
+ return not normalized or normalized == "auto"
+
+
+def resolve_te_quant_request(
+ value: Optional[str], auto_scheme: Optional[str]
+) -> tuple[Optional[str], bool]:
+ """``(mode, auto_selected)`` for a raw text-encoder request on a family offering ``auto_scheme``.
+
+ The tri-state: unset / "auto" takes ``auto_scheme`` (the family's ``te_quant_auto``, None on a
+ family that has not opted in); "none" / "off" pins the released bf16 encoder; an explicit
+ scheme pins that scheme. ``auto_selected`` is what keeps an auto pick from being reported as a
+ request the caller made, and from REFUSING the load when it does not engage: nobody asked for
+ it, so falling back to dense is the correct outcome rather than an error.
+
+ Raises ValueError for an unsupported explicit value, via ``normalize_te_quant``.
+ """
+ if not te_quant_is_auto(value):
+ return normalize_te_quant(value), False
+ if auto_scheme is None:
+ return None, False
+ # Validate the family's own field rather than trusting it: a typo here would otherwise reach
+ # quantize_text_encoders as an unknown mode on every default load of that family.
+ return normalize_te_quant(auto_scheme), True
+
+
def effective_te_quant(mode: Optional[str], family: Optional[str]) -> Optional[str]:
"""The text-encoder mode ``quantize_text_encoders`` will ACTUALLY attempt for ``family``.
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index 9f88909c080..15ff0859fca 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -3777,9 +3777,14 @@ class DiffusionLoadRequest(BaseModel):
"default (also regional torch.compile where eligible), "
"max (also TF32 + fused QKV).",
)
- text_encoder_quant: Optional[Literal["fp8", "fp8_dynamic", "int8", "nvfp4"]] = Field(
+ text_encoder_quant: Optional[
+ Literal["auto", "none", "off", "fp8", "fp8_dynamic", "int8", "nvfp4"]
+ ] = Field(
None,
- description = "Quantise the companion text encoder(s): fp8 (layerwise cast, ~2x smaller, "
+ description = "Quantise the companion text encoder(s). Unset or 'auto' lets the family "
+ "choose (Qwen-Image-2.1 takes its hosted pre-cast fp8 encoder, 8.75 GiB against 16.33 "
+ "dense); 'none'/'off' pins the released bf16 encoder. Explicit: fp8 (layerwise cast, "
+ "~2x smaller, "
"CUDA cc>=8.9), fp8_dynamic (torchao compute fp8 on the tensor cores, ~2x + faster, "
"cc>=8.9), int8 (torchao compute int8 with per-family keep-bf16 layers; falls back to "
"fp8 where no schedule exists; cc>=8.0), or nvfp4 (~4x smaller, Blackwell sm_100+). A "
diff --git a/studio/backend/tests/test_diffusion_precision.py b/studio/backend/tests/test_diffusion_precision.py
index 7278ecac6d0..f2a4f16ee95 100644
--- a/studio/backend/tests/test_diffusion_precision.py
+++ b/studio/backend/tests/test_diffusion_precision.py
@@ -26,6 +26,8 @@ from core.inference.diffusion_precision import (
_keep_bf16_block_fqns,
effective_te_quant,
normalize_te_quant,
+ resolve_te_quant_request,
+ te_quant_is_auto,
quantize_text_encoders,
te_quant_supported,
)
@@ -583,3 +585,74 @@ def test_no_torchao_config_is_constructed_outside_quiet_config():
"torchao config constructed outside _quiet_config (pass the CLASS as its first argument instead):\n "
+ "\n ".join(offenders)
)
+
+
+# ── the text-encoder tri-state ───────────────────────────────────────────────────
+
+
+def test_unset_and_auto_are_the_only_spellings_that_invite_a_family_default():
+ """The tri-state hinges on telling "choose for me" from "leave it alone", and
+ ``normalize_te_quant`` deliberately folds both into None. ``te_quant_is_auto`` is what
+ recovers the distinction, so an opt-out must NOT read as auto or every "off" request
+ silently gets the family's scheme."""
+ for auto in (None, "", " ", "auto", "AUTO", " Auto "):
+ assert te_quant_is_auto(auto) is True
+ for pinned in ("none", "off", "OFF", " None ", "fp8", "int8", "nvfp4", "fp8_dynamic"):
+ assert te_quant_is_auto(pinned) is False
+
+
+def test_an_unset_request_takes_the_family_scheme_and_is_marked_as_not_asked_for():
+ """The whole point: a family that hosts a pre-cast encoder answers an unset request with
+ it. ``auto_selected`` is the second half, and it is load-bearing rather than cosmetic --
+ it is what stops the loader refusing when the scheme does not engage."""
+ assert resolve_te_quant_request(None, "fp8") == ("fp8", True)
+ assert resolve_te_quant_request("auto", "fp8") == ("fp8", True)
+ assert resolve_te_quant_request("", "fp8") == ("fp8", True)
+
+
+def test_an_opt_out_still_pins_the_released_bf16_encoder():
+ """"none"/"off" has to survive the new default, or the bf16 reference configuration
+ becomes unreachable and no comparison against it can be run."""
+ for opt_out in ("none", "off", " OFF "):
+ assert resolve_te_quant_request(opt_out, "fp8") == (None, False)
+
+
+def test_an_explicit_scheme_still_wins_over_the_family_default():
+ assert resolve_te_quant_request("int8", "fp8") == ("int8", False)
+ assert resolve_te_quant_request("nvfp4", "fp8") == ("nvfp4", False)
+ # And is still validated: a bad explicit value is refused cheaply, as before.
+ with pytest.raises(ValueError):
+ resolve_te_quant_request("int3", "fp8")
+
+
+def test_a_family_that_has_not_opted_in_keeps_todays_dense_bf16_default():
+ """Backwards compatibility for every family without ``te_quant_auto``: unset must still
+ mean the released encoder, not a scheme inferred from the fact that an artifact exists."""
+ for unset in (None, "auto", ""):
+ assert resolve_te_quant_request(unset, None) == (None, False)
+
+
+def test_a_typo_in_a_familys_own_default_is_refused_rather_than_passed_through():
+ """The field is code, not a request, so a bad value would otherwise reach
+ ``quantize_text_encoders`` as an unknown mode on EVERY default load of that family."""
+ with pytest.raises(ValueError):
+ resolve_te_quant_request(None, "fp9")
+
+
+def test_the_dense_opt_out_survives_the_image_request_schema_too():
+ """The normaliser accepting "none" is not enough: ``DiffusionLoadRequest`` is the API
+ boundary, and while its scheme list was fp8/fp8_dynamic/int8/nvfp4 only, omitting the field
+ was the ONLY way to ask for the released encoder. Once an omitted request can resolve to a
+ family scheme, that spelling stops meaning dense and the opt-out has to be sendable, or the
+ bf16 reference configuration is unreachable through the API."""
+ from pydantic import ValidationError
+
+ from models.inference import DiffusionLoadRequest
+
+ def _request(value):
+ return DiffusionLoadRequest(model_path = "Qwen/Qwen-Image-2.1", text_encoder_quant = value)
+
+ for accepted in (None, "auto", "none", "off", "fp8", "fp8_dynamic", "int8", "nvfp4"):
+ assert _request(accepted).text_encoder_quant == accepted
+ with pytest.raises(ValidationError):
+ _request("int3")
diff --git a/studio/backend/tests/test_diffusion_te_prequant.py b/studio/backend/tests/test_diffusion_te_prequant.py
index af972406265..24df566cc57 100644
--- a/studio/backend/tests/test_diffusion_te_prequant.py
+++ b/studio/backend/tests/test_diffusion_te_prequant.py
@@ -1030,3 +1030,42 @@ def test_the_video_prefetch_advances_only_on_a_missing_name():
# Anything else is about the repo, not the name.
assert miss(PermissionError("401"), local_files_only = False) is False
assert miss(OSError("corrupt cache"), local_files_only = True) is False
+
+
+# ── the family opt-in ────────────────────────────────────────────────────────────
+
+
+def test_every_family_default_scheme_is_one_we_actually_host_for_that_family():
+ """``te_quant_auto`` promises a scheme an UNSET request gets. If the family has no hosted
+ pre-cast encoder for it, that promise costs a dense download and an in-place cast on every
+ default load, which is the opposite of why the field exists. Catches a family opting in
+ before its artifact is published, and a scheme/component pair that does not line up."""
+ from core.inference.diffusion_families import _FAMILIES
+ from core.inference.diffusion_te_prequant import family_te_prequant_repo
+
+ offenders = []
+ for fam in _FAMILIES:
+ scheme = getattr(fam, "te_quant_auto", None)
+ if scheme is None:
+ continue
+ if not any(
+ family_te_prequant_repo(fam, scheme, component) for component in tpq.TE_PREQUANT_COMPONENTS
+ ):
+ offenders.append(f"{fam.name}: te_quant_auto={scheme!r} with no hosted {scheme} encoder")
+ assert not offenders, "\n ".join(["families default to an unhosted encoder scheme:", *offenders])
+
+
+def test_qwen_image_2_1_defaults_to_the_hosted_fp8_encoder():
+ """The family this was built for. Its encoder (Qwen3-VL-8B, 16.33 GiB dense) is bigger than
+ its INT8 denoiser (6.76 GiB), so leaving it dense is what made a quantised pick still cost
+ ~26 GB. Named rather than covered only by the sweep above, because the whole change is
+ pointless if this one row regresses."""
+ from core.inference.diffusion_families import detect_family
+ from core.inference.diffusion_te_prequant import resolve_te_prequant_source
+
+ fam = detect_family("Qwen/Qwen-Image-2.1")
+ assert fam.te_quant_auto == "fp8"
+ source = resolve_te_prequant_source(fam, "text_encoder", "fp8")
+ assert source is not None and source.kind == "repo"
+ assert source.location == "unsloth/Qwen-Image-2.1-FP8"
+ assert source.filename == "Qwen-Image-2.1-text_encoder-FP8.safetensors"
diff --git a/studio/frontend/src/features/images/api.ts b/studio/frontend/src/features/images/api.ts
index f1da1eefdd8..87abe421366 100644
--- a/studio/frontend/src/features/images/api.ts
+++ b/studio/frontend/src/features/images/api.ts
@@ -93,7 +93,16 @@ export interface DiffusionLoadRequest {
transformer_quant?: "auto" | "none" | "off" | "int8" | "fp8" | "nvfp4" | "mxfp8";
// Text-encoder precision (omit to keep the dense bf16 encoder). Refused with a 409 when the host
// cannot run it, rather than loading dense and reporting nothing.
- text_encoder_quant?: "fp8" | "fp8_dynamic" | "int8" | "nvfp4";
+ // "none"/"off" pin the released bf16 encoder; omitting the field (or "auto") lets the family
+ // choose, which is no longer the same thing.
+ text_encoder_quant?:
+ | "auto"
+ | "none"
+ | "off"
+ | "fp8"
+ | "fp8_dynamic"
+ | "int8"
+ | "nvfp4";
attention_backend?:
| "auto"
| "native"
diff --git a/studio/frontend/src/features/images/images-page.tsx b/studio/frontend/src/features/images/images-page.tsx
index b6bd552f166..4c69fca0464 100644
--- a/studio/frontend/src/features/images/images-page.tsx
+++ b/studio/frontend/src/features/images/images-page.tsx
@@ -2375,9 +2375,13 @@ export function ImagesPage({
);
if (quant) setTransformerQuant(quant);
const encoder = resolvedSelectValue(record.text_encoder_quant, (v) =>
- // A declined request runs dense: "off" (or "none", older backend) is the select's Default.
- (["auto", "fp8", "fp8_dynamic", "int8", "nvfp4"] as const).find(
- (o) => o === v || (o === "auto" && (v === "none" || v === "off")),
+ // The engaged value spells the dense encoder "off"; the select's option for it is "none".
+ // It maps to Dense, NOT to Default: an unset request is already caught upstream by
+ // `source === "auto"`, so reaching here with "off" means dense was pinned or a scheme was
+ // declined. Folding it into Default would snap a pinned Dense back to Default, and the next
+ // reapply would omit the field and silently take the family's scheme instead.
+ (["auto", "none", "fp8", "fp8_dynamic", "int8", "nvfp4"] as const).find(
+ (o) => o === v || (o === "none" && v === "off"),
) ?? null,
);
if (encoder) setTextEncoderQuant(encoder);
@@ -3775,12 +3779,15 @@ export function ImagesPage({
)}
<AdvancedSelect
label="Text encoder precision"
- hint="Lower precision reduces text-encoder memory but can change image quality. Supported modes depend on the GPU and model. Default keeps the existing encoder precision; the loaded build below reports what was applied."
+ hint="Lower precision reduces text-encoder memory but can change image quality. Supported modes depend on the GPU and model. Default lets the model choose, which on Qwen-Image 2.1 means its hosted FP8 encoder (8.75 GB rather than 16.3); pick Dense (bf16) to pin the released encoder. The loaded build below reports what was applied."
badge={<ResolvedBadge status={status} controlKey="text_encoder_quant" />}
value={textEncoderQuant}
onValueChange={(v) => setTextEncoderQuant(v as typeof textEncoderQuant)}
options={[
["auto", "Default"],
+ // The opt-out. Reachable only since a family default can pick a scheme on its own: with
+ // "Default" meaning bf16 everywhere, omitting the field WAS the dense request.
+ ["none", "Dense (bf16)"],
["fp8", "FP8 (storage)"],
["fp8_dynamic", "FP8 (compute)"],
["int8", "INT8"],
diff --git a/studio/frontend/tests/resolved-precision.test.ts b/studio/frontend/tests/resolved-precision.test.ts
index 0c1b9aa728d..2ea6de1cd47 100644
--- a/studio/frontend/tests/resolved-precision.test.ts
+++ b/studio/frontend/tests/resolved-precision.test.ts
@@ -400,3 +400,50 @@ test("the reseed key moves when the text encoder build changes, and only then",
key,
);
});
+
+// The text-encoder select's own option vocabulary, as images-page.tsx spells it. Kept in step
+// with that file: these two mappings are the only thing standing between "Dense pinned" and
+// "Default", which since the family-default change are no longer the same request.
+const TE_OPTIONS = ["auto", "none", "fp8", "fp8_dynamic", "int8", "nvfp4"] as const;
+const toTeOption = (v: string) =>
+ TE_OPTIONS.find((o) => o === v || (o === "none" && v === "off")) ?? null;
+
+test("an unset text-encoder request reseeds as Default even when a scheme engaged", () => {
+ // The case a naive fix breaks. Once a family default can pick fp8 for a request nobody made,
+ // mapping the ENGAGED value back would pin fp8 into the select, and the next load would send
+ // it explicitly. `source: "auto"` is what keeps this honest, so assert it end to end rather
+ // than trusting the early return to stay.
+ const autoFp8: ResolvedControl = {
+ value: "fp8",
+ requested: null,
+ source: "auto",
+ status: "applied",
+ reason: "selected automatically for qwen-image-2.1 (no text_encoder_quant requested)",
+ };
+ assert.equal(resolvedSelectValue(autoFp8, toTeOption), "auto");
+});
+
+test("a pinned dense text encoder reseeds as Dense, not Default", () => {
+ // The reported bug: "none"/"off" folded into "auto", so the select snapped back to Default
+ // after a dense load and the next reapply omitted the field, silently restoring the family's
+ // fp8 default and changing output.
+ const pinnedDense: ResolvedControl = {
+ value: "off",
+ requested: "none",
+ source: "explicit",
+ status: "applied",
+ reason: "dense bf16 text encoder(s) loaded",
+ };
+ assert.equal(resolvedSelectValue(pinnedDense, toTeOption), "none");
+
+ // A declined scheme ran dense too, and must read as what ACTUALLY ran, same as the
+ // transformer control.
+ const declined: ResolvedControl = {
+ value: "off",
+ requested: "nvfp4",
+ source: "explicit",
+ status: "unsupported",
+ reason: "nvfp4 needs Blackwell sm_100+",
+ };
+ assert.equal(resolvedSelectValue(declined, toTeOption), "none");
+});