From 482aaff66a2592b5b41f0b70f430c47f96e1d9e5 Mon Sep 17 00:00:00 2001 From: Perfloop Agent Date: Tue, 22 Sep 2026 15:23:36 +0000 Subject: [PATCH 1/2] Add conditioning regression tests --- .../comfy_test/samplers_conditioning_test.py | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests-unit/comfy_test/samplers_conditioning_test.py diff --git a/tests-unit/comfy_test/samplers_conditioning_test.py b/tests-unit/comfy_test/samplers_conditioning_test.py new file mode 100644 index 00000000000..b960151606d --- /dev/null +++ b/tests-unit/comfy_test/samplers_conditioning_test.py @@ -0,0 +1,79 @@ +import pytest +import torch + +from comfy.cli_args import args as cli_args + +if not torch.cuda.is_available(): + cli_args.cpu = True + +from comfy import samplers # noqa: E402 + + +@pytest.mark.parametrize("name", ["gligen", "control"]) +def test_empty_regional_destinations_are_left_unchanged(name): + source_payloads = [object(), object()] + conds = [{name: payload} for payload in source_payloads] + identities = [object(), object()] + uncond = [ + { + "area": (8, 8, 0, 0), + "strength": 0.75, + "marker": "region-a", + "identity": identities[0], + }, + { + "area": (4, 4, 4, 4), + "strength": 0.25, + "marker": "region-b", + "identity": identities[1], + }, + ] + original = [entry.copy() for entry in uncond] + original_entry_ids = [id(entry) for entry in uncond] + + samplers.apply_empty_x_to_equal_area( + conds, uncond, name, lambda payloads, index: payloads[index] + ) + + assert uncond == original + assert [id(entry) for entry in uncond] == original_entry_ids + assert all("area" in entry and name not in entry for entry in uncond) + assert [entry["identity"] for entry in uncond] == identities + + +def test_global_fill_wraps_round_robin_without_changing_destination_count(): + conds = [{"gligen": payload} for payload in ("A", "B", "C")] + uncond = [ + {"marker": "destination-0"}, + {"marker": "destination-1"}, + ] + + samplers.apply_empty_x_to_equal_area( + conds, uncond, "gligen", lambda payloads, index: payloads[index] + ) + + assert [entry["gligen"] for entry in uncond] == ["C", "B"] + assert [entry["marker"] for entry in uncond] == [ + "destination-0", + "destination-1", + ] + assert len(uncond) == 2 + + +@pytest.mark.parametrize("name", ["gligen", "control"]) +def test_existing_global_destination_is_not_overwritten(name): + existing_payload = object() + conds = [{name: object()}] + uncond = [ + {name: existing_payload, "marker": "existing"}, + {"marker": "empty"}, + ] + original = [entry.copy() for entry in uncond] + + samplers.apply_empty_x_to_equal_area( + conds, uncond, name, lambda payloads, index: payloads[index] + ) + + assert uncond == original + assert uncond[0][name] is existing_payload + assert uncond[1] == {"marker": "empty"} From e0d4ea77a9f6fda218619802b8c4e83cda5db082 Mon Sep 17 00:00:00 2001 From: Perfloop Agent Date: Tue, 22 Sep 2026 16:04:14 +0000 Subject: [PATCH 2/2] Fix conditioning fill for regional negatives --- comfy/samplers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comfy/samplers.py b/comfy/samplers.py index 17f7bb8babd..a11a884fba7 100755 --- a/comfy/samplers.py +++ b/comfy/samplers.py @@ -919,7 +919,7 @@ def apply_empty_x_to_equal_area(conds, uncond, name, uncond_fill_func): else: uncond_other.append((x, t)) - if len(uncond_cnets) > 0: + if len(uncond_cnets) > 0 or len(uncond_other) == 0: return for x in range(len(cond_cnets)):