llmcompressor.entrypoints.utils
Utility functions for entrypoint pre and post-processing operations.
Provides common utility functions used by the one-shot entrypoint. Includes model loading, configuration setup, preprocessing steps, and post-processing operations for compression workflows.
Functions:
-
post_process–Saves the model and tokenizer/processor to the output directory if model_args,
-
pre_process–Prepares the model and tokenizer/processor for calibration.
post_process
post_process(
model_args: ModelArguments | None = None,
recipe_args: RecipeArguments | None = None,
output_dir: str | None = None,
)
Saves the model and tokenizer/processor to the output directory if model_args, output_dir is provided.
If the output_dir is not the default directory, the method resets lifecycle actions. The model is saved in a compressed format if specified in model_args. Additionally, the tokenizer or processor, if available, is also saved.
Raises: ValueError: If saving fails due to an invalid output_dir or other issues.
Source code in llmcompressor/entrypoints/utils.py
pre_process
Prepares the model and tokenizer/processor for calibration. - Initializes the model if it's specified as a path or string. - Applies patches to fix tied tensor issues and modifies save_pretrained behavior. - Initializes the processor if specified as a path or None. - Sets the minimum tokens per module if dataset_args are provided. Raises: FileNotFoundError: If the model or processor path is invalid.