11
11
from abc import ABC , abstractmethod
12
12
from typing import Any , Callable , Dict , Optional , Tuple , Type
13
13
14
- import torch
15
-
16
14
17
15
class QuantConfigReader (ABC ):
18
16
"""Base class for reading and parsing quantization config."""
@@ -30,16 +28,18 @@ def read_config(self, config: Dict) -> Dict:
30
28
Parse and normalize a quantization config dictionary.
31
29
32
30
Args:
33
- config: The raw "quantization" field from the JSON file .
31
+ config: The raw parsed JSON object .
34
32
35
33
Returns:
36
- A processed and normalized config dictionary.
34
+ A dictionary of extra model kwargs derived from the quantization config.
35
+ Implementations must also populate self._quant_config with the normalized
36
+ quantization config.
37
37
"""
38
38
pass
39
39
40
40
@classmethod
41
41
@abstractmethod
42
- def from_file (cls , file_path : str ) -> Optional ["QuantConfigReader" ]:
42
+ def from_file (cls , file_path : str ) -> Optional [Tuple [ "QuantConfigReader" , Dict [ str , Any ]] ]:
43
43
"""
44
44
Load and parse a quantization config file from disk.
45
45
@@ -49,7 +49,7 @@ def from_file(cls, file_path: str) -> Optional["QuantConfigReader"]:
49
49
file_path: Path to the quant config JSON file.
50
50
51
51
Returns:
52
- An initialized QuantConfigReader instance , or None if the file doesn't exist.
52
+ A (reader, extra_model_kwargs) tuple , or None if the file doesn't exist.
53
53
"""
54
54
pass
55
55
@@ -109,7 +109,7 @@ def read_config(self, config: Dict) -> Dict:
109
109
@classmethod
110
110
def from_file (
111
111
cls , ckpt_dir : str
112
- ) -> Optional [Tuple ["ModelOPTQuantConfigReader" , Optional [ torch . dtype ]]]:
112
+ ) -> Optional [Tuple ["ModelOPTQuantConfigReader" , Dict [ str , Any ]]]:
113
113
"""
114
114
Load and parse a modelopt-style quantization config from a checkpoint directory.
115
115
0 commit comments