@@ -222,96 +222,29 @@ def test_shared_embeddings_prefers_quantized_path_only_when_both_layers_are_quan
222222 assert model .tied_unquantized_embeddings is expected_tied_unquantized
223223
224224
225+ # fmt: off
226+ _TIED_QUANTIZED_EMBEDDING_WEIGHT_NAME_CASES = [
227+ ("default" , 32 , True , 4 , "lm_head.MatMul.weight_Q4" , "lm_head.MatMul.weight_scales" , "" ),
228+ ("default" , 32 , False , 4 , "lm_head.MatMul.weight" , "" , "" ),
229+ ("rtn" , 32 , True , 4 , "lm_head.MatMul.weight_Q4G32" , "lm_head.MatMul.weight_scale" , "" ),
230+ ("rtn" , 32 , False , 4 , "lm_head.MatMul.weight_Q4G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
231+ ("rtn_last" , 32 , True , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "" ),
232+ ("rtn_last" , 32 , False , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
233+ ("k_quant" , 32 , True , 4 , "lm_head.MatMul.weight_Q4G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
234+ ("k_quant" , 32 , False , 4 , "lm_head.MatMul.weight_Q4G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
235+ ("k_quant_last" , 32 , True , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
236+ ("k_quant_last" , 32 , False , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
237+ ("k_quant_mixed" , 32 , True , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
238+ ("k_quant_mixed" , 32 , False , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
239+ ("k_quant_linear" , 32 , True , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
240+ ("k_quant_linear" , 32 , False , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
241+ ]
242+ # fmt: on
243+
244+
225245@pytest .mark .parametrize (
226246 "int4_algo_config, matmul_block_size, is_symmetric, expected_bits, expected_weight, expected_scale, expected_zp" ,
227- [
228- ("default" , 32 , True , 4 , "lm_head.MatMul.weight_Q4" , "lm_head.MatMul.weight_scales" , "" ),
229- ("default" , 32 , False , 4 , "lm_head.MatMul.weight" , "" , "" ),
230- ("rtn" , 32 , True , 4 , "lm_head.MatMul.weight_Q4G32" , "lm_head.MatMul.weight_scale" , "" ),
231- ("rtn" , 32 , False , 4 , "lm_head.MatMul.weight_Q4G32" , "lm_head.MatMul.weight_scale" , "lm_head.MatMul.weight_zp" ),
232- ("rtn_last" , 32 , True , 8 , "lm_head.MatMul.weight_Q8G32" , "lm_head.MatMul.weight_scale" , "" ),
233- (
234- "rtn_last" ,
235- 32 ,
236- False ,
237- 8 ,
238- "lm_head.MatMul.weight_Q8G32" ,
239- "lm_head.MatMul.weight_scale" ,
240- "lm_head.MatMul.weight_zp" ,
241- ),
242- (
243- "k_quant" ,
244- 32 ,
245- True ,
246- 4 ,
247- "lm_head.MatMul.weight_Q4G32" ,
248- "lm_head.MatMul.weight_scale" ,
249- "lm_head.MatMul.weight_zp" ,
250- ),
251- (
252- "k_quant" ,
253- 32 ,
254- False ,
255- 4 ,
256- "lm_head.MatMul.weight_Q4G32" ,
257- "lm_head.MatMul.weight_scale" ,
258- "lm_head.MatMul.weight_zp" ,
259- ),
260- (
261- "k_quant_last" ,
262- 32 ,
263- True ,
264- 8 ,
265- "lm_head.MatMul.weight_Q8G32" ,
266- "lm_head.MatMul.weight_scale" ,
267- "lm_head.MatMul.weight_zp" ,
268- ),
269- (
270- "k_quant_last" ,
271- 32 ,
272- False ,
273- 8 ,
274- "lm_head.MatMul.weight_Q8G32" ,
275- "lm_head.MatMul.weight_scale" ,
276- "lm_head.MatMul.weight_zp" ,
277- ),
278- (
279- "k_quant_mixed" ,
280- 32 ,
281- True ,
282- 8 ,
283- "lm_head.MatMul.weight_Q8G32" ,
284- "lm_head.MatMul.weight_scale" ,
285- "lm_head.MatMul.weight_zp" ,
286- ),
287- (
288- "k_quant_mixed" ,
289- 32 ,
290- False ,
291- 8 ,
292- "lm_head.MatMul.weight_Q8G32" ,
293- "lm_head.MatMul.weight_scale" ,
294- "lm_head.MatMul.weight_zp" ,
295- ),
296- (
297- "k_quant_linear" ,
298- 32 ,
299- True ,
300- 8 ,
301- "lm_head.MatMul.weight_Q8G32" ,
302- "lm_head.MatMul.weight_scale" ,
303- "lm_head.MatMul.weight_zp" ,
304- ),
305- (
306- "k_quant_linear" ,
307- 32 ,
308- False ,
309- 8 ,
310- "lm_head.MatMul.weight_Q8G32" ,
311- "lm_head.MatMul.weight_scale" ,
312- "lm_head.MatMul.weight_zp" ,
313- ),
314- ],
247+ _TIED_QUANTIZED_EMBEDDING_WEIGHT_NAME_CASES ,
315248)
316249def test_tied_quantized_embedding_weight_names_cover_all_supported_algorithms (
317250 int4_algo_config ,
0 commit comments