diff --git a/src/diffusers/modular_pipelines/components_manager.py b/src/diffusers/modular_pipelines/components_manager.py index 4d467e53ea45..197e2ec80a79 100644 --- a/src/diffusers/modular_pipelines/components_manager.py +++ b/src/diffusers/modular_pipelines/components_manager.py @@ -411,7 +411,9 @@ def add(self, name: str, component: Any, collection: str | None = None): if comp == component: comp_name = self._id_to_name(comp_id) if comp_name == name: - logger.warning(f"ComponentsManager: component '{name}' already exists as '{comp_id}'") + # The same object registered again under its name: a second pipeline sharing it, or a collection + # it joins below. Nothing is duplicated, so this is not worth a warning. + logger.debug(f"ComponentsManager: component '{name}' is already registered as '{comp_id}'") component_id = comp_id is_new_component = False break @@ -454,7 +456,7 @@ def add(self, name: str, component: Any, collection: str | None = None): logger.info( f"ComponentsManager: added component '{name}' in collection '{collection}': {component_id}" ) - else: + elif is_new_component: logger.info(f"ComponentsManager: added component '{name}' as '{component_id}'") if self._auto_offload_enabled and is_new_component: diff --git a/tests/modular_pipelines/test_components_manager.py b/tests/modular_pipelines/test_components_manager.py index be2a247995f1..4ca22a1aff71 100644 --- a/tests/modular_pipelines/test_components_manager.py +++ b/tests/modular_pipelines/test_components_manager.py @@ -218,6 +218,15 @@ def test_add_same_component_twice_reuses_id(self): assert first_id == second_id assert len(cm.components) == 1 + def test_add_same_component_to_second_collection(self): + cm = ComponentsManager() + model = self.get_dummy_model() + first_id = cm.add("unet", model, collection="first") + second_id = cm.add("unet", model, collection="second") + assert first_id == second_id + assert len(cm.components) == 1 + assert cm.collections["first"] == cm.collections["second"] == {first_id} + def test_remove(self): cm = ComponentsManager() component_id = cm.add("unet", self.get_dummy_model())