File tree Expand file tree Collapse file tree 2 files changed +8
-5
lines changed
neural_compressor/torch/quantization
test/3x/torch/quantization/weight_only Expand file tree Collapse file tree 2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -402,7 +402,7 @@ def autoround_quantize_entry(
402
402
if getattr (model , "quantizer" , False ):
403
403
del model .quantizer
404
404
else :
405
- model .quantizer = quantizer
405
+ model .quantizer = quantizer
406
406
logger .info ("AutoRound quantization done." )
407
407
return model
408
408
Original file line number Diff line number Diff line change
1
+ import copy
2
+
1
3
import pytest
2
4
import torch
3
5
import transformers
4
- import copy
5
6
6
7
from neural_compressor .torch .algorithms .weight_only .autoround import AutoRoundQuantizer , get_autoround_default_run_fn
7
8
from neural_compressor .torch .quantization import (
20
21
except ImportError :
21
22
auto_round_installed = False
22
23
24
+
23
25
def get_gpt_j ():
24
26
tiny_gptj = transformers .AutoModelForCausalLM .from_pretrained (
25
27
"hf-internal-testing/tiny-random-GPTJForCausalLM" ,
26
28
torchscript = True ,
27
29
)
28
30
return tiny_gptj
29
31
32
+
30
33
@pytest .mark .skipif (not auto_round_installed , reason = "auto_round module is not installed" )
31
34
class TestAutoRound :
32
35
def setup_class (self ):
33
- self .gptj = get_gpt_j ()
34
-
36
+ self .gptj = get_gpt_j ()
37
+
35
38
def setup_method (self , method ):
36
39
logger .info (f"Running TestAutoRound test: { method .__name__ } " )
37
40
@@ -100,7 +103,7 @@ def test_quantizer(self):
100
103
}
101
104
}
102
105
quantizer = AutoRoundQuantizer (weight_config = weight_config )
103
- fp32_model = gpt_j_model
106
+ fp32_model = gpt_j_model
104
107
105
108
# quantizer execute
106
109
model = quantizer .prepare (model = fp32_model )
You can’t perform that action at this time.
0 commit comments