Comfy-Org/ComfyUI · critical · ValueError
Unknown block type: {self.block_type}
Error message
Unknown block type: {self.block_type} What it means
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.
Source
Thrown at comfy/ldm/cosmos/blocks.py:720
adaln_norm_state(self.norm_state, x, scale_1_1_1_B_D, shift_1_1_1_B_D),
)
elif self.block_type in ["full_attn", "fa"]:
x = x + gate_1_1_1_B_D * self.block(
adaln_norm_state(self.norm_state, x, scale_1_1_1_B_D, shift_1_1_1_B_D),
context=None,
rope_emb_L_1_1_D=rope_emb_L_1_1_D,
transformer_options=transformer_options,
)
elif self.block_type in ["cross_attn", "ca"]:
x = x + gate_1_1_1_B_D * self.block(
adaln_norm_state(self.norm_state, x, scale_1_1_1_B_D, shift_1_1_1_B_D),
context=crossattn_emb,
crossattn_mask=crossattn_mask,
rope_emb_L_1_1_D=rope_emb_L_1_1_D,
transformer_options=transformer_options,
)
else:
raise ValueError(f"Unknown block type: {self.block_type}")
return x
class GeneralDITTransformerBlock(nn.Module):
"""
A wrapper module that manages a sequence of DITBuildingBlocks to form a complete transformer layer.
Each block in the sequence is specified by a block configuration string.
Parameters:
x_dim (int): Dimension of input features
context_dim (int): Dimension of context features for cross-attention blocks
num_heads (int): Number of attention heads
block_config (str): String specifying block sequence (e.g. "ca-fa-mlp" for cross-attention,
full-attention, then MLP)
mlp_ratio (float): MLP hidden dimension multiplier. Default: 4.0
x_format (str): Input tensor format. Default: "BTHWD"
use_adaln_lora (bool): Whether to use AdaLN-LoRA. Default: FalseView on GitHub (pinned to 1c6d8d45b3)
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
Example fix
# before
block.block_type = "window_attn" # forward raises
# after
block = DITBuildingBlock("self_attn", x_dim, num_heads, operations=operations) Defensive patterns
Strategy: type-guard
Validate before calling
assert block.block_type in {"self_attn", "sa", "cross_attn", "ca", "full_attn", "fa", "mlp", "ff"} Type guard
def is_supported_block_type(block) -> bool:
return block.block_type in {"self_attn", "sa", "cross_attn", "ca", "full_attn", "fa", "mlp", "ff"} Prevention
- Rebuild blocks instead of reassigning block_type at runtime
- In forks, keep __init__ and forward block-type branches in sync
When it happens
Trigger: 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.
Common situations: Custom nodes patching Cosmos block types for inference tricks; reusing serialized module configs with new block names against older forward code.
Related errors
- Unknown block type: {block_type}
- Scalar feature is not implemented yet.
- Unknown x_format {self.blocks[0].x_format}
- Input img and txt tensors must have 3 dimensions.
- Input img tensor must be in [B, C, H, W] format.
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/08173b8a31f0cf1b.
Report an issue: GitHub.