Merge branch 'diffusion-fp16-accum' into diffusion-auto-install
# Conflicts: # studio/backend/core/inference/diffusion.py
This commit is contained in:
commit
32e68b4fd0
19 changed files with 256 additions and 25 deletions
|
|
@ -136,6 +136,29 @@ def test_incompatible_model_runs_uncached(monkeypatch):
|
|||
assert apply_step_cache(_pipe(t), mode = "fbcache") is None
|
||||
|
||||
|
||||
def test_enable_cache_failure_rolls_back_partial_hooks(monkeypatch):
|
||||
# enable_cache can raise after hooking some blocks; the reported-uncached model
|
||||
# must not actually run half-cached, so the failure path calls disable_cache.
|
||||
_stub_diffusers(monkeypatch)
|
||||
t = _MixinTransformer(fail = True)
|
||||
t.disabled = False
|
||||
t.disable_cache = lambda: setattr(t, "disabled", True)
|
||||
assert apply_step_cache(_pipe(t), mode = "fbcache") is None
|
||||
assert t.disabled is True
|
||||
|
||||
|
||||
def test_config_import_falls_back_to_hooks_module(monkeypatch):
|
||||
# Older diffusers exports FirstBlockCacheConfig only from diffusers.hooks.
|
||||
diffusers = types.ModuleType("diffusers") # no FirstBlockCacheConfig attribute
|
||||
monkeypatch.setitem(sys.modules, "diffusers", diffusers)
|
||||
hooks = types.ModuleType("diffusers.hooks")
|
||||
hooks.FirstBlockCacheConfig = _Config
|
||||
monkeypatch.setitem(sys.modules, "diffusers.hooks", hooks)
|
||||
t = _MixinTransformer()
|
||||
assert apply_step_cache(_pipe(t), mode = "fbcache") == TC_FBCACHE
|
||||
assert t.enabled_with.threshold == DEFAULT_FBCACHE_THRESHOLD
|
||||
|
||||
|
||||
def test_missing_transformer_is_none(monkeypatch):
|
||||
_stub_diffusers(monkeypatch)
|
||||
pipe = types.SimpleNamespace(transformer = None)
|
||||
|
|
@ -143,8 +166,11 @@ def test_missing_transformer_is_none(monkeypatch):
|
|||
|
||||
|
||||
def test_diffusers_unavailable_runs_uncached(monkeypatch):
|
||||
# no diffusers import -> best-effort returns None, load proceeds uncached.
|
||||
# no diffusers import -> best-effort returns None, load proceeds uncached. Block the
|
||||
# hooks module too: the config import falls back to diffusers.hooks, which a REAL
|
||||
# earlier import in the test session may have left cached in sys.modules.
|
||||
monkeypatch.setitem(sys.modules, "diffusers", None)
|
||||
monkeypatch.setitem(sys.modules, "diffusers.hooks", None)
|
||||
t = _MixinTransformer()
|
||||
assert apply_step_cache(_pipe(t), mode = "fbcache") is None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue