Display warning for unknown quants config instead of an error (#35963)
* add supports_quant_method check * fix * add test and fix suggestions * change logic slightly --------- Co-authored-by: Mohamed Mekkouri <93391238+MekkCyber@users.noreply.github.com>
This commit is contained in:
@@ -1819,6 +1819,19 @@ class ModelUtilsTest(TestCasePlus):
|
||||
self.assertIsNone(model_outputs.past_key_values)
|
||||
self.assertTrue(model.training)
|
||||
|
||||
def test_unknown_quantization_config(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
config = BertConfig(
|
||||
vocab_size=99, hidden_size=32, num_hidden_layers=5, num_attention_heads=4, intermediate_size=37
|
||||
)
|
||||
model = BertModel(config)
|
||||
config.quantization_config = {"quant_method": "unknown"}
|
||||
model.save_pretrained(tmpdir)
|
||||
with self.assertLogs("transformers", level="WARNING") as cm:
|
||||
BertModel.from_pretrained(tmpdir)
|
||||
self.assertEqual(len(cm.records), 1)
|
||||
self.assertTrue(cm.records[0].message.startswith("Unknown quantization type, got"))
|
||||
|
||||
|
||||
@slow
|
||||
@require_torch
|
||||
|
||||
Reference in New Issue
Block a user