Skip to content

BSM circuit that can be used for quantum teleportation #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion src/CircuitZoo/CircuitZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using DocStringExtensions
export EntanglementSwap, LocalEntanglementSwap,
Purify2to1, Purify2to1Node, Purify3to1, Purify3to1Node,
PurifyStringent, PurifyStringentNode, PurifyExpedient, PurifyExpedientNode,
SDDecode, SDEncode
SDDecode, SDEncode, BellStateMeasurement

abstract type AbstractCircuit end

Expand Down Expand Up @@ -938,4 +938,45 @@ function (circuit::SDDecode)(rrefA, rrefB)
return b1-1, b2-1
end

"""
$TYPEDEF

Fields:

$FIELDS

Bell State measurement circuit used in the Teleportation protocol. When Alice and Bob share a Bell pair, Alice can locally apply this circuit to teleport her qubit to Bob.
The circuit takes as arguments the qubit to be teleported and the half of the Bell pair that Alice has. Both qubits are measured and the circuit returns the measurement results.
These results are used to apply the necessary correction gates on Bob's side to recover the original qubit.

```jldoctest
julia> regA = Register(2); regB = Register(1);

julia> initialize!(regA[1], Y1);

julia> initialize!((regA[2], regB[1]), StabilizerState("XX ZZ"));

julia> xmeas, zmeas = BellStateMeasurement()(regA[1], regA[2]);

julia> if xmeas==2 apply!(regB[1], X) end

julia> if zmeas==2 apply!(regB[1], Z) end

julia> observable(regB[1], projector(Y1))
0.9999999999999997 + 0.0im
```
"""
struct BellStateMeasurement <: AbstractCircuit
end

function (circuit::BellStateMeasurement)(tobeteleported::RegRef, bellpairhalf::RegRef)
apply!((tobeteleported, bellpairhalf), CNOT)
apply!(tobeteleported, H)
zmeas = project_traceout!(tobeteleported, σᶻ)
xmeas = project_traceout!(bellpairhalf, σᶻ)
xmeas, zmeas
end



end # module
29 changes: 29 additions & 0 deletions test/test_circuitzoo_bellstatemeasurement.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@testitem "Bell State Measurement" tags=[:circuitzoo_bsm] begin
using QuantumSavory.CircuitZoo: BellStateMeasurement
using Random

for _ in 1:10
# Randomly generate a state for Alice to send
a = rand()
state_to_send = √(a)*X1 + √(1-a)*X2
# Create a Bell state
bell = StabilizerState("XX ZZ")
# Create registers for Alice and Bob
regA = Register(2);
regB = Register(1);

# Initialize the registers
initialize!(regA[1], state_to_send);
initialize!((regA[2], regB[1]), bell);

# Execute BSM
xmeas, zmeas = BellStateMeasurement()(regA[1], regA[2]);

# Apply corrections on Bob's end
if xmeas==2 apply!(regB[1], X) end
if zmeas==2 apply!(regB[1], Z) end

@test real(observable(regB[1], projector(state_to_send))) ≈ 1.0
@test isnothing(regA.staterefs[1]) & isnothing(regA.staterefs[2])
end
end
Loading