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

Features for simulation with different controlplane architectures for arbitrary network topologies #157

Closed
wants to merge 18 commits into from
Closed
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
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
- 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: 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 = 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

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 = 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

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
Loading
Loading