@@ -408,8 +408,8 @@ def calculate_reference(tape, lightning_sv):
408
408
m = LightningMeasurements (statevector )
409
409
return m .measure_final_state (tape )
410
410
411
- @flaky (max_runs = 15 )
412
- @pytest .mark .parametrize ("shots" , [None , 200_000 , [190_000 , 190_000 ]])
411
+ @flaky (max_runs = 5 )
412
+ @pytest .mark .parametrize ("shots" , [None , 500_000 , [500_000 , 500_000 ]])
413
413
@pytest .mark .parametrize ("measurement" , [qml .expval , qml .probs , qml .var ])
414
414
@pytest .mark .parametrize (
415
415
"observable" ,
@@ -449,16 +449,12 @@ def test_single_return_value(self, shots, measurement, observable, lightning_sv,
449
449
pytest .skip (
450
450
f"Measurement of type { type (measurement ).__name__ } does not have a keyword argument 'wires'."
451
451
)
452
- rtol = 1.0e-2 # 1% of expected value as tolerance
453
452
if shots != None and measurement is qml .expval :
454
453
# Increase the number of shots
455
454
if isinstance (shots , int ):
456
- shots *= 10
455
+ shots = 1_000_000
457
456
else :
458
- shots = [i * 10 for i in shots ]
459
-
460
- # Extra tolerance
461
- rtol = 5.0e-2 # 5% of expected value as tolerance
457
+ shots = [1_000_000 , 1_000_000 ]
462
458
463
459
n_qubits = 4
464
460
n_layers = 1
@@ -499,14 +495,13 @@ def test_single_return_value(self, shots, measurement, observable, lightning_sv,
499
495
if shots is None :
500
496
assert np .allclose (result , expected , max (tol , 1.0e-4 ))
501
497
else :
502
- atol = max (tol , 1.0e-2 ) if statevector .dtype == np .complex64 else max (tol , 1.0e-3 )
503
- rtol = max (tol , rtol ) # % of expected value as tolerance
504
-
498
+ # TODO Set better atol and rtol
499
+ dtol = max (tol , 1.0e-2 )
505
500
# allclose -> absolute(a - b) <= (atol + rtol * absolute(b))
506
- assert np .allclose (result , expected , rtol = rtol , atol = atol )
501
+ assert np .allclose (result , expected , rtol = dtol , atol = dtol )
507
502
508
- @flaky (max_runs = 10 )
509
- @pytest .mark .parametrize ("shots" , [None , 100_000 , (90_000 , 90_000 )])
503
+ @flaky (max_runs = 5 )
504
+ @pytest .mark .parametrize ("shots" , [None , 400_000 , (400_000 , 400_000 )])
510
505
@pytest .mark .parametrize ("measurement" , [qml .expval , qml .probs , qml .var ])
511
506
@pytest .mark .parametrize (
512
507
"obs0_" ,
@@ -557,16 +552,12 @@ def test_double_return_value(self, shots, measurement, obs0_, obs1_, lightning_s
557
552
f"Observable of type { type (obs0_ ).__name__ } is not supported for rotating probabilities."
558
553
)
559
554
560
- rtol = 1.0e-2 # 1% of expected value as tolerance
561
555
if shots != None and measurement is qml .expval :
562
556
# Increase the number of shots
563
557
if isinstance (shots , int ):
564
- shots *= 10
558
+ shots = 1_000_000
565
559
else :
566
- shots = [i * 10 for i in shots ]
567
-
568
- # Extra tolerance
569
- rtol = 5.0e-2 # 5% of expected value as tolerance
560
+ shots = [1_000_000 , 1_000_000 ]
570
561
571
562
n_qubits = 4
572
563
n_layers = 1
@@ -610,14 +601,14 @@ def test_double_return_value(self, shots, measurement, obs0_, obs1_, lightning_s
610
601
assert isinstance (result , Sequence )
611
602
assert len (result ) == len (expected )
612
603
# a few tests may fail in single precision, and hence we increase the tolerance
613
- atol = tol if shots is None else max (tol , 1.0e-2 )
614
- rtol = max ( tol , rtol ) # % of expected value as tolerance
604
+ dtol = tol if shots is None else max (tol , 1.0e-2 )
605
+ # TODO Set better atol and rtol
615
606
for r , e in zip (result , expected ):
616
607
if isinstance (shots , tuple ) and isinstance (r [0 ], np .ndarray ):
617
608
r = np .concatenate (r )
618
609
e = np .concatenate (e )
619
610
# allclose -> absolute(r - e) <= (atol + rtol * absolute(e))
620
- assert np .allclose (r , e , atol = atol , rtol = rtol )
611
+ assert np .allclose (r , e , atol = dtol , rtol = dtol )
621
612
622
613
@pytest .mark .parametrize (
623
614
"cases" ,
0 commit comments