Skip to content
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

Connection-less, Centralized controller #165

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9816e20
Initial changes for different control plane simulations
ba2tro Sep 23, 2024
bd6bbb1
update the examples to use the new protocols
ba2tro Sep 23, 2024
7a8d4c4
fixup
ba2tro Oct 4, 2024
b9b726a
update docstrings and changelog
ba2tro Oct 4, 2024
98454b0
add tests
ba2tro Oct 5, 2024
057541c
avoid using CliffordRepr() in tests
ba2tro Oct 7, 2024
70dc334
Send RequestCompletion from controller instead of RequestTracker
ba2tro Oct 10, 2024
20e501e
Try to add a sequence diagram to the readme and fix a typo in wgl app
ba2tro Oct 14, 2024
0fe7fc7
fix typo in the sequence diagram
ba2tro Oct 14, 2024
46f5d3f
move path selection to controller and related modifications
ba2tro Nov 4, 2024
ce88cb8
update controlplane test
ba2tro Nov 4, 2024
49ab5e6
update ProtocolZoo/ProtocolZoo.jl
ba2tro Nov 4, 2024
1a7bddb
fix for congestionchain example
ba2tro Nov 4, 2024
859292e
Add a connection-less and centralized protocol
ba2tro Nov 6, 2024
c965b4c
add the new example to tests
ba2tro Nov 6, 2024
a1fa6be
add new protocol to tests
ba2tro Nov 6, 2024
7dbc582
Merge branch 'master' into clcontroller
ba2tro Nov 8, 2024
656679f
Make classical and quantum channel delays customizable when initializ…
ba2tro Oct 24, 2024
a3842db
a more general predicate and choosing function
ba2tro Nov 14, 2024
a65fae9
Merge branch 'clcontroller' of https://github.com/ba2tro/QuantumSavor…
ba2tro Nov 14, 2024
bed4af2
Improve swap predicate with memoization and add condition for swaps o…
ba2tro Nov 22, 2024
1cf393a
Merge branch 'QuantumSavory:master' into clcontroller
ba2tro Nov 25, 2024
37ffab2
Add compat entry for Memoize.jl
ba2tro Nov 25, 2024
65a7d9f
infinite rounds for swapper in connection-less controller and separat…
ba2tro Dec 5, 2024
3dbd8aa
update test_controlplane.jl
ba2tro Dec 6, 2024
b61b6b6
update docstrings
ba2tro Dec 6, 2024
c86b7d7
fix
ba2tro Dec 11, 2024
3673750
Update sequence diagrams
ba2tro Dec 12, 2024
5297517
documentation and performance visualization
ba2tro Dec 24, 2024
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## v0.5.1-dev

- Simplify one of the switch protocols to avoid dependence on GraphMatching.jl which does not install well on non-linux systems. Do not rely on the default `SimpleSwitchDiscreteProt` for the time being.
- Implement a network control protocol that is connection-oriented, centralized and non-distributed and another that is connection-less, centralized and non-distributed
- Implement protocols: request generator and request tracker for simulation with the above control protocol in an asynchronous way.
- Add `PhysicalGraph` struct for storing network metadata as the simulation evolves.
- New tags: `EntanglementRequest`,`SwapRequest`, `DistributionRequest` and `RequestCompletion`
- Add `classical_delay` and `quantum_delay` as keyword arguments to the `RegisterNet` constructor to set a default global network edge latency.

## v0.5.0 - 2024-10-16
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Memoize = "c03570c3-d221-55d1-a50c-7939bbd78826"
NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Expand Down Expand Up @@ -40,6 +41,7 @@ Graphs = "1.9"
IterTools = "1.4.0"
LinearAlgebra = "1"
Makie = "0.20, 0.21"
Memoize = "0.4.4"
NetworkLayout = "0.4.4"
PrecompileTools = "1"
Printf = "1"
Expand Down
2 changes: 1 addition & 1 deletion examples/congestionchain/1_visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ scatter!(ax_fidZZ,ts,fidZZ,label="ZZ",color=(c2,0.1))

display(fig)

step_ts = range(0, 1000, step=0.1)
step_ts = range(0.0, 1000.0, step=0.1)

