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
- Rename 'lossconfig' to 'loss_config' in your YAML config
- Keep the old key if the warning is acceptable (it is auto-mapped)
- 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
- Audit legacy SD 1.x configs for 'lossconfig'
- Prefer loss_config in all new configs
- Silence-or-fail on deprecation warnings in CI
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
- Checkpoint path is deprecated, use `checkpoint_egnine` inste
- unknown merge strategy {self.merge_strategy}
- Unknown loss type {self.loss_type}
- provide num_res_blocks either as an int (globally constant)
- need either 'input_key' or 'input_keys' for embedder {embedd
AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29).
Data as JSON: /api/errors/86440dffd5de4eca.
Report an issue: GitHub.