Stability-AI/generative-models · warning
Did not find parameters for pattern {pattern_}
Error message
Did not find parameters for pattern {pattern_} What it means
get_param_groups builds optimizer parameter groups from regex patterns over named_parameters. When a pattern matches zero parameters it logs a warning 'Did not find parameters for pattern ...' and continues with an empty group — the user likely misspelled a pattern, so part of the model silently gets no (or wrong) training configuration.
Source
Thrown at sgm/models/autoencoder.py:358
self.log_dict(full_log_dict, sync_dist=True)
return full_log_dict
def get_param_groups(
self, parameter_names: List[List[str]], optimizer_args: List[dict]
) -> Tuple[List[Dict[str, Any]], int]:
groups = []
num_params = 0
for names, args in zip(parameter_names, optimizer_args):
params = []
for pattern_ in names:
pattern_params = []
pattern = re.compile(pattern_)
for p_name, param in self.named_parameters():
if re.match(pattern, p_name):
pattern_params.append(param)
num_params += param.numel()
if len(pattern_params) == 0:
logpy.warn(f"Did not find parameters for pattern {pattern_}")
params.extend(pattern_params)
groups.append({"params": params, **args})
return groups, num_params
def configure_optimizers(self) -> List[torch.optim.Optimizer]:
if self.trainable_ae_params is None:
ae_params = self.get_autoencoder_params()
else:
ae_params, num_ae_params = self.get_param_groups(
self.trainable_ae_params, self.ae_optimizer_args
)
logpy.info(f"Number of trainable autoencoder parameters: {num_ae_params:,}")
if self.trainable_disc_params is None:
disc_params = self.get_discriminator_params()
else:
disc_params, num_disc_params = self.get_param_groups(
self.trainable_disc_params, self.disc_optimizer_args
)View on GitHub (pinned to e8cd657656)
Solutions
- Print [n for n, _ in model.named_parameters()] and fix the regex patterns to match actual names
- Verify trainable_ae_params/trainable_disc_params entries in the config match the model being instantiated
- Treat the warning as fatal during development (raise or assert) to catch config mistakes early
Example fix
// before
trainable_ae_params: [[{"name": "decder", "pattern": "decder\.", "lr": 1e-4}]] # typo
// after
trainable_ae_params: [[{"name": "decoder", "pattern": "^decoder\.", "lr": 1e-4}]] Defensive patterns
Strategy: validation
Validate before calling
import re
for group in trainable_params:
matched = [n for n, _ in model.named_parameters() if re.search(group["pattern"], n)]
assert matched, f"pattern {group['pattern']} matches nothing" Type guard
def pattern_matches(model, pattern: str) -> bool:
return any(re.search(pattern, n) for n, _ in model.named_parameters()) Try / catch
try:
groups, n = model.get_param_groups()
except Exception:
for name, _ in model.named_parameters():
print(name) # debug actual names Prevention
- Validate patterns against named_parameters in a startup check
- Copy patterns only from the same model variant
- Promote the get_param_groups warning to an error in tests
When it happens
Trigger: Configuring trainable_ae_params / trainable_disc_params with regex patterns like '^encoder\.' that do not match any parameter names of the autoencoder (e.g. pattern 'decoder.conv_in' when names are prefixed differently, or using '.*disc.*' on a model without a discriminator).
Common situations: Copy-pasting optimizer configs between AutoencoderKL variants, typos in YAML regex patterns, switching models where parameter names changed, or freezing everything so the pattern's params are excluded from named_parameters.
Related errors
- 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
- NotImplementedError
AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29).
Data as JSON: /api/errors/451be0ba8a56394f.
Report an issue: GitHub.