record(fig, "congestionchain.mp4", step_ts; framerate=50, visible=true) do t
run(sim, t)
Expand Down
46 changes: 46 additions & 0 deletions examples/controlplane/1a_cdd_interactive.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
include("setup.jl")

succ_prob = Observable(0.001)
for (;src, dst) in edges(net)
eprot = EntanglerProt(sim, net, src, dst; rounds=-1, randomize=true, success_prob=succ_prob[])
@process eprot()
end

local_busy_time = Observable(0.0)
retry_lock_time = Observable(0.1)
for node in 2:7
swapper = SwapperProt(sim, net, node; nodeL = <(node), nodeH = >(node), chooseL = argmin, chooseH = argmax, rounds=-1, local_busy_time=local_busy_time[],
retry_lock_time=retry_lock_time[])
@process swapper()
end

for v in vertices(net)
tracker = EntanglementTracker(sim, net, v)
@process tracker()
end

period_cons = Observable(0.1)
consumer = EntanglementConsumer(sim, net, 1, 8; period=period_cons[])
@process consumer()

period_dec = Observable(0.1)
for v in vertices(net)
cutoff = CutoffProt(sim, net, v; period=period_dec[])
@process cutoff()
end
params = [succ_prob, local_busy_time, retry_lock_time, period_cons, period_dec]
sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer, params)

step_ts = range(0.0, 1000.0, step=0.1)
record(fig, "sim.mp4", step_ts; framerate=10, visible=true) do t
run(sim, t)
notify.((obs,entlog))
notify.(params)
ylims!(entlogaxis, (-1.04,1.04))
xlims!(entlogaxis, max(0,t-50), 1+t)
ylims!(fid_axis, (0, 1.04))
xlims!(fid_axis, max(0, t-50), 1+t)
autolimits!(histaxis)
ylims!(num_epr_axis, (0, 4))
xlims!(num_epr_axis, max(0, t-50), 1+t)
end
115 changes: 115 additions & 0 deletions examples/controlplane/1b_cdd_wglmakie.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
using WGLMakie
WGLMakie.activate!()
import Bonito
using Markdown

include("setup.jl")


const custom_css = Bonito.DOM.style("ul {list-style: circle !important;}") # TODO remove after fix of bug in JSServe https://github.com/SimonDanisch/JSServe.jl/issues/178

succ_prob = Observable(0.001)
for (;src, dst) in edges(net)
eprot = EntanglerProt(sim, net, src, dst; rounds=-1, randomize=true, success_prob=succ_prob[])
@process eprot()
end

local_busy_time = Observable(0.0)
retry_lock_time = Observable(0.1)
for node in 2:7
swapper = SwapperProt(sim, net, node; nodeL = <(node), nodeH = >(node), chooseL = argmin, chooseH = argmax, rounds=-1, local_busy_time=local_busy_time[],
retry_lock_time=retry_lock_time[])
@process swapper()
end

for v in vertices(net)
tracker = EntanglementTracker(sim, net, v)
@process tracker()
end

period_cons = Observable(0.1)
consumer = EntanglementConsumer(sim, net, 1, 8; period=period_cons[])
@process consumer()

period_dec = Observable(0.1)
for v in vertices(net)
cutoff = CutoffProt(sim, net, v; period=period_dec[])
@process cutoff()
end
params = [succ_prob, local_busy_time, retry_lock_time, period_cons, period_dec]

# All the calls that happen in the main event loop of the simulation,
# encapsulated here so that we can conveniently pause the simulation from the WGLMakie app.
function continue_singlerun!(sim, obs, entlog, params, entlogaxis, fid_axis, histaxis, num_epr_axis, running)
step_ts = range(0, 1000, step=0.1)
for t in step_ts
run(sim, t)
notify.((obs,entlog))
notify.(params)
ylims!(entlogaxis, (-1.04,1.04))
xlims!(entlogaxis, max(0,t-50), 1+t)
ylims!(fid_axis, (0, 1.04))
xlims!(fid_axis, max(0, t-50), 1+t)
autolimits!(histaxis)
ylims!(num_epr_axis, (0, 4))
xlims!(num_epr_axis, max(0, t-50), 1+t)
end
running[] = nothing
end

