File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
src/llmcompressor/entrypoints/weights_ptq Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,16 @@ def ptq_weights(
4040 max_workers : int = 1 ,
4141 device : Optional [torch .device | str ] = None ,
4242):
43+ """
44+ Name TBD
45+
46+ :param model_stub: huggingface model hub or path to local weights files
47+ :param scheme: weight quantization scheme or preset scheme name
48+ :param ignore: modules to ignore. Modules ending with "norm" are automatically
49+ ignored
50+ :param max_workers: number of worker threads to process files with
51+ :param device: gpu device to accelerate quantization with
52+ """
4353 # validate arguments
4454 model_files = get_checkpoint_files (model_stub )
4555 scheme_name , scheme = validate_scheme (scheme )
@@ -87,6 +97,16 @@ def _process_file(
8797 ignore : str | list [str ],
8898 device : str | torch .device ,
8999) -> tuple [int , dict [str , str ]]:
100+ """
101+ Quantize and compress tensors in a given safetensors file
102+
103+ :param file_path: safetensors file to process
104+ :param save_path: save path of file with quantized weights
105+ :param scheme: quantization scheme to apply to tensors
106+ :param ignore: modules to ignore. Modules ending with "norm" are automatically
107+ ignored
108+ :param device: device used to quantize and compress weights
109+ """
90110 tensors = load_file (file_path )
91111
92112 for name in list (tensors .keys ()):
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ def get_checkpoint_files(model_stub: str | os.PathLike) -> list[str]:
3030
3131
3232def walk_file_paths (root_dir : str , ignore : str | None = None ) -> list [str ]:
33+ """
34+ Return all file paths relative to the root directory
35+ """
36+
3337 all_files = []
3438 for dirpath , _ , filenames in os .walk (root_dir ):
3539 for filename in filenames :
You can’t perform that action at this time.
0 commit comments