Skip to content

llmcompressor.pipelines.registry

Classes:

CalibrationPipeline

Bases: ABC, RegistryMixin

Methods:

  • from_modifiers –

    Infer which calibration pipeline to use based on the available modifiers and

from_modifiers classmethod

from_modifiers(
    modifiers: list[Modifier], user: str | None = None
) -> CalibrationPipeline

Infer which calibration pipeline to use based on the available modifiers and any user specifications

Parameters:

  • modifiers (list[Modifier]) –

    modifiers to apply to model

  • user (str | None, default: None ) –

    pipeline name passed by user

Returns:

  • CalibrationPipeline –

    CalibrationPipeline instance to be called with data (if not datafree)

Source code in src/llmcompressor/pipelines/registry.py
@classmethod
def from_modifiers(
    cls, modifiers: list[Modifier], user: str | None = None
) -> "CalibrationPipeline":
    """
    Infer which calibration pipeline to use based on the available modifiers and
    any user specifications

    :param modifiers: modifiers to apply to model
    :param user: pipeline name passed by user
    :return: CalibrationPipeline instance to be called with data (if not datafree)
    """
    user = standardize_lookup_name(user) if user else None
    inferred = standardize_lookup_name(cls._infer_pipeline(modifiers))
    independent = standardize_lookup_name("independent")
    deferred_transform = cls._deferred_transform_precedes_quantization(modifiers)

    if deferred_transform is not None or user == independent:
        inferred = independent

    if user is not None and user != inferred:
        if deferred_transform is not None:
            logger.warning(
                f"User requested pipeline {user} but when {deferred_transform} "
                "is followed by a quantization modifier, the independent "
                "calibration pipeline is recommended. Change or remove the "
                "pipeline argument in oneshot if you'd like to use the "
                "recommended pipeline"
            )
        else:
            logger.warning(
                f"Calibration pipeline is set to `{user}`, but it is recommended "
                f"to use `{inferred}`"
            )

    pipeline = user or inferred
    return cls.load_from_registry(pipeline)