{"record":{"id":"08173b8a31f0cf1b","repo":"Comfy-Org/ComfyUI","slug":"unknown-block-type-self-block-type","errorCode":null,"errorMessage":"Unknown block type: {self.block_type}","messagePattern":"Unknown block type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"comfy/ldm/cosmos/blocks.py","lineNumber":720,"sourceCode":"                adaln_norm_state(self.norm_state, x, scale_1_1_1_B_D, shift_1_1_1_B_D),\n            )\n        elif self.block_type in [\"full_attn\", \"fa\"]:\n            x = x + gate_1_1_1_B_D * self.block(\n                adaln_norm_state(self.norm_state, x, scale_1_1_1_B_D, shift_1_1_1_B_D),\n                context=None,\n                rope_emb_L_1_1_D=rope_emb_L_1_1_D,\n                transformer_options=transformer_options,\n            )\n        elif self.block_type in [\"cross_attn\", \"ca\"]:\n            x = x + gate_1_1_1_B_D * self.block(\n                adaln_norm_state(self.norm_state, x, scale_1_1_1_B_D, shift_1_1_1_B_D),\n                context=crossattn_emb,\n                crossattn_mask=crossattn_mask,\n                rope_emb_L_1_1_D=rope_emb_L_1_1_D,\n                transformer_options=transformer_options,\n            )\n        else:\n            raise ValueError(f\"Unknown block type: {self.block_type}\")\n\n        return x\n\n\nclass GeneralDITTransformerBlock(nn.Module):\n    \"\"\"\n    A wrapper module that manages a sequence of DITBuildingBlocks to form a complete transformer layer.\n    Each block in the sequence is specified by a block configuration string.\n\n    Parameters:\n        x_dim (int): Dimension of input features\n        context_dim (int): Dimension of context features for cross-attention blocks\n        num_heads (int): Number of attention heads\n        block_config (str): String specifying block sequence (e.g. \"ca-fa-mlp\" for cross-attention,\n                          full-attention, then MLP)\n        mlp_ratio (float): MLP hidden dimension multiplier. Default: 4.0\n        x_format (str): Input tensor format. Default: \"BTHWD\"\n        use_adaln_lora (bool): Whether to use AdaLN-LoRA. Default: False","sourceCodeStart":702,"sourceCodeEnd":738,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/ldm/cosmos/blocks.py#L702-L738","documentation":"DITBuildingBlock.forward dispatches on self.block_type with the same vocabulary as the constructor (self_attn/sa, cross_attn/ca, and the else covers mlp/ff plus anything else after the first two branches). If block_type was mutated after construction or the forward dispatch was extended in a fork without extending the constructor (or vice versa), forward raises 'Unknown block type'. Under normal flow the constructor check at blocks.py:647 fires first, so a runtime hit here indicates attribute mutation or inconsistent custom edits.","triggerScenarios":"Setting block.block_type after construction (e.g. converting a cross_attn block to another type at runtime); running a partially-updated fork where __init__ accepts a type forward() does not handle.","commonSituations":"Custom nodes patching Cosmos block types for inference tricks; reusing serialized module configs with new block names against older forward code.","solutions":["Do not reassign block_type after construction; rebuild the block with a supported type","If extending the block vocabulary in a fork, update both __init__ and forward branches together","Recreate the model from its config rather than mutating loaded modules"],"exampleFix":"# before\nblock.block_type = \"window_attn\"  # forward raises\n\n# after\nblock = DITBuildingBlock(\"self_attn\", x_dim, num_heads, operations=operations)","handlingStrategy":"type-guard","validationCode":"assert block.block_type in {\"self_attn\", \"sa\", \"cross_attn\", \"ca\", \"full_attn\", \"fa\", \"mlp\", \"ff\"}","typeGuard":"def is_supported_block_type(block) -> bool:\n    return block.block_type in {\"self_attn\", \"sa\", \"cross_attn\", \"ca\", \"full_attn\", \"fa\", \"mlp\", \"ff\"}","tryCatchPattern":null,"preventionTips":["Rebuild blocks instead of reassigning block_type at runtime","In forks, keep __init__ and forward block-type branches in sync"],"tags":["cosmos","dit","forward","monkey-patching"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}