File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
src/llmcompressor/modifiers/quantization Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 5
5
from compressed_tensors .quantization import (
6
6
DynamicType ,
7
7
KVCacheScaleType ,
8
+ QuantizationArgs ,
8
9
QuantizationScheme ,
9
10
QuantizationStatus ,
10
11
QuantizationStrategy ,
@@ -48,16 +49,17 @@ def initialize_observer(
48
49
:param base_name: str used to name the observer attribute
49
50
50
51
"""
51
-
52
- arg_name = "weights" if base_name == "weight" else f"{ base_name } _activations"
53
- quantization_scheme = getattr (module , "quantization_scheme" , None )
54
- if not quantization_scheme :
55
- # no quantization scheme nothing to do
56
- return
57
-
58
- args = getattr (quantization_scheme , arg_name , None )
59
- # dont need observers for dynamic
60
- if args is not None and args .dynamic in (False , DynamicType .LOCAL ):
52
+ if base_name == "weight" :
53
+ arg_name = "weights"
54
+ elif base_name == "output" :
55
+ arg_name = "output_activations"
56
+ else : # input, q, k, v
57
+ arg_name = "input_activations"
58
+
59
+ args : QuantizationArgs = getattr_chain (
60
+ module , f"quantization_scheme.{ arg_name } " , None
61
+ )
62
+ if args is not None and args .dynamic is not True :
61
63
observer = Observer .load_from_registry (
62
64
args .observer , base_name = base_name , args = args , module = module
63
65
)
You can’t perform that action at this time.
0 commit comments