Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Commit

Permalink
fixed but different seed for each qubit in RB seed (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
dekelmeirom authored Sep 15, 2020
1 parent 5bdc29b commit 0af27dd
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 15 deletions.
3 changes: 3 additions & 0 deletions qiskit/ignis/verification/randomized_benchmarking/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ def randomized_benchmarking_seq(nseeds: int = 1,
for (rb_pattern_index, rb_q_num) in enumerate(pattern_sizes):

for _ in range(length_multiplier[rb_pattern_index]):
# make the seed unique for each element
if rand_seed:
rand_seed += (seed + 1)
new_elmnt = rb_group.random(rb_q_num, rand_seed)
Elmnts[rb_pattern_index] = rb_group.compose(
Elmnts[rb_pattern_index], new_elmnt)
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/rb-seed-fix-24957ed1e9ffe31c.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
fix a bug at func:`qiskit.ignis.verification.randomized_benchmarking.randomized_benchmarking_seq`
which caused all the subsystems with the same size in the given rb_pattern to have the same gates
when a 'rand_seed' parameter was given to the function.
2 changes: 1 addition & 1 deletion test/rb/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def rb_cnotdihedral_execution(rb_opts: dict, shots: int):
"""
# Load simulator
backend = qiskit.Aer.get_backend('qasm_simulator')
basis_gates = ['u1', 'u2', 'u3', 'cx']
basis_gates = ['u1', 'u2', 'u3', 'cx', 'id']

rb_cnotdihedral_z_circs, xdata, rb_cnotdihedral_x_circs = \
rb.randomized_benchmarking_seq(**rb_opts)
Expand Down
2 changes: 1 addition & 1 deletion test/rb/test_fitter_cnotdihedral_X_results.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/rb/test_fitter_cnotdihedral_Z_results.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/rb/test_fitter_cnotdihedral_expected_results.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cnotdihedral_Z_ydata": [{"mean": [0.97, 0.725, 0.578, 0.462, 0.373, 0.348, 0.32, 0.311, 0.263, 0.268], "std": [0.01643168, 0.04301163, 0.0256125, 0.03059412, 0.03722902, 0.02063977, 0.01760682, 0.00860233, 0.03026549, 0.02976575]}, {"mean": [0.997, 0.953, 0.913, 0.855, 0.806, 0.772, 0.742, 0.7, 0.682, 0.654], "std": [0.006, 0.01630951, 0.01077033, 0.0083666, 0.02517936, 0.02014944, 0.00509902, 0.03193744, 0.00812404, 0.02782086]}], "cnotdihedral_X_ydata": [{"mean": [0.961, 0.72, 0.565, 0.462, 0.353, 0.34, 0.303, 0.301, 0.28, 0.233], "std": [0.00969536, 0.01048809, 0.03271085, 0.03385262, 0.02839014, 0.02167948, 0.03919184, 0.03152777, 0.02280351, 0.0150333]}, {"mean": [0.995, 0.936, 0.894, 0.859, 0.82, 0.78, 0.763, 0.709, 0.695, 0.66], "std": [0.00547723, 0.02154066, 0.01593738, 0.0174356, 0.03937004, 0.03114482, 0.026, 0.01529706, 0.02387467, 0.02302173]}], "joint_fit": [{"alpha": 0.980236195543166, "alpha_err": 0.0008249166207232896, "epg_est": 0.014822853342625508, "epg_est_err": 0.0006311616203884836}, {"alpha": 0.99867758415237, "alpha_err": 0.00018607263163029097, "epg_est": 0.0006612079238150215, "epg_est_err": 9.315951142941721e-05}]}
{"cnotdihedral_Z_ydata": [{"mean": [0.985, 0.744, 0.51, 0.454, 0.42299999999999993, 0.368, 0.329, 0.265, 0.262, 0.254], "std": [0.005477225575051666, 0.0037416573867739447, 0.01581138830084191, 0.007999999999999985, 0.00509901951359279, 0.00244948974278318, 0.0037416573867739447, 0.006324555320336764, 0.0024494897427831805, 0.0073484692283495405]}, {"mean": [0.998, 0.95, 0.9030000000000001, 0.813, 0.776, 0.751, 0.7379999999999999, 0.702, 0.662, 0.6940000000000001], "std": [0.0024494897427831805, 0.005477225575051666, 0.006000000000000005, 0.01661324772583612, 0.009695359714832666, 0.014628738838327807, 0.012083045973594584, 0.00979795897113272, 0.006000000000000005, 0.009165151389911644]}], "cnotdihedral_X_ydata": [{"mean": [0.983, 0.74, 0.502, 0.449, 0.41200000000000003, 0.363, 0.32700000000000007, 0.262, 0.26, 0.251], "std": [0.00509901951359279, 0.0054772255750516665, 0.011224972160321832, 0.006633249580710805, 0.006782329983125263, 0.006000000000000005, 0.0040000000000000036, 0.006782329983125274, 0.003162277660168382, 0.00489897948556636]}, {"mean": [0.999, 0.945, 0.9059999999999999, 0.818, 0.7790000000000001, 0.74, 0.743, 0.698, 0.662, 0.688], "std": [0.0020000000000000018, 0.013038404810405258, 0.004898979485566361, 0.020396078054371117, 0.011135528725660055, 0.015491933384829683, 0.006000000000000005, 0.0040000000000000036, 0.006782329983125275, 0.013999999999999959]}], "joint_fit": [{"alpha": 0.9814918856067555, "alpha_err": 0.0014540396034355267, "epg_est": 0.013881085794933384, "epg_est_err": 0.0011110939566275505}, {"alpha": 0.998345289408381, "alpha_err": 0.00045055481537860153, "epg_est": 0.0008273552958095176, "epg_est_err": 0.00022565079444888258}]}
2 changes: 1 addition & 1 deletion test/rb/test_fitter_coherent_purity_expected_results.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ydata": [{"mean": [1.03547598, 1.00945614, 0.9874103, 0.99794296, 0.98926947, 0.98898662, 0.9908188, 1.04339706, 1.02311855, 1.02636139], "std": [0.00349072, 0.05013115, 0.01657108, 0.03048466, 0.03496286, 0.02572242, 0.03661921, 0.02406485, 0.04192087, 0.05903551]}, {"mean": [1.04122543, 0.98568824, 0.98702183, 1.00184751, 1.02116973, 0.98867042, 1.06620605, 1.11332653, 1.04427034, 1.0687145], "std": [0.00519259, 0.02815319, 0.06940576, 0.0232619, 0.0442728, 0.05649533, 0.05882039, 0.13732109, 0.06189085, 0.0890274]}], "fit": [{"params": [0.04050766, 0.91275946, 1.00172827], "params_err": [0.09520572, 1.04827404, 0.00820391], "epc": 0.12515262778294844, "epc_err": 1.8031488429069056, "pepc": 0.06543040590251992, "pepc_err": 0.8613501881980827}, {"params": [0.07347761, 0.68002963, 1.00724559], "params_err": [12067.3822, 46049.0058, 0.0115476367], "epc": 0.4031697796194298, "epc_err": 123174.20450564621, "pepc": 0.23997777961599784, "pepc_err": 50787.13189860349}]}
{"ydata": [{"mean": [1.0179333333333334, 1.010888888888889, 1.0236629629629628, 0.996874074074074, 0.9761518518518516, 0.9840999999999999, 0.9292481481481479, 0.9723092592592592, 1.0266574074074073, 1.0119240740740743], "std": [0.016342023387422307, 0.011895968816118855, 0.026129214108043457, 0.02009279518587061, 0.052380323586627184, 0.011367829671504114, 0.01542899395927467, 0.04327126712148644, 0.027047786675814377, 0.07657176041110317]}], "fit": [{"params": [0.0691698988892262, 0.994270991971856, 0.9555007714222372], "params_err": [0.0713199011474918, 0.013762574123281022, 0.08015301957627916], "epc": 0.008568895892476197, "epc_err": 0.02082254343199294, "pepc": 0.004296756021108017, "pepc_err": 0.010381405749342168}]}
2 changes: 1 addition & 1 deletion test/rb/test_fitter_coherent_purity_results.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/rb/test_fitter_expected_results_1.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ydata": [{"mean": [0.96367187, 0.73457031, 0.58066406, 0.4828125, 0.41035156, 0.34902344, 0.31210938, 0.2765625, 0.29453125, 0.27695313], "std": [0.01013745, 0.0060955, 0.00678272, 0.01746491, 0.02015981, 0.02184184, 0.02340167, 0.02360293, 0.00874773, 0.01308156]}, {"mean": [0.98925781, 0.87734375, 0.78125, 0.73066406, 0.68496094, 0.64296875, 0.59238281, 0.57421875, 0.56074219, 0.54980469], "std": [0.00276214, 0.01602991, 0.00768946, 0.01413015, 0.00820777, 0.01441348, 0.01272682, 0.01031649, 0.02103036, 0.01224408]}], "fit": [{"params": [0.71936804, 0.98062119, 0.25803749], "params_err": [0.0065886, 0.00046714, 0.00556488], "epc": 0.014534104912075935, "epc_err": 0.0003572769714798349}, {"params": [0.49507094, 0.99354093, 0.50027262], "params_err": [0.0146191, 0.0004157, 0.01487439], "epc": 0.0032295343343508587, "epc_err": 0.00020920242080699664}]}
{"ydata": [{"mean": [0.9791015625, 0.741796875, 0.5666015625, 0.451953125, 0.3912109375, 0.363671875, 0.3134765625, 0.2869140625, 0.2744140625, 0.2435546875], "std": [0.005714351108721793, 0.020620042609717434, 0.012156536187183934, 0.005503516720158348, 0.004305743688486055, 0.00568087483290976, 0.005167483029423029, 0.0024237643839825893, 0.0017469281074217107, 0.001586726250905461]}, {"mean": [0.9982421875, 0.9541015625, 0.921875, 0.8865234375, 0.8505859375, 0.8306640625, 0.796875, 0.770703125, 0.7859375, 0.752734375], "std": [0.000956831930774679, 0.007307924583542854, 0.004744124141207468, 0.003460946317708858, 0.0032682032286487327, 0.00266370736269255, 0.0034938562148434213, 0.0034609463177088574, 0.005774119335583782, 0.0031127690333025834]}], "fit": [{"params": [0.7620766419861829, 0.9817626163565161, 0.22558530252541104], "params_err": [0.021612209964848098, 0.0012058766125511496, 0.009375493914022396], "epc": 0.013678037732612947, "epc_err": 0.0009212078809537161}, {"params": [0.3655354160846289, 0.9968040205413361, 0.6352140246436535], "params_err": [0.03816494633041967, 0.0005271133771675397, 0.038551171275502276], "epc": 0.00159798972933195, "epc_err": 0.0002644017110210286}]}
2 changes: 1 addition & 1 deletion test/rb/test_fitter_expected_results_2.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ydata": [{"mean": [0.99199219, 0.93867188, 0.87871094, 0.83945313, 0.79335937, 0.74785156, 0.73613281, 0.69414062, 0.67460937, 0.65664062], "std": [0.00567416, 0.00791919, 0.01523437, 0.01462368, 0.01189002, 0.01445049, 0.00292317, 0.00317345, 0.00406888, 0.01504794]}], "fit": [{"params": [0.59599995, 0.99518211, 0.39866989], "params_err": [0.08843152, 0.00107311, 0.09074325], "epc": 0.0024089464034862673, "epc_err": 0.0005391508310961153}]}
{"ydata": [{"mean": [0.9990234375, 0.987890625, 0.9701171875, 0.96484375, 0.9521484375, 0.9376953125, 0.942578125, 0.9212890625, 0.9287109375, 0.8955078125], "std": [0.0, 0.001324673824829154, 0.0004784159653873395, 0.0008734640537108553, 0.0017469281074217107, 0.0047601787527163835, 0.0014352478961620185, 0.0027343750000000003, 0.004784159653873394, 0.0016341016143243663]}], "fit": [{"params": [0.47456343486654723, 0.9988134618986855, 0.5230245131560771], "params_err": [1.2368946423797071, 0.0034490352610457363, 1.2411431959509107], "epc": 0.0005932690506572635, "epc_err": 0.0017265662671833255}]}
2 changes: 1 addition & 1 deletion test/rb/test_fitter_interleaved_expected_results.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"original_ydata": [{"mean": [0.9775, 0.79, 0.66, 0.5775, 0.5075, 0.4825, 0.4075, 0.3825, 0.3925, 0.325], "std": [0.0125, 0.02, 0.01, 0.0125, 0.0025, 0.0125, 0.0225, 0.0325, 0.0425, 0.0]}, {"mean": [0.985, 0.9425, 0.8875, 0.8225, 0.775, 0.7875, 0.7325, 0.705, 0.69, 0.6175], "std": [0.005, 0.0125, 0.0025, 0.0025, 0.015, 0.0125, 0.0075, 0.01, 0.02, 0.0375]}], "interleaved_ydata": [{"mean": [0.955, 0.7425, 0.635, 0.4875, 0.44, 0.3625, 0.3575, 0.2875, 0.2975, 0.3075], "std": [0.0, 0.0025, 0.015, 0.0075, 0.055, 0.0075, 0.0075, 0.0025, 0.0025, 0.0075]}, {"mean": [0.9775, 0.85, 0.77, 0.7775, 0.6325, 0.615, 0.64, 0.6125, 0.535, 0.55], "std": [0.0075, 0.005, 0.01, 0.0025, 0.0175, 0.005, 0.01, 0.0075, 0.01, 0.005]}], "joint_fit": [{"alpha": 0.9707393978697902, "alpha_err": 0.0028343593038762326, "alpha_c": 0.9661036105117012, "alpha_c_err": 0.003096602375173838, "epc_est": 0.003581641505636224, "epc_est_err": 0.0032362911276774308, "systematic_err": 0.04030926168967841, "systematic_err_L": -0.03672762018404219, "systematic_err_R": 0.043890903195314634}, {"alpha": 0.9953124384370953, "alpha_err": 0.0014841466685991903, "alpha_c": 0.9955519189829325, "alpha_c_err": 0.002194868426034655, "epc_est": -0.00012030420629183247, "epc_est_err": 0.001331116936065506, "systematic_err": 0.004807865769196562, "systematic_err_L": -0.0049281699754883945, "systematic_err_R": 0.00468756156290473}]}
{"original_ydata": [{"mean": [0.985, 0.8300000000000001, 0.7424999999999999, 0.625, 0.5800000000000001, 0.5025, 0.4575, 0.3925, 0.41000000000000003, 0.365], "std": [0.0, 0.019999999999999962, 0.04250000000000004, 0.03500000000000003, 0.034999999999999976, 0.02250000000000002, 0.0025000000000000022, 0.012500000000000011, 0.004999999999999977, 0.0]}, {"mean": [1.0, 0.9775, 0.9325, 0.9175, 0.87, 0.9, 0.84, 0.85, 0.8175, 0.7925], "std": [0.0, 0.007500000000000007, 0.01749999999999996, 0.007500000000000007, 0.0, 0.010000000000000009, 0.0050000000000000044, 0.010000000000000009, 0.007499999999999951, 0.012500000000000011]}], "interleaved_ydata": [{"mean": [0.98, 0.7625, 0.5549999999999999, 0.49, 0.435, 0.3875, 0.3325, 0.28500000000000003, 0.265, 0.29], "std": [0.0, 0.0025000000000000022, 0.02999999999999997, 0.03, 0.010000000000000009, 0.007500000000000007, 0.0025000000000000022, 0.009999999999999981, 0.0050000000000000044, 0.0]}, {"mean": [1.0, 0.92, 0.86, 0.765, 0.735, 0.6675, 0.66, 0.6, 0.6174999999999999, 0.605], "std": [0.0, 0.0050000000000000044, 0.0050000000000000044, 0.0050000000000000044, 0.0050000000000000044, 0.0025000000000000022, 0.010000000000000009, 0.0, 0.0025000000000000022, 0.0050000000000000044]}], "joint_fit": [{"alpha": 0.9783310082822834, "alpha_err": 0.002320182781126247, "alpha_c": 0.9631739128428493, "alpha_c_err": 0.00344566273194399, "epc_est": 0.011619606741827326, "epc_est_err": 0.003169207331243424, "systematic_err": 0.020883880834747626, "systematic_err_L": -0.0092642740929203, "systematic_err_R": 0.03250348757657495}, {"alpha": 0.9973036666669781, "alpha_err": 0.002255740642196331, "alpha_c": 0.9927592351330009, "alpha_c_err": 0.0012625439502364708, "epc_est": 0.002278358982257034, "epc_est_err": 0.0012915153745741983, "systematic_err": 0.002278358982257034, "systematic_err_L": 0.0, "systematic_err_R": 0.004556717964514068}]}
Loading

0 comments on commit 0af27dd

Please sign in to comment.