{"record":{"id":"7383d3d6de010411","repo":"Comfy-Org/ComfyUI","slug":"bad-block-type","errorCode":null,"errorMessage":"Bad block_type","messagePattern":"Bad block_type","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"comfy/ldm/chroma/model.py","lineNumber":140,"sourceCode":"            return (tensor[:, -2:-1, :], tensor[:, -1:, :])\n        single_block_count = self.params.depth_single_blocks\n        double_block_count = self.params.depth\n        offset = 3 * idx\n        if block_type == \"single\":\n            return ChromaModulationOut.from_offset(tensor, offset)\n        # Double block modulations are 6 elements so we double 3 * idx.\n        offset *= 2\n        if block_type in {\"double_img\", \"double_txt\"}:\n            # Advance past the single block modulations.\n            offset += 3 * single_block_count\n            if block_type == \"double_txt\":\n                # Advance past the double block img modulations.\n                offset += 6 * double_block_count\n            return (\n                ChromaModulationOut.from_offset(tensor, offset),\n                ChromaModulationOut.from_offset(tensor, offset + 3),\n            )\n        raise ValueError(\"Bad block_type\")\n\n\n    def forward_orig(\n        self,\n        img: Tensor,\n        img_ids: Tensor,\n        txt: Tensor,\n        txt_ids: Tensor,\n        timesteps: Tensor,\n        guidance: Tensor = None,\n        control = None,\n        transformer_options={},\n        attn_mask: Tensor = None,\n    ) -> Tensor:\n        transformer_options = transformer_options.copy()\n        patches_replace = transformer_options.get(\"patches_replace\", {})\n\n        # running on sequences img","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/chroma/model.py#L122-L158","documentation":"Chroma calculates modulation-vector offsets for its single and double transformer blocks via calc_double_or_single_modulation. Callers must pass block_type 'double_img' or 'double_txt'; anything else falls through to raise ValueError('Bad block_type'). In practice this is an internal invariant: both call sites in forward_orig pass literal strings, so a user seeing this error means custom/patched code invoked the offset helper with a wrong literal.","triggerScenarios":"Calling ChromaModulationOut / the modulation offset helper (model.py around line 120-140) with block_type values like 'single', 'img', 'double' or a typo such as 'double_image'. Standard ComfyUI sampling never passes anything but 'double_img'/'double_txt'.","commonSituations":"Custom model patches or nodes that reimplement Chroma's modulation slicing; copy-pasting code from flux model.py where the block_type vocabulary differs; monkey-patched forward_orig from an out-of-date custom node.","solutions":["Pass exactly 'double_img' or 'double_txt' as block_type","If the call comes from a custom node patch of Chroma, update the node to match the current block_type vocabulary in comfy/ldm/chroma/model.py","Remove stale monkey-patches of forward_orig so the shipped implementation runs"],"exampleFix":"# before\nmod = model.calc_modulations(vec, block_type=\"single\")\n\n# after\nmod = model.calc_modulations(vec, block_type=\"double_img\")","handlingStrategy":"validation","validationCode":"VALID_BLOCK_TYPES = {\"double_img\", \"double_txt\"}\nassert block_type in VALID_BLOCK_TYPES, f\"block_type must be one of {VALID_BLOCK_TYPES}\"","typeGuard":"def is_valid_chroma_block_type(bt: str) -> bool:\n    return bt in {\"double_img\", \"double_txt\"}","tryCatchPattern":null,"preventionTips":["Treat the modulation offset helper as internal API; do not call it from custom nodes","When patching Chroma, copy block_type literals from the current model.py, not from memory or flux code"],"tags":["chroma","modulation","internal-api","custom-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}