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

remove GraphMatching as BlossomV does not compile on mac and windows #153

Merged
merged 3 commits into from
Sep 15, 2024
Merged
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
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ jobs:
- '2'
arch:
- x64
include:
- arch: aarch64
os: macos-latest
version: '1'
threads: '1'
- arch: x64
os: macos-latest
version: '1'
threads: '1'
- arch: x64
os: windows-latest
version: '1'
threads: '1'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# News

## v0.6.0 - 2024-09-13

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

## v0.5.0 - 2024-09-05

Expand Down
8 changes: 1 addition & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
name = "QuantumSavory"
uuid = "2de2e421-972c-4cb5-a0c3-999c85908079"
authors = ["Stefan Krastanov <[email protected]>"]
version = "0.5"
version = "0.6"

[deps]
Cbc = "9961bab8-2fa3-5c5a-9d89-47fab24efd76"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
GraphsMatching = "c3af3a8c-b79e-4b01-bf44-c718d7e0e0d6"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
JuMP = "4076af6c-e467-56ae-b986-b466b2749572"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Expand All @@ -35,15 +32,12 @@ Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
QuantumSavoryMakie = "Makie"

[compat]
Cbc = "1.2"
Combinatorics = "1"
ConcurrentSim = "1.4.1"
Distributions = "0.25.90"
DocStringExtensions = "0.9"
Graphs = "1.9"
GraphsMatching = "0.2"
IterTools = "1.4.0"
JuMP = "1.21.1"
LinearAlgebra = "1"
Makie = "0.20, 0.21"
NetworkLayout = "0.4.4"
Expand Down
1 change: 1 addition & 0 deletions examples/simpleswitch/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
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"
Expand Down
15 changes: 11 additions & 4 deletions src/ProtocolZoo/switches.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ using QuantumSavory
using QuantumSavory.ProtocolZoo
using QuantumSavory.ProtocolZoo: EntanglementCounterpart, AbstractProtocol
using Graphs: edges, complete_graph, neighbors
using GraphsMatching: maximum_weight_matching
#using GraphsMatching: maximum_weight_matching # TODO-MATCHING due to the dependence on BlossomV.jl this has trouble installing. See https://github.com/JuliaGraphs/GraphsMatching.jl/issues/14
using Combinatorics: combinations
using JuMP: MOI, optimizer_with_attributes
import Cbc
using DocStringExtensions: TYPEDEF, TYPEDFIELDS
using ConcurrentSim: @process, timeout, Simulation, Process
#using ResumableFunctions: @resumable, @yield # TODO serious bug that makes it not work without full `using`
using ResumableFunctions
using Random

export SimpleSwitchDiscreteProt, SwitchRequest

Expand Down Expand Up @@ -65,6 +64,9 @@ julia> let
```
"""
function promponas_bruteforce_choice(M,N,backlog,eprobs) # TODO mark as public but unexported
@warn "The switch optimization routine is using a random placeholder optimization method due to issues with installing the BlossomV algorithm. Do not rely on this code to validate research results."
return randperm(N)[1:M]
# TODO-MATCHING due to the dependence on BlossomV.jl this has trouble installing. See https://github.com/JuliaGraphs/GraphsMatching.jl/issues/14
best_weight = 0.0
best_assignment = zeros(Int, M)
graphs = [complete_graph(i) for i in 1:M] # preallocating them to avoid expensive allocations in the inner loop
Expand Down Expand Up @@ -298,9 +300,14 @@ function _switch_successful_entanglements_best_match(prot, reverseclientindex)
end
# get the maximum match for the actually connected nodes
ne = length(entangled_clients)
if ne < 2 return nothing end
entangled_clients_revindex = [reverseclientindex[k] for k in entangled_clients]
@debug "Switch $(prot.switchnode) successfully entangled with clients $entangled_clients" # (indexed as $entangled_clients_revindex)"
(;weight, mate) = match_entangled_pattern(prot.backlog, entangled_clients_revindex, complete_graph(ne), zeros(Int, ne, ne))

# TODO-MATCHING due to the dependence on BlossomV.jl this has trouble installing. See https://github.com/JuliaGraphs/GraphsMatching.jl/issues/14
# (;weight, mate) = match_entangled_pattern(prot.backlog, entangled_clients_revindex, complete_graph(ne), zeros(Int, ne, ne))
mate = collect(zip(entangled_clients_revindex[1:2:end], entangled_clients_revindex[2:2:end]))

isempty(mate) && return nothing
return mate
end
Expand Down
3 changes: 2 additions & 1 deletion test/test_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ end

@safetestset "simpleswitch" begin
if get(ENV,"QUANTUMSAVORY_PLOT_TEST","")=="true"
include("../examples/simpleswitch/1_interactive_visualization.jl")
# TODO-MATCHING due to the dependence on BlossomV.jl this has trouble installing. See https://github.com/JuliaGraphs/GraphsMatching.jl/issues/14
#include("../examples/simpleswitch/1_interactive_visualization.jl")
end
end

Expand Down
6 changes: 4 additions & 2 deletions test/test_protocolzoo_switch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ end
@process switch()
run(sim, 30)
res = query(net[2], EntanglementCounterpart, ❓, ❓)
@test abs(observable([res.slot, net[3][res.tag[3]]], X⊗X)) ≈ 1.0 # we are not running an EntanglementTracker so Pauli corrections are not applied
@test abs(observable([res.slot, net[3][res.tag[3]]], Z⊗Z)) ≈ 1.0 # we are not running an EntanglementTracker so Pauli corrections are not applied

# TODO-MATCHING due to the dependence on BlossomV.jl this has trouble installing. See https://github.com/JuliaGraphs/GraphsMatching.jl/issues/14
#@test abs(observable([res.slot, net[3][res.tag[3]]], X⊗X)) ≈ 1.0 # we are not running an EntanglementTracker so Pauli corrections are not applied
#@test abs(observable([res.slot, net[3][res.tag[3]]], Z⊗Z)) ≈ 1.0 # we are not running an EntanglementTracker so Pauli corrections are not applied
end
6 changes: 3 additions & 3 deletions test/test_stateszoo_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ r_drms = Register(2)
initialize!(r_drms[1:2], drms)
@test ! iszero(observable(r_drms[1:2], Z⊗Z))

@test tr(zalm) == tr(express(zalm))
@test tr(zalm) tr(express(zalm))

@test tr(srms) == tr(express(srms))
@test tr(srms) tr(express(srms))

@test tr(drms) == tr(express(drms))
@test tr(drms) tr(express(drms))
Loading