route refmods per generated chunk

This commit is contained in:
2026-10-20 16:14:05 +00:00
parent bacc2db407
commit 4639ce05c0
4 changed files with 54 additions and 5 deletions
+14 -2
View File
@@ -9,19 +9,31 @@ from comfy.patcher_extension import WrappersMP
BRIDGE_KEY = "minimax_h3_refmod_bridge"
def attach(model, blocks, enabled=True):
def attach(model, blocks, enabled=True, chunk_blocks=None):
model = model.clone()
model.remove_wrappers_with_key(WrappersMP.OUTER_SAMPLE, BRIDGE_KEY)
if not enabled or not blocks:
return model
refs = tuple(dict(b) for b in blocks)
per_chunk = tuple(
tuple(dict(b) for b in chunk)
for chunk in (chunk_blocks or ())
)
call_index = 0
def inject(executor, *args, **kwargs):
nonlocal call_index
# Continuum samples physical groups in sequence order. The DUMAS
# prompt builder supplies one block set per logical chunk; use that
# set for the corresponding sampling call. A normal RefMod bundle
# has no per-chunk map and continues to apply to every chunk.
selected = per_chunk[call_index] if call_index < len(per_chunk) else refs
call_index += 1
guider = executor.class_obj
original = guider.conds
guider.conds = {
key: [dict(entry, minimax_refs=list(entry.get("minimax_refs") or [])
+ [dict(ref) for ref in refs]) for entry in entries]
+ [dict(ref) for ref in selected]) for entry in entries]
for key, entries in original.items()
}
try: