@@ -29,9 +29,9 @@ def test_save_model_bert(
2929
3030 Args:
3131 model_tiny_bert (BertModel): Bert Tiny Model
32- config_tiny_bert (BertConfig): Bert Tiny config
3332 input_tiny (BatchEncoding): Fake tiny input
34- qcfg_bert (dict): Quantized config for Bert
33+ qcfg_bert (dict): Quantized config for Tiny Bert
34+ bert_linear_names (list): Names of linear layers for Bert
3535 """
3636 # Quantize model and save state dict
3737 qmodel_prep (model_tiny_bert , input_tiny , qcfg_bert , use_dynamo = True )
@@ -54,8 +54,8 @@ def test_large_outlier_bert(
5454 Args:
5555 model_tiny_bert (BertModel): Bert Tiny Model
5656 input_tiny (BatchEncoding): Bert Tiny config
57- qcfg_bert (dict): Fake tiny input
58- bert_linear_names (list): Quantized config for Bert
57+ qcfg_bert (dict): Quantized config for Tiny Bert
58+ bert_linear_names (list): Names of linear layers for Bert
5959 """
6060 # Third Party
6161 import torch
@@ -87,6 +87,27 @@ def test_large_outlier_bert(
8787 assert torch .all (perCh_stdev_loaded >= perCh_stdev_model )
8888
8989
90+ def test_clip_vals_zero_bert (
91+ model_tiny_bert : BertModel ,
92+ input_tiny : BatchEncoding ,
93+ qcfg_bert : dict ,
94+ ):
95+ """
96+ Test if uninitialized clip vals throws an error
97+
98+ Args:
99+ model_tiny_bert (BertModel): Bert Tiny Model
100+ input_tiny (BatchEncoding): Bert Tiny config
101+ qcfg_bert (dict): Quantized config for Tiny Bert
102+ """
103+ # Turn off calibration -> clip vals are init as 0
104+ qcfg_bert ["qmodel_calibration" ] = 0
105+ qmodel_prep (model_tiny_bert , input_tiny , qcfg_bert , use_dynamo = True )
106+
107+ with pytest .raises (ValueError ):
108+ save_for_aiu (model_tiny_bert , qcfg = qcfg_bert , verbose = True )
109+
110+
90111def test_save_model_llama (
91112 model_tiny_llama : LlamaModel ,
92113 input_tiny : BatchEncoding ,
0 commit comments