diff --git a/lora_optimizer.py b/lora_optimizer.py index e1e910c..2373cbc 100644 --- a/lora_optimizer.py +++ b/lora_optimizer.py @@ -11572,7 +11572,13 @@ class LoRAAutoTuner(LoRAOptimizer): lora_stack = clean_stack # --- Normalize & validate stack --- - normalized_stack = self._normalize_stack(lora_stack, normalize_keys=normalize_keys) + # Pass the model-class arch hint so captured (inline) chains score + # candidates under the correct preset (else key-based detection + # mis-tags e.g. attention-only Qwen as ACE-Step). File-based stacks + # have no virtual items, so the hint is unreachable — identical. + normalized_stack = self._normalize_stack( + lora_stack, normalize_keys=normalize_keys, + _arch_hint=self._model_class_arch(model)) active_loras = [item for item in normalized_stack if item["strength"] != 0] if not active_loras: return (model, clip, "No active LoRAs in stack.", "", None, None) diff --git a/tests/test_inline_optimizer.py b/tests/test_inline_optimizer.py index 8650eb1..c1263e8 100644 --- a/tests/test_inline_optimizer.py +++ b/tests/test_inline_optimizer.py @@ -1622,6 +1622,31 @@ class TestInlineAutoTunerDelegation(unittest.TestCase): "analysis report", {"td": 1}, {"ld": 2}) node._autotuner_delegate = types.SimpleNamespace(auto_tune=fake_auto_tune) + def test_autotune_threads_model_class_arch_hint(self): + """auto_tune must pass the model-class arch hint to _normalize_stack so + captured chains score candidates under the right preset (was hintless → + attention-only Qwen scored under the ACE-Step preset).""" + class QwenImage: # mirrors comfy.model_base.QwenImage + pass + model = _FakePatcher({}) + model.model = QwenImage() + delegate = lora_optimizer.LoRAAutoTuner() + seen = {} + + class _Stop(Exception): + pass + + def rec_normalize(stack, normalize_keys="disabled", _arch_hint=None): + seen["hint"] = _arch_hint + raise _Stop + + delegate._normalize_stack = rec_normalize + stack = [{"name": "chain lora #1 [x]", "lora": {"k": _adapter()}, + "strength": 1.0, "_precomputed_diffs": True}] + with self.assertRaises(_Stop): + delegate.auto_tune(model, stack, 1.0) + self.assertEqual(seen.get("hint"), "qwen_image") + def test_delegates_with_virtual_stack_and_stripped_model(self): model = self._model(_chain_patches( (0.8, {"a": _adapter()}), (0.5, {"a": _adapter()})))