#
landing = Bonito.App() do

sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer, params)

running = Observable{Any}(false)
fig[5,1] = buttongrid = GridLayout(tellwidth = false)
buttongrid[1,1] = b = Makie.Button(fig, label = @lift(isnothing($running) ? "Done" : $running ? "Running..." : "Run once"), height=30, tellwidth=false)

on(b.clicks) do _
if !running[]
running[] = true
end
end
on(running) do r
if r
Threads.@spawn begin
continue_singlerun!(
sim, obs, entlog, params, entlogaxis, fid_axis, histaxis, num_epr_axis, running)
end
end
end


content = md"""
Pick simulation settings and hit run (see below for technical details).

$(fig.scene)

# Connectionless, Distributed and Decentralized Control Plane for Entanglement Distribution

The above simulation visualizes entanglement distribution between Alice and Bob on an arbitrary network topology
given by the adjacency matrix of the graph. The control plane architecture used for this simulation is connectionless,
distributed and decentralized. The node representing Alice is the node on the top left and the bottom right is Bob.
The actual connectivity of the physical graph isn't fully captured by the visualization above as we use edges only to
show the virtual graph.

[See and modify the code for this simulation on github.](https://github.com/QuantumSavory/QuantumSavory.jl/tree/master/examples/controlplane/1b_cdd_wglmakie.jl)
"""
return Bonito.DOM.div(Bonito.MarkdownCSS, Bonito.Styling, custom_css, content)
end;

#
# Serve the Makie app

isdefined(Main, :server) && close(server);
port = parse(Int, get(ENV, "CDD_PORT", "8888"))
interface = get(ENV, "CDD_IP", "127.0.0.1")
proxy_url = get(ENV, "CDD_PROXY", "")
server = Bonito.Server(interface, port; proxy_url);
Bonito.HTTPServer.start(server)
Bonito.route!(server, "/" => landing);

##

wait(server)
40 changes: 40 additions & 0 deletions examples/controlplane/2a_cnc_interactive.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
include("setup.jl")

controller = Controller(sim, net, 6, zeros(8,8))
@process controller()

req_gen = RequestGeneratorCO(sim, net, 1, 8, 6)
@process req_gen()

consumer = EntanglementConsumer(sim, net, 1, 8)
@process consumer()

for node in 1:7
tracker = RequestTracker(sim, net, node)
@process tracker()
end

for v in 1:8
tracker = EntanglementTracker(sim, net, v)
@process tracker()
end

for v in 1:8
c_prot = CutoffProt(sim, net, v)
@process c_prot()
end

sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer)

step_ts = range(0.0, 1000.0, step=0.1)
record(fig, "sim.mp4", step_ts; framerate=10, visible=true) do t
run(sim, t)
notify.((obs,entlog))
ylims!(entlogaxis, (-1.04,1.04))
xlims!(entlogaxis, max(0,t-50), 1+t)
ylims!(fid_axis, (0, 1.04))
xlims!(fid_axis, max(0, t-50), 1+t)
autolimits!(histaxis)
ylims!(num_epr_axis, (0, 4))
xlims!(num_epr_axis, max(0, t-50), 1+t)
end
107 changes: 107 additions & 0 deletions examples/controlplane/2b_cnc_wglmakie.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using WGLMakie
WGLMakie.activate!()
import Bonito
using Markdown

include("setup.jl")

const custom_css = Bonito.DOM.style("ul {list-style: circle !important;}") # TODO remove after fix of bug in JSServe https://github.com/SimonDanisch/JSServe.jl/issues/178

controller = Controller(sim, net, 6, zeros(8,8))
@process controller()

req_gen = RequestGenerator(sim, net, 1, 8, 6)
@process req_gen()

consumer = EntanglementConsumer(sim, net, 1, 8)
@process consumer()

for node in 1:7
tracker = RequestTracker(sim, net, node)
@process tracker()
end

for v in 1:8
tracker = EntanglementTracker(sim, net, v)
@process tracker()
end

