Stability-AI/generative-models · warning

Parameter `lossconfig` is deprecated, use `loss_config`.

Error message

Parameter `lossconfig` is deprecated, use `loss_config`.

What it means

VectorQuantizer wrapper's __init__ accepts kwargs and renames the legacy 'lossconfig' key to 'loss_config' before delegating to super(), logging a deprecation warning. This is a backward-compatibility shim for old SD VQModel configs.

Source

Thrown at sgm/models/autoencoder.py:532

                "target": (
                    "sgm.modules.autoencoding.regularizers"
                    ".DiagonalGaussianRegularizer"
                )
            },
            **kwargs,
        )


class AutoencoderLegacyVQ(AutoencodingEngineLegacy):
    def __init__(
        self,
        embed_dim: int,
        n_embed: int,
        sane_index_shape: bool = False,
        **kwargs,
    ):
        if "lossconfig" in kwargs:
            logpy.warn(f"Parameter `lossconfig` is deprecated, use `loss_config`.")
            kwargs["loss_config"] = kwargs.pop("lossconfig")
        super().__init__(
            regularizer_config={
                "target": (
                    "sgm.modules.autoencoding.regularizers.quantize" ".VectorQuantizer"
                ),
                "params": {
                    "n_e": n_embed,
                    "e_dim": embed_dim,
                    "sane_index_shape": sane_index_shape,
                },
            },
            **kwargs,
        )


class IdentityFirstStage(AbstractAutoencoder):
    def __init__(self, *args, **kwargs):

View on GitHub (pinned to e8cd657656)

Solutions

  1. Rename 'lossconfig' to 'loss_config' in your YAML config
  2. Keep the old key if the warning is acceptable (it is auto-mapped)
  3. Update the config from the repository's current VQModel example configs

Example fix

// before
lossconfig:
  target: sgm.modules.autoencoding.losses.LPIPSWithDiscriminator
// after
loss_config:
  target: sgm.modules.autoencoding.losses.LPIPSWithDiscriminator
Defensive patterns

Strategy: validation

Validate before calling

if "lossconfig" in vq_params:
    vq_params["loss_config"] = vq_params.pop("lossconfig")

Type guard

def normalize_vq_config(params: dict) -> dict:
    return {"loss_config" if k == "lossconfig" else k: v for k, v in params.items()}

Try / catch

try:
    model = instantiate_from_config(config)
except Exception:
    config["params"] = normalize_vq_config(config.get("params", {}))
    model = instantiate_from_config(config)

Prevention

When it happens

Trigger: Instantiating a VQModel from an old config YAML containing `lossconfig: {target: ...}` instead of the new `loss_config` key.

Common situations: Reusing SD 1.x / latent-diffusion VQ config files with the newer generative-models (sgm) codebase; copying old model cards' configs verbatim.

Related errors


AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29). Data as JSON: /api/errors/86440dffd5de4eca. Report an issue: GitHub.