Lightning-AI/pytorch-lightning · error · MisconfigurationException
The provided `parameter_names` name: {name} isn't in {self.P
Error message
The provided `parameter_names` name: {name} isn't in {self.PARAMETER_NAMES} What it means
ModelPruning prunes parameters by name (e.g., 'weight' or 'bias') on the modules you list. Each name in parameter_names must exist in the callback's PARAMETER_NAMES set; otherwise __init__ raises MisconfigurationException listing the accepted names.
Source
Thrown at src/lightning/pytorch/callbacks/pruning.py:175
if ``pruning_norm`` is not provided when ``"ln_structured"``,
if ``pruning_fn`` is neither ``str`` nor :class:`torch.nn.utils.prune.BasePruningMethod`, or
if ``amount`` is none of ``int``, ``float`` and ``Callable``.
"""
self._use_global_unstructured = use_global_unstructured
self._parameters_to_prune = parameters_to_prune
self._use_lottery_ticket_hypothesis = use_lottery_ticket_hypothesis
self._resample_parameters = resample_parameters
self._prune_on_train_epoch_end = prune_on_train_epoch_end
self._parameter_names = parameter_names or self.PARAMETER_NAMES
self._global_kwargs: dict[str, Any] = {}
self._original_layers: Optional[dict[int, _LayerRef]] = None
self._pruning_method_name: Optional[str] = None
for name in self._parameter_names:
if name not in self.PARAMETER_NAMES:
raise MisconfigurationException(
f"The provided `parameter_names` name: {name} isn't in {self.PARAMETER_NAMES}"
)
if isinstance(pruning_fn, str):
pruning_kwargs = {}
pruning_fn = pruning_fn.lower()
if pruning_fn not in _PYTORCH_PRUNING_FUNCTIONS:
raise MisconfigurationException(
f"The provided `pruning_fn` {pruning_fn} isn't available in PyTorch's"
f" built-in functions: {list(_PYTORCH_PRUNING_FUNCTIONS.keys())} "
)
if pruning_fn.endswith("_structured"):
if pruning_dim is None:
raise MisconfigurationException(
"When requesting `structured` pruning, the `pruning_dim` should be provided."
)
if pruning_fn == "ln_structured":
if pruning_norm is None:View on GitHub (pinned to 9fed5c27d2)
Solutions
- Restrict parameter_names to the supported set: ['weight'] and/or ['bias']
- Check available names via the callback's PARAMETER_NAMES attribute before constructing
- For custom-named parameters, subclass ModelPruning and override filter_parameters_to_prune to map to the real attributes
Example fix
# before ModelPruning(parameter_names=['weights']) # after ModelPruning(parameter_names=['weight'])
Defensive patterns
Strategy: validation
Validate before calling
from lightning.pytorch.callbacks.pruning import ModelPruning
assert set(names).issubset(ModelPruning.PARAMETER_NAMES), f'allowed: {ModelPruning.PARAMETER_NAMES}' Type guard
def valid_param_names(names) -> bool:
return set(names).issubset({'weight', 'bias'}) Prevention
- Inspect PARAMETER_NAMES on the callback class before writing configs
- Use only 'weight'/'bias' unless subclassing
When it happens
Trigger: Passing parameter_names=['weights'], ['keras_weight'], or any string not in PARAMETER_NAMES (typically {'weight','bias'}) to ModelPruning; singular/plural or casing mistakes in config.
Common situations: Assuming arbitrary attribute names work; configs written for other pruning tools; misspelling 'weight'.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The provided `pruning_fn` {pruning_fn} isn't available in Py
- `verbose` must be any of (0, 1, 2)
- The provided `parameters_to_prune` should either be list of
- Invalid value for every_n_train_steps={self._every_n_train_s
- Invalid value for every_n_epochs={self._every_n_epochs}. Mus
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/b28e8a0e2dfc885c.
Report an issue: GitHub.