Comfy-Org/ComfyUI · error · ValueError

Unknown activation function: {act_fn}

Error message

Unknown activation function: {act_fn}

What it means

The LTX text projection feed-forward only implements two activations: gelu_tanh and silu. A config string outside this set means the checkpoint's projection type is not implemented in this port, and the error names the exact unsupported value.

Source

Thrown at comfy/ldm/lightricks/model.py:269

    Adapted from https://github.com/PixArt-alpha/PixArt-alpha/blob/master/diffusion/model/nets/PixArt_blocks.py
    """

    def __init__(
        self, in_features, hidden_size, out_features=None, act_fn="gelu_tanh", dtype=None, device=None, operations=None
    ):
        super().__init__()
        if out_features is None:
            out_features = hidden_size
        self.linear_1 = operations.Linear(
            in_features=in_features, out_features=hidden_size, bias=True, dtype=dtype, device=device
        )
        if act_fn == "gelu_tanh":
            self.act_1 = nn.GELU(approximate="tanh")
        elif act_fn == "silu":
            self.act_1 = nn.SiLU()
        else:
            raise ValueError(f"Unknown activation function: {act_fn}")
        self.linear_2 = operations.Linear(
            in_features=hidden_size, out_features=out_features, bias=True, dtype=dtype, device=device
        )

    def forward(self, caption):
        hidden_states = self.linear_1(caption)
        hidden_states = self.act_1(hidden_states)
        hidden_states = self.linear_2(hidden_states)
        return hidden_states


class NormSingleLinearTextProjection(nn.Module):
    """Text projection for 20B models - single linear with RMSNorm (no activation)."""

    def __init__(
        self, in_features, hidden_size, dtype=None, device=None, operations=None
    ):
        super().__init__()

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Map 'gelu' -> 'gelu_tanh' and 'swish' -> 'silu' when converting configs
  2. Use the config values shipped with the repo's checkpoint conversions
  3. Verify against the checkpoint's config.json after conversion

Example fix

# before
proj = FeedForward(..., act_fn="gelu")
# after
proj = FeedForward(..., act_fn="gelu_tanh")
Defensive patterns

Strategy: validation

Validate before calling

assert act_fn in {"gelu_tanh", "silu"}, act_fn

Type guard

def is_supported_act(v: str) -> bool:
    return v in {"gelu_tanh", "silu"}

Prevention

When it happens

Trigger: Constructing the caption projection with act_fn='gelu' (exact), 'swish', 'relu', etc.; usually from a config key copied from the original Lightricks repo which uses different activation names.

Common situations: Porting new LTX checkpoints whose configs use 'gelu' vs this repo's 'gelu_tanh' naming, or hand-written config dicts.

Related errors


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