Skip to content

Commit

Permalink
configure two gate noise in various code evaluation setups (QuantumSa…
Browse files Browse the repository at this point in the history
…vory#253)


---------

Co-authored-by: Stefan Krastanov <stefan@krastanov.org>
  • Loading branch information
ismoldayev and Krastanov authored Apr 18, 2024
1 parent 8ea1a6a commit 3cdf46b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

## v0.9.4 - dev

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

## v0.9.3 - 2024-04-10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function Quantikz.QuantikzOp(op::Reset) # TODO This is complicated because quant
Quantikz.Initialize("$str",affectedqubits(op)) # TODO make Quantikz work with tuples and remove the collect
end
end
Quantikz.QuantikzOp(op::NoiseOp) = Quantikz.Noise(op.indices)
Quantikz.QuantikzOp(op::NoiseOp) = Quantikz.Noise(collect(op.indices))
Quantikz.QuantikzOp(op::NoiseOpAll) = Quantikz.NoiseAll()
Quantikz.QuantikzOp(op::ClassicalXORConcreteWorkaround) = Quantikz.ClassicalDecision(sort([op.store, op.bits...]))

Expand Down
38 changes: 33 additions & 5 deletions src/ecc/decoder_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,46 @@ struct ShorSyndromeECCSetup <: AbstractECCSetup
end
end

function add_two_qubit_gate_noise(g, gate_error)
return ()
end

"""Applies gate_error to a given two-qubit gate g."""
function add_two_qubit_gate_noise(g::AbstractTwoQubitOperator, gate_error)
qubits = affectedqubits(g)
return (PauliError(qubits, gate_error), )
end

function physical_ECC_circuit(H, setup::NaiveSyndromeECCSetup)
syndrome_circ, n_anc, syndrome_bits = naive_syndrome_circuit(H)
noisy_syndrome_circ = syndrome_circ # add_two_qubit_gate_noise(syndrome_circ, gate_error)
mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)];
noisy_syndrome_circ = []

for op in syndrome_circ
push!(noisy_syndrome_circ, op)
for noise_op in add_two_qubit_gate_noise(op, setup.two_qubit_gate_noise)
push!(noisy_syndrome_circ, noise_op)
end
end

mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)]
circ = [mem_error_circ..., noisy_syndrome_circ...]
circ, syndrome_bits, n_anc
return circ, syndrome_bits, n_anc
end


function physical_ECC_circuit(H, setup::ShorSyndromeECCSetup)
prep_anc, syndrome_circ, n_anc, syndrome_bits = shor_syndrome_circuit(H)
noisy_syndrome_circ = syndrome_circ # add_two_qubit_gate_noise(syndrome_circ, gate_error)
mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)];

noisy_syndrome_circ = []
for op in syndrome_circ
push!(noisy_syndrome_circ, op)
for noise_op in add_two_qubit_gate_noise(op, setup.two_qubit_gate_noise)
push!(noisy_syndrome_circ, noise_op)
end
end

mem_error_circ = [PauliError(i, setup.mem_noise) for i in 1:nqubits(H)]

circ = [prep_anc..., mem_error_circ..., noisy_syndrome_circ...]
circ, syndrome_bits, n_anc
end
Expand Down
8 changes: 5 additions & 3 deletions src/noise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ function applynoise!(s::AbstractStabilizer,noise::UnbiasedUncorrelatedNoise,i::I
end

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

NoiseOp(noise, indices::AbstractVector{Int}) = NoiseOp(noise, tuple(indices...))

"""A convenient constructor for various types of Pauli errors,
that can be used as circuit gates in simulations.
Returns more specific types when necessary."""
Expand Down

0 comments on commit 3cdf46b

Please sign in to comment.