Comfy-Org/ComfyUI · error · ValueError
unknown merge strategy {self.merge_strategy}
Error message
unknown merge strategy {self.merge_strategy} What it means
Raised by the VideoAnimationMerge/alpha-mixing module (util.py) when merge_strategy is neither 'fixed', 'learned', nor 'learned_with_images'. An assert just above already constrains membership in self.strategies, so this else-branch ValueError is the hard backstop for a strategy string outside the known set — it fires at module init.
Source
Thrown at comfy/ldm/modules/diffusionmodules/util.py:47
super().__init__()
self.merge_strategy = merge_strategy
self.rearrange_pattern = rearrange_pattern
assert (
merge_strategy in self.strategies
), f"merge_strategy needs to be in {self.strategies}"
if self.merge_strategy == "fixed":
self.register_buffer("mix_factor", torch.Tensor([alpha]))
elif (
self.merge_strategy == "learned"
or self.merge_strategy == "learned_with_images"
):
self.register_parameter(
"mix_factor", torch.nn.Parameter(torch.Tensor([alpha]))
)
else:
raise ValueError(f"unknown merge strategy {self.merge_strategy}")
def get_alpha(self, image_only_indicator: torch.Tensor, device) -> torch.Tensor:
# skip_time_mix = rearrange(repeat(skip_time_mix, 'b -> (b t) () () ()', t=t), '(b t) 1 ... -> b 1 t ...', t=t)
if self.merge_strategy == "fixed":
# make shape compatible
# alpha = repeat(self.mix_factor, '1 -> b () t () ()', t=t, b=bs)
alpha = self.mix_factor.to(device)
elif self.merge_strategy == "learned":
alpha = torch.sigmoid(self.mix_factor.to(device))
# make shape compatible
# alpha = repeat(alpha, '1 -> s () ()', s = t * bs)
elif self.merge_strategy == "learned_with_images":
if image_only_indicator is None:
alpha = rearrange(torch.sigmoid(self.mix_factor.to(device)), "... -> ... 1")
else:
alpha = torch.where(
image_only_indicator.bool(),
torch.ones(1, 1, device=image_only_indicator.device),View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Set merge_strategy to 'fixed' (uses the constant alpha buffer) or 'learned'/'learned_with_images'
- Restore the original model config from the checkpoint
- Check for case sensitivity and stray whitespace in the config string
Example fix
# before merge_strategy='Fixed' # after merge_strategy='fixed'
Defensive patterns
Strategy: validation
Validate before calling
if merge_strategy not in ('fixed', 'learned', 'learned_with_images'):
raise ValueError(f"merge_strategy must be fixed|learned|learned_with_images, got {merge_strategy!r}") Type guard
def is_valid_merge_strategy(s: str) -> bool:
return s in ('fixed', 'learned', 'learned_with_images') Prevention
- Validate strategy strings from video-model configs at load time
- Watch for case differences when configs come from other forks
When it happens
Trigger: Constructing the time-mixing module with merge_strategy set to a typo ('Learned'), an unsupported value ('interpolated'), or None in a video-model config.
Common situations: Loading animated/video diffusion model configs (AnimateDiff-style) edited by hand; configs from forks that define extra strategies not present in this build.
Related errors
- ar_video sampler requires 5-D video latents [B,C,T,H,W], got
- Unknown rope_img: {rope_img}
- Unsupported spatial_scale {scale}. Choose from {list(mapping
- Invalid {cls.__name__} string: '{value}'. Valid values are:
- Invalid normalization type: {normtype}
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/144e0b086e4b7da8.
Report an issue: GitHub.