Skip to content

Commit 3f5ab7f

Browse files
committed
Lazy torchao import (#384)
Import the dependency if and only if Int8 quantization is used
1 parent 1f7f01e commit 3f5ab7f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

quantize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import torch
1616
import torch.nn as nn
1717
import torch.nn.functional as F
18-
import torchao.quantization.quant_api as quant_api
1918
from build.utils import find_multiple, get_precision
2019

2120

@@ -76,6 +75,7 @@ def quantized_model(self) -> nn.Module:
7675

7776
class Int8DynActInt4WeightQuantizer(QuantHandler):
7877
def __init__(self, model: nn.Module, device="cpu", tokenizer=None, **kwargs):
78+
import torchao.quantization.quant_api as quant_api
7979
self.model_ = model
8080
self.device = device
8181
self.tokenizer = tokenizer

0 commit comments

Comments
 (0)