{"record":{"id":"94ec4b2474a8b132","repo":"Lightning-AI/pytorch-lightning","slug":"when-requesting-ln-structured-pruning-the-prun","errorCode":null,"errorMessage":"When requesting `ln_structured` pruning, the `pruning_norm` should be provided.","messagePattern":"When requesting `ln_structured` pruning, the `pruning_norm` should be provided\\.","errorType":"exception","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/callbacks/pruning.py","lineNumber":194,"sourceCode":"                    f\"The provided `parameter_names` name: {name} isn't in {self.PARAMETER_NAMES}\"\n                )\n\n        if isinstance(pruning_fn, str):\n            pruning_kwargs = {}\n            pruning_fn = pruning_fn.lower()\n            if pruning_fn not in _PYTORCH_PRUNING_FUNCTIONS:\n                raise MisconfigurationException(\n                    f\"The provided `pruning_fn` {pruning_fn} isn't available in PyTorch's\"\n                    f\" built-in functions: {list(_PYTORCH_PRUNING_FUNCTIONS.keys())} \"\n                )\n            if pruning_fn.endswith(\"_structured\"):\n                if pruning_dim is None:\n                    raise MisconfigurationException(\n                        \"When requesting `structured` pruning, the `pruning_dim` should be provided.\"\n                    )\n                if pruning_fn == \"ln_structured\":\n                    if pruning_norm is None:\n                        raise MisconfigurationException(\n                            \"When requesting `ln_structured` pruning, the `pruning_norm` should be provided.\"\n                        )\n                    pruning_kwargs[\"n\"] = pruning_norm\n                pruning_kwargs[\"dim\"] = pruning_dim\n            pruning_fn = self._create_pruning_fn(pruning_fn, **pruning_kwargs)\n        elif self._is_pruning_method(pruning_fn):\n            if not use_global_unstructured:\n                raise MisconfigurationException(\n                    \"PyTorch `BasePruningMethod` is currently only supported with `use_global_unstructured=True`.\"\n                )\n        else:\n            raise MisconfigurationException(\n                f\"`pruning_fn` is expected to be a str in {list(_PYTORCH_PRUNING_FUNCTIONS.keys())}\"\n                f\" or a PyTorch `BasePruningMethod`. Found: {pruning_fn}.\"\n                \" HINT: if passing a `BasePruningMethod`, pass the class, not an instance\"\n            )\n\n        # need to ignore typing here since pytorch base class does not define the PRUNING_TYPE attribute","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/callbacks/pruning.py#L176-L212","documentation":"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__.","triggerScenarios":"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).","commonSituations":"Mirroring torch.nn.utils.prune.ln_structured docs but omitting n; switching from random_structured where no norm is needed.","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"],"exampleFix":"# before\nModelPruning(pruning_fn='ln_structured', pruning_dim=0)\n# after\nModelPruning(pruning_fn='ln_structured', pruning_norm=1, pruning_dim=0)","handlingStrategy":"validation","validationCode":"if pruning_fn == 'ln_structured':\n    assert pruning_norm is not None and pruning_dim is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check ln_structured requirements (n and dim) together","Prefer l1_unstructured unless channel pruning is required"],"tags":["pytorch-lightning","pruning","ln-structured","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}