Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(calibration): check FLUX.1 and Z-Image encoder prerequisites (#10398)
Nianze Wuecae7e7b6f7b
diff --git a/invokeai/app/services/working_memory_calibration/working_memory_calibration_plan.py b/invokeai/app/services/working_memory_calibration/working_memory_calibration_plan.pyindex 974de4a6fd..bb07f075b0 100644--- a/invokeai/app/services/working_memory_calibration/working_memory_calibration_plan.py+++ b/invokeai/app/services/working_memory_calibration/working_memory_calibration_plan.py@@ -318,41 +318,49 @@ def _lacks_flux2_text_encoder(main: ModelConfig, models: Sequence[ModelConfig])return not _has_standalone_encoder(main, models)-_SD3_ENCODERS: Final[tuple[tuple[str, Callable[[ModelConfig], bool]], ...]] = (+_FLUX1_ENCODERS: Final[tuple[tuple[str, Callable[[ModelConfig], bool]], ...]] = (("T5", lambda model: model.type == ModelType.T5Encoder),("CLIP-L", lambda model: model.type == ModelType.CLIPEmbed and _variant(model) == ClipVariantType.L.value),+)+_SD3_ENCODERS: Final = (+ *_FLUX1_ENCODERS,("CLIP-G", lambda model: model.type == ModelType.CLIPEmbed and _variant(model) == ClipVariantType.G.value),)-"""The standalone text encoders the `sd-3` component policy requires for an SD3 main model that is no Diffusers-pipeline, as a reason names them, and the models each slot takes: any T5 encoder, and a CLIP embed model of the-variant. Generate fills each from the installed models; `Sd3ModelLoaderInvocation` refuses the graph without one."""---def _sd3_missing_encoders(main: ModelConfig, models: Sequence[ModelConfig]) -> list[str]:- """The `_SD3_ENCODERS` no installed model fills for an SD3 main model that is no Diffusers pipeline (a GGUF holds- the transformer alone); none for any other model."""- if main.base != BaseModelType.StableDiffusion3 or not _is_main(main) or _is_diffusers(main):- return []- return [name for name, fits in _SD3_ENCODERS if not any(fits(model) for model in models)]---def _lacks_text_encoder(main: ModelConfig, models: Sequence[ModelConfig]) -> bool:- """Whether Generate cannot compile a main model's graph for want of a text encoder: a FLUX.2 model- (`_lacks_flux2_text_encoder`), or an SD3 model that is no Diffusers pipeline (`_sd3_missing_encoders`)."""- return _lacks_flux2_text_encoder(main, models) or bool(_sd3_missing_encoders(main, models))-def _text_encoder_reason(main: ModelConfig, models: Sequence[ModelConfig]) -> str:- """Why no case of a main model that `_lacks_text_encoder` compiles, and what to install."""- missing = _sd3_missing_encoders(main, models)- if missing:- listed = [f"a {name} encoder" for name in missing]- install = listed[0] if len(listed) == 1 else f"{', '.join(listed[:-1])} and {listed[-1]}"+def _main_model_blocker(main: ModelConfig, models: Sequence[ModelConfig]) -> Optional[str]:+ """Why a main model cannot compile or run a calibration graph."""+ if main.base == BaseModelType.Flux and _is_diffusers(main):+ # The graph can compile, but FluxModelLoaderInvocation rejects a plain Diffusers FLUX.1 config.+ return (+ f"{main.name} is a FLUX.1 Diffusers model, which the FLUX.1 model loader cannot run. "+ "Select a FLUX.1 checkpoint, GGUF, or SDNQ model for calibration."+ )+ if main.base in (BaseModelType.Flux, BaseModelType.StableDiffusion3) and not ships_its_vae(main):+ slots = _FLUX1_ENCODERS if main.base == BaseModelType.Flux else _SD3_ENCODERS+ missing = [f"a {name} encoder" for name, fits in slots if not any(fits(model) for model in models)]+ if not missing:+ return None+ install = missing[0] if len(missing) == 1 else f"{', '.join(missing[:-1])} and {missing[-1]}"+ if main.base == BaseModelType.Flux:+ return f"Generate cannot compile a calibration case for {main.name} (FLUX.1). Install {install}."return (f"{main.name} holds only the SD3 transformer, so no case compiles without standalone text encoders: ""Generate needs a T5, a CLIP-L and a CLIP-G encoder for it, and only an SD3 Diffusers pipeline brings its "f"own. Install {install}.")+ if main.base == BaseModelType.ZImage:+ # Generate fills required encoder slots from the catalog, but only picks a Z-Image source by default settings.+ if ships_its_vae(main) or default_component_source(main, models) is not None:+ return None+ if any(_qwen3_encoder_variant(model) == Qwen3VariantType.Qwen3_4B.value for model in models):+ return None+ return (+ "Install a Qwen3 4B encoder or set a bundled Z-Image pipeline as the default component source "+ f"for {main.name}."+ )+ if not _lacks_flux2_text_encoder(main, models):+ return Noneencoder = _standalone_encoder_name(main)pipeline = "a Diffusers FLUX.2 [dev] pipeline" if _is_dev(main) else "a fitting FLUX.2 pipeline"return (@@ -386,8 +394,7 @@ def vae_source(model: ModelConfig, models: Sequence[ModelConfig]) -> Optional[Mofrom (`_flux2_sources`), the first fitting one, else the first one (`getAutoFlux2ComponentSourceModel`), which thegraph keeps only beside a standalone text encoder. Generate lists the models in the order the server does, which is`models`' order. None: a standalone VAE decodes, the model's default one included (`default_vae`), or, for a model- without an encoder, no graph compiles (`_lacks_text_encoder`); without a VAE either, none compiles- (`_needs_gpu_vae`)."""+ with missing prerequisites, no case can run (`_main_model_blocker`, `_needs_gpu_vae`)."""if default_vae(model, models) is not None:return Noneif (source := default_component_source(model, models)) is not None:@@ -708,12 +715,12 @@ def build_plan(device_class,estimators,)- # One whose graph compiles and decodes on the GPU, where there is one; otherwise the first says what it lacks.+ # Prefer a runnable graph that decodes on the GPU. Otherwise the first candidate supplies the reason.main = next((modelfor model in candidates- if not _lacks_text_encoder(model, models) and _decodes_on_the_gpu(model, models)+ if _main_model_blocker(model, models) is None and _decodes_on_the_gpu(model, models)),candidates[0],)@@ -744,8 +751,8 @@ def build_plan(device_class,estimators,)- if _lacks_text_encoder(main, models):- return _unsupported(target, _text_encoder_reason(main, models), device_class, estimators)+ if (reason := _main_model_blocker(main, models)) is not None:+ return _unsupported(target, reason, device_class, estimators)if not _decodes_on_the_gpu(main, models):cpu_vae = _cpu_default_vae(main, models)assert cpu_vae is not Nonediff --git a/tests/app/services/working_memory_calibration/test_working_memory_calibration_plan.py b/tests/app/services/working_memory_calibration/test_working_memory_calibration_plan.pyindex 1d6daf8323..9f4dd64aab 100644--- a/tests/app/services/working_memory_calibration/test_working_memory_calibration_plan.py+++ b/tests/app/services/working_memory_calibration/test_working_memory_calibration_plan.py@@ -75,10 +75,13 @@ QWEN3_8B = _model("qwen3-8b", BaseModelType.Any, ModelType.Qwen3Encoder, variant"""The standalone text encoder Generate fills in for a FLUX.2 Klein 9B model, or one without a variant, that is nopipeline: without one, or a pipeline whose encoder fits, its graph does not compile."""-SD3_T5 = _model("t5", BaseModelType.Any, ModelType.T5Encoder)-SD3_CLIP_L = _model("clip-l", BaseModelType.Any, ModelType.CLIPEmbed, variant=ClipVariantType.L)-SD3_CLIP_G = _model("clip-g", BaseModelType.Any, ModelType.CLIPEmbed, variant=ClipVariantType.G)-SD3_ENCODERS = [SD3_T5, SD3_CLIP_L, SD3_CLIP_G]+QWEN3_4B = _model("qwen3-4b", BaseModelType.Any, ModelType.Qwen3Encoder, variant=Qwen3VariantType.Qwen3_4B)++T5 = _model("t5", BaseModelType.Any, ModelType.T5Encoder)+CLIP_L = _model("clip-l", BaseModelType.Any, ModelType.CLIPEmbed, variant=ClipVariantType.L)+CLIP_G = _model("clip-g", BaseModelType.Any, ModelType.CLIPEmbed, variant=ClipVariantType.G)+FLUX1_ENCODERS = [T5, CLIP_L]+SD3_ENCODERS = [*FLUX1_ENCODERS, CLIP_G]"""The standalone encoders Generate fills in for an SD3 model that is no Diffusers pipeline: without all three itsgraph does not compile."""@@ -150,7 +153,7 @@ def test_an_sdxl_model_runs_three_sizes_per_vae_precision() -> None:)def test_each_covered_base_plans_the_lines_its_decode_runs(base, precision, estimator, lines) -> None:vae_base = BaseModelType.Flux if base == BaseModelType.ZImage else base- models = [_model("vae", vae_base, ModelType.VAE), QWEN3_8B, *SD3_ENCODERS]+ models = [_model("vae", vae_base, ModelType.VAE), QWEN3_4B, QWEN3_8B, *SD3_ENCODERS]plan = _plan(_model("main", base), models, precision=precision)assert plan.supported and plan.estimators == [estimator]@@ -170,7 +173,10 @@ def _shipped_untiled_decode(estimator: str, height: int, width: int, dtype: str)@pytest.mark.parametrize("target, models",[- (_model("flux", BaseModelType.Flux), [_model("ae", BaseModelType.Flux, ModelType.VAE)]),+ (+ _model("flux", BaseModelType.Flux),+ [_model("ae", BaseModelType.Flux, ModelType.VAE), *FLUX1_ENCODERS],+ ),(_model("flux2-vae", BaseModelType.Flux2, ModelType.VAE),[_model("klein", BaseModelType.Flux2, format="diffusers")],@@ -259,10 +265,10 @@ def test_a_pipeline_decodes_in_the_dtype_its_own_vae_loads_in(pipeline, line) ->def test_a_flux_sdnq_pipeline_without_the_t5_pair_decodes_with_a_standalone_vae() -> None:"""Generate requires FLUX.1's `vae` slot unless the SDNQ pipeline ships every component, T5 included."""partial = _model("flux-sdnq", BaseModelType.Flux, format=ModelFormat.SDNQQuantized, submodels=_PIPELINE_SUBMODELS)- vae = [_model("ae", BaseModelType.Flux, ModelType.VAE)]+ models = [_model("ae", BaseModelType.Flux, ModelType.VAE), *FLUX1_ENCODERS]- assert {case.line for case in _plan(partial, vae, vae_dtypes=FP32_VAES).cases} == {"decode_fp32"}- assert {case.line for case in _plan(partial, vae).cases} == {"decode_bf16"}+ assert {case.line for case in _plan(partial, models, vae_dtypes=FP32_VAES).cases} == {"decode_fp32"}+ assert {case.line for case in _plan(partial, models).cases} == {"decode_bf16"}GGUF_KLEIN_9B = _model("klein-9b-gguf", BaseModelType.Flux2, format="gguf_quantized", variant=Flux2VariantType.Klein9B)@@ -297,7 +303,6 @@ def test_a_flux2_model_without_its_own_vae_decodes_with_its_component_source_vaeKLEIN_4B_SDNQ = _sdnq_pipeline("klein-4b-sdnq", BaseModelType.Flux2, variant=Flux2VariantType.Klein4B)FLUX2_VAE = _model("flux2-vae", BaseModelType.Flux2, ModelType.VAE)-QWEN3_4B = _model("qwen3-4b", BaseModelType.Any, ModelType.Qwen3Encoder, variant=Qwen3VariantType.Qwen3_4B)GGUF_DEV = _model("dev-gguf", BaseModelType.Flux2, format="gguf_quantized", variant=Flux2VariantType.Dev)SDNQ_DEV = _sdnq_pipeline("dev-sdnq", BaseModelType.Flux2, variant=Flux2VariantType.Dev)MISTRAL = _model("mistral", BaseModelType.Any, ModelType.MistralEncoder, variant=MistralVariantType.Mistral24B)@@ -424,7 +429,7 @@ def test_a_standalone_flux_vae_is_not_calibrated_through_an_sdnq_pipeline_that_dsdnq = _sdnq_pipeline("a-flux-sdnq", BaseModelType.Flux)flux = _model("b-flux", BaseModelType.Flux)- plan = _plan(flux_vae, [sdnq, flux], vae_dtypes=FP32_VAES)+ plan = _plan(flux_vae, [sdnq, flux, *FLUX1_ENCODERS], vae_dtypes=FP32_VAES)alone = _plan(flux_vae, [sdnq])assert (plan.calibrated_through, _lines_of(plan)) == ("b-flux", {("decode_fp32", (("vae", "ae"),))})@@ -582,7 +587,9 @@ def test_a_card_that_cannot_hold_a_small_decode_with_headroom_is_unsupported() -small = DeviceClass(vendor="nvidia", name="Test GPU 2GB", total_mib=2048, backend="cuda", arch="sm_75")plan = _plan(- _model("flux", BaseModelType.Flux), [_model("ae", BaseModelType.Flux, ModelType.VAE)], device_class=small+ _model("flux", BaseModelType.Flux),+ [_model("ae", BaseModelType.Flux, ModelType.VAE), *FLUX1_ENCODERS],+ device_class=small,)assert not plan.supported and "Test GPU 2GB cannot hold" in (plan.reason or "") and plan.cases == []@@ -617,7 +624,7 @@ def test_a_standalone_vae_is_calibrated_through_a_compatible_main_model() -> Nonsdxl_vae = _model("sdxl-vae", BaseModelType.StableDiffusionXL, ModelType.VAE)sdxl = _model("sdxl", BaseModelType.StableDiffusionXL)- flux_plan = _plan(flux_vae, [z_image, sdxl])+ flux_plan = _plan(flux_vae, [z_image, sdxl, QWEN3_4B])sd_plan = _plan(sdxl_vae, [z_image, sdxl])# Z-Image decodes with a FLUX.1 VAE, through its `vae` slot.@@ -635,8 +642,10 @@ def test_a_main_model_picks_a_gpu_vae_where_generate_could_fill_in_one_on_the_cpcpu = _model("a-cpu-vae", BaseModelType.Flux, ModelType.VAE, cpu_only=True)gpu = _model("b-gpu-vae", BaseModelType.Flux, ModelType.VAE, cpu_only=False)- assert {tuple(case.components.items()) for case in _plan(flux, [cpu, gpu]).cases} == {(("vae", "b-gpu-vae"),)}- assert {tuple(case.components.items()) for case in _plan(flux, [gpu]).cases} == {()}+ assert {tuple(case.components.items()) for case in _plan(flux, [cpu, gpu, *FLUX1_ENCODERS]).cases} == {+ (("vae", "b-gpu-vae"),)+ }+ assert {tuple(case.components.items()) for case in _plan(flux, [gpu, *FLUX1_ENCODERS]).cases} == {()}def _with_default_vae(model: SimpleNamespace, vae_key: str) -> SimpleNamespace:@@ -885,9 +894,11 @@ def test_a_model_that_needs_a_standalone_vae_and_has_none_on_the_gpu_cannot_be_ccpu_vae = _model("cpu-vae", vae_base, ModelType.VAE, cpu_only=True)for models in ([cpu_vae], []):- plan = _plan(main, [*models, QWEN3_8B])+ plan = _plan(main, [*models, QWEN3_8B, QWEN3_4B, *FLUX1_ENCODERS])assert not plan.supported and plan.cases == [] and "GPU" in (plan.reason or "")- assert _plan(main, [cpu_vae, _model("gpu-vae", vae_base, ModelType.VAE), QWEN3_8B]).supported+ assert _plan(+ main, [cpu_vae, _model("gpu-vae", vae_base, ModelType.VAE), QWEN3_8B, QWEN3_4B, *FLUX1_ENCODERS]+ ).supporteddef test_a_pipeline_with_its_own_vae_needs_no_gpu_vae_beside_it() -> None:@@ -908,10 +919,10 @@ SD3_VAE = _model("sd3-vae", BaseModelType.StableDiffusion3, ModelType.VAE)"encoders, install",[([], "Install a T5 encoder, a CLIP-L encoder and a CLIP-G encoder."),- ([SD3_T5, SD3_CLIP_L], "Install a CLIP-G encoder."),+ ([T5, CLIP_L], "Install a CLIP-G encoder."),# A CLIP-L does not fill the CLIP-G slot, nor a CLIP-G the CLIP-L one.- ([SD3_T5, SD3_CLIP_G], "Install a CLIP-L encoder."),- ([SD3_CLIP_L, SD3_CLIP_G], "Install a T5 encoder."),+ ([T5, CLIP_G], "Install a CLIP-L encoder."),+ ([CLIP_L, CLIP_G], "Install a T5 encoder."),],ids=["none", "no-clip-g", "no-clip-l", "no-t5"],)@@ -938,7 +949,7 @@ def test_an_sd3_vae_is_calibrated_through_a_main_model_whose_graph_compiles() ->def test_an_sd3_vae_whose_only_main_model_is_a_gguf_without_encoders_cannot_be_calibrated() -> None:- plan = _plan(SD3_VAE, [SD3_GGUF, SD3_T5])+ plan = _plan(SD3_VAE, [SD3_GGUF, T5])assert not plan.supported and plan.cases == []assert "A-SD3-GGUF holds only the SD3 transformer" in (plan.reason or "")@@ -1044,17 +1055,124 @@ def _with_default_components(model: SimpleNamespace, **components: str) -> Simplreturn SimpleNamespace(**{**vars(model), "default_settings": SimpleNamespace(vae=None, components=components)})-def test_a_z_image_model_decodes_with_the_vae_of_its_default_component_source() -> None:+ "target, encoders, install",+ [+ (_model("flux", BaseModelType.Flux, format="checkpoint"), [], "a T5 encoder and a CLIP-L encoder"),+ (_model("flux", BaseModelType.Flux, format="gguf_quantized"), [CLIP_L], "a T5 encoder"),+ (+ _model("flux", BaseModelType.Flux, format=ModelFormat.SDNQQuantized, submodels=_PIPELINE_SUBMODELS),+ [T5, CLIP_G],+ "a CLIP-L encoder",+ ),+ ],+ ids=["missing-both", "missing-t5", "partial-sdnq-with-wrong-clip"],+)+def test_a_flux1_model_without_its_standalone_encoders_cannot_be_calibrated(target, encoders, install) -> None:+ vae = _model("ae", BaseModelType.Flux, ModelType.VAE)+ plan = _plan(target, [vae, *encoders])++ assert not plan.supported and plan.cases == []+ assert (plan.reason or "").endswith(f"Install {install}.")+ assert _plan(target, [vae, *FLUX1_ENCODERS]).supported+++ "source_key, encoders",+ [+ (None, []),+ ("missing", [QWEN3_8B]),+ ("partial", [_text_llm_serving_qwen3("llm-06b", Qwen3VariantType.Qwen3_06B)]),+ ("wrong-base", [_model("llm", BaseModelType.Any, ModelType.TextLLM, variant=Qwen3VariantType.Qwen3_4B)]),+ ],+ ids=["unselected-source", "stale-source-and-qwen3-8b", "partial-source-and-role-06b", "wrong-base-and-no-role"],+)+def test_a_split_z_image_model_needs_a_default_bundled_source_or_qwen3_4b(source_key, encoders) -> None:+ target = _model("z-image-gguf", BaseModelType.ZImage, format="gguf_quantized")+ if source_key is not None:+ target = _with_default_components(target, component_source=source_key)+ models = [+ _model("ae", BaseModelType.Flux, ModelType.VAE),+ _model("bundled", BaseModelType.ZImage, format="diffusers"),+ _model("partial", BaseModelType.ZImage, format=ModelFormat.SDNQQuantized, submodels={SubModelType.VAE: None}),+ _model("wrong-base", BaseModelType.Flux2, format="diffusers"),+ *encoders,+ ]+ plan = _plan(target, models)++ assert not plan.supported and plan.cases == []+ assert "Install a Qwen3 4B encoder" in (plan.reason or "")+++def test_a_plain_flux1_diffusers_main_cannot_be_calibrated_even_with_its_standalone_components() -> None:+ diffusers = _model("flux-diffusers", BaseModelType.Flux, format=ModelFormat.Diffusers, variant=FluxVariantType.Dev)+ vae = _model("ae", BaseModelType.Flux, ModelType.VAE)++ plan = _plan(diffusers, [vae, *FLUX1_ENCODERS])++ assert not plan.supported and plan.cases == []+ assert "FLUX.1 Diffusers" in (plan.reason or "") and "loader" in (plan.reason or "")+++def test_a_flux_vae_skips_a_plain_flux1_diffusers_main() -> None:+ vae = _model("ae", BaseModelType.Flux, ModelType.VAE)+ # Both graphs have their required components. The Diffusers main sorts first but its invocation fails.+ diffusers = _model("a-diffusers", BaseModelType.Flux, format=ModelFormat.Diffusers, variant=FluxVariantType.Dev)+ checkpoint = _model("b-checkpoint", BaseModelType.Flux, format=ModelFormat.Checkpoint, variant=FluxVariantType.Dev)++ plan = _plan(vae, [diffusers, checkpoint, *FLUX1_ENCODERS], vae_dtypes=FP32_VAES)+ assert (plan.supported, plan.calibrated_through) == (True, checkpoint.key)+ assert {(case.model_key, case.line, tuple(case.components.items())) for case in plan.cases} == {+ (checkpoint.key, "decode_fp32", (("vae", vae.key),))+ }++ blocked = _plan(vae, [diffusers, *FLUX1_ENCODERS])+ assert not blocked.supported and blocked.cases == [] and "FLUX.1 Diffusers" in (blocked.reason or "")+++def test_a_qwen3_4b_role_satisfies_z_image_calibration() -> None:+ target = _model("z-image", BaseModelType.ZImage, format="checkpoint")+ llm = _text_llm_serving_qwen3("llm-4b", Qwen3VariantType.Qwen3_4B)+ target = _with_default_components(target, qwen3_encoder=llm.key)+ vae = _model("ae", BaseModelType.Flux, ModelType.VAE)++ assert _lines_of(_plan(target, [vae, llm])) == {("decode_bf16", ())}++[email protected]("base, encoder", [(BaseModelType.Flux, "T5"), (BaseModelType.ZImage, "Qwen3 4B")])+def test_a_flux_vae_skips_a_main_model_without_its_encoders(base, encoder) -> None:+ vae = _model("ae", BaseModelType.Flux, ModelType.VAE)+ split = _model("a-split", base, format="gguf_quantized")+ bundled = _model("b-z-image", BaseModelType.ZImage, format="diffusers")++ plan = _plan(vae, [split, bundled], vae_dtypes=FP32_VAES)+ assert (plan.supported, plan.calibrated_through) == (True, bundled.key)+ assert {(case.model_key, case.line, tuple(case.components.items())) for case in plan.cases} == {+ (bundled.key, "decode_fp32", (("vae", vae.key),))+ }++ blocked = _plan(vae, [split])+ assert not blocked.supported and blocked.cases == []+ assert f"Install a {encoder} encoder" in (blocked.reason or "")+++ "pipeline, bundled_line",+ [+ (_model("z-image", BaseModelType.ZImage, format="diffusers"), "decode_bf16"),+ (_sdnq_pipeline("z-image", BaseModelType.ZImage), "decode_fp32"),+ ],+ ids=["diffusers", "sdnq"],+)+def test_a_z_image_model_decodes_with_the_vae_of_its_default_component_source(pipeline, bundled_line) -> None:"""Selecting the model fills its `component_source` slot (a Z-Image pipeline), whose own VAE the model loader nodethen takes where no VAE is set: under `precision: float32` the pipeline's VAE loads in bf16 where a standalone FLUXVAE stays fp32, and the case needs no VAE pick."""gguf = _model("z-image-gguf", BaseModelType.ZImage, format="gguf_quantized")- pipeline = _model("z-image", BaseModelType.ZImage, format="diffusers")flux_vae = _model("ae", BaseModelType.Flux, ModelType.VAE)with_source = _with_default_components(gguf, component_source="z-image")- assert _lines_of(_plan(gguf, [pipeline, flux_vae], vae_dtypes=FP32_VAES)) == {("decode_fp32", ())}- assert _lines_of(_plan(with_source, [pipeline, flux_vae], vae_dtypes=FP32_VAES)) == {("decode_bf16", ())}+ assert _lines_of(_plan(with_source, [pipeline, flux_vae], vae_dtypes=FP32_VAES)) == {(bundled_line, ())}# A default VAE is set beside the source and wins, as the loader takes a picked VAE first.with_vae = SimpleNamespace(**{@@ -1063,10 +1181,6 @@ def test_a_z_image_model_decodes_with_the_vae_of_its_default_component_source()})assert _lines_of(_plan(with_vae, [pipeline, flux_vae], vae_dtypes=FP32_VAES)) == {("decode_fp32", ())}- # A key that names no installed Z-Image pipeline leaves the model as it was.- assert _lines_of(- _plan(_with_default_components(gguf, component_source="missing"), [pipeline, flux_vae], vae_dtypes=FP32_VAES)- ) == {("decode_fp32", ())}def test_a_self_contained_z_image_pipeline_decodes_with_the_vae_of_its_default_component_source() -> None:@@ -1086,6 +1200,7 @@ def test_a_z_image_default_source_whose_files_are_gone_sizes_no_case(tmp_path: P(models_dir / "z-image").mkdir(parents=True)(models_dir / "z-image-gguf.gguf").touch()(models_dir / "ae.safetensors").touch()+ (models_dir / "qwen3.safetensors").touch()gguf = _with_default_components(_model("z-image-gguf", BaseModelType.ZImage, format="gguf_quantized", path="z-image-gguf.gguf"),component_source="z-image",@@ -1093,7 +1208,16 @@ def test_a_z_image_default_source_whose_files_are_gone_sizes_no_case(tmp_path: Ppipeline = _model("z-image", BaseModelType.ZImage, format="diffusers", path="z-image")flux_vae = _model("ae", BaseModelType.Flux, ModelType.VAE, format="checkpoint", path="ae.safetensors")- def plan_lines(models: list) -> set:+ qwen3 = _model(+ "qwen3-4b",+ BaseModelType.Any,+ ModelType.Qwen3Encoder,+ variant=Qwen3VariantType.Qwen3_4B,+ format=ModelFormat.Qwen3Encoder,+ path="qwen3.safetensors",+ )++ def get_plan(models: list):model_manager = MagicMock()model_manager.store.get_model.return_value = ggufmodel_manager.store.all_models.return_value = [gguf, *models]@@ -1107,11 +1231,15 @@ def test_a_z_image_default_source_whose_files_are_gone_sizes_no_case(tmp_path: P)service.start(mock_invoker)try:- return {(case.line, tuple(case.components.items())) for case in service.get_plan(gguf.key).cases}+ return service.get_plan(gguf.key)finally:service.stop(mock_invoker)- # The pipeline's own VAE loads in bf16; the standalone FLUX VAE the model falls back to stays fp32.- assert plan_lines([pipeline, flux_vae]) == {("decode_bf16", ())}+ assert _lines_of(get_plan([pipeline, flux_vae])) == {("decode_bf16", ())}(models_dir / "z-image").rmdir()- assert plan_lines([pipeline, flux_vae]) == plan_lines([flux_vae]) == {("decode_fp32", ())}++ plan = get_plan([pipeline, flux_vae])+ assert not plan.supported and plan.cases == []+ assert "Install a Qwen3 4B encoder" in (plan.reason or "")+ # With a standalone encoder, the standalone FLUX VAE the model falls back to stays fp32.+ assert _lines_of(get_plan([pipeline, flux_vae, qwen3])) == {("decode_fp32", ())}