Skip to content

Commit 7417662

Browse files
check recalc_clipvals
Signed-off-by: cliu-us <[email protected]>
1 parent 4c643a4 commit 7417662

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

fms_mo/modules/linear.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,11 @@ def from_fms_mo(cls, fms_mo_qlinear, **kwargs):
784784
Qa = fms_mo_qlinear.quantize_feature
785785
Qw = fms_mo_qlinear.quantize_weight
786786
# if no calibration has been run before swapping, clipvals stored in Qw will be the
787-
# original one, e.g. per-tensor. If want to experiment with new quantizers, need to run
788-
# at least one fwd, which will update the clipvals.
789-
Qw(fms_mo_qlinear.weight)
787+
# ones from ckpt or default. But if want to experiment with new quantizers different
788+
# from the ckpt, need to run one quantizer.fwd() to update the clipvals.
789+
# NOTE currently it will recalc by default, but user can choose to turn it off
790+
if kwargs.get("recalc_clipvals", True):
791+
Qw(fms_mo_qlinear.weight)
790792
w_cv = Qw.clip_val
791793
a_cv = getattr(Qa, "clip_val", torch.tensor(8.0, device=tar_dev))
792794
a_cvn = getattr(Qa, "clip_valn", torch.tensor(-8.0, device=tar_dev))

0 commit comments

Comments
 (0)