llmcompressor.transformers.utils.helpers
Helper variables and functions for integrating LLM Compressor with huggingface/transformers flows
Functions:
-
is_model_ct_quantized_from_path
–Determine if model from path is quantized based
infer_recipe_from_model_path
Infer the recipe from the model_path.
Parameters:
-
model_path
Union[str, Path]
) –The path to the model to load. It can be one of the following: - a path to the model directory - a path to the model file - Hugging face model ID
Returns:
-
Optional[str]
–The path to the recipe file if found, None otherwise.
Source code in llmcompressor/transformers/utils/helpers.py
is_model_ct_quantized_from_path
Determine if model from path is quantized based on the config
Parameters:
-
path
str
) –path to the model or HF stub
Returns:
-
bool
–True if config contains quantization_config from the given path
Source code in llmcompressor/transformers/utils/helpers.py
recipe_from_huggingface_model_id
recipe_from_huggingface_model_id(
hf_stub: str, recipe_file_name: str = RECIPE_FILE_NAME
) -> Optional[str]
Attempts to download the recipe from the Hugging Face model ID.
Parameters:
-
hf_stub
str
) –Assumed to be the Hugging Face model ID.
-
recipe_file_name
str
, default:RECIPE_FILE_NAME
) –The name of the recipe file to download. Defaults to RECIPE_FILE_NAME.
Returns:
-
Optional[str]
–A tuple: - The path to the recipe file if found, None otherwise. - True if hf_stub is a valid Hugging Face model ID, False otherwise.