Lightning-AI/pytorch-lightning · error · MisconfigurationException
When requesting `ln_structured` pruning, the `pruning_norm`
Error message
When requesting `ln_structured` pruning, the `pruning_norm` should be provided.
What it means
The 'ln_structured' (ln-norm) PyTorch pruning method requires the norm order n in addition to the dimension. If pruning_fn == 'ln_structured' and pruning_norm is None, ModelPruning raises MisconfigurationException in __init__.
Source
Thrown at src/lightning/pytorch/callbacks/pruning.py:194
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:
raise MisconfigurationException(
"When requesting `ln_structured` pruning, the `pruning_norm` should be provided."
)
pruning_kwargs["n"] = pruning_norm
pruning_kwargs["dim"] = pruning_dim
pruning_fn = self._create_pruning_fn(pruning_fn, **pruning_kwargs)
elif self._is_pruning_method(pruning_fn):
if not use_global_unstructured:
raise MisconfigurationException(
"PyTorch `BasePruningMethod` is currently only supported with `use_global_unstructured=True`."
)
else:
raise MisconfigurationException(
f"`pruning_fn` is expected to be a str in {list(_PYTORCH_PRUNING_FUNCTIONS.keys())}"
f" or a PyTorch `BasePruningMethod`. Found: {pruning_fn}."
" HINT: if passing a `BasePruningMethod`, pass the class, not an instance"
)
# need to ignore typing here since pytorch base class does not define the PRUNING_TYPE attributeView on GitHub (pinned to 9fed5c27d2)
Solutions
- Set pruning_norm to the desired norm order, e.g., pruning_norm=1 (L1) or 2 (L2)
- Double-check that pruning_fn really needs to be ln_structured; l1-like selection with random_structured needs no norm
Example fix
# before ModelPruning(pruning_fn='ln_structured', pruning_dim=0) # after ModelPruning(pruning_fn='ln_structured', pruning_norm=1, pruning_dim=0)
Defensive patterns
Strategy: validation
Validate before calling
if pruning_fn == 'ln_structured':
assert pruning_norm is not None and pruning_dim is not None Prevention
- Check ln_structured requirements (n and dim) together
- Prefer l1_unstructured unless channel pruning is required
When it happens
Trigger: ModelPruning(pruning_fn='ln_structured', pruning_dim=0) without pruning_norm; supplying dim but assuming a default norm exists (there is none in this callback).
Common situations: Mirroring torch.nn.utils.prune.ln_structured docs but omitting n; switching from random_structured where no norm is needed.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- When requesting `structured` pruning, the `pruning_dim` shou
- The provided `parameter_names` name: {name} isn't in {self.P
- The provided `pruning_fn` {pruning_fn} isn't available in Py
- PyTorch `BasePruningMethod` is currently only supported with
- `pruning_fn` is expected to be a str in {list(_PYTORCH_PRUNI
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/94ec4b2474a8b132.
Report an issue: GitHub.