llmcompressor.modifiers.factory
Classes:
-
ModifierFactory
–A factory for loading and registering modifiers
ModifierFactory
A factory for loading and registering modifiers
Methods:
-
create
–Instantiate a modifier of the given type from registered modifiers.
-
load_from_package
–:param package_path: The path to the package to load modifiers from
-
refresh
–A method to refresh the factory by reloading the modifiers
-
register
–Register a modifier class to be used by the factory.
create staticmethod
Instantiate a modifier of the given type from registered modifiers.
Parameters:
-
type_
str
) –The type of modifier to create
-
framework
The framework the modifier is for
-
allow_registered
bool
) –Whether or not to allow registered modifiers
-
allow_experimental
bool
) –Whether or not to allow experimental modifiers
-
kwargs
Additional keyword arguments to pass to the modifier during instantiation
Returns:
-
Modifier
–The instantiated modifier
Raises:
-
ValueError
–If no modifier of the given type is found
Source code in llmcompressor/modifiers/factory.py
load_from_package staticmethod
Parameters:
-
package_path
str
) –The path to the package to load modifiers from
Returns:
-
Dict[str, Type[Modifier]]
–The loaded modifiers, as a mapping of name to class
Source code in llmcompressor/modifiers/factory.py
refresh staticmethod
A method to refresh the factory by reloading the modifiers Note: this will clear any previously registered modifiers
Source code in llmcompressor/modifiers/factory.py
register staticmethod
Register a modifier class to be used by the factory.
Parameters:
-
type_
str
) –The type of modifier to register
-
modifier_class
Type[Modifier]
) –The class of the modifier to register, must subclass the Modifier base class
Raises:
-
ValueError
–If the provided class does not subclass the Modifier base class or is not a type