@@ -280,6 +280,79 @@ def create_pipeline_kwargs(test_model_param, subset_size, test_case_name, refere
280
280
}
281
281
282
282
283
+ def _update_status (pipeline : BaseTestPipeline , errors : List [ErrorReason ]) -> List [str ]:
284
+ """ """
285
+ pipeline .run_info .status = "" # Successful status
286
+ xfails , unexpected_errors = [], []
287
+ for report in errors :
288
+ xfail_reason = report .reason .value + XFAIL_SUFFIX
289
+ if xfail_reason in pipeline .reference_data :
290
+ xfails .append (f"XFAIL: { pipeline .reference_data [xfail_reason ]} - { report .msg } " )
291
+ else :
292
+ unexpected_errors .append (report .msg )
293
+ if xfails :
294
+ pipeline .run_info .status = "\n " .join (xfails )
295
+ if unexpected_errors :
296
+ pipeline .run_info .status = "\n " .join (unexpected_errors )
297
+ return unexpected_errors
298
+
299
+
300
+ def _collect_errors (err_msg : str , pipeline : BaseTestPipeline ) -> List [ErrorReason ]:
301
+ errors = []
302
+
303
+ if err_msg :
304
+ errors .append (ErrorReport (ErrorReason .EXCEPTION , err_msg ))
305
+ return errors
306
+
307
+ run_info = pipeline .run_info
308
+ reference_data = pipeline .reference_data
309
+
310
+ metric_value = run_info .metric_value
311
+ metric_reference = reference_data .get ("metric_value" )
312
+ metric_value_fp32 = reference_data .get ("metric_value_fp32" )
313
+
314
+ if metric_value is not None and metric_value_fp32 is not None :
315
+ run_info .metric_diff = round (metric_value - metric_value_fp32 , 5 )
316
+
317
+ if metric_value is not None and metric_reference is not None :
318
+ atol = reference_data .get ("atol" , 0.001 )
319
+ if not np .isclose (metric_value , metric_reference , atol = atol ):
320
+ status_msg = (
321
+ f"Regression: Metric value is less than reference { metric_value } < { metric_reference } "
322
+ if metric_value < metric_reference
323
+ else f"Improvement: Metric value is better than reference { metric_value } > { metric_reference } "
324
+ )
325
+ errors .append (ErrorReport (ErrorReason .METRICS , status_msg ))
326
+
327
+ num_int4_reference = reference_data .get ("num_int4" ) # None means the check is skipped
328
+ num_int8_reference = reference_data .get ("num_int8" )
329
+ ref_num_sparse_activations = reference_data .get ("num_sparse_activations" )
330
+ num_int4_value = run_info .num_compress_nodes .num_int4
331
+ num_int8_value = run_info .num_compress_nodes .num_int8
332
+ num_sparse_activations = run_info .num_compress_nodes .num_sparse_activations
333
+
334
+ if num_int4_reference is not None and num_int4_reference != num_int4_value :
335
+ status_msg = (
336
+ f"Regression: The number of int4 ops is different than reference { num_int4_reference } != { num_int4_value } "
337
+ )
338
+ errors .append (ErrorReport (ErrorReason .NUM_COMPRESSED , status_msg ))
339
+
340
+ if num_int8_reference is not None and num_int8_reference != num_int8_value :
341
+ status_msg = (
342
+ f"Regression: The number of int8 ops is different than reference { num_int8_reference } != { num_int8_value } "
343
+ )
344
+ errors .append (ErrorReport (ErrorReason .NUM_COMPRESSED , status_msg ))
345
+
346
+ if ref_num_sparse_activations is not None and num_sparse_activations != ref_num_sparse_activations :
347
+ status_msg = (
348
+ f"Regression: The number of sparse activations is { num_sparse_activations } , "
349
+ f"which differs from reference { ref_num_sparse_activations } ."
350
+ )
351
+ errors .append (ErrorReport (ErrorReason .NUM_COMPRESSED , status_msg ))
352
+
353
+ return errors
354
+
355
+
283
356
def run_pipeline (
284
357
test_case_name : str ,
285
358
reference_data : dict ,
@@ -303,34 +376,34 @@ def run_pipeline(
303
376
err_msg = None
304
377
test_model_param = None
305
378
start_time = time .perf_counter ()
379
+ if test_case_name not in reference_data :
380
+ msg = f"{ test_case_name } does not exist in 'reference_data.yaml'"
381
+ raise nncf .ValidationError (msg )
382
+ test_model_param = test_cases [test_case_name ]
383
+ maybe_skip_test_case (test_model_param , run_fp32_backend , run_torch_cuda_backend , batch_size )
384
+ pipeline_cls = test_model_param ["pipeline_cls" ]
385
+ # Recalculates subset_size when subset_size is None
386
+ if batch_size is None :
387
+ batch_size = test_model_param .get ("batch_size" , 1 )
388
+ if batch_size > 1 and subset_size is None :
389
+ subset_size = 300 // batch_size
390
+ print (f"Update subset_size value based on provided batch_size to { subset_size } ." )
391
+ pipeline_kwargs = create_pipeline_kwargs (test_model_param , subset_size , test_case_name , reference_data )
392
+ pipeline_kwargs .update (
393
+ {
394
+ "output_dir" : output_dir ,
395
+ "data_dir" : data_dir ,
396
+ "no_eval" : no_eval ,
397
+ "run_benchmark_app" : run_benchmark_app ,
398
+ "torch_compile_validation" : torch_compile_validation ,
399
+ "batch_size" : batch_size ,
400
+ "memory_monitor" : memory_monitor ,
401
+ }
402
+ )
403
+ if use_avx2 is not None :
404
+ pipeline_kwargs ["use_avx2" ] = use_avx2
405
+ pipeline : BaseTestPipeline = pipeline_cls (** pipeline_kwargs )
306
406
try :
307
- if test_case_name not in reference_data :
308
- msg = f"{ test_case_name } does not exist in 'reference_data.yaml'"
309
- raise nncf .ValidationError (msg )
310
- test_model_param = test_cases [test_case_name ]
311
- maybe_skip_test_case (test_model_param , run_fp32_backend , run_torch_cuda_backend , batch_size )
312
- pipeline_cls = test_model_param ["pipeline_cls" ]
313
- # Recalculates subset_size when subset_size is None
314
- if batch_size is None :
315
- batch_size = test_model_param .get ("batch_size" , 1 )
316
- if batch_size > 1 and subset_size is None :
317
- subset_size = 300 // batch_size
318
- print (f"Update subset_size value based on provided batch_size to { subset_size } ." )
319
- pipeline_kwargs = create_pipeline_kwargs (test_model_param , subset_size , test_case_name , reference_data )
320
- pipeline_kwargs .update (
321
- {
322
- "output_dir" : output_dir ,
323
- "data_dir" : data_dir ,
324
- "no_eval" : no_eval ,
325
- "run_benchmark_app" : run_benchmark_app ,
326
- "torch_compile_validation" : torch_compile_validation ,
327
- "batch_size" : batch_size ,
328
- "memory_monitor" : memory_monitor ,
329
- }
330
- )
331
- if use_avx2 is not None :
332
- pipeline_kwargs ["use_avx2" ] = use_avx2
333
- pipeline : BaseTestPipeline = pipeline_cls (** pipeline_kwargs )
334
407
pipeline .run ()
335
408
except Exception as e :
336
409
err_msg = str (e )
@@ -435,76 +508,3 @@ def test_weight_compression(
435
508
memory_monitor ,
436
509
use_avx2 ,
437
510
)
438
-
439
-
440
- def _update_status (pipeline : BaseTestPipeline , errors : List [ErrorReason ]) -> List [str ]:
441
- """ """
442
- pipeline .run_info .status = "" # Successful status
443
- xfails , unexpected_errors = [], []
444
- for report in errors :
445
- xfail_reason = report .reason .value + XFAIL_SUFFIX
446
- if xfail_reason in pipeline .reference_data :
447
- xfails .append (f"XFAIL: { pipeline .reference_data [xfail_reason ]} - { report .msg } " )
448
- else :
449
- unexpected_errors .append (report .msg )
450
- if xfails :
451
- pipeline .run_info .status = "\n " .join (xfails )
452
- if unexpected_errors :
453
- pipeline .run_info .status = "\n " .join (unexpected_errors )
454
- return unexpected_errors
455
-
456
-
457
- def _collect_errors (err_msg : str , pipeline : BaseTestPipeline ) -> List [ErrorReason ]:
458
- errors = []
459
-
460
- if err_msg :
461
- errors .append (ErrorReport (ErrorReason .EXCEPTION , err_msg ))
462
- return errors
463
-
464
- run_info = pipeline .run_info
465
- reference_data = pipeline .reference_data
466
-
467
- metric_value = run_info .metric_value
468
- metric_reference = reference_data .get ("metric_value" )
469
- metric_value_fp32 = reference_data .get ("metric_value_fp32" )
470
-
471
- if metric_value is not None and metric_value_fp32 is not None :
472
- run_info .metric_diff = round (metric_value - metric_value_fp32 , 5 )
473
-
474
- if metric_value is not None and metric_reference is not None :
475
- atol = reference_data .get ("atol" , 0.001 )
476
- if not np .isclose (metric_value , metric_reference , atol = atol ):
477
- status_msg = (
478
- f"Regression: Metric value is less than reference { metric_value } < { metric_reference } "
479
- if metric_value < metric_reference
480
- else f"Improvement: Metric value is better than reference { metric_value } > { metric_reference } "
481
- )
482
- errors .append (ErrorReport (ErrorReason .METRICS , status_msg ))
483
-
484
- num_int4_reference = reference_data .get ("num_int4" ) # None means the check is skipped
485
- num_int8_reference = reference_data .get ("num_int8" )
486
- ref_num_sparse_activations = reference_data .get ("num_sparse_activations" )
487
- num_int4_value = run_info .num_compress_nodes .num_int4
488
- num_int8_value = run_info .num_compress_nodes .num_int8
489
- num_sparse_activations = run_info .num_compress_nodes .num_sparse_activations
490
-
491
- if num_int4_reference is not None and num_int4_reference != num_int4_value :
492
- status_msg = (
493
- f"Regression: The number of int4 ops is different than reference { num_int4_reference } != { num_int4_value } "
494
- )
495
- errors .append (ErrorReport (ErrorReason .NUM_COMPRESSED , status_msg ))
496
-
497
- if num_int8_reference is not None and num_int8_reference != num_int8_value :
498
- status_msg = (
499
- f"Regression: The number of int8 ops is different than reference { num_int8_reference } != { num_int8_value } "
500
- )
501
- errors .append (ErrorReport (ErrorReason .NUM_COMPRESSED , status_msg ))
502
-
503
- if ref_num_sparse_activations is not None and num_sparse_activations != ref_num_sparse_activations :
504
- status_msg = (
505
- f"Regression: The number of sparse activations is { num_sparse_activations } , "
506
- f"which differs from reference { ref_num_sparse_activations } ."
507
- )
508
- errors .append (ErrorReport (ErrorReason .NUM_COMPRESSED , status_msg ))
509
-
510
- return errors
0 commit comments