{"record":{"id":"ae4699cdada8dbc2","repo":"Stability-AI/generative-models","slug":"unknown-merge-strategy-self-merge-strategy-ae4699","errorCode":null,"errorMessage":"unknown merge strategy {self.merge_strategy}","messagePattern":"unknown merge strategy (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sgm/modules/diffusionmodules/util.py","lineNumber":369,"sourceCode":"        super().__init__()\n        self.merge_strategy = merge_strategy\n        self.rearrange_pattern = rearrange_pattern\n\n        assert (\n            merge_strategy in self.strategies\n        ), f\"merge_strategy needs to be in {self.strategies}\"\n\n        if self.merge_strategy == \"fixed\":\n            self.register_buffer(\"mix_factor\", torch.Tensor([alpha]))\n        elif (\n            self.merge_strategy == \"learned\"\n            or self.merge_strategy == \"learned_with_images\"\n        ):\n            self.register_parameter(\n                \"mix_factor\", torch.nn.Parameter(torch.Tensor([alpha]))\n            )\n        else:\n            raise ValueError(f\"unknown merge strategy {self.merge_strategy}\")\n\n    def get_alpha(self, image_only_indicator: torch.Tensor) -> torch.Tensor:\n        if self.merge_strategy == \"fixed\":\n            alpha = self.mix_factor\n        elif self.merge_strategy == \"learned\":\n            alpha = torch.sigmoid(self.mix_factor)\n        elif self.merge_strategy == \"learned_with_images\":\n            assert image_only_indicator is not None, \"need image_only_indicator ...\"\n            alpha = torch.where(\n                image_only_indicator.bool(),\n                torch.ones(1, 1, device=image_only_indicator.device),\n                rearrange(torch.sigmoid(self.mix_factor), \"... -> ... 1\"),\n            )\n            alpha = rearrange(alpha, self.rearrange_pattern)\n        else:\n            raise NotImplementedError\n        return alpha\n","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/Stability-AI/generative-models/blob/e8cd657656fa5d61688191730d0e03242bf4ed44/sgm/modules/diffusionmodules/util.py#L351-L387","documentation":"AlphaBlender.__init__ only accepts merge_strategy values 'learned', 'fixed', or 'learned_with_images' (class attribute AlphaBlender.strategies). Any other string raises ValueError('unknown merge strategy {merge_strategy}'). This guard exists because get_alpha cannot compute a blend factor for unknown strategies.","triggerScenarios":"Instantiating AlphaBlender(alpha=..., merge_strategy=...) with a misspelled or unsupported strategy, e.g. 'fixed_with_images' (which is only valid for the video_model variant, not AlphaBlender) or a typo like 'leanred'.","commonSituations":"Copying a merge_strategy value from the video-model config (which supports 'fixed_with_images') into an AlphaBlender config, or typos in YAML/CLI overrides.","solutions":["Use one of the supported strategies: 'fixed', 'learned', or 'learned_with_images'.","If you need 'fixed_with_images', use the video-model class that supports it (e.g. VideoResBlock in video_model.py), not AlphaBlender.","Validate against AlphaBlender.strategies before construction."],"exampleFix":"// before\nblend = AlphaBlender(alpha=0.5, merge_strategy=\"fixed_with_images\")\n// after\nblend = AlphaBlender(alpha=0.5, merge_strategy=\"fixed\")","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"fixed\", \"learned\", \"learned_with_images\"}\nif merge_strategy not in SUPPORTED:\n    raise ValueError(f\"merge_strategy must be one of {SUPPORTED}, got {merge_strategy!r}\")","typeGuard":"def is_valid_merge_strategy(s) -> bool:\n    return isinstance(s, str) and s in {\"fixed\", \"learned\", \"learned_with_images\"}","tryCatchPattern":"try:\n    blend = AlphaBlender(alpha=a, merge_strategy=strategy)\nexcept ValueError as e:\n    logger.warning(\"%s; falling back to 'fixed'\", e)\n    blend = AlphaBlender(alpha=a, merge_strategy=\"fixed\")","preventionTips":["Copy merge_strategy values only from AlphaBlender.strategies, not from other classes.","Use Literal types / enum in structured configs.","Watch for the AlphaBlender-vs-video-model strategy mismatch ('learned_with_images' vs 'fixed_with_images')."],"tags":["pytorch","valueerror","configuration"],"backgroundTag":"invalid-enum-value","analyzedSha":"e8cd657656fa5d61688191730d0e03242bf4ed44","analyzedAt":"2026-08-29T11:23:43.234Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}