Skip to content

Commit 3cdf46b

Browse files
configure two gate noise in various code evaluation setups (#253)
--------- Co-authored-by: Stefan Krastanov <[email protected]>
1 parent 8ea1a6a commit 3cdf46b

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
## v0.9.4 - dev
99

10+
- Gate errors are now conveniently supported by the various ECC benchmark setups in the `ECC` module.
1011
- Remove printing of spurious debug info from the PyBP decoder.
1112

1213
## v0.9.3 - 2024-04-10

ext/QuantumCliffordQuantikzExt/QuantumCliffordQuantikzExt.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function Quantikz.QuantikzOp(op::Reset) # TODO This is complicated because quant
7171
Quantikz.Initialize("$str",affectedqubits(op)) # TODO make Quantikz work with tuples and remove the collect
7272
end
7373
end
74-
Quantikz.QuantikzOp(op::NoiseOp) = Quantikz.Noise(op.indices)
74+
Quantikz.QuantikzOp(op::NoiseOp) = Quantikz.Noise(collect(op.indices))
7575
Quantikz.QuantikzOp(op::NoiseOpAll) = Quantikz.NoiseAll()
7676
Quantikz.QuantikzOp(op::ClassicalXORConcreteWorkaround) = Quantikz.ClassicalDecision(sort([op.store, op.bits...]))
7777

src/ecc/decoder_pipeline.jl

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,46 @@ struct ShorSyndromeECCSetup <: AbstractECCSetup
7979
end
8080
end
8181

82+
function add_two_qubit_gate_noise(g, gate_error)
83+
return ()
84+
end
85+
86+
"""Applies gate_error to a given two-qubit gate g."""
87+
function add_two_qubit_gate_noise(g::AbstractTwoQubitOperator, gate_error)
88+
qubits = affectedqubits(g)
89+
return (PauliError(qubits, gate_error), )
90+
end
91+
8292
function physical_ECC_circuit(H, setup::NaiveSyndromeECCSetup)
8393
syndrome_circ, n_anc, syndrome_bits = naive_syndrome_circuit(H)
84-
noisy_syndrome_circ = syndrome_circ # add_two_qubit_gate_noise(syndrome_circ, gate_error)
85-
mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)];
94+
noisy_syndrome_circ = []
95+
96+
for op in syndrome_circ
97+
push!(noisy_syndrome_circ, op)
98+
for noise_op in add_two_qubit_gate_noise(op, setup.two_qubit_gate_noise)
99+
push!(noisy_syndrome_circ, noise_op)
100+
end
101+
end
102+
103+
mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)]
86104
circ = [mem_error_circ..., noisy_syndrome_circ...]
87-
circ, syndrome_bits, n_anc
105+
return circ, syndrome_bits, n_anc
88106
end
89107

108+
90109
function physical_ECC_circuit(H, setup::ShorSyndromeECCSetup)
91110
prep_anc, syndrome_circ, n_anc, syndrome_bits = shor_syndrome_circuit(H)
92-
noisy_syndrome_circ = syndrome_circ # add_two_qubit_gate_noise(syndrome_circ, gate_error)
93-
mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)];
111+
112+
noisy_syndrome_circ = []
113+
for op in syndrome_circ
114+
push!(noisy_syndrome_circ, op)
115+
for noise_op in add_two_qubit_gate_noise(op, setup.two_qubit_gate_noise)
116+
push!(noisy_syndrome_circ, noise_op)
117+
end
118+
end
119+
120+
mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)]
121+
94122
circ = [prep_anc..., mem_error_circ..., noisy_syndrome_circ...]
95123
circ, syndrome_bits, n_anc
96124
end

src/noise.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ function applynoise!(s::AbstractStabilizer,noise::UnbiasedUncorrelatedNoise,i::I
5252
end
5353

5454
"""An operator that applies the given `noise` model to the qubits at the selected `indices`."""
55-
struct NoiseOp <: AbstractNoiseOp
56-
noise::AbstractNoise
57-
indices::AbstractVector{Int}
55+
struct NoiseOp{N, Q} <: AbstractNoiseOp where {N, Q}
56+
noise::N #<:AbstractNoise
57+
indices::NTuple{Q, Int}
5858
end
5959

60+
NoiseOp(noise, indices::AbstractVector{Int}) = NoiseOp(noise, tuple(indices...))
61+
6062
"""A convenient constructor for various types of Pauli errors,
6163
that can be used as circuit gates in simulations.
6264
Returns more specific types when necessary."""

0 commit comments

Comments
 (0)