sparsegpt

Utility functions of SparseGPT.

Classes

SparseGPTSearcher

SparseGPT-based sparse mask searching algorithm.

Functions

create_sgpt_mask

Create a sparse mask for the given tensor.

invert

Invert a Hessian matrix.

prepare

Prepare the inverse Hessian matrix.

class SparseGPTSearcher

Bases: BaseSparseSearcher

SparseGPT-based sparse mask searching algorithm.

Remove Hessian artifcats from network.

Register the forward hook to collect the hessian matrix.

property default_search_config: Dict[str, Any]

Get the default config for the searcher.

create_sgpt_mask(tensor, hessian, config)

Create a sparse mask for the given tensor.

Parameters:
  • tensor (Tensor) –

  • hessian (Tensor) –

  • config (Dict[str, Any]) –

Return type:

Tensor

invert(hessian)

Invert a Hessian matrix.

Parameters:

hessian (Tensor) –

Return type:

Tensor

prepare(tensor, hessian, hessian_damp)

Prepare the inverse Hessian matrix.

Parameters:
  • tensor (Tensor) –

  • hessian (Tensor) –

  • hessian_damp (float) –

Return type:

Tuple[Tensor, Tensor]