-
Notifications
You must be signed in to change notification settings - Fork 16
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
Piecemaker #159
Draft
Luisenden
wants to merge
21
commits into
master
Choose a base branch
from
piecemaker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Piecemaker #159
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d8b724e
added new interactive example (no visualization yet) termed 'piecemaker'
Luisenden 337fc92
added depolarization channel for stabilizer state repr and updated fi…
Luisenden 39ae298
execute ghz generation only once, only entanglement generation should…
Luisenden 54d9ad2
simple run finished, runs fusion protocol multiple times and collects…
Luisenden 307fd09
updated README
Luisenden f7a3f47
adjustements in simulation setup and run script, noise applied after …
Luisenden 8a14160
deleted init function, moved param value setting to run script
Luisenden 0957cf6
changed GHZConsumer to FusionConsumer
Luisenden 0aaeae1
deleted tag Piecemaker
Luisenden be08d75
reset project env in parent directory and added specific dependencies…
Luisenden 81f12d1
deleted .DS_Store; updated local env
Luisenden cef2e06
updated readme
Luisenden 467a314
Uptdated to event-driven implementation; added slot variables to Enta…
Luisenden 77631f2
cleaned up code; deleted FusionSwitchDiscreteProtocol as it is not ne…
Luisenden e7d4349
deleted functions not in use (entangler functions and fusion function)
Luisenden 5ab85ce
deleted .vscode
Luisenden 46681bb
added explanation to tag FusionCounterpart
Luisenden badefaa
changed order of parameters in fusioncircuit to (control, target); ad…
Luisenden 3a40643
extended function apply_noninstant! to work with depolarizing noise (…
Luisenden 9a12dd6
updated readme
Luisenden 751c5b1
updated readme
Luisenden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ Manifest.toml | |
build | ||
.gitignore | ||
ROADMAP.md | ||
coverage | ||
coverage | ||
.DS_Store |
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,3 @@ | ||
{ | ||
"julia.environmentPath": "/Users/localadmin/Documents/github/QuantumSavory.jl/examples/piecemakerswitch" | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "QuantumSavory" | ||
uuid = "2de2e421-972c-4cb5-a0c3-999c85908079" | ||
authors = ["Stefan Krastanov <[email protected]>"] | ||
version = "0.6" | ||
version = "0.6.0" | ||
|
||
[deps] | ||
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" | ||
|
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,11 @@ | ||
[deps] | ||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499" | ||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" | ||
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" | ||
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" | ||
NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a" | ||
QuantumSavory = "2de2e421-972c-4cb5-a0c3-999c85908079" | ||
ResumableFunctions = "c5292f4c-5179-55e1-98c5-05642aab7184" | ||
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" |
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,52 @@ | ||
# System Overview | ||
A central switch node connects to **n** clients. The switch possesses **m = n + 1** qubit slots, while each client has a single qubit slot. | ||
|
||
# Entanglement Initiation | ||
At each clock tick, the switch initiates entanglement attempts with each of the **n** clients, resulting in **n** entanglement processes per cycle. Successful entanglement links are then merged into a GHZ (Greenberger–Horne–Zeilinger) state using an additional "piecemaker" qubit located in the \((n + 1)\)th slot of the switch node. This fusion process is assumed to occur instantaneously. Once all clients went through the fusion operation, the piecemaker qubit is measured out. This completes the fusing process and all nodes are sharing an n-GHZ state. | ||
|
||
# Fusion Operation | ||
The fusion operation consists of applying a **CNOT** gate followed by a measurement in the computational basis. This procedure allows the merging of two GHZ states into a single GHZ state, modulo any required Pauli corrections. We iterate over all existing entangled states with the switch node: in each iteration, the piecemaker qubit (initialized in the state \(|+\rangle\)) is fused with one of the existing entangled states. | ||
|
||
# Noise | ||
The memories residing the nodes' `Register`s suffer from depolarizing noise. | ||
|
||
### Protocol flow | ||
|
||
```mermaid | ||
sequenceDiagram | ||
participant Client1 | ||
participant ClientN | ||
|
||
participant SwitchNode | ||
participant Log | ||
|
||
Note over Client1,SwitchNode: Round 1 (1 unit time) | ||
par Entanglement Generation | ||
Client1->>+SwitchNode: Try to generate entanglement | ||
ClientN->>+SwitchNode: Try to generate entanglement | ||
end | ||
|
||
SwitchNode->>SwitchNode: Run fusions with successful clients | ||
|
||
par Send Measurement Outcomes | ||
SwitchNode-->>-Client1: Send measurement outcomes | ||
SwitchNode-->>-ClientN: Send measurement outcomes | ||
end | ||
|
||
par Apply Corrections (No time cost) | ||
Client1->>Client1: Apply correction gates | ||
ClientN->>ClientN: Apply correction gates | ||
end | ||
|
||
loop Check Fusion Status (No time cost) | ||
SwitchNode->>SwitchNode: Check if all clients are fused | ||
alt All clients fused | ||
SwitchNode->>SwitchNode: Measure piecemaker | ||
SwitchNode->>SwitchNode: Compute fidelity to GHZ state | ||
SwitchNode->>Log: Log fidelity and time | ||
SwitchNode->>SwitchNode: Trigger STOP | ||
else | ||
SwitchNode->>SwitchNode: Keep checking | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using QuantumSavory | ||
using QuantumSavory.ProtocolZoo | ||
using Graphs | ||
using ConcurrentSim | ||
using ResumableFunctions | ||
using Distributions | ||
using DataFrames | ||
using CSV | ||
using Profile | ||
using NetworkLayout | ||
|
||
@resumable function entangle_and_fuse(sim, net, client, link_success_prob) | ||
|
||
# Set up the entanglement trackers at each client | ||
tracker = EntanglementTracker(sim, net, client) | ||
@process tracker() | ||
|
||
# Set up the entangler and fuser protocols at each client | ||
entangler = EntanglerProt( | ||
sim=sim, net=net, nodeA=1, slotA=client-1, nodeB=client, | ||
success_prob=link_success_prob, rounds=1, attempts=-1, | ||
start_timer_after_first_attempt=true, # TODO: for some reason attempt_timeout=1 is not working, hardcoded in constructor for now | ||
) | ||
@yield @process entangler() | ||
|
||
fuser = FusionProt( | ||
sim=sim, net=net, node=1, | ||
nodeC=client, | ||
rounds=1 | ||
) | ||
@yield @process fuser() | ||
end | ||
|
||
|
||
@resumable function run_protocols(sim, net, nclients, link_success_prob) | ||
# Run entangler and fusion for each client and wait for all to finish | ||
procs_succeeded = [] | ||
for k in 2:nclients+1 | ||
proc_succeeded = @process entangle_and_fuse(sim, net, k, link_success_prob) | ||
push!(procs_succeeded, proc_succeeded) | ||
end | ||
@yield reduce(&, procs_succeeded) | ||
end | ||
|
||
function prepare_simulation(nclients=2, mem_depolar_prob = 0.1, link_success_prob = 0.5) | ||
|
||
m = nclients+1 # memory slots in switch is equal to the number of clients + 1 slot for piecemaker qubit | ||
r_depol = - log(1 - mem_depolar_prob) # depolarization rate | ||
|
||
# The graph of network connectivity. Index 1 corresponds to the switch. | ||
graph = star_graph(nclients+1) | ||
|
||
switch_register = Register(m, Depolarization(1/r_depol)) # the first slot is reserved for the 'piecemaker' qubit used as fusion qubit | ||
client_registers = [Register(1, Depolarization(1/r_depol)) for _ in 1:nclients] #Depolarization(1/r_depol) | ||
net = RegisterNet(graph, [switch_register, client_registers...]) | ||
sim = get_time_tracker(net) | ||
|
||
# Set up the initial |+> state of the piecemaker qubit | ||
initialize!(net[1][m], X1) | ||
|
||
# Run entangler and fusion for each client and wait for all to finish | ||
@process run_protocols(sim, net, nclients, link_success_prob) | ||
|
||
# Set up the consumer to measure final entangled state | ||
consumer = FusionConsumer(net, net[1][m]; period=1) | ||
@process consumer() | ||
|
||
return sim, consumer | ||
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,60 @@ | ||
include("setup.jl") | ||
using DataFrames | ||
using CSV | ||
|
||
|
||
# Set up the simulation parameters | ||
name = "qs_piecemeal" | ||
nruns = 1000 | ||
mem_depolar_prob = 0.1 | ||
link_success_prob = 0.5 | ||
|
||
results_per_client = DataFrame[] | ||
for nclients in 2:9 | ||
# Prepare simulation data storage | ||
distribution_times = Float64[] | ||
fidelities = Float64[] | ||
elapsed_times = Float64[] | ||
|
||
# Run the simulation nruns times | ||
for i in 1:nruns | ||
sim, consumer = prepare_simulation(nclients, mem_depolar_prob, link_success_prob) | ||
elapsed_time = @elapsed run(sim) | ||
# Extract data from consumer.log | ||
distribution_time, fidelity = consumer.log[1] | ||
append!(distribution_times, distribution_time) | ||
append!(fidelities, fidelity) | ||
append!(elapsed_times, elapsed_time) | ||
@info "Run $i completed" | ||
end | ||
|
||
# Fill the results DataFrame | ||
results = DataFrame( | ||
distribution_times = distribution_times, | ||
fidelities = fidelities, | ||
elapsed_times = elapsed_times | ||
) | ||
results.num_remote_nodes .= nclients | ||
results.link_success_prob .= link_success_prob | ||
results.mem_depolar_prob .= mem_depolar_prob | ||
results.type .= name | ||
|
||
push!(results_per_client, results) | ||
@info "Clients $nclients completed" | ||
end | ||
results_total = vcat(results_per_client...) | ||
|
||
# Group and summarize the data | ||
grouped_df = groupby(results_total, [:num_remote_nodes, :distribution_times]) | ||
summary_df = combine( | ||
grouped_df, | ||
:fidelities => mean => :mean_fidelities, | ||
:fidelities => std => :std_fidelities | ||
) | ||
|
||
@info summary_df | ||
|
||
# Write results to CSV | ||
# CSV.write("examples/piecemakerswitch/output/piecemaker-eventdriven.csv", results_total) | ||
# CSV.write("examples/piecemakerswitch/output/piecemaker-eventdriven_summary.csv", summary_df) | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ module CircuitZoo | |
using QuantumSavory | ||
using DocStringExtensions | ||
|
||
export EntanglementSwap, LocalEntanglementSwap, | ||
export EntanglementFusion, EntanglementSwap, LocalEntanglementSwap, | ||
Purify2to1, Purify2to1Node, Purify3to1, Purify3to1Node, | ||
PurifyStringent, PurifyStringentNode, PurifyExpedient, PurifyExpedientNode, | ||
SDDecode, SDEncode | ||
|
@@ -46,6 +46,16 @@ end | |
|
||
inputqubits(::LocalEntanglementSwap) = 2 | ||
|
||
struct EntanglementFusion <: AbstractCircuit | ||
end | ||
|
||
function (::EntanglementFusion)(localq, piecemaker) | ||
apply!((piecemaker, localq), CNOT) | ||
zmeas = project_traceout!(localq, σᶻ) | ||
zmeas | ||
end | ||
|
||
inputqubits(::EntanglementFusion) = 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add tests for the correctness of this circuit? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and a docstring |
||
|
||
""" | ||
$TYPEDEF | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove file