@@ -116,7 +116,7 @@ def validate_scheme(
116116
117117 def initialize_quantization (self , model : torch .nn .Module ):
118118 """
119- Attach quantization schemes and observers to modules in the model according to
119+ Attach quantization schemes to modules in the model according to
120120 the quantization config specified on this modifier
121121
122122 :param model: model to attach schemes and observers to
@@ -127,25 +127,25 @@ def initialize_quantization(self, model: torch.nn.Module):
127127 config = self .resolve_quantization_config ()
128128 apply_quantization_config (model , config )
129129
130- # apply observers, disable quantization until calibration
131- model .apply (self ._initialize_observers )
130+ # disable quantization until calibration
132131 model .apply (disable_quantization )
133132
134133 def start_calibration (self , model : torch .nn .Module ):
135134 """
136- Register activation calibration hooks (including kv_cache quantization) and
137- enable quantization as we calibrate
135+ Attach observers, register activation calibration hooks (including
136+ kv_cache quantization) and enable quantization as we calibrate
138137
139138 :param model: model to prepare for calibration
140139 """
141140 self ._calibration_hooks = self ._initialize_hooks (model )
141+ model .apply (self ._initialize_observers )
142142 model .apply (apply_calibration_status )
143143 model .apply (enable_quantization ) # quantize at the same time as calibrate
144144
145145 def end_calibration (self , model : torch .nn .Module ):
146146 """
147- Remove calibration hooks and set the model status to frozen. Keep quantization
148- enabled for future operations
147+ Remove calibration hooks and observers, and set the model status to frozen.
148+ Keep quantization enabled for future operations
149149
150150 :param model: model to end calibration for
151151 """
0 commit comments