llmcompressor.pytorch.utils.sparsification_info.configs
Classes:
-
SparsificationInfo
– -
SparsificationPruning
–A model that contains the pruning information for a torch module.
-
SparsificationQuantization
–A model that contains the quantization information for a torch module.
-
SparsificationSummaries
–A model that contains the sparsification summaries for a torch module.
SparsificationInfo
Bases: BaseModel
, ABC
Methods:
-
filter_loggable_items_non_zero_only
–Filter the loggable items to only yield the non-zero items
-
filter_loggable_items_percentages_only
–Filter the loggable items to only yield the percentages of the loggable items
-
from_module
–Factory method to create SparsificationInfo object from a module.
-
loggable_items
–Yield the loggable items for SparsificationInfo object.
filter_loggable_items_non_zero_only staticmethod
Filter the loggable items to only yield the non-zero items
Parameters:
-
items_to_log
A generator that yields the loggable items for this object.
-
non_zero_only
If True, only yield information for non-zero items.
Returns:
- –
A generator that yields the loggable items for this object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
filter_loggable_items_percentages_only staticmethod
filter_loggable_items_percentages_only(
items_to_log: Generator[Tuple[str, Any], None, None],
percentage_only: bool = False,
)
Filter the loggable items to only yield the percentages of the loggable items
Parameters:
-
items_to_log
Generator[Tuple[str, Any], None, None]
) –A generator that yields the loggable items for this object.
-
percentage_only
bool
, default:False
) –If True, only yield the percentages of the loggable items. If False, yield both the counts and percentages. Defaults to False
Returns:
- –
A generator that yields the loggable items for this object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
from_module abstractmethod
classmethod
Factory method to create SparsificationInfo object from a module.
Parameters:
-
module
Module
) –The module to create the SparsificationInfo object from.
-
kwargs
Additional arguments to pass to the SparsificationInfo object.
Returns:
-
SparsificationInfo
–A SparsificationInfo object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items abstractmethod
loggable_items(
**kwargs,
) -> Generator[
Tuple[str, Union[Dict[str, int], float, int]],
None,
None,
]
Yield the loggable items for SparsificationInfo object.
Returns:
-
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None]
–A generator that yields the loggable items for this object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
SparsificationPruning
Bases: SparsificationInfo
A model that contains the pruning information for a torch module.
Methods:
-
from_module
–Factory method to create a SparsificationPruning object from a module.
-
loggable_items
–Yield the loggable items for SparsificationPruning object.
from_module classmethod
Factory method to create a SparsificationPruning object from a module.
Parameters:
-
module
Module
) –The module to create the SparsificationPruning object from.
Returns:
-
SparsificationPruning
–A SparsificationPruning object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items
loggable_items(
percentages_only: bool = False,
non_zero_only: bool = False,
**kwargs
) -> Generator[
Tuple[str, Union[Dict[str, int], float, int]],
None,
None,
]
Yield the loggable items for SparsificationPruning object.
Parameters:
-
percentages_only
bool
, default:False
) –If True, only yield the percentages of the loggable items. If False, yield both the counts and percentages. Default is False.
-
non_zero_only
bool
, default:False
) –If True, only yield information for non-zero counts/percentages. Default is False.
Returns:
-
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None]
–A generator that yields the loggable items for this object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
SparsificationQuantization
Bases: SparsificationInfo
A model that contains the quantization information for a torch module.
Methods:
-
from_module
–Factory method to create a SparsificationQuantization object from a module.
-
loggable_items
–Yield the loggable items for SparsificationQuantization object.
from_module classmethod
Factory method to create a SparsificationQuantization object from a module.
Parameters:
-
module
Module
) –The module to create the SparsificationQuantization object from.
Returns:
-
SparsificationQuantization
–A SparsificationQuantization object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items
loggable_items(
enabled_only: bool = False, **kwargs
) -> Generator[
Tuple[str, Union[Dict[str, int], float, int]],
None,
None,
]
Yield the loggable items for SparsificationQuantization object.
Parameters:
-
enabled_only
bool
, default:False
) –If True, only yield loggable items for operations where quantization is enabled. If False, yield irrespective of whether quantization is enabled or not. Defaults to False.
Returns:
-
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None]
–A generator that yields the loggable items for this object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
SparsificationSummaries
Bases: SparsificationInfo
A model that contains the sparsification summaries for a torch module.
Methods:
-
from_module
–Factory method to create a SparsificationSummaries object from a module.
-
loggable_items
–Yield the loggable items for SparsificationSummaries object.
from_module classmethod
from_module(
module=torch.nn.Module,
pruning_thresholds: Tuple[float, float] = (
0.05,
1 - 1e-09,
),
) -> SparsificationSummaries
Factory method to create a SparsificationSummaries object from a module.
Parameters:
-
module
The module to create the SparsificationSummaries object from.
-
pruning_thresholds
Tuple[float, float]
, default:(0.05, 1 - 1e-09)
) –The lower and upper thresholds used to determine whether a parameter is pruned. If it's percentage of zero weights is between the lower and upper thresholds, it is considered pruned.
Returns:
-
SparsificationSummaries
–A SparsificationSummaries object.
Source code in llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items
loggable_items(
non_zero_only: bool = False,
percentages_only: bool = True,
**kwargs
) -> Generator[
Tuple[str, Union[Dict[str, int], float, int]],
None,
None,
]
Yield the loggable items for SparsificationSummaries object.
Parameters:
-
non_zero_only
bool
, default:False
) –If True, only yield information for non-zero items.
-
percentages_only
bool
, default:True
) –If True, only yield the percentages of the loggable items. If False, yield both the counts and percentages. Defaults to True
Returns:
-
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None]
–A generator that yields the loggable items for this object.