unstructured
unstructured
¶
Global L1 unstructured weight pruning.
UnstructuredPruner
¶
Bases: BasePruner
Global L1 unstructured pruning across all target layers.
Initialize with pruning amount and target layer types.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amount
|
float
|
Fraction of weights to zero, must be in (0, 1). |
required |
layer_types
|
list[str] | None
|
PrunableLayerType values to target. Defaults to convolution and linear layers (normalization scales and embedding tables are usually not good pruning targets). |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If amount is not in the open interval (0, 1). |
Source code in src/versatil/post_training_compression/pruning/unstructured.py
prune
¶
Apply global L1 unstructured pruning.
Identifies all target layers, applies global L1 unstructured pruning, then removes the pruning reparametrization to make weights permanent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
Neural network module to prune. |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int]
|
Tuple of (total_parameters, zero_parameters). |