Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

remove costly operations

wenhuach21ad3a7bba57bd
diff --git a/auto_round/autoround.py b/auto_round/autoround.py
index ba3b74a99..59e076d66 100644
--- a/auto_round/autoround.py
+++ b/auto_round/autoround.py
@@ -954,7 +954,6 @@ class AutoRound(object):
init_loss = total_loss
self.scale_loss_and_backward(scaler, loss)
- torch.cuda.empty_cache()
if total_loss < best_loss:
best_loss = total_loss
@@ -1090,12 +1089,10 @@ class AutoRound(object):
)
total_loss += loss.item() / self.gradient_accumulate_steps
- torch.cuda.empty_cache()
if i == 0:
init_loss = total_loss
self.scale_loss_and_backward(scaler, loss)
- torch.cuda.empty_cache()
if total_loss < best_loss:
best_loss = total_loss