Comfy-Org/ComfyUI · critical · ValueError

Unknown block type: {block_type}

Error message

Unknown block type: {block_type}

What it means

DITBuildingBlock in the Cosmos prediction network wraps one sub-block chosen by a block_type string: 'self_attn'/'sa' (CrossAttention as self-attention), 'full_attn'/'fa' (VideoAttn), 'cross_attn'/'ca', or 'mlp'/'ff' (GPT2FeedForward). Any other string falls to the else-branch and raises at construction. The block strings come from the per-layer block configuration lists of the Cosmos model config.

Source

Thrown at comfy/ldm/cosmos/blocks.py:647

        if block_type in ["cross_attn", "ca"]:
            self.block = VideoAttn(
                x_dim,
                context_dim,
                num_heads,
                bias=bias,
                qkv_norm_mode=qkv_norm_mode,
                x_format=self.x_format,
                weight_args=weight_args,
                operations=operations,
            )
        elif block_type in ["full_attn", "fa"]:
            self.block = VideoAttn(
                x_dim, None, num_heads, bias=bias, qkv_norm_mode=qkv_norm_mode, x_format=self.x_format, weight_args=weight_args, operations=operations
            )
        elif block_type in ["mlp", "ff"]:
            self.block = GPT2FeedForward(x_dim, int(x_dim * mlp_ratio), dropout=mlp_dropout, bias=bias, weight_args=weight_args, operations=operations)
        else:
            raise ValueError(f"Unknown block type: {block_type}")

        self.block_type = block_type
        self.use_adaln_lora = use_adaln_lora

        self.norm_state = nn.LayerNorm(x_dim, elementwise_affine=False, eps=1e-6)
        self.n_adaln_chunks = 3
        if use_adaln_lora:
            self.adaLN_modulation = nn.Sequential(
                nn.SiLU(),
                operations.Linear(x_dim, adaln_lora_dim, bias=False, **weight_args),
                operations.Linear(adaln_lora_dim, self.n_adaln_chunks * x_dim, bias=False, **weight_args),
            )
        else:
            self.adaLN_modulation = nn.Sequential(nn.SiLU(), operations.Linear(x_dim, self.n_adaln_chunks * x_dim, bias=False, **weight_args))

    def forward(
        self,
        x: torch.Tensor,

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Use only the supported tags: self_attn/sa, cross_attn/ca, full_attn/fa, mlp/ff
  2. Check which Cosmos variant the checkpoint is and whether your ComfyUI version supports its block vocabulary
  3. Update ComfyUI to a release matching the checkpoint's architecture

Example fix

# before
block_types = ["self_attn", "cross_attn", "conv"]  # 'conv' unknown

# after
block_types = ["self_attn", "cross_attn", "mlp"]
Defensive patterns

Strategy: validation

Validate before calling

VALID_BLOCKS = {"self_attn", "sa", "cross_attn", "ca", "full_attn", "fa", "mlp", "ff"}
assert all(b in VALID_BLOCKS for layer in block_config for b in layer), "unknown Cosmos block tag"

Type guard

def is_valid_cosmos_block(tag: str) -> bool:
    return tag in {"self_attn", "sa", "cross_attn", "ca", "full_attn", "fa", "mlp", "ff"}

Prevention

When it happens

Trigger: Building a Cosmos DIT with a block list containing an unknown tag, e.g. 'window_attn', 'conv', or a typo like 'selfatten'. Each GeneralDITTransformerBlock layer specifies a list like ['self_attn', 'cross_attn', 'mlp']; every entry is dispatched through this constructor.

Common situations: Porting configs from upstream Cosmos versions with additional block types (e.g. window attention variants); hand-editing block lists to prune layers; loading a Cosmos variant (Predict2 vs Predict1) not supported by the current ComfyUI code.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/59ca2908918bba39. Report an issue: GitHub.