llmcompressor.pytorch.model_load.helpers
Functions:
-
get_completed_stages–Given a checkpoint directory for a staged run, get the list of stages that
-
get_session_model–:return: pytorch module stored by the active CompressionSession,
-
parse_dtype–:param dtype_arg: dtype or string to parse
-
save_checkpoint–Save a model, processor, and recipe
-
save_completed_stages–Save a list of completed stages to a checkpoint directory
get_completed_stages
Given a checkpoint directory for a staged run, get the list of stages that have completed in a prior run if the checkpoint_dir is a string
Parameters:
-
(checkpoint_dirAny) –path to staged checkpoint
Returns:
-
List[str]–list of completed stage names
Source code in llmcompressor/pytorch/model_load/helpers.py
get_session_model
Returns:
-
Optional[Module]–pytorch module stored by the active CompressionSession, or None if no session is active
Source code in llmcompressor/pytorch/model_load/helpers.py
load_safetensors_state_dict
Load a safetensors file from disk
Parameters:
-
(file_pathstr) –path to the safetensors file
Returns:
-
Dict[str, Tensor]–dictionary of safetensors data
Source code in llmcompressor/pytorch/model_load/helpers.py
parse_dtype
Parameters:
-
(dtype_argUnion[str, dtype]) –dtype or string to parse
Returns:
-
dtype–torch.dtype parsed from input string
Source code in llmcompressor/pytorch/model_load/helpers.py
save_checkpoint
save_checkpoint(
save_path: str,
model: PreTrainedModel,
processor: Optional[Processor] = None,
save_safetensors: bool = True,
save_compressed: bool = True,
skip_sparsity_compression_stats: bool = False,
)
Save a model, processor, and recipe
Parameters:
-
(save_pathstr) –Path used to save model and processor
-
(modelPreTrainedModel) –model to save
-
(processorOptional[Processor], default:None) –processor to save
-
(save_safetensorsbool, default:True) –save model checkpoint using safetensors file type
-
(save_compressedbool, default:True) –save model checkpoint using compressed-tensors format
Source code in llmcompressor/pytorch/model_load/helpers.py
save_completed_stages
Save a list of completed stages to a checkpoint directory
Parameters:
-
(checkpoint_dirstr) –model checkpoint directory to save stages to
-
(completed_stagesList[str]) –list of stage names that have been run