for v in 1:8
c_prot = CutoffProt(sim, net, v)
@process c_prot()
end

# All the calls that happen in the main event loop of the simulation,
# encapsulated here so that we can conveniently pause the simulation from the WGLMakie app.
function continue_singlerun!(sim, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, running)
step_ts = range(0, 1000, step=0.1)
for t in step_ts
run(sim, t)
notify.((obs,entlog))
ylims!(entlogaxis, (-1.04,1.04))
xlims!(entlogaxis, max(0,t-50), 1+t)
ylims!(fid_axis, (0, 1.04))
xlims!(fid_axis, max(0, t-50), 1+t)
autolimits!(histaxis)
ylims!(num_epr_axis, (0, 4))
xlims!(num_epr_axis, max(0, t-50), 1+t)
end
running[] = nothing
end

#
landing = Bonito.App() do

sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer)

running = Observable{Any}(false)
fig[5,1] = buttongrid = GridLayout(tellwidth = false)
buttongrid[1,1] = b = Makie.Button(fig, label = @lift(isnothing($running) ? "Done" : $running ? "Running..." : "Run once"), height=30, tellwidth=false)

on(b.clicks) do _
if !running[]
running[] = true
end
end
on(running) do r
if r
Threads.@spawn begin
continue_singlerun!(
sim, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, running)
end
end
end


content = md"""
Pick simulation settings and hit run (see below for technical details).

$(fig.scene)

# Connection-Oriented, Non-Distributed and Centralized Control Plane for Entanglement Distribution

The above simulation visualizes entanglement distribution between Alice and Bob on an arbitrary network topology
given by the adjacency matrix of the graph. The control plane architecture used for this simulation is connection-oriented,
non-distributed and centralized. The node representing Alice is the node on the top left and the bottom right is Bob.
The actual connectivity of the physical graph isn't fully captured by the visualization above as we use edges only to
show the virtual graph.

[See and modify the code for this simulation on github.](https://github.com/QuantumSavory/QuantumSavory.jl/tree/master/examples/controlplane/2b_cnc_wglmakie.jl)
"""
return Bonito.DOM.div(Bonito.MarkdownCSS, Bonito.Styling, custom_css, content)
end;

#
# Serve the Makie app

isdefined(Main, :server) && close(server);
port = parse(Int, get(ENV, "CNC_PORT", "8888"))
interface = get(ENV, "CNC_IP", "127.0.0.1")
proxy_url = get(ENV, "CNC_PROXY", "")
server = Bonito.Server(interface, port; proxy_url);
Bonito.HTTPServer.start(server)
Bonito.route!(server, "/" => landing);

##

wait(server)
45 changes: 45 additions & 0 deletions examples/controlplane/3a_cl_interactive.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
include("setup.jl")

for (;src, dst) in edges(net)
entangler = EntanglerProt(sim, net, src, dst; rounds=-1, randomize=true)
@process entangler()
end

controller = CLController(sim, net, 6)
@process controller()

req_gen = RequestGeneratorCL(sim, net, 1, 8, 6)
@process req_gen()

consumer = EntanglementConsumer(sim, net, 1, 8)
@process consumer()

for node in 1:7
tracker = RequestTracker(sim, net, node)
@process tracker()
end

for v in 1:8
tracker = EntanglementTracker(sim, net, v)
@process tracker()
end

for v in 1:8
c_prot = CutoffProt(sim, net, v)
@process c_prot()
end

sim, net, obs, entlog, entlogaxis, fid_axis, histaxis, num_epr_axis, fig = prepare_vis(consumer)

step_ts = range(0.0, 1000.0, step=0.1)
record(fig, "sim2.mp4", step_ts; framerate=10, visible=true) do t
run(sim, t)
notify.((obs,entlog))
ylims!(entlogaxis, (-1.04,1.04))
xlims!(entlogaxis, max(0,t-50), 1+t)
ylims!(fid_axis, (0, 1.04))
xlims!(fid_axis, max(0, t-50), 1+t)
autolimits!(histaxis)
ylims!(num_epr_axis, (0, 4))
xlims!(num_epr_axis, max(0, t-50), 1+t)
end
Loading
Loading