llmcompressor.pytorch.utils.sparsification_info.configs
SparsificationInfo
Bases: BaseModel
, ABC
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
filter_loggable_items_non_zero_only(items_to_log, non_zero_only)
staticmethod
Filter the loggable items to only yield the non-zero items
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items_to_log | A generator that yields the loggable items for this object. | required | |
non_zero_only | If True, only yield information for non-zero items. | required |
Returns:
Type | Description |
---|---|
A generator that yields the loggable items for this object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
filter_loggable_items_percentages_only(items_to_log, percentage_only=False)
staticmethod
Filter the loggable items to only yield the percentages of the loggable items
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items_to_log | Generator[Tuple[str, Any], None, None] | A generator that yields the loggable items for this object. | required |
percentage_only | bool | If True, only yield the percentages of the loggable items. If False, yield both the counts and percentages. Defaults to False | False |
Returns:
Type | Description |
---|---|
A generator that yields the loggable items for this object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
from_module(module, **kwargs)
abstractmethod
classmethod
Factory method to create SparsificationInfo object from a module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module | Module | The module to create the SparsificationInfo object from. | required |
kwargs | Additional arguments to pass to the SparsificationInfo object. | {} |
Returns:
Type | Description |
---|---|
SparsificationInfo | A SparsificationInfo object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items(**kwargs)
abstractmethod
Yield the loggable items for SparsificationInfo object.
Returns:
Type | Description |
---|---|
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None] | A generator that yields the loggable items for this object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
SparsificationPruning
Bases: SparsificationInfo
A model that contains the pruning information for a torch module.
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
from_module(module)
classmethod
Factory method to create a SparsificationPruning object from a module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module | Module | The module to create the SparsificationPruning object from. | required |
Returns:
Type | Description |
---|---|
SparsificationPruning | A SparsificationPruning object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items(percentages_only=False, non_zero_only=False, **kwargs)
Yield the loggable items for SparsificationPruning object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
percentages_only | bool | If True, only yield the percentages of the loggable items. If False, yield both the counts and percentages. Default is False. | False |
non_zero_only | bool | If True, only yield information for non-zero counts/percentages. Default is False. | False |
Returns:
Type | Description |
---|---|
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None] | A generator that yields the loggable items for this object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
SparsificationQuantization
Bases: SparsificationInfo
A model that contains the quantization information for a torch module.
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
|
from_module(module)
classmethod
Factory method to create a SparsificationQuantization object from a module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module | Module | The module to create the SparsificationQuantization object from. | required |
Returns:
Type | Description |
---|---|
SparsificationQuantization | A SparsificationQuantization object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items(enabled_only=False, **kwargs)
Yield the loggable items for SparsificationQuantization object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
enabled_only | bool | 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. | False |
Returns:
Type | Description |
---|---|
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None] | A generator that yields the loggable items for this object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
SparsificationSummaries
Bases: SparsificationInfo
A model that contains the sparsification summaries for a torch module.
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
|
from_module(module=torch.nn.Module, pruning_thresholds=(0.05, 1 - 1e-09))
classmethod
Factory method to create a SparsificationSummaries object from a module.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module | The module to create the SparsificationSummaries object from. | Module | |
pruning_thresholds | Tuple[float, float] | 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. | (0.05, 1 - 1e-09) |
Returns:
Type | Description |
---|---|
SparsificationSummaries | A SparsificationSummaries object. |
Source code in src/llmcompressor/pytorch/utils/sparsification_info/configs.py
loggable_items(non_zero_only=False, percentages_only=True, **kwargs)
Yield the loggable items for SparsificationSummaries object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
non_zero_only | bool | If True, only yield information for non-zero items. | False |
percentages_only | bool | If True, only yield the percentages of the loggable items. If False, yield both the counts and percentages. Defaults to True | True |
Returns:
Type | Description |
---|---|
Generator[Tuple[str, Union[Dict[str, int], float, int]], None, None] | A generator that yields the loggable items for this object. |