|
73 | 73 |
|
74 | 74 |
|
75 | 75 | class OVQuantizerTest(unittest.TestCase): |
76 | | - SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS = ( |
| 76 | + SUPPORTED_ARCHITECTURES_TORCH_MODEL = ( |
77 | 77 | (OVModelForSequenceClassification, "bert", 32, 35), |
78 | | - # (OVModelForCausalLM, "gpt2", 41, 23), |
| 78 | + (OVModelForCausalLM, "gpt2", 41, 3), |
| 79 | + ) |
| 80 | + SUPPORTED_ARCHITECTURES_OV_MODEL = ( |
| 81 | + (OVModelForSequenceClassification, "bert", 32, 35), |
| 82 | + (OVModelForCausalLM, "gpt2", 31, 22), |
79 | 83 | ) |
80 | 84 |
|
81 | | - @parameterized.expand(SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS) |
| 85 | + @parameterized.expand(SUPPORTED_ARCHITECTURES_TORCH_MODEL) |
82 | 86 | def test_automodel_static_quantization(self, model_cls, model_name, expected_fake_quantize, expected_int8): |
83 | 87 | model_id = MODEL_NAMES[model_name] |
84 | 88 | task = model_cls.export_feature |
@@ -123,23 +127,21 @@ def preprocess_function(examples, tokenizer): |
123 | 127 | loaded_config = OVConfig.from_pretrained(tmp_dir) |
124 | 128 | self.assertEqual(ov_config.quantization_config.to_dict(), loaded_config.quantization_config.to_dict()) |
125 | 129 |
|
126 | | - @parameterized.expand(SUPPORTED_ARCHITECTURES_WITH_EXPECTED_QUANTIZED_MATMULS) |
| 130 | + @parameterized.expand(SUPPORTED_ARCHITECTURES_OV_MODEL) |
127 | 131 | def test_ovmodel_static_quantization(self, model_cls, model_name, expected_fake_quantize, expected_int8): |
128 | 132 | model_id = MODEL_NAMES[model_name] |
129 | 133 | task = model_cls.export_feature |
130 | 134 | dataset_name, dataset_config_name, column_name = _TASK_TO_DATASET[task] |
131 | | - if "gpt2" in model_id: |
132 | | - expected_int8 -= 1 |
133 | 135 |
|
134 | 136 | def preprocess_function(examples, tokenizer): |
135 | 137 | return tokenizer(examples[column_name], padding="max_length", max_length=128, truncation=True) |
136 | 138 |
|
137 | 139 | with tempfile.TemporaryDirectory() as tmp_dir: |
138 | | - transformers_model = model_cls.from_pretrained(model_id, export=True) |
| 140 | + ov_model = model_cls.from_pretrained(model_id, export=True) |
139 | 141 | tokenizer = AutoTokenizer.from_pretrained(model_id) |
140 | 142 | if tokenizer.pad_token is None: |
141 | 143 | tokenizer.pad_token = tokenizer.eos_token |
142 | | - quantizer = OVQuantizer.from_pretrained(transformers_model, task=task) |
| 144 | + quantizer = OVQuantizer.from_pretrained(ov_model, task=task) |
143 | 145 |
|
144 | 146 | calibration_dataset = quantizer.get_calibration_dataset( |
145 | 147 | dataset_name, |
|
0 commit comments