|
5 | 5 |
|
6 | 6 | include("test_ecc_base.jl") |
7 | 7 |
|
| 8 | + using QuantumClifford: Tableau |
| 9 | + reinterpret_frame(frame) = PauliFrame(reinterpret_stab(frame.frame), copy(frame.measurements)) |
| 10 | + reinterpret_stab(s) = Stabilizer(Tableau(copy(phases(s)), nqubits(s), collect(reinterpret(UInt8, collect(s.tab.xzs)))[[1:1+(nqubits(s)-1)÷8;end÷2+1:end÷2+1+(nqubits(s)-1)÷8],:])) |
| 11 | + reinterpret_p(p) = PauliOperator(p.phase, nqubits(p), collect(reinterpret(UInt8, p.xz))[[1:1+(nqubits(p)-1)÷8;end÷2+1:end÷2+1+(nqubits(p)-1)÷8]]) |
| 12 | + |
8 | 13 | function pframe_naive_vs_shor_syndrome(code) |
9 | 14 | ecirc = naive_encoding_circuit(code) |
10 | 15 | naive_scirc, naive_ancillaries = naive_syndrome_circuit(code) |
|
30 | 35 | pftrajectories(shor_frames, vcat(ecirc, shor_cat_scirc)) |
31 | 36 | # manually injecting the same type of noise in the frames -- not really a user accessible API |
32 | 37 | p = random_pauli(dataqubits, realphase=true) |
33 | | - pₙ = embed(naive_qubits, 1:dataqubits, p) |
34 | | - pₛ = embed(shor_qubits, 1:dataqubits, p) |
| 38 | + pₙ = embed(naive_qubits+1, 1:dataqubits, p) # +1 to account for the buffer qubit hidden in pauli frames |
| 39 | + pₛ = embed(shor_qubits+1, 1:dataqubits, p) # +1 to account for the buffer qubit hidden in pauli frames |
35 | 40 | mul_left!(naive_frames.frame, pₙ) |
36 | 41 | mul_left!(shor_frames.frame, pₛ) |
37 | 42 | # run the syndrome circuits using the public API |
38 | 43 | pftrajectories(naive_frames, naive_scirc) |
39 | 44 | pftrajectories(shor_frames, shor_scirc) |
40 | 45 | @test pfmeasurements(naive_frames) == pfmeasurements(shor_frames)[:,shor_bits] |
| 46 | + |
| 47 | + # just for completeness, let's also try bitpacking in UInt8 instead of the default UInt |
| 48 | + _naive_frames = PauliFrame(nframes, naive_qubits, syndromebits) |
| 49 | + _shor_frames = PauliFrame(nframes, shor_qubits, last(shor_bits)) |
| 50 | + naive_uint8 = reinterpret_frame(_naive_frames) |
| 51 | + shor_uint8 = reinterpret_frame(_shor_frames) |
| 52 | + pftrajectories(naive_uint8, ecirc) |
| 53 | + pftrajectories(shor_uint8, vcat(ecirc, shor_cat_scirc)) |
| 54 | + p_uint8 = reinterpret_p(p) |
| 55 | + pₙ_uint8 = embed(naive_qubits+1, 1:dataqubits, p_uint8) |
| 56 | + pₛ_uint8 = embed(shor_qubits+1, 1:dataqubits, p_uint8) |
| 57 | + mul_left!(naive_uint8.frame, pₙ_uint8) |
| 58 | + mul_left!(shor_uint8.frame, pₛ_uint8) |
| 59 | + pftrajectories(naive_uint8, naive_scirc) |
| 60 | + pftrajectories(shor_uint8, shor_scirc) |
| 61 | + @test pfmeasurements(shor_uint8)[:,shor_bits] == pfmeasurements(shor_frames)[:,shor_bits] == pfmeasurements(naive_frames) == pfmeasurements(naive_uint8) |
41 | 62 | end |
42 | 63 | end |
43 | 64 |
|
44 | 65 | @testset "naive and shor measurement circuits" begin |
45 | | - for c in all_testablable_code_instances() |
| 66 | + for (i,c) in enumerate(all_testablable_code_instances()) |
46 | 67 | pframe_naive_vs_shor_syndrome(c) |
47 | 68 | end |
48 | 69 | end |
|
0 commit comments