|
9 | 9 | "source": [ |
10 | 10 | "import numpy as np\n", |
11 | 11 | "import stim\n", |
12 | | - "from tqdm import tqdm\n", |
13 | 12 | "from quits.qldpc_code import *\n", |
14 | 13 | "from quits.circuit import get_qldpc_mem_circuit, check_overlapping_CX\n", |
15 | 14 | "from quits.decoder import sliding_window_bposd_circuit_mem\n", |
|
63 | 62 | "# z-check qubits: 108 # x-check qubits: 108\n", |
64 | 63 | "# layers of entangling gates: 8\n" |
65 | 64 | ] |
| 65 | + }, |
| 66 | + { |
| 67 | + "data": { |
| 68 | + "text/plain": [ |
| 69 | + "{'css_condition': True,\n", |
| 70 | + " 'lz_commutes_with_X': True,\n", |
| 71 | + " 'lx_commutes_with_Z': True,\n", |
| 72 | + " 'rank_hz': 108,\n", |
| 73 | + " 'rank_hx': 108,\n", |
| 74 | + " 'rank_lz': 9,\n", |
| 75 | + " 'rank_lx': 9,\n", |
| 76 | + " 'k_expected': 9,\n", |
| 77 | + " 'lz_independent_mod_Z_stabilizers': True,\n", |
| 78 | + " 'lx_independent_mod_X_stabilizers': True,\n", |
| 79 | + " 'rank_hz_plus_lz': 117,\n", |
| 80 | + " 'rank_hx_plus_lx': 117,\n", |
| 81 | + " 'dim_ker_hz': 117,\n", |
| 82 | + " 'dim_ker_hx': 117,\n", |
| 83 | + " 'hx_plus_lx_spans_ker_hz': True,\n", |
| 84 | + " 'hz_plus_lz_spans_ker_hx': True,\n", |
| 85 | + " 'pairing_rank': 9,\n", |
| 86 | + " 'pairing_is_identity': True,\n", |
| 87 | + " 'ok': True}" |
| 88 | + ] |
| 89 | + }, |
| 90 | + "execution_count": 3, |
| 91 | + "metadata": {}, |
| 92 | + "output_type": "execute_result" |
66 | 93 | } |
67 | 94 | ], |
68 | 95 | "source": [ |
|
75 | 102 | "depth = sum(list(code.num_colors.values())) \n", |
76 | 103 | "print('# data qubits: ', num_data, ' # logical qubits: ', num_logical)\n", |
77 | 104 | "print('# z-check qubits: ', num_zcheck, ' # x-check qubits: ', num_xcheck)\n", |
78 | | - "print('# layers of entangling gates: ', depth)" |
| 105 | + "print('# layers of entangling gates: ', depth)\n", |
| 106 | + "\n", |
| 107 | + "code.verify_css_logicals() # Verify that the logical operators are valid" |
79 | 108 | ] |
80 | 109 | }, |
81 | 110 | { |
|
176 | 205 | "# z-check qubits: 240 # x-check qubits: 240\n", |
177 | 206 | "# layers of entangling gates: 12\n" |
178 | 207 | ] |
| 208 | + }, |
| 209 | + { |
| 210 | + "data": { |
| 211 | + "text/plain": [ |
| 212 | + "{'css_condition': True,\n", |
| 213 | + " 'lz_commutes_with_X': True,\n", |
| 214 | + " 'lx_commutes_with_Z': True,\n", |
| 215 | + " 'rank_hz': 232,\n", |
| 216 | + " 'rank_hx': 232,\n", |
| 217 | + " 'rank_lz': 80,\n", |
| 218 | + " 'rank_lx': 80,\n", |
| 219 | + " 'k_expected': 80,\n", |
| 220 | + " 'lz_independent_mod_Z_stabilizers': True,\n", |
| 221 | + " 'lx_independent_mod_X_stabilizers': True,\n", |
| 222 | + " 'rank_hz_plus_lz': 312,\n", |
| 223 | + " 'rank_hx_plus_lx': 312,\n", |
| 224 | + " 'dim_ker_hz': 312,\n", |
| 225 | + " 'dim_ker_hx': 312,\n", |
| 226 | + " 'hx_plus_lx_spans_ker_hz': True,\n", |
| 227 | + " 'hz_plus_lz_spans_ker_hx': True,\n", |
| 228 | + " 'pairing_rank': 80,\n", |
| 229 | + " 'pairing_is_identity': True,\n", |
| 230 | + " 'ok': True}" |
| 231 | + ] |
| 232 | + }, |
| 233 | + "execution_count": 7, |
| 234 | + "metadata": {}, |
| 235 | + "output_type": "execute_result" |
179 | 236 | } |
180 | 237 | ], |
181 | 238 | "source": [ |
|
188 | 245 | "depth = sum(list(code.num_colors.values())) \n", |
189 | 246 | "print('# data qubits: ', num_data, ' # logical qubits: ', num_logical)\n", |
190 | 247 | "print('# z-check qubits: ', num_zcheck, ' # x-check qubits: ', num_xcheck)\n", |
191 | | - "print('# layers of entangling gates: ', depth)" |
| 248 | + "print('# layers of entangling gates: ', depth)\n", |
| 249 | + "\n", |
| 250 | + "code.verify_css_logicals() # Verify that the logical operators are valid" |
192 | 251 | ] |
193 | 252 | }, |
194 | 253 | { |
|
246 | 305 | "# z-check qubits: 30 # x-check qubits: 30\n", |
247 | 306 | "# layers of entangling gates: 8\n" |
248 | 307 | ] |
| 308 | + }, |
| 309 | + { |
| 310 | + "data": { |
| 311 | + "text/plain": [ |
| 312 | + "{'css_condition': True,\n", |
| 313 | + " 'lz_commutes_with_X': True,\n", |
| 314 | + " 'lx_commutes_with_Z': True,\n", |
| 315 | + " 'rank_hz': 30,\n", |
| 316 | + " 'rank_hx': 30,\n", |
| 317 | + " 'rank_lz': 5,\n", |
| 318 | + " 'rank_lx': 5,\n", |
| 319 | + " 'k_expected': 5,\n", |
| 320 | + " 'lz_independent_mod_Z_stabilizers': True,\n", |
| 321 | + " 'lx_independent_mod_X_stabilizers': True,\n", |
| 322 | + " 'rank_hz_plus_lz': 35,\n", |
| 323 | + " 'rank_hx_plus_lx': 35,\n", |
| 324 | + " 'dim_ker_hz': 35,\n", |
| 325 | + " 'dim_ker_hx': 35,\n", |
| 326 | + " 'hx_plus_lx_spans_ker_hz': True,\n", |
| 327 | + " 'hz_plus_lz_spans_ker_hx': True,\n", |
| 328 | + " 'pairing_rank': 5,\n", |
| 329 | + " 'pairing_is_identity': True,\n", |
| 330 | + " 'ok': True}" |
| 331 | + ] |
| 332 | + }, |
| 333 | + "execution_count": 10, |
| 334 | + "metadata": {}, |
| 335 | + "output_type": "execute_result" |
249 | 336 | } |
250 | 337 | ], |
251 | 338 | "source": [ |
|
258 | 345 | "depth = sum(list(code.num_colors.values())) \n", |
259 | 346 | "print('# data qubits: ', num_data, ' # logical qubits: ', num_logical)\n", |
260 | 347 | "print('# z-check qubits: ', num_zcheck, ' # x-check qubits: ', num_xcheck)\n", |
261 | | - "print('# layers of entangling gates: ', depth)" |
| 348 | + "print('# layers of entangling gates: ', depth)\n", |
| 349 | + "\n", |
| 350 | + "code.verify_css_logicals() # Verify that the logical operators are valid" |
262 | 351 | ] |
263 | 352 | }, |
264 | 353 | { |
|
316 | 405 | "# z-check qubits: 45 # x-check qubits: 45\n", |
317 | 406 | "# layers of entangling gates: 8\n" |
318 | 407 | ] |
| 408 | + }, |
| 409 | + { |
| 410 | + "data": { |
| 411 | + "text/plain": [ |
| 412 | + "{'css_condition': True,\n", |
| 413 | + " 'lz_commutes_with_X': True,\n", |
| 414 | + " 'lx_commutes_with_Z': True,\n", |
| 415 | + " 'rank_hz': 41,\n", |
| 416 | + " 'rank_hx': 41,\n", |
| 417 | + " 'rank_lz': 8,\n", |
| 418 | + " 'rank_lx': 8,\n", |
| 419 | + " 'k_expected': 8,\n", |
| 420 | + " 'lz_independent_mod_Z_stabilizers': True,\n", |
| 421 | + " 'lx_independent_mod_X_stabilizers': True,\n", |
| 422 | + " 'rank_hz_plus_lz': 49,\n", |
| 423 | + " 'rank_hx_plus_lx': 49,\n", |
| 424 | + " 'dim_ker_hz': 49,\n", |
| 425 | + " 'dim_ker_hx': 49,\n", |
| 426 | + " 'hx_plus_lx_spans_ker_hz': True,\n", |
| 427 | + " 'hz_plus_lz_spans_ker_hx': True,\n", |
| 428 | + " 'pairing_rank': 8,\n", |
| 429 | + " 'pairing_is_identity': True,\n", |
| 430 | + " 'ok': True}" |
| 431 | + ] |
| 432 | + }, |
| 433 | + "execution_count": 13, |
| 434 | + "metadata": {}, |
| 435 | + "output_type": "execute_result" |
319 | 436 | } |
320 | 437 | ], |
321 | 438 | "source": [ |
|
328 | 445 | "depth = sum(list(code.num_colors.values())) \n", |
329 | 446 | "print('# data qubits: ', num_data, ' # logical qubits: ', num_logical)\n", |
330 | 447 | "print('# z-check qubits: ', num_zcheck, ' # x-check qubits: ', num_xcheck)\n", |
331 | | - "print('# layers of entangling gates: ', depth)" |
| 448 | + "print('# layers of entangling gates: ', depth)\n", |
| 449 | + "\n", |
| 450 | + "code.verify_css_logicals() # Verify that the logical operators are valid" |
332 | 451 | ] |
333 | 452 | }, |
334 | 453 | { |
|
341 | 460 | "name": "stdout", |
342 | 461 | "output_type": "stream", |
343 | 462 | "text": [ |
344 | | - "Z0 : [ 2 5 8 11 14 17 20 23 26 29] , X0 : [15 16 18 19 21 22 24 25 27 28]\n", |
345 | | - "Z1 : [ 0 3 6 9 12 30 33 36 39 42] , X1 : [15 17 18 20 21 23 24 26 27 29]\n", |
346 | | - "Z2 : [ 1 4 7 10 13 31 34 37 40 43] , X2 : [30 31 33 34 36 37 39 40 42 43]\n", |
347 | | - "Z3 : [ 0 3 6 9 12 15 18 21 24 27] , X3 : [30 32 33 35 36 38 39 41 42 44]\n", |
| 463 | + "Z0 : [ 0 3 6 9 12 15 18 21 24 27] , X0 : [ 3 4 5 7 9 11 15 17 18 20 21 23 24 26 27 29 30 31 32 33 35 36 37 38\n", |
| 464 | + " 39 41 60 61 75 76]\n", |
| 465 | + "Z1 : [ 1 4 7 10 13 16 19 22 25 28] , X1 : [16 17 19 20 22 23 25 26 28 29]\n", |
| 466 | + "Z2 : [ 0 3 6 9 12 30 33 36 39 42] , X2 : [ 0 2 4 6 7 8 12 14 16 22 27 29 33 34 35 37 39 41 45 46 75 76]\n", |
| 467 | + "Z3 : [ 1 4 7 10 13 31 34 37 40 43] , X3 : [ 1 2 4 5 7 8 10 11 13 14 16 17 19 20 22 23 25 26 28 29]\n", |
348 | 468 | "Z4 : [ 1 2 3 4 5 7 8 12 13 14 15 18 19 20 24 31 32 33 36 37 38 39 40 41\n", |
349 | | - " 45 46] , X4 : [15 17 20 22 24 25 32 37 39 42 45 60]\n", |
350 | | - "Z5 : [ 1 3 7 15 16 18 21 24 25 30 31 33 34 39 45 47] , X5 : [16 18 21 23 25 26 30 31 34 36 37 38 39 42 46 61]\n", |
351 | | - "Z6 : [ 0 1 2 3 7 8 15 21 24 25 26 30 33 34 35 39 60 61] , X6 : [ 0 5 10 12 15 17 20 22 24 25 30 35 40 42 45 75]\n", |
352 | | - "Z7 : [ 3 4 6 7 12 16 18 22 30 31 33 36 39 40 60 62] , X7 : [ 0 3 4 7 9 10 11 12 16 18 21 23 25 26 30 33 34 37 39 40 41 42 46 76]\n" |
| 469 | + " 45 46] , X4 : [ 0 3 4 7 9 10 11 12 17 18 19 20 21 22 28 29 30 33 34 37 39 40 41 42\n", |
| 470 | + " 46 76]\n", |
| 471 | + "Z5 : [ 1 3 7 15 16 18 21 24 25 30 31 33 34 39 45 47] , X5 : [ 3 4 5 7 9 11 15 16 17 18 20 21 22 23 24 26 33 34 35 37 39 41 45 46\n", |
| 472 | + " 75 76]\n", |
| 473 | + "Z6 : [ 0 1 2 3 7 8 15 21 24 25 26 30 33 34 35 39 60 61] , X6 : [ 0 1 2 3 5 8 9 12 13 14 31 33 36 38 40 41 61 76]\n", |
| 474 | + "Z7 : [ 3 4 6 7 12 16 18 22 30 31 33 36 39 40 60 62] , X7 : [ 3 4 5 7 9 11 30 31 32 33 35 36 37 38 39 41 60 61 75 76]\n" |
353 | 475 | ] |
354 | 476 | } |
355 | 477 | ], |
|
365 | 487 | "metadata": {}, |
366 | 488 | "outputs": [], |
367 | 489 | "source": [ |
368 | | - "p = 2e-3 # physical error rate\n", |
| 490 | + "p = 1e-3 # physical error rate\n", |
369 | 491 | "num_rounds = 15 # number of rounds (T-1)\n", |
370 | 492 | "basis = 'Z' # 'Z' or 'X'\n", |
371 | 493 | "\n", |
|
393 | 515 | "name": "stderr", |
394 | 516 | "output_type": "stream", |
395 | 517 | "text": [ |
396 | | - "100%|██████████| 100/100 [00:10<00:00, 9.50it/s]" |
| 518 | + "100%|██████████| 100/100 [00:02<00:00, 33.96it/s]" |
397 | 519 | ] |
398 | 520 | }, |
399 | 521 | { |
400 | 522 | "name": "stdout", |
401 | 523 | "output_type": "stream", |
402 | 524 | "text": [ |
403 | | - "p: 0.0020000, LFR: 0.0006698\n" |
| 525 | + "p: 0.0010000, LFR: 0.0000000\n" |
404 | 526 | ] |
405 | 527 | }, |
406 | 528 | { |
|
414 | 536 | "source": [ |
415 | 537 | "num_trials = 100\n", |
416 | 538 | "## Simulate the circuit using Stim. \n", |
417 | | - "detection_events, observable_flips = get_stim_mem_result(circuit, num_trials, seed=2) # simulate the circuit using Stim\n", |
| 539 | + "detection_events, observable_flips = get_stim_mem_result(circuit, num_trials, seed=1) # simulate the circuit using Stim\n", |
418 | 540 | "\n", |
419 | 541 | "W, F = 5, 3 # sliding window parameters\n", |
420 | | - "max_iter, osd_order = 20, 10 # BP-OSD decoder parameters \n", |
| 542 | + "max_iter, osd_order = 10, 1 # BP-OSD decoder parameters \n", |
421 | 543 | "\n", |
422 | 544 | "# Perform decoding of the detection_events generated from simulating the circuit. \n", |
423 | 545 | "# Returns the logical observable flip predicted from decoding. \n", |
|
448 | 570 | "name": "stderr", |
449 | 571 | "output_type": "stream", |
450 | 572 | "text": [ |
451 | | - "100%|██████████| 100/100 [00:09<00:00, 10.09it/s]\n" |
| 573 | + "100%|██████████| 100/100 [00:02<00:00, 33.67it/s]\n" |
452 | 574 | ] |
453 | 575 | } |
454 | 576 | ], |
455 | 577 | "source": [ |
456 | 578 | "#use the BP-OSD decoder from the LDPC package (https://software.roffe.eu/ldpc/) as an example\n", |
457 | | - "from quits.decoder import sliding_window_bposd_circuit_mem,sliding_window_circuit_mem\n", |
| 579 | + "from quits.decoder import sliding_window_circuit_mem\n", |
458 | 580 | "from ldpc.bposd_decoder import BpOsdDecoder\n", |
459 | 581 | "'''\n", |
460 | 582 | "Note that it is allowed to use a different decoder (Decoder2) for the last decoding window \n", |
|
0 commit comments