@@ -29,7 +29,7 @@ def _ccnot_bitcode(self) -> bytes:
29
29
bitcode_filename = path .join (path .dirname (__file__ ), "qir" , "ccnot.bc" )
30
30
with open (bitcode_filename , "rb" ) as f :
31
31
return f .read ()
32
-
32
+
33
33
def _mock_result_data (self ) -> dict :
34
34
"""
35
35
A small result data for tests.
@@ -43,6 +43,34 @@ def _mock_result_data(self) -> dict:
43
43
"reportData" : {"groups" : [], "assumptions" : []}
44
44
}
45
45
46
+ def _mock_result_data_full (self , status ) -> dict :
47
+ formatted = {
48
+ "algorithmicLogicalQubits" : 10 ,
49
+ "logicalDepth" : 100 ,
50
+ "numTstates" : 15 ,
51
+ "numTfactories" : 1000 ,
52
+ "physicalQubitsForTfactoriesPercentage" : 10 ,
53
+ "physicalQubits" : 30000 ,
54
+ "rqops" : 45678 ,
55
+ "runtime" : 23456789
56
+ }
57
+
58
+ result = {
59
+ "physicalCounts" : {
60
+ "physicalQubits" : 655321 ,
61
+ "runtime" : 1729 ,
62
+ "rqops" : 314
63
+ },
64
+ "logicalQubit" : {
65
+ "codeDistance" : 11
66
+ },
67
+ "reportData" : {"groups" : [], "assumptions" : []}
68
+ }
69
+
70
+ result ["physicalCountsFormatted" ] = formatted
71
+ result ["status" ] = status
72
+ return result
73
+
46
74
@pytest .mark .microsoft_qc
47
75
@pytest .mark .live_test
48
76
def test_estimator_non_batching_job (self ):
@@ -88,7 +116,7 @@ def test_estimator_batching_job(self):
88
116
params .items [0 ].qubit_params .t_gate_time = "10 ns"
89
117
params .items [0 ].qubit_params .idle_error_rate = 0.00002
90
118
params .items [0 ].qubit_params .two_qubit_joint_measurement_error_rate = \
91
- MeasurementErrorRate (process = 0.00005 , readout = 0.00007 )
119
+ MeasurementErrorRate (process = 0.00005 , readout = 0.00007 )
92
120
93
121
specification1 = DistillationUnitSpecification ()
94
122
specification1 .display_name = "S"
@@ -110,10 +138,11 @@ def test_estimator_batching_job(self):
110
138
specification2 = DistillationUnitSpecification ()
111
139
specification2 .name = "15-1 RM"
112
140
113
- specification3 = DistillationUnitSpecification ()
141
+ specification3 = DistillationUnitSpecification ()
114
142
specification3 .name = "15-1 space-efficient"
115
143
116
- params .items [0 ].distillation_unit_specifications = [specification1 , specification2 , specification3 ]
144
+ params .items [0 ].distillation_unit_specifications = [
145
+ specification1 , specification2 , specification3 ]
117
146
118
147
params .items [1 ].error_budget = 0.002
119
148
params .items [1 ].constraints .max_duration = "20s"
@@ -318,21 +347,20 @@ def test_estimator_params_validation_measurement_error_rates_valid(self):
318
347
params .qubit_params .idle_error_rate = 0.02
319
348
params .qubit_params .one_qubit_measurement_error_rate = 0.01
320
349
params .qubit_params .two_qubit_joint_measurement_error_rate = \
321
- MeasurementErrorRate (process = 0.02 , readout = 0.03 )
350
+ MeasurementErrorRate (process = 0.02 , readout = 0.03 )
322
351
323
352
assert params .as_dict () == {
324
- "errorBudget" : 0.1 ,
325
- "qubitParams" : {"name" : "qubit_gate_ns_e3" ,
326
- "instructionSet" : "gate_based" ,
327
- "tGateErrorRate" : 0.03 ,
328
- "tGateTime" : "10 ns" ,
329
- "idleErrorRate" : 0.02 ,
330
- "oneQubitMeasurementErrorRate" : 0.01 ,
331
- "twoQubitJointMeasurementErrorRate" :
353
+ "errorBudget" : 0.1 ,
354
+ "qubitParams" : {"name" : "qubit_gate_ns_e3" ,
355
+ "instructionSet" : "gate_based" ,
356
+ "tGateErrorRate" : 0.03 ,
357
+ "tGateTime" : "10 ns" ,
358
+ "idleErrorRate" : 0.02 ,
359
+ "oneQubitMeasurementErrorRate" : 0.01 ,
360
+ "twoQubitJointMeasurementErrorRate" :
332
361
{"process" : 0.02 , "readout" : 0.03 }}
333
362
}
334
363
335
-
336
364
def test_estimator_error_budget_float (self ):
337
365
params = MicrosoftEstimatorParams ()
338
366
params .error_budget = 0.001
@@ -398,9 +426,9 @@ def test_estimator_custom_distillation_units_name_and_custom_not_allowed_togethe
398
426
params .distillation_unit_specifications .append (unit )
399
427
400
428
with raises (LookupError , match = "If predefined name is provided, "
401
- "custom specification is not allowed. "
402
- "Either remove name or remove all other "
403
- "specification of the distillation unit" ):
429
+ "custom specification is not allowed. "
430
+ "Either remove name or remove all other "
431
+ "specification of the distillation unit" ):
404
432
params .as_dict ()
405
433
406
434
def test_estimator_custom_distillation_units_by_specification_short (self ):
@@ -414,9 +442,9 @@ def test_estimator_custom_distillation_units_by_specification_short(self):
414
442
params .distillation_unit_specifications .append (unit )
415
443
416
444
assert params .as_dict () == {
417
- "distillationUnitSpecifications" :
445
+ "distillationUnitSpecifications" :
418
446
[{"displayName" : "T" , "failureProbabilityFormula" : "c" ,
419
- "outputErrorRateFormula" : "r" , "numInputTs" : 1 , "numOutputTs" : 2 }]
447
+ "outputErrorRateFormula" : "r" , "numInputTs" : 1 , "numOutputTs" : 2 }]
420
448
}
421
449
422
450
def test_estimator_custom_distillation_units_by_specification_full (self ):
@@ -449,13 +477,13 @@ def test_estimator_custom_distillation_units_by_specification_full(self):
449
477
450
478
print (params .as_dict ())
451
479
assert params .as_dict () == {
452
- "distillationUnitSpecifications" :
453
- [{"displayName" : "T" , "numInputTs" : 1 , "numOutputTs" : 2 ,
454
- "failureProbabilityFormula" : "c" , "outputErrorRateFormula" : "r" ,
455
- "physicalQubitSpecification" : {"numUnitQubits" : 1 , "durationInQubitCycleTime" : 2 },
456
- "logicalQubitSpecification" : {"numUnitQubits" :3 , "durationInQubitCycleTime" :4 },
457
- "logicalQubitSpecificationFirstRoundOverride" :
458
- {"numUnitQubits" :5 , "durationInQubitCycleTime" :6 }}]
480
+ "distillationUnitSpecifications" :
481
+ [{"displayName" : "T" , "numInputTs" : 1 , "numOutputTs" : 2 ,
482
+ "failureProbabilityFormula" : "c" , "outputErrorRateFormula" : "r" ,
483
+ "physicalQubitSpecification" : {"numUnitQubits" : 1 , "durationInQubitCycleTime" : 2 },
484
+ "logicalQubitSpecification" : {"numUnitQubits" : 3 , "durationInQubitCycleTime" : 4 },
485
+ "logicalQubitSpecificationFirstRoundOverride" :
486
+ {"numUnitQubits" : 5 , "durationInQubitCycleTime" : 6 }}]
459
487
}
460
488
461
489
def test_estimator_protocol_specific_distillation_unit_specification_empty_not_allowed (self ):
@@ -496,7 +524,67 @@ def test_batch_result_as_json(self):
496
524
497
525
import json
498
526
assert json .loads (result .json ) == data
499
-
527
+
528
+ def test_list_status_all_failed (self ):
529
+ data = [self ._mock_result_data_full (
530
+ "error" ), self ._mock_result_data_full ("failure" )]
531
+ result = MicrosoftEstimatorResult (data )
532
+
533
+ import json
534
+ assert json .loads (result .json ) == data
535
+
536
+ data_frame = result .summary_data_frame ()
537
+ assert data_frame .values .real [0 ][0 ] == "No solution found"
538
+ assert data_frame .values .real [1 ][5 ] == "No solution found"
539
+
540
+ assert not hasattr (result [0 ], "summary" )
541
+ assert not hasattr (result [1 ], "summary" )
542
+
543
+ assert not hasattr (result [0 ], "diagram" )
544
+ assert not hasattr (result [1 ], "diagram" )
545
+
546
+ def test_list_status_partial_success (self ):
547
+ data = [self ._mock_result_data_full (
548
+ "success" ), self ._mock_result_data_full ("error" )]
549
+ result = MicrosoftEstimatorResult (data )
550
+
551
+ import json
552
+ assert json .loads (result .json ) == data
553
+
554
+ data_frame = result .summary_data_frame ()
555
+ assert data_frame .values .real [0 ][0 ] == 10
556
+ assert data_frame .values .real [1 ][5 ] == "No solution found"
557
+
558
+ assert hasattr (result [0 ], "summary" )
559
+ assert not hasattr (result [1 ], "summary" )
560
+
561
+ assert hasattr (result [0 ], "diagram" )
562
+ assert not hasattr (result [1 ], "diagram" )
563
+
564
+ def test_dict_status_failed (self ):
565
+ data = self ._mock_result_data_full ("error" )
566
+ result = MicrosoftEstimatorResult (data )
567
+
568
+ import json
569
+ assert json .loads (result .json ) == data
570
+
571
+ assert not hasattr (result , "summary_data_frame" )
572
+
573
+ assert not hasattr (result , "summary" )
574
+ assert not hasattr (result , "diagram" )
575
+
576
+ def test_dict_status_success (self ):
577
+ data = self ._mock_result_data_full ("success" )
578
+ result = MicrosoftEstimatorResult (data )
579
+
580
+ import json
581
+ assert json .loads (result .json ) == data
582
+
583
+ assert not hasattr (result , "summary_data_frame" )
584
+
585
+ assert hasattr (result , "summary" )
586
+ assert hasattr (result , "diagram" )
587
+
500
588
def test_duration_and_physical_qubits_constraints_not_allowed_together (self ):
501
589
constraints = MicrosoftEstimatorConstraints ()
502
590
constraints .max_physical_qubits = 100
0 commit comments