huggingface/candle · error

GroupNorm doesn't support causal evaluation.

Error message

GroupNorm doesn't support causal evaluation.

What it means

In Mimi's conv1d, TimeGroupNorm cannot be applied to causally-evaluated convolutions, so new bails when causal is true and norm is TimeGroupNorm. GroupNorm mixes statistics across the time dimension of the output, which is incompatible with causal (streaming) evaluation in this implementation.

Source

Thrown at candle-transformers/src/models/mimi/conv.rs:86

    ) -> Result<Self> {
        let conv = match norm {
            None | Some(Norm::TimeGroupNorm) => {
                if bias {
                    candle_nn::conv1d(in_c, out_c, k_size, cfg, vb.pp("conv"))?
                } else {
                    candle_nn::conv1d_no_bias(in_c, out_c, k_size, cfg, vb.pp("conv"))?
                }
            }
            Some(Norm::WeightNorm) => {
                conv1d_weight_norm(in_c, out_c, k_size, bias, cfg, vb.pp("conv"))?
            }
            Some(Norm::SpectralNorm) => candle::bail!("SpectralNorm is not supported yet."),
        };
        let norm = match norm {
            None | Some(Norm::WeightNorm) | Some(Norm::SpectralNorm) => None,
            Some(Norm::TimeGroupNorm) => {
                if causal {
                    candle::bail!("GroupNorm doesn't support causal evaluation.")
                }
                let norm = candle_nn::group_norm(1, out_c, 1e-5, vb.pp("norm"))?;
                Some(norm)
            }
        };
        Ok(Self {
            conv,
            norm,
            span: tracing::span!(tracing::Level::TRACE, "norm-conv1d"),
        })
    }
}

impl Module for NormConv1d {
    fn forward(&self, xs: &Tensor) -> Result<Tensor> {
        let _enter = self.span.enter();
        let xs = xs.apply(&self.conv)?;
        match self.norm.as_ref() {

View on GitHub (pinned to d5fee525bf)

Solutions

  1. Set the conv layer's norm to None (or WeightNorm) when causal evaluation is required
  2. Set causal=false if your use case permits non-streaming inference and the checkpoint needs TimeGroupNorm
  3. Verify the config against the official Mimi setup, where causal convs pair with weight norm, not group norm

Example fix

// before
let cfg = Conv1dConfig { causal: true, norm: Some(Norm::TimeGroupNorm), .. };
// after
let cfg = Conv1dConfig { causal: true, norm: None, .. };
Defensive patterns

Strategy: validation

Validate before calling

if causal && cfg.norm == Some(Norm::TimeGroupNorm) {
    return Err("TimeGroupNorm is incompatible with causal evaluation");
}

Try / catch

let layer = Conv1d::new(in_c, out_c, k, cfg, causal, vb)
    .map_err(|e| format!("invalid causal/norm combination: {e}"))?;

Prevention

When it happens

Trigger: Constructing a causal Mimi Conv1d layer with cfg.norm = Some(Norm::TimeGroupNorm) — i.e. causal=true in the layer config plus time group norm.

Common situations: Streaming/real-time Mimi inference configs that set causal=true while the source checkpoint still specifies TimeGroupNorm on conv blocks; hand-building configs mixing causal mode with the checkpoint's norm settings.

Related errors


AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02). Data as JSON: /api/errors/179020bd5e086c43. Report an issue: GitHub.