Comfy-Org/ComfyUI · error · ValueError

Invalid latent_log_var: {latent_log_var}

Error message

Invalid latent_log_var: {latent_log_var}

What it means

Raised by the causal video autoencoder Encoder when latent_log_var is not one of 'per_channel', 'uniform', 'constant', or 'none'. This field selects how many extra output channels the final conv emits for the latent distribution's log variance; unrecognized values are rejected because output channel count would be ambiguous.

Source

Thrown at comfy/ldm/lightricks/vae/causal_video_autoencoder.py:222

            self.conv_norm_out = nn.GroupNorm(
                num_channels=output_channel, num_groups=norm_num_groups, eps=1e-6
            )
        elif norm_layer == "pixel_norm":
            self.conv_norm_out = PixelNorm()
        elif norm_layer == "layer_norm":
            self.conv_norm_out = LayerNorm(output_channel, eps=1e-6)

        self.conv_act = nn.SiLU()

        conv_out_channels = out_channels
        if latent_log_var == "per_channel":
            conv_out_channels *= 2
        elif latent_log_var == "uniform":
            conv_out_channels += 1
        elif latent_log_var == "constant":
            conv_out_channels += 1
        elif latent_log_var != "none":
            raise ValueError(f"Invalid latent_log_var: {latent_log_var}")
        self.conv_out = make_conv_nd(
            dims,
            output_channel,
            conv_out_channels,
            3,
            padding=1,
            causal=True,
            spatial_padding_mode=spatial_padding_mode,
        )

        self.gradient_checkpointing = False

    def _forward_chunk(self, sample: torch.FloatTensor) -> Optional[torch.FloatTensor]:
        sample = self.conv_in(sample)

        checkpoint_fn = (
            partial(torch.utils.checkpoint.checkpoint, use_reentrant=False)
            if self.gradient_checkpointing and self.training

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Set latent_log_var to one of 'none', 'per_channel', 'uniform', or 'constant'
  2. Check the checkpoint's config JSON for the exact spelling of the field
  3. Update ComfyUI if the checkpoint comes from a newer model that added a new mode

Example fix

# before
Encoder(..., latent_log_var="per-channel")

# after
Encoder(..., latent_log_var="per_channel")
Defensive patterns

Strategy: validation

Validate before calling

VALID_LOG_VAR = {"none", "per_channel", "uniform", "constant"}
if cfg.get("latent_log_var", "none") not in VALID_LOG_VAR:
    raise ValueError(f"latent_log_var must be one of {sorted(VALID_LOG_VAR)}")

Prevention

When it happens

Trigger: Constructing Encoder(latent_log_var="per-channel"), "", "learned", or any other string; typically the value comes straight from the checkpoint's config JSON.

Common situations: Checkpoint configs from newer LTX VAE variants that rename the option; typo or missing field defaulting incorrectly; porting configs between repos with different vocabularies.

Related errors


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