-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from Abhishek-1Bhatt/ab/firstgenrepeaterv2
entanglement tracker and swapper added to ProtocolZoo, with significant improvements to the query and messaging systems
- Loading branch information
Showing
35 changed files
with
1,601 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ jobs: | |
matrix: | ||
version: | ||
- '1' | ||
- '1.9' | ||
os: | ||
- ubuntu-latest | ||
threads: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
include("setup.jl") | ||
|
||
using GLMakie # For plotting | ||
GLMakie.activate!() | ||
|
||
## | ||
# Demo the entangler on its own | ||
## | ||
|
||
sizes = [2,3,4,3,2] # Number of qubits in each register | ||
T2 = 10.0 # T2 dephasing time of all qubits | ||
#TODO F = 0.9 # Fidelity of the raw Bell pairs | ||
|
||
sim, network = simulation_setup(sizes, T2) | ||
|
||
## | ||
|
||
for (;src, dst) in edges(network) | ||
eprot = EntanglerProt(sim, network, src, dst) | ||
@process eprot() | ||
end | ||
|
||
## | ||
|
||
# set up a plot and save a handle to the plot observable | ||
fig = Figure(resolution=(400,400)) | ||
_,ax,_,obs = registernetplot_axis(fig[1,1],network) | ||
display(fig) | ||
|
||
## | ||
|
||
# record the simulation progress | ||
step_ts = range(0, 4, step=0.1) | ||
record(fig, "firstgenrepeater_v2-01.entangler.mp4", step_ts, framerate=10, visible=true) do t | ||
run(sim, t) | ||
notify(obs) | ||
ax.title = "t=$(t)" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
include("setup.jl") | ||
|
||
using GLMakie # For plotting | ||
GLMakie.activate!() | ||
|
||
## | ||
# Demo the entangler on its own | ||
## | ||
|
||
sizes = [2,3,4,3,2] # Number of qubits in each register | ||
T2 = 10.0 # T2 dephasing time of all qubits | ||
#TODO F = 0.9 # Fidelity of the raw Bell pairs | ||
|
||
sim, network = simulation_setup(sizes, T2) | ||
|
||
## | ||
|
||
for (;src, dst) in edges(network) | ||
eprot = EntanglerProt(sim, network, src, dst) | ||
@process eprot() | ||
end | ||
for node in vertices(network) | ||
sprot = SwapperProt(sim, network, node; nodeL = <(node), nodeR = >(node)) | ||
@process sprot() | ||
end | ||
|
||
## | ||
|
||
# set up a plot and save a handle to the plot observable | ||
fig = Figure(resolution=(400,400)) | ||
_,ax,_,obs = registernetplot_axis(fig[1,1],network) | ||
display(fig) | ||
|
||
## | ||
|
||
# record the simulation progress | ||
step_ts = range(0, 30, step=0.1) | ||
record(fig, "firstgenrepeater-03.swapper.mp4", step_ts, framerate=10, visible=true) do t | ||
run(sim, t) | ||
notify(obs) | ||
ax.title = "t=$(t)" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# For convenient graph data structures | ||
using Graphs | ||
|
||
# For discrete event simulation | ||
using ResumableFunctions | ||
using ConcurrentSim | ||
|
||
# Useful for interactive work | ||
# Enables automatic re-compilation of modified codes | ||
using Revise | ||
|
||
# The workhorse for the simulation | ||
using QuantumSavory | ||
|
||
# Predefined useful circuits | ||
using QuantumSavory.CircuitZoo: EntanglementSwap, Purify2to1 | ||
using QuantumSavory.ProtocolZoo: EntanglerProt, SwapperProt | ||
|
||
## | ||
# Create a handful of qubit registers in a chain | ||
## | ||
|
||
"""Creates the datastructures representing the simulated network""" | ||
function simulation_setup( | ||
sizes, # Array giving the number of qubits in each node | ||
T2 # T2 dephasing times for the qubits | ||
; | ||
representation = QuantumOpticsRepr # Representation to use for the qubits | ||
) | ||
R = length(sizes) # Number of registers | ||
|
||
# All of the quantum register we will be simulating | ||
registers = Register[] | ||
for s in sizes | ||
traits = [Qubit() for _ in 1:s] | ||
repr = [representation() for _ in 1:s] | ||
bg = [T2Dephasing(T2) for _ in 1:s] | ||
push!(registers, Register(traits,repr,bg)) | ||
end | ||
|
||
# A graph structure defining the connectivity among registers | ||
# It is not necessary to use such a structure, however, it is a convenient way to | ||
# store data about the simulation (and we have created helper plotting functions | ||
# expecting such a structure). | ||
graph = grid([R]) | ||
network = RegisterNet(graph, registers) # A graphs with extra "meta data" | ||
|
||
# The scheduler datastructure for the discrete event simulation | ||
sim = get_time_tracker(network) | ||
|
||
sim, network | ||
end | ||
|
||
## | ||
# The Entangler | ||
## | ||
|
||
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2) | ||
const perfect_pair_dm = SProjector(perfect_pair) | ||
const mixed_dm = MixedState(perfect_pair_dm) | ||
noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper | ||
const XX = X⊗X | ||
const ZZ = Z⊗Z | ||
const YY = Y⊗Y | ||
|
||
## | ||
# The Swapper | ||
## | ||
|
||
|
||
## | ||
# The Purifier | ||
## | ||
|
||
@resumable function purifier( | ||
sim::Environment, # The scheduler for all simulation events | ||
network, # The graph of quantum nodes | ||
nodea, # One of the nodes on which the pairs to be purified rest | ||
nodeb, # The other such node | ||
purifier_wait_time,# The wait time in case there are no pairs available for purification | ||
purifier_busy_time # The duration of the purification circuit | ||
) | ||
round = 0 | ||
while true | ||
pairs_of_bellpairs = findqubitstopurify(network,nodea,nodeb) | ||
if isnothing(pairs_of_bellpairs) | ||
@yield timeout(sim, purifier_wait_time) | ||
continue | ||
end | ||
pair1qa, pair1qb, pair2qa, pair2qb = pairs_of_bellpairs | ||
locks = [network[nodea][[pair1qa,pair2qa]]; | ||
network[nodeb][[pair1qb,pair2qb]]] | ||
@yield mapreduce(request, &, locks) | ||
@yield timeout(sim, purifier_busy_time) | ||
rega = network[nodea] | ||
regb = network[nodeb] | ||
purifyerror = (:X, :Z)[round%2+1] | ||
purificationcircuit = Purify2to1(purifyerror) | ||
success = purificationcircuit(rega[pair1qa],regb[pair1qb],rega[pair2qa],regb[pair2qb]) | ||
if !success | ||
network[nodea,:enttrackers][pair1qa] = nothing | ||
network[nodeb,:enttrackers][pair1qb] = nothing | ||
@simlog sim "failed purification at $(nodea):$(pair1qa)&$(pair2qa) and $(nodeb):$(pair1qb)&$(pair2qb)" | ||
else | ||
round += 1 | ||
@simlog sim "purification at $(nodea):$(pair1qa) $(nodeb):$(pair1qb) by sacrifice of $(nodea):$(pair1qa) $(nodeb):$(pair1qb)" | ||
end | ||
network[nodea,:enttrackers][pair2qa] = nothing | ||
network[nodeb,:enttrackers][pair2qb] = nothing | ||
release.(locks) | ||
end | ||
end | ||
|
||
function findqubitstopurify(network,nodea,nodeb) | ||
enttrackers = network[nodea,:enttrackers] | ||
rega = network[nodea] | ||
regb = network[nodeb] | ||
enttrackers = [(i=i,n...) for (i,n) in enumerate(enttrackers) | ||
if !isnothing(n) && n.node==nodeb && !islocked(rega[i]) && !islocked(regb[n.slot])] | ||
if length(enttrackers)>=2 | ||
aqubits = [n.i for n in enttrackers[end-1:end]] | ||
bqubits = [n.slot for n in enttrackers[end-1:end]] | ||
return aqubits[2], bqubits[2], aqubits[1], bqubits[1] | ||
else | ||
return nothing | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.