@@ -28,6 +28,7 @@ function my_plot_both_synd(code::AbstractECC, decoder::AbstractSyndromeDecoder,
2828 # p_shift = 0
2929 error_rates = exp10 .(range (- 4 ,- 0.5 ,length= 30 ))
3030
31+ f = Figure (size= (1400 , 1400 ),px_per_unit = 5.0 )
3132
3233 # All to all connectivty - no gate noise
3334 post_ec_error_rates_MA_CA = [evaluate_code_decoder_naive_syndrome (checks, decoder, ecirc, scirc, p, 0 , 0 , gate_noise* p* m, nsamples= nsamples) for p in error_rates]
@@ -74,8 +75,7 @@ function my_plot_both_synd(code::AbstractECC, decoder::AbstractSyndromeDecoder,
7475 post_ec_error_rates_MC_CB = [evaluate_code_decoder_naive_syndrome (checks, decoder, ecirc, new_circuit, p, p_shift, p_wait, gate_noise, nsamples= nsamples) for p in error_rates]
7576 x_error_MC_CB = [post_ec_error_rates_MC_CB[i][1 ] for i in eachindex (post_ec_error_rates_MC_CB)]
7677 z_error_MC_CB = [post_ec_error_rates_MC_CB[i][2 ] for i in eachindex (post_ec_error_rates_MC_CB)]
77-
78- f = Figure (size= (1500 , 1500 ))
78+
7979 # X plot
8080 f_x = f[1 ,1 ]
8181 ax = f[1 ,1 ] = Axis (f_x, xlabel= " p_mem = physical qubit error rate after encoding" ,ylabel= " Logical error rate" ,title= title* " Logical X" )
@@ -431,21 +431,174 @@ function LDPC_plot(code::AbstractECC, decoder::AbstractSyndromeDecoder, p_shift=
431431 return f
432432end
433433
434- # f_Steane = my_plot_both_synd(Steane7(), TableDecoder(Steane7()))
435- # f_Shor = my_plot_both_synd(Shor9(), TableDecoder(Shor9()))
434+ function plot_for_paper_figure (code:: AbstractECC , decoder:: AbstractSyndromeDecoder , p_shift= 0.0001 , p_wait= 1 - exp (- 14.5 / 28_000 ); name= string (typeof (code)))
435+ title = name* " Code - Naive Syndrome Circuit"
436+ checks = parity_checks (code)
437+ scirc, _ = naive_syndrome_circuit (checks)
438+ # ecirc = naive_encoding_circuit(code)
439+ ecirc = nothing
440+ nsamples = 20_000
441+ gate_fidelity = 0.9995
442+ m = 10 # improvment factor
443+ # gate_noise = (1 - gate_fidelity)/m #improvement in gate fidelity
444+ gate_noise = 1 - gate_fidelity
445+ # p_wait = 1-exp(-14.5/m/28_000) # improvement in time to shuttle
446+ # p_shift = p_shift/m #improvement in shuttling fidelity
447+
448+ # gate_noise = 0
449+ # p_wait = 0
450+ # p_shift = 0
451+ error_rates = exp10 .(range (- 4 ,- 0.5 ,length= 30 ))
452+
453+ pt = 4 / 3
454+ f = Figure (size= (900 , 700 ),px_per_unit = 5.0 , fontsize = 15 pt)
455+ # ############### Shor syndrome simulation ################
456+ cat, scirc, anc_qubits, bit_indices = shor_syndrome_circuit (checks)
457+ title = name* " Code - Shor Syndrome Circuit"
458+
459+ # All to all connectivty - no gate noise
460+ post_ec_error_rates_MA_CA_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, cat, scirc, p, 0 , 0 , gate_noise* p* m, nsamples= nsamples) for p in error_rates]
461+ x_error_MA_CA_shor = [post_ec_error_rates_MA_CA_shor[i][1 ] for i in eachindex (post_ec_error_rates_MA_CA_shor)]
462+ z_error_MA_CA_shor = [post_ec_error_rates_MA_CA_shor[i][2 ] for i in eachindex (post_ec_error_rates_MA_CA_shor)]
463+
464+ # All to all connectivty - gate noise == init noise
465+ post_ec_error_rates_MA_CB_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, cat, scirc, p, 0 , 0 , gate_noise, nsamples= nsamples) for p in error_rates]
466+ x_error_MA_CB_shor = [post_ec_error_rates_MA_CB_shor[i][1 ] for i in eachindex (post_ec_error_rates_MA_CB_shor)]
467+ z_error_MA_CB_shor = [post_ec_error_rates_MA_CB_shor[i][2 ] for i in eachindex (post_ec_error_rates_MA_CB_shor)]
468+
469+ # Naive compilation and shuttle noise -> no gate noise and gate noise == init noise
470+ post_ec_error_rates_MB_CA_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, cat, scirc, p, p_shift* p* m, p_wait* p* m, gate_noise* p* m, nsamples= nsamples) for p in error_rates]
471+ x_error_MB_CA_shor = [post_ec_error_rates_MB_CA_shor[i][1 ] for i in eachindex (post_ec_error_rates_MB_CA_shor)]
472+ z_error_MB_CA_shor = [post_ec_error_rates_MB_CA_shor[i][2 ] for i in eachindex (post_ec_error_rates_MB_CA_shor)]
473+
474+ # Naive compilation and shuttle noise - gate noise == init noise
475+ post_ec_error_rates_MB_CB_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, cat, scirc, p, p_shift, p_wait, gate_noise, nsamples= nsamples) for p in error_rates]
476+ x_error_MB_CB_shor = [post_ec_error_rates_MB_CB_shor[i][1 ] for i in eachindex (post_ec_error_rates_MB_CB_shor)]
477+ z_error_MB_CB_shor = [post_ec_error_rates_MB_CB_shor[i][2 ] for i in eachindex (post_ec_error_rates_MB_CB_shor)]
478+
479+ # Gate shuffled circuit
480+ gate_shuffle_circ = CircuitCompilation2xn. gate_Shuffle! (scirc)
481+
482+ # Gate shuffle - no gate noise
483+ post_ec_error_rates_MS_CA_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, cat, gate_shuffle_circ, p, p_shift* p* m, p_wait* p* m, gate_noise* p* m, nsamples= nsamples) for p in error_rates]
484+ x_error_MS_CA_shor = [post_ec_error_rates_MS_CA_shor[i][1 ] for i in eachindex (post_ec_error_rates_MS_CA_shor)]
485+ z_error_MS_CA_shor = [post_ec_error_rates_MS_CA_shor[i][2 ] for i in eachindex (post_ec_error_rates_MS_CA_shor)]
486+
487+ # Gate shuffle- gate noise== init noise
488+ post_ec_error_rates_MS_CB_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, cat, gate_shuffle_circ, p, p_shift, p_wait, gate_noise, nsamples= nsamples) for p in error_rates]
489+ x_error_MS_CB_shor = [post_ec_error_rates_MS_CB_shor[i][1 ] for i in eachindex (post_ec_error_rates_MS_CB_shor)]
490+ z_error_MS_CB_shor = [post_ec_error_rates_MS_CB_shor[i][2 ] for i in eachindex (post_ec_error_rates_MS_CB_shor)]
491+
492+ # Circuit compilation
493+ new_circuit, order = CircuitCompilation2xn. ancil_reindex_pipeline (scirc)
494+ new_cat = CircuitCompilation2xn. perfect_reindex (cat, order)
495+
496+ # Circuit comp - no gate noise
497+ post_ec_error_rates_MC_CA_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, new_cat, new_circuit, p, p_shift* p* m, p_wait* p* m, gate_noise* p* m, nsamples= nsamples) for p in error_rates]
498+ x_error_MC_CA_shor = [post_ec_error_rates_MC_CA_shor[i][1 ] for i in eachindex (post_ec_error_rates_MC_CA_shor)]
499+ z_error_MC_CA_shor = [post_ec_error_rates_MC_CA_shor[i][2 ] for i in eachindex (post_ec_error_rates_MC_CA_shor)]
500+
501+ # Circuit Comp gate noise == init noise
502+ post_ec_error_rates_MC_CB_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, new_cat, new_circuit, p, p_shift, p_wait, gate_noise, nsamples= nsamples) for p in error_rates]
503+ x_error_MC_CB_shor = [post_ec_error_rates_MC_CB_shor[i][1 ] for i in eachindex (post_ec_error_rates_MC_CB_shor)]
504+ z_error_MC_CB_shor = [post_ec_error_rates_MC_CB_shor[i][2 ] for i in eachindex (post_ec_error_rates_MC_CB_shor)]
505+
506+ shor_failed = false
507+ x_error_MD_CA_shor = []
508+ z_error_MD_CA_shor = []
509+ x_error_MD_CB_shor = []
510+ z_error_MD_CB_shor = []
511+ try
512+ # Special shor syndrome Compiled circuit
513+ shor_new_circuit, shor_order = CircuitCompilation2xn. ancil_reindex_pipeline_shor_syndrome (scirc)
514+ shor_cat = CircuitCompilation2xn. perfect_reindex (cat, shor_order)
515+
516+ # TODO hack for working around gate commuting problem with Steane code
517+ if isa (code, QuantumClifford. ECC. Steane7)
518+ non_mz, mz = CircuitCompilation2xn. clifford_grouper (shor_new_circuit)
519+ batches = CircuitCompilation2xn. calculate_shifts (non_mz)
520+ reordered_batches = batches[[1 ,2 ,4 ,3 ,5 ,6 ]]
521+ new_non_mz = reduce (vcat, reordered_batches)
522+ shor_new_circuit = vcat (new_non_mz,mz)
523+ end
524+
525+ # Special Shor circuit Compilation - no gate noise
526+ post_ec_error_rates_MD_CA_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, shor_cat, shor_new_circuit, p, p_shift* p* m, p_wait* p* m, gate_noise* p* m, nsamples= nsamples) for p in error_rates]
527+ x_error_MD_CA_shor = [post_ec_error_rates_MD_CA_shor[i][1 ] for i in eachindex (post_ec_error_rates_MD_CA_shor)]
528+ z_error_MD_CA_shor = [post_ec_error_rates_MD_CA_shor[i][2 ] for i in eachindex (post_ec_error_rates_MD_CA_shor)]
529+
530+ # Special Shor circuit Compilation - gate noise == init noise
531+ post_ec_error_rates_MD_CB_shor = [evaluate_code_decoder_shor_syndrome (checks, decoder, ecirc, shor_cat, shor_new_circuit, p, p_shift, p_wait, gate_noise, nsamples= nsamples) for p in error_rates]
532+ x_error_MD_CB_shor = [post_ec_error_rates_MD_CB_shor[i][1 ] for i in eachindex (post_ec_error_rates_MD_CB_shor)]
533+ z_error_MD_CB_shor = [post_ec_error_rates_MD_CB_shor[i][2 ] for i in eachindex (post_ec_error_rates_MD_CB_shor)]
534+ catch e
535+ println (" Step 5 was needed for SSSC" )
536+ shor_failed = true
537+ end
538+
539+
540+ # Shor syndrome plots
541+ f_shor_x = f[1 , 1 ]
542+ ax = f[1 ,1 ] = Axis (f_shor_x, xlabel= " p_mem = physical qubit error rate after encoding" ,ylabel= " Logical error rate" ,title= title* " Logical X" )
543+ lines! (f_shor_x, [- 5 , - 0.5 ], [- 5 , - 0.5 ], color= :gray )
544+
545+ # All to all connectivty
546+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MA_CA_shor), color= :black , marker= :circle )
547+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MA_CB_shor), color= :black , marker= :utriangle )
548+
549+ # Naive compilation
550+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MB_CA_shor), color= :red , marker= :circle )
551+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MB_CB_shor), color= :red , marker= :utriangle )
552+
553+ # Gate shuffle compilation
554+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MS_CA_shor), color= :blue , marker= :circle )
555+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MS_CB_shor), color= :blue , marker= :utriangle )
556+
557+ # Ancil reindex Compilation
558+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MC_CA_shor), color= :green , marker= :circle )
559+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MC_CB_shor), color= :green , marker= :utriangle )
560+
561+ # Fancy Shor- specialized comilation
562+ if ! shor_failed
563+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MD_CA_shor), color= :orange , marker= :circle )
564+ scatter! (f_shor_x, log10 .(error_rates), log10 .(x_error_MD_CB_shor), color= :orange , marker= :utriangle )
565+ end
566+ xlims! (ax, high= - 0.5 , low= - 4.0 )
567+ ylims! (ax, high= - 0.5 , low= - 4.0 )
568+
569+ lines! (f_shor_x, [0 ,0 ], [0 ,0 ], label= " All to all connectivty" , color= :black )
570+ lines! (f_shor_x, [0 ,0 ], [0 ,0 ], label= " Naive compilation" , color= :red )
571+ lines! (f_shor_x, [0 ,0 ], [0 ,0 ], label= " Gate shuffling" , color= :blue )
572+ lines! (f_shor_x, [0 ,0 ], [0 ,0 ], label= " Ancil heuristic" , color= :green )
573+ lines! (f_shor_x, [0 ,0 ], [0 ,0 ], label= " Shor-syndrome specialized comp" , color= :orange )
574+
575+ scatter! (f_shor_x, [0 ,0 ], [0 ,0 ], label= " Constant near-term noise parameters \n (shift error, decoherence, gate noise)" , color= :gray , marker= :utriangle )
576+ scatter! (f_shor_x, [0 ,0 ], [0 ,0 ], label= " Near-term noise parameters are \n multiplied by 10*p_mem" , color= :gray , marker= :circle )
577+
578+ xlims! (ax, high= - 0.5 , low= - 4.0 )
579+ ylims! (ax, high= - 0.5 , low= - 4.0 )
580+ f[1 ,2 ] = Legend (f, ax, " Compilation Style/Gate Noise" )
581+
582+ return f
583+ end
584+
585+ # f_Steane = my_plot_both_synd(Steane7(), TableDecoder(Steane7()))
586+ # f_Shor = my_plot_both_synd(Shor9(), TableDecoder(Shor9()))
436587# f_Cleve = my_plot_both_synd(Cleve8(), TableDecoder(Cleve8()))
437588# f_P5 = my_plot_both_synd(Perfect5(), TableDecoder(Perfect5()))
438589
439590# f_x_Gottesman3 = my_plot_both_synd(Gottesman(3), TableDecoder(Gottesman(3)))
440591
441592# f_t3 = my_plot_both_synd(Toric(3, 3), PyMatchingDecoder(Toric(3, 3)), name="Toric 3x3")
593+ f_t3 = plot_for_paper_figure (Toric (3 , 3 ), PyMatchingDecoder (Toric (3 , 3 )), name= " Toric 3x3" )
594+
442595# f_t4 = my_plot_both_synd(Toric(4, 4), PyMatchingDecoder(Toric(4, 4)), name="Toric 4x4")
443596# f_t6 = my_plot_both_synd(Toric(6, 6), PyMatchingDecoder(Toric(6, 6)), name="Toric 6x6")
444597# f_t10 = the_plot_both_synd(Toric(10, 10), PyMatchingDecoder(Toric(10, 10)), name="Toric10")
445598
446- H = LDPCDecoders. parity_check_matrix (n, wr, wc)
447- code = CSS (zeros (Bool,size (H)),H)
448- f_ldpc = LDPC_plot (code, PyBeliefPropDecoder (code))
599+ # H = LDPCDecoders.parity_check_matrix(n, wr, wc)
600+ # code = CSS(zeros(Bool,size(H)),H)
601+ # f_ldpc = LDPC_plot(code, PyBeliefPropDecoder(code))
449602
450603# stab, Cx, Cz = CircuitCompilation2xn.getGoodLDPC(1)
451604# code = CSS(Cx, Cz)
0 commit comments