[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-07-06 13:18:19 +00:00
commit 04ddf5449c
3 changed files with 21 additions and 10 deletions

View file

@ -920,6 +920,7 @@ class DiffusionBackend:
safetensors shard headers. Returns 0 when no ``transformer/*.safetensors`` shards
are present (an uncached base, or a .bin-only transformer); the caller then gates
the fast path on the plain plan."""
def _params(d: Path) -> int:
tdir = d / "transformer"
if not tdir.is_dir():

View file

@ -2005,11 +2005,16 @@ def test_dense_quant_skipped_when_dense_transformer_does_not_fit(
monkeypatch.setattr(
DiffusionBackend,
"_dense_transformer_resident_bytes",
staticmethod(lambda base: 40 * 1024 ** 3),
staticmethod(lambda base: 40 * 1024**3),
)
orig_plan = DiffusionBackend._plan_memory
def plan_wrap(self, *a, transformer_mib_override = None, **k):
def plan_wrap(
self,
*a,
transformer_mib_override = None,
**k,
):
# GGUF budget fits (real plan -> none); the dense-transformer preflight does not.
if transformer_mib_override is not None:
return types.SimpleNamespace(offload_policy = "model")
@ -2029,9 +2034,9 @@ def test_dense_quant_skipped_when_dense_transformer_does_not_fit(
family_override = "z-image",
transformer_quant = "fp8",
)
assert status["transformer_quant"] is None # dense quant skipped
assert status["offload_policy"] == "none" # GGUF loaded resident, not offloaded
assert _FakeTransformer.last["path"] # GGUF path used
assert status["transformer_quant"] is None # dense quant skipped
assert status["offload_policy"] == "none" # GGUF loaded resident, not offloaded
assert _FakeTransformer.last["path"] # GGUF path used
def test_dense_quant_prequant_skips_dense_refit(fake_runtime, tmp_path, monkeypatch):
@ -2051,12 +2056,17 @@ def test_dense_quant_prequant_skips_dense_refit(fake_runtime, tmp_path, monkeypa
monkeypatch.setattr(
DiffusionBackend,
"_dense_transformer_resident_bytes",
staticmethod(lambda base: 999 * 1024 ** 3),
staticmethod(lambda base: 999 * 1024**3),
)
dense_refit_ran = []
orig_plan = DiffusionBackend._plan_memory
def spy_plan(self, *a, transformer_mib_override = None, **k):
def spy_plan(
self,
*a,
transformer_mib_override = None,
**k,
):
if transformer_mib_override is not None:
dense_refit_ran.append(True)
return orig_plan(self, *a, **k)
@ -2076,8 +2086,8 @@ def test_dense_quant_prequant_skips_dense_refit(fake_runtime, tmp_path, monkeypa
family_override = "z-image",
transformer_quant = "fp8",
)
assert dense_refit_ran == [] # prequant -> dense re-check skipped
assert attempted == [True] # fast path still attempted (with the prequant)
assert dense_refit_ran == [] # prequant -> dense re-check skipped
assert attempted == [True] # fast path still attempted (with the prequant)
def test_transformer_quant_unsupported_scheme_skips_dense_download(

View file

@ -583,7 +583,7 @@ def test_diffusion_dataset_upload_over_cap_preserves_existing_file(
(folder / "existing.png").write_bytes(b"ORIGINAL") # from an earlier upload
files = [
("files", ("existing.png", b"NEW", "image/png")), # re-upload, small
("files", ("big.png", b"y" * 200, "image/png")), # trips the cap
("files", ("big.png", b"y" * 200, "image/png")), # trips the cap
]
r = client.post("/api/train/diffusion/dataset", data = {"name": "keep"}, files = files)
assert r.status_code == 413, r.text