Skip to content

Commit fbf94e0

Browse files
committed
fix: Added recompute_clips var to Qmax for eval mode
Signed-off-by: Brandon Groth <[email protected]>
1 parent 454391f commit fbf94e0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fms_mo/quant_refactor/quantizers_new.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2913,6 +2913,7 @@ def __init__(
29132913
self.perCh = perCh
29142914
self.extend_act_range = extend_act_range
29152915
self.perGp = perGp
2916+
self.recompute_clips = False
29162917

29172918
self.set_quantizer()
29182919

@@ -2997,7 +2998,7 @@ def forward(self, input):
29972998
if len(clipvaln_new.shape) == 0:
29982999
clipvaln_new = clipvaln_new.unsqueeze(dim=0)
29993000

3000-
if self.Niter == 0 and self.training:
3001+
if (self.Niter == 0 and self.training) or self.recompute_clips:
30013002
# to avoid unintended bwd ops added to the graph, cause memory leak sometimes
30023003
with torch.no_grad():
30033004
# similar to fill_(), will not change id(self.clip_val) but update the values

0 commit comments

Comments
 (0)