Skip to content

llmcompressor.modifiers.interface

Classes:

ModifierInterface

Bases: ABC

Defines the contract that all modifiers must implement

Methods:

Attributes:

  • finalized (bool) –

    :return: True if the modifier has been finalized

  • initialized (bool) –

    :return: True if the modifier has been initialized

finalized abstractmethod property

finalized: bool

Returns:

  • bool

    True if the modifier has been finalized

initialized abstractmethod property

initialized: bool

Returns:

  • bool

    True if the modifier has been initialized

finalize abstractmethod

finalize(state: State, **kwargs)

Finalize the modifier

Parameters:

  • state

    (State) –

    The current state of the model

  • kwargs

    Additional keyword arguments for modifier finalization

Source code in llmcompressor/modifiers/interface.py
@abstractmethod
def finalize(self, state: State, **kwargs):
    """
    Finalize the modifier

    :param state: The current state of the model
    :param kwargs: Additional keyword arguments for
        modifier finalization
    """
    raise NotImplementedError()

initialize abstractmethod

initialize(state: State, **kwargs)

Initialize the modifier

Parameters:

  • state

    (State) –

    The current state of the model

  • kwargs

    Additional keyword arguments for modifier initialization

Source code in llmcompressor/modifiers/interface.py
@abstractmethod
def initialize(self, state: State, **kwargs):
    """
    Initialize the modifier

    :param state: The current state of the model
    :param kwargs: Additional keyword arguments
        for modifier initialization
    """
    raise NotImplementedError()

update_event abstractmethod

update_event(state: State, event: Event, **kwargs)

Update the modifier based on the event

Parameters:

  • state

    (State) –

    The current state of the model

  • event

    (Event) –

    The event to update the modifier with

  • kwargs

    Additional keyword arguments for modifier update

Source code in llmcompressor/modifiers/interface.py
@abstractmethod
def update_event(self, state: State, event: Event, **kwargs):
    """
    Update the modifier based on the event

    :param state: The current state of the model
    :param event: The event to update the modifier with
    :param kwargs: Additional keyword arguments for
        modifier update
    """
    raise NotImplementedError()