Studio diffusion (Phase 14): guard the int8 exclusion filter against a None fqn

The filter callback can be invoked without a module name, so fqn.lower() would raise
AttributeError on None. Fall back to an empty name (nothing matches the exclusion tokens,
so the linear is kept) instead of crashing the quantise pass.
This commit is contained in:
Daniel Han 2026-06-28 06:20:41 +00:00
commit ce060f3644
2 changed files with 5 additions and 1 deletions

View file

@ -324,7 +324,7 @@ def make_filter_fn(min_features: int, exclude_name_tokens: tuple[str, ...] = ())
if in_features < min_features or out_features < min_features:
return False
if exclude_name_tokens:
name = fqn.lower()
name = fqn.lower() if fqn else ""
if any(tok in name for tok in exclude_name_tokens):
return False
return True

View file

@ -351,6 +351,10 @@ def test_make_filter_fn_int8_excludes_modulation_and_embedders(monkeypatch):
assert keep(big(), fqn) is True, fqn
# Without the exclusion (fp8 path), the modulation layer is kept.
assert make_filter_fn(512)(big(), "transformer_blocks.0.norm1.linear") is True
# A None / empty fqn must not crash the exclusion check (defensive against the callback
# passing no name); with no name nothing matches the exclusion tokens -> kept.
assert keep(big(), None) is True
assert keep(big(), "") is True
# ── apply ───────────────────────────────────────────────────────────────────────