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 oriented and centralized control protocol #167

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8af6e75
Initial changes for different control plane simulations
ba2tro Sep 23, 2024
8bb3031
update the examples to use the new protocols
ba2tro Sep 23, 2024
03b19cd
fixup
ba2tro Oct 4, 2024
e11906f
update docstrings and changelog
ba2tro Oct 4, 2024
7cbe56f
add tests
ba2tro Oct 5, 2024
328cc10
avoid using CliffordRepr() in tests
ba2tro Oct 7, 2024
48c263c
Send RequestCompletion from controller instead of RequestTracker
ba2tro Oct 10, 2024
089a40a
Try to add a sequence diagram to the readme and fix a typo in wgl app
ba2tro Oct 14, 2024
808b5d0
fix typo in the sequence diagram
ba2tro Oct 14, 2024
26e36ce
fix incorrect version number (#163)
Krastanov Oct 16, 2024
18a51d9
convert zmeas and xmeas in swapper to Int explicitly (#161)
ba2tro Oct 18, 2024
cf7c707
Make classical and quantum channel delays customizable when initializ…
ba2tro Oct 24, 2024
41b0271
move path selection to controller and related modifications
ba2tro Nov 4, 2024
abf880a
update controlplane test
ba2tro Nov 4, 2024
1593425
update ProtocolZoo/ProtocolZoo.jl
ba2tro Nov 4, 2024
0a9cc0c
fix for congestionchain example
ba2tro Nov 4, 2024
c8f301a
Merge branch 'master' into ab/controlplane
ba2tro Nov 8, 2024
c63ebe4
Simplify the swapping predicate, since the path is already decided
ba2tro Nov 22, 2024
8275f3f
Merge branch 'ab/controlplane' of https://github.com/ba2tro/QuantumSa…
ba2tro Nov 22, 2024
160c579
Merge branch 'QuantumSavory:master' into ab/controlplane
ba2tro Nov 25, 2024
62a420c
Use nothing for initializing path matrix in the controller
ba2tro Nov 26, 2024
7c9f176
keep record of node wise workloads(requests being served)
ba2tro Nov 26, 2024
b741cfb
update test
ba2tro Nov 27, 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
- 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, fill(nothing, 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)
15 changes: 15 additions & 0 deletions examples/controlplane/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[deps]
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c"
QuantumSavory = "2de2e421-972c-4cb5-a0c3-999c85908079"
QuantumSymbolics = "efa7fd63-0460-4890-beb7-be1bbdfbaeae"
ResumableFunctions = "c5292f4c-5179-55e1-98c5-05642aab7184"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"

[compat]
Bonito = "3.1"
26 changes: 26 additions & 0 deletions examples/controlplane/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Different control plane architectures with arbitrary network topologies can be simulated using QuantumSavory. The `setup.jl` contains basic functionality required by the simulations. The other files are described below:

1a. A simulation that generates an interactive visualization for a connectionless, distributed and decentralized entanglement distribution network

1b. An interactive web app with the same simulation as 1a

2a. A simulation that generates an interactive visualization for a connection-oriented, non-distributed and centralized entanglement distribution network

2b. An interactive web app with the same simulation as 2a

The control protocol is illustrated at a high level by the sequence diagram below:

```mermaid
sequenceDiagram
Alice(Request Generator)->>+Controller: DistributionRequest(path_id)
Controller-->>+RequestTracker1: EntanglementRequest
Controller-->>+RequestTracker2: EntanglementRequest
Controller-->>+RequestTrackerN: EntanglementRequest
Controller-->>+RequestTracker1: SwapRequest
Controller-->>+RequestTracker2: SwapRequest
Controller-->>+RequestTrackerN: SwapRequest
Controller-->>-Alice(Request Generator): RequestCompletion(path_id)
```

The `RequestGenerator` (Alice) sends a message to the controller, requesting entanglement generation with an end node (Bob).
The message contains index of the path selected by Alice and the controller sends `EntanglementRequest`s to the nodes on the path followed by `SwapRequest`s
Loading
Loading