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_dir
Any
) –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_path
str
) –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_arg
Union[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_path
str
) –Path used to save model and processor
-
model
PreTrainedModel
) –model to save
-
processor
Optional[Processor]
, default:None
) –processor to save
-
save_safetensors
bool
, default:True
) –save model checkpoint using safetensors file type
-
save_compressed
bool
, 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_dir
str
) –model checkpoint directory to save stages to
-
completed_stages
List[str]
) –list of stage names that have been run