跳到内容

llmcompressor.modifiers.interface

ModifierInterface

基类:ABC

定义所有 modifier 必须实现的契约

方法

属性

  • finalized (bool) –

    :return: 如果修饰符已最终确定,则为 True

  • initialized (bool) –

    :return: 如果修饰符已初始化,则为 True

finalized abstractmethod property

finalized: bool

返回

  • bool

    如果修饰符已最终确定,则为 True

initialized abstractmethod property

initialized: bool

返回

  • bool

    如果修饰符已初始化,则为 True

finalize abstractmethod

finalize(state: State, **kwargs)

最终化 modifier

参数

  • state

    (State) –

    模型的当前状态

  • kwargs

    用于 modifier 最终化的附加关键字参数

源代码位于 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)

初始化 modifier

参数

  • state

    (State) –

    模型的当前状态

  • kwargs

    用于 modifier 初始化 的附加关键字参数

源代码位于 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)

根据事件更新 modifier

参数

  • state

    (State) –

    模型的当前状态

  • event

    (Event) –

    用于更新修饰符的事件

  • kwargs

    用于 modifier 更新的附加关键字参数

源代码位于 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()