From 3347ef5a24fa78d1c01185c62329b98f2fee8912 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 4 Jul 2026 09:46:38 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- studio/backend/core/inference/diffusion.py | 5 ++++- .../core/inference/diffusion_auto_policy.py | 1 + studio/backend/models/inference.py | 20 ++++++++++--------- .../tests/test_diffusion_auto_policy.py | 4 +--- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/studio/backend/core/inference/diffusion.py b/studio/backend/core/inference/diffusion.py index 7e9965eb41..9555b3c38a 100644 --- a/studio/backend/core/inference/diffusion.py +++ b/studio/backend/core/inference/diffusion.py @@ -996,7 +996,10 @@ class DiffusionBackend: # as-is, so auto is the DEFAULT. An explicit "none"/"off" pins # GGUF-as-is and an explicit scheme pins that scheme. The overwritten # "auto" still records source=auto in the resolved provenance. - if transformer_quant is None or str(transformer_quant).strip().lower() in ("", "auto"): + if transformer_quant is None or str(transformer_quant).strip().lower() in ( + "", + "auto", + ): transformer_quant = TQ_AUTO # Default-on fast path: load the DENSE bf16 transformer and torchao-quantise it diff --git a/studio/backend/core/inference/diffusion_auto_policy.py b/studio/backend/core/inference/diffusion_auto_policy.py index 1bdd88e5f6..0aa0a51371 100644 --- a/studio/backend/core/inference/diffusion_auto_policy.py +++ b/studio/backend/core/inference/diffusion_auto_policy.py @@ -135,6 +135,7 @@ def _hf_cache_free_mib() -> Optional[int]: """Free MiB on the filesystem holding the HF model cache (None when unprobeable).""" try: import shutil + try: from huggingface_hub.constants import HF_HUB_CACHE as cache_dir except Exception: # noqa: BLE001 -- hub missing/old: probe the conventional path diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py index e655817ad5..9a47105532 100644 --- a/studio/backend/models/inference.py +++ b/studio/backend/models/inference.py @@ -1750,15 +1750,17 @@ class DiffusionLoadRequest(BaseModel): "memory-vs-quality tradeoff (shifts fine detail), not free; " "pairs well with balanced mode.", ) - transformer_quant: Optional[Literal["auto", "none", "off", "int8", "fp8", "nvfp4", "mxfp8"]] = Field( - None, - description = "Transformer compute dtype. UNSET or auto (the default) picks the " - "fastest precision the hardware supports: the DENSE bf16 transformer " - "is loaded instead of the GGUF and torchao-quantised onto the " - "low-precision tensor cores (data-center fp8, consumer/Ampere int8), " - "falling back to the GGUF when the device, VRAM or disk cannot take " - "it. none/off pins running the GGUF as-is; an explicit scheme forces " - "that scheme. Dense path needs CUDA + bf16.", + transformer_quant: Optional[Literal["auto", "none", "off", "int8", "fp8", "nvfp4", "mxfp8"]] = ( + Field( + None, + description = "Transformer compute dtype. UNSET or auto (the default) picks the " + "fastest precision the hardware supports: the DENSE bf16 transformer " + "is loaded instead of the GGUF and torchao-quantised onto the " + "low-precision tensor cores (data-center fp8, consumer/Ampere int8), " + "falling back to the GGUF when the device, VRAM or disk cannot take " + "it. none/off pins running the GGUF as-is; an explicit scheme forces " + "that scheme. Dense path needs CUDA + bf16.", + ) ) transformer_quant_fast_accum: Optional[bool] = Field( None, diff --git a/studio/backend/tests/test_diffusion_auto_policy.py b/studio/backend/tests/test_diffusion_auto_policy.py index d9deadac0e..7190395f5f 100644 --- a/studio/backend/tests/test_diffusion_auto_policy.py +++ b/studio/backend/tests/test_diffusion_auto_policy.py @@ -151,9 +151,7 @@ def test_candidate_disk_gate_unprobeable_disk_passes(monkeypatch): _patch_selector(monkeypatch, scheme = "int8") monkeypatch.setattr(ap, "_hf_cache_free_mib", lambda: None) - est = resolve_dense_quant_candidate( - fam = _fam("z-image"), target = object(), requested = "auto" - ) + est = resolve_dense_quant_candidate(fam = _fam("z-image"), target = object(), requested = "auto") assert isinstance(est, DenseQuantEstimate)