diffusion: accept vae_quant in the native sd.cpp backend load interface

The image load route calls engine.begin_load(..., vae_quant=request.vae_quant, ...)
uniformly for both engines, but the native SdCppDiffusionBackend.begin_load accepted
every other diffusers-only knob except vae_quant and had no **kwargs, so a native
(CPU-only / MPS / forced-native) image GGUF load raised TypeError on every request
(vae_quant is always passed, defaulting to None). Accept and ignore it like the other
diffusers-only knobs; sd.cpp has no torchao VAE quant.
This commit is contained in:
Daniel Han 2026-07-09 07:58:30 +00:00
commit 4fd93b2c7a
2 changed files with 18 additions and 0 deletions

View file

@ -378,6 +378,7 @@ class SdCppDiffusionBackend:
# diffusers-only knobs accepted (so the route calls both engines uniformly)
# and ignored -- sd.cpp has no torchao quant / SDPA dispatcher / fbcache.
text_encoder_quant: Optional[str] = None,
vae_quant: Optional[str] = None,
transformer_quant: Optional[str] = None,
transformer_quant_fast_accum: Optional[bool] = None,
transformer_prequant_path: Optional[str] = None,

View file

@ -307,6 +307,23 @@ def test_begin_load_resolves_family_from_filename_only(monkeypatch):
assert b._loading is not None and b._loading.repo_id == "/models/gguf-store"
def test_begin_load_accepts_diffusers_only_vae_quant(monkeypatch):
# The image load route calls engine.begin_load(..., vae_quant=...) uniformly for both
# engines, so the native backend must accept (and ignore) vae_quant like the other
# diffusers-only knobs; otherwise a native (CPU / MPS / forced) image load raises
# TypeError on every request, since vae_quant is always passed (defaults to None).
b = SdCppDiffusionBackend(engine = _FakeEngine())
monkeypatch.setattr(b, "_run_load", lambda **kwargs: None) # skip the download thread
b.begin_load(
"/models/gguf-store",
gguf_filename = "Z-Image-Turbo-Q4_K_M.gguf",
text_encoder_quant = "auto",
vae_quant = "auto",
transformer_quant = "fp8",
)
assert b._loading is not None and b._loading.repo_id == "/models/gguf-store"
def test_ensure_binary_returns_found(monkeypatch):
monkeypatch.setattr(bk, "find_sd_cpp_binary", lambda: "/usr/bin/sd-cli")
assert ensure_sd_cpp_binary() == "/usr/bin/sd-cli"