video/image: honor explicit Speed=off for companions + trim, probe explicit TE kernels, bench fidelity
Address the Codex review round on the video/quant work: - Companion auto-quant now honors an explicit Speed=off. Both loaders already pin the DiT dense under an explicit off (bit-exact reference), but the unset text-encoder / VAE quant still promoted to auto and silently fp8/int8'd the companions, breaking the bit-exact request. An UNSET speed still auto-quantises; an explicit companion scheme still forces it. - The HunyuanVideo joint-attention trim is a speed lever (it swaps to the fused SDPA kernel), so gate it on a non-off speed tier exactly like the adjacent attention-backend selection -- the off path keeps the stock dense-mask attention. - Explicit torchao text-encoder modes (int8 / fp8_dynamic / nvfp4) now run the same kernel smoke test the auto ladder uses. They could clear the capability gate yet fail the real GEMM on a build where quantize_ wraps the encoder but the kernel is broken; the caster's try/except only covers the cast, not the first forward, so the load would report engaged then crash at generation. Now it falls back to dense. Layerwise fp8 has no torchao GEMM, so the probe is a no-op for it. - The trim pre-hook's fallback restores the caller's original kwargs (it may have emptied the image stream / trimmed a text stream before failing), so the stock dense-mask path runs on exactly what it expects, matching the empty-prompt guard. - video_speedmem_bench mirrors the loader: installs the Hunyuan trim before the backend set (gated on an active tier) and skips the auto int8 quant when it is the fp8-denied memory fallback and dense fits resident, so the shipped/auto rows measure what the loader actually runs. Tests: TE explicit-mode kernel probe (+ layerwise-fp8 bypass), trim mid-trim restore, and loader-level speed=off companion suppression + trim skip for both backends. 262 backend tests pass; ruff clean.
This commit is contained in:
parent
5eb64bdcac
commit
be04ba00f4
9 changed files with 201 additions and 15 deletions
|
|
@ -2273,6 +2273,31 @@ def test_speed_off_load_suppresses_auto_dtype_quant(fake_runtime, tmp_path, monk
|
|||
assert _FakeTransformer.last["path"] # GGUF from_single_file was used, not a dense build
|
||||
|
||||
|
||||
def test_speed_off_load_suppresses_auto_companion_quant(fake_runtime, tmp_path, monkeypatch):
|
||||
# Mirror the DiT suppression for the companions: an explicit Speed="off" load with TE/VAE left at
|
||||
# auto must keep them dense (mode "off"), not promote them to auto-quant and silently fp8/int8 the
|
||||
# text encoder + VAE, which would break the bit-exact request. Unset speed still auto-quantises.
|
||||
from core.inference import diffusion as dmod
|
||||
|
||||
te_modes: list = []
|
||||
vae_modes: list = []
|
||||
monkeypatch.setattr(
|
||||
dmod, "quantize_text_encoders", lambda pipe, target, *, mode, **kw: te_modes.append(mode)
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
dmod, "quantize_vae", lambda pipe, target, *, mode, **kw: vae_modes.append(mode)
|
||||
)
|
||||
(tmp_path / "m.gguf").write_bytes(b"x")
|
||||
backend = DiffusionBackend()
|
||||
backend.load_pipeline(
|
||||
str(tmp_path), gguf_filename = "m.gguf", family_override = "z-image", speed_mode = "off"
|
||||
)
|
||||
assert te_modes == ["off"] and vae_modes == ["off"] # dense, not auto
|
||||
backend.unload()
|
||||
backend.load_pipeline(str(tmp_path), gguf_filename = "m.gguf", family_override = "z-image")
|
||||
assert te_modes[-1] == "auto" and vae_modes[-1] == "auto" # promoted when speed is not off
|
||||
|
||||
|
||||
def test_transformer_quant_dense_path_engaged(fake_runtime, tmp_path, monkeypatch):
|
||||
# transformer_quant + a CUDA resident plan -> load the DENSE transformer from the
|
||||
# base repo, place it on the device, quantise it, and report the engaged scheme.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue