From d016c658b2b17a086beed6345f6a6f34bdb20aed Mon Sep 17 00:00:00 2001 From: Tortar Date: Sat, 3 Aug 2024 22:02:42 +0200 Subject: [PATCH 01/15] Enable more Aqua tests by solving piracy and ambiguities issues --- docs/src/register_interface.md | 4 +-- .../6.1_compare_formalisms_noplot.jl | 4 +-- src/QuantumSavory.jl | 4 ++- src/ambiguity_fix.jl | 6 +++++ src/backends/clifford/clifford.jl | 4 --- src/backends/clifford/express.jl | 7 +++--- src/backends/clifford/should_upstream.jl | 1 - src/backends/quantumoptics/express.jl | 5 ++-- src/backends/quantumoptics/quantumoptics.jl | 8 ++---- src/baseops/apply.jl | 2 +- src/baseops/initialize.jl | 7 +----- src/baseops/observable.jl | 6 ++--- src/baseops/subsystemcompose.jl | 1 - src/noninstant.jl | 4 +-- src/quantumchannel.jl | 5 ++-- src/representations.jl | 25 +++++++++++++++++-- src/states_registers.jl | 1 + test/runtests.jl | 2 +- test/test_aqua.jl | 10 +++++--- 19 files changed, 62 insertions(+), 44 deletions(-) create mode 100644 src/ambiguity_fix.jl diff --git a/docs/src/register_interface.md b/docs/src/register_interface.md index 34b7f082..abf787c9 100644 --- a/docs/src/register_interface.md +++ b/docs/src/register_interface.md @@ -138,13 +138,13 @@ Measure a quantum observable. The dispatch down the call three is very similar t observable ``` -#### `observable(refs::Tuple{Vararg{RegRef, N}}, obs, something=nothing; time)` +#### `observable(refs::Tuple{Vararg{RegRef, N}}, obs; something=nothing, time=nothing)` Calculate the value of an observable on the state in the sequence of [`RegRef`](@ref)s at a specified `time`. If these registers are not instantiated, return `something`. `refs` can also be `Tuple{Vararg{RegRef, N}}` or a single [`RegRef`](@ref). -#### `observable(regs::Vector{Register}, indices, obs, something=nothing; time)` +#### `observable(regs::Vector{Register}, indices, obs; something=nothing, time=nothing)` `indices` refers to the slots inside of the given `regs`. diff --git a/examples/firstgenrepeater/6.1_compare_formalisms_noplot.jl b/examples/firstgenrepeater/6.1_compare_formalisms_noplot.jl index 6a1ec536..ab56a4cb 100644 --- a/examples/firstgenrepeater/6.1_compare_formalisms_noplot.jl +++ b/examples/firstgenrepeater/6.1_compare_formalisms_noplot.jl @@ -47,8 +47,8 @@ function monte_carlo_trajectory(; for t in sampled_times run(sim, t) - fXX = real(observable(registers[[1,len]], [2,2], XX, 0.0; time=t)) - fZZ = real(observable(registers[[1,len]], [2,2], ZZ, 0.0; time=t)) + fXX = real(observable(registers[[1,len]], [2,2], XX; something=0.0, time=t)) + fZZ = real(observable(registers[[1,len]], [2,2], ZZ; something=0.0, time=t)) push!(fidXX,fXX) push!(fidZZ,fZZ) end diff --git a/src/QuantumSavory.jl b/src/QuantumSavory.jl index f32ec294..aea3770c 100644 --- a/src/QuantumSavory.jl +++ b/src/QuantumSavory.jl @@ -34,7 +34,7 @@ export project_traceout! #TODO should move to QuantumInterface using QuantumSymbolics: AbstractRepresentation, AbstractUse, - CliffordRepr, QuantumOpticsRepr, QuantumMCRepr, + CliffordRepr, consistent_representation, QuantumOpticsRepr, QuantumMCRepr, metadata, istree, operation, arguments, Symbolic, # from Symbolics HGate, XGate, YGate, ZGate, CPHASEGate, CNOTGate, XBasisState, YBasisState, ZBasisState, @@ -102,6 +102,8 @@ include("noninstant.jl") include("backends/quantumoptics/quantumoptics.jl") include("backends/clifford/clifford.jl") +include("ambiguity_fix.jl") + include("concurrentsim.jl") include("plots.jl") diff --git a/src/ambiguity_fix.jl b/src/ambiguity_fix.jl new file mode 100644 index 00000000..6b2b4654 --- /dev/null +++ b/src/ambiguity_fix.jl @@ -0,0 +1,6 @@ + +Register(traits, ::Union{Tuple{}, AbstractVector{Union{}}}) = Register(traits) +subsystemcompose() = error() +project_traceout!(::Union{Ket,Operator}, ::Int, ::Union{Tuple{}, AbstractVector{Union{}}}) = error() +QuantumClifford.apply!(::QuantumClifford.MixedDestabilizer, ::QuantumSavory.QCGateSequence, ::Type{<:QuantumClifford.AbstractSymbolicOperator}) = error() +observable(::Union{Tuple{}, AbstractVector{Union{}}}, ::Base.AbstractVecOrTuple{Int}) = error() diff --git a/src/backends/clifford/clifford.jl b/src/backends/clifford/clifford.jl index e2b9501d..9dc23548 100644 --- a/src/backends/clifford/clifford.jl +++ b/src/backends/clifford/clifford.jl @@ -3,12 +3,8 @@ import QuantumClifford: MixedDestabilizer subsystemcompose(states::QuantumClifford.MixedDestabilizer...) = QuantumClifford.tensor(states...) -nsubsystems(state::QuantumClifford.MixedDestabilizer) = QuantumClifford.nqubits(state) - default_repr(::QuantumClifford.MixedDestabilizer) = CliffordRepr() -apply!(state::QuantumClifford.MixedDestabilizer, indices, operation::Type{<:QuantumClifford.AbstractSymbolicOperator}) = QuantumClifford.apply!(state, operation, indices) - ispadded(::QuantumClifford.MixedDestabilizer) = false const _qc_l = copy(express(Z1, CliffordRepr())) diff --git a/src/backends/clifford/express.jl b/src/backends/clifford/express.jl index 2d68a615..941bb775 100644 --- a/src/backends/clifford/express.jl +++ b/src/backends/clifford/express.jl @@ -1,4 +1,5 @@ -function project_traceout!(state::QuantumClifford.MixedDestabilizer,stateindex,basis::Symbolic{AbstractOperator}) + +function project_traceout!(state::QuantumClifford.MixedDestabilizer,stateindex::Int,basis::Symbolic{AbstractOperator}) # do this if ispadded() = true #state, res = express_qc_proj(basis)(state, stateindex) # do this if ispadded() = false @@ -12,14 +13,14 @@ express_qc_proj(::XGate) = QuantumClifford.projectX! # should be project*rand! i express_qc_proj(::YGate) = QuantumClifford.projectY! # should be project*rand! if ispadded()=true express_qc_proj(::ZGate) = QuantumClifford.projectZ! # should be project*rand! if ispadded()=true -function observable(state::QuantumClifford.MixedDestabilizer, indices, operation) +function observable(state::QuantumClifford.MixedDestabilizer, indices::Base.AbstractVecOrTuple{Int}, operation) operation = express(operation, CliffordRepr(), UseAsObservable()) op = embed(QuantumClifford.nqubits(state), indices, operation) QuantumClifford.expect(op, state) end # This is a bit of a hack to work specifically with SProjector. If you start needing more of these for other types, consider doing a bit of a redesign. This all should pass through `express(...,::UseAsObservable)`. -function observable(state::QuantumClifford.MixedDestabilizer, indices, operation::SProjector) +function observable(state::QuantumClifford.MixedDestabilizer, indices::Base.AbstractVecOrTuple{Int}, operation::SProjector) pstate = express(operation.ket, CliffordRepr()) QuantumClifford.nqubits(state)==length(indices)==QuantumClifford.nqubits(pstate) || error("An attempt was made to measure a projection observable while using Clifford representation for the qubits. However, the qubits that are being observed are entangled with other qubits. Currently this is not supported. Consider tracing out the extra qubits or using Pauli observables that do not suffer from this embedding limitation.") dot(pstate, state) diff --git a/src/backends/clifford/should_upstream.jl b/src/backends/clifford/should_upstream.jl index da02c997..9f8d2688 100644 --- a/src/backends/clifford/should_upstream.jl +++ b/src/backends/clifford/should_upstream.jl @@ -1,4 +1,3 @@ -QuantumClifford.apply!(state::QuantumClifford.MixedDestabilizer, op::Type{<:QuantumClifford.AbstractSymbolicOperator}, indices) = QuantumClifford.apply!(state, op(indices...)) # TODO piracy to be moved to QuantumClifford struct QCGateSequence <: QuantumClifford.AbstractSymbolicOperator gates # TODO constructor that flattens nested QCGateSequence diff --git a/src/backends/quantumoptics/express.jl b/src/backends/quantumoptics/express.jl index 66fd151d..cfd9fc83 100644 --- a/src/backends/quantumoptics/express.jl +++ b/src/backends/quantumoptics/express.jl @@ -4,10 +4,9 @@ _overlap(l::Symbolic{AbstractKet}, r::Operator) = _overlap(express(l, QOR), r) _project_and_drop(state::Ket, project_on::Symbolic{AbstractKet}, basis_index) = _project_and_drop(state, express(project_on, QOR), basis_index) _project_and_drop(state::Operator, project_on::Symbolic{AbstractKet}, basis_index) = _project_and_drop(state, express(project_on, QOR), basis_index) -function project_traceout!(state::Union{Ket,Operator},stateindex,basis::Symbolic{AbstractOperator}) +function project_traceout!(state::Union{Ket,Operator},stateindex::Int,basis::Symbolic{AbstractOperator}) project_traceout!(state,stateindex,eigvecs(basis)) end - -function project_traceout!(state::Union{Ket,Operator},stateindex,basis::Base.AbstractVecOrTuple{<:Symbolic{AbstractKet}}) +function project_traceout!(state::Union{Ket,Operator},stateindex::Int,basis::Base.AbstractVecOrTuple{<:Symbolic{AbstractKet}}) project_traceout!(state,stateindex,express.(basis,(QOR,))) end diff --git a/src/backends/quantumoptics/quantumoptics.jl b/src/backends/quantumoptics/quantumoptics.jl index cee1108f..f3648169 100644 --- a/src/backends/quantumoptics/quantumoptics.jl +++ b/src/backends/quantumoptics/quantumoptics.jl @@ -17,21 +17,17 @@ subsystemcompose(op::Operator, k::Ket) = tensor(op,dm(k)) # TODO this should be default_repr(::StateVector) = QOR default_repr(::Operator) = QOR -traceout!(s::StateVector, i) = ptrace(s,i) -traceout!(s::Operator, i) = ptrace(s,i) - ispadded(::StateVector) = false ispadded(::Operator) = false -function observable(state::Union{<:Ket,<:Operator}, indices, operation) +function observable(state::Union{<:Ket,<:Operator}, indices::Base.AbstractVecOrTuple{Int}, operation) operation = express(operation, QOR) e = basis(state)==basis(operation) op = e ? operation : embed(basis(state), indices, operation) expect(op, state) end - -function project_traceout!(state::Union{Ket,Operator},stateindex,psis::Base.AbstractVecOrTuple{<:Ket}) +function project_traceout!(state::Union{Ket,Operator},stateindex::Int,psis::Base.AbstractVecOrTuple{Ket}) if nsubsystems(state) == 1 # TODO is there a way to do this in a single function, instead of _overlap vs _project_and_drop _overlaps = [_overlap(psi,state) for psi in psis] branch_probs = cumsum(_overlaps) diff --git a/src/baseops/apply.jl b/src/baseops/apply.jl index 961ea193..29934617 100644 --- a/src/baseops/apply.jl +++ b/src/baseops/apply.jl @@ -7,7 +7,7 @@ The appropriate representation of the gate is used, depending on the formalism under which a quantum state is stored in the given registers. The Hilbert spaces of the registers are automatically joined if necessary. """ -function apply!(regs::Vector{Register}, indices::Vector{Int}, operation; time=nothing) +function apply!(regs::Vector{Register}, indices::Base.AbstractVecOrTuple{Int}, operation; time=nothing) max_time = maximum((r.accesstimes[i] for (r,i) in zip(regs,indices))) if !isnothing(time) times===staterefs[1], staterefs)) && return something @@ -14,5 +14,5 @@ function observable(regs::Base.AbstractVecOrTuple{Register}, indices::Base.Abstr state_indices = [r.stateindices[i] for (r,i) in zip(regs, indices)] observable(state, state_indices, obs) end -observable(refs::Base.AbstractVecOrTuple{RegRef}, obs, something=nothing; time=nothing) = observable(map(r->r.reg, refs), map(r->r.idx, refs), obs, something; time) -observable(ref::RegRef, obs, something=nothing; time=nothing) = observable([ref.reg], [ref.idx], obs, something; time) +observable(refs::Base.AbstractVecOrTuple{RegRef}, obs; something=nothing, time=nothing) = observable(map(r->r.reg, refs), map(r->r.idx, refs), obs; something, time) +observable(ref::RegRef, obs; something=nothing, time=nothing) = observable([ref.reg], [ref.idx], obs; something, time) diff --git a/src/baseops/subsystemcompose.jl b/src/baseops/subsystemcompose.jl index 40a9fb51..0e417f43 100644 --- a/src/baseops/subsystemcompose.jl +++ b/src/baseops/subsystemcompose.jl @@ -2,7 +2,6 @@ nsubsystems(s::StateRef) = length(s.registers) # nsubsystems(s.state[]) TODO thi nsubsystems_padded(s::StateRef) = nsubsystems(s.state[]) nsubsystems(r::Register) = length(r.staterefs) nsubsystems(r::RegRef) = 1 -nsubsystems(::Nothing) = 1 # TODO consider removing this and reworking the functions that depend on it. E.g., a reason to have it when performing a project_traceout measurement on a state that contains only one subsystem function swap!(reg1::Register, reg2::Register, i1::Int, i2::Int; time=nothing) if reg1===reg2 && i1==i2 diff --git a/src/noninstant.jl b/src/noninstant.jl index c993db67..60a41da6 100644 --- a/src/noninstant.jl +++ b/src/noninstant.jl @@ -6,7 +6,7 @@ struct NonInstantGate <: AbstractNoninstantOperation duration # TODO assert larger than zero end -function apply!(regs::Vector{Register}, indices::Vector{Int}, operation::NonInstantGate; time=nothing) +function apply!(regs::Vector{Register}, indices::Base.AbstractVecOrTuple{Int}, operation::NonInstantGate; time=nothing) _, new_time = apply!(regs, indices, operation.gate; time) uptotime!(regs, indices, new_time+operation.duration) regs, new_time+operation.duration @@ -18,7 +18,7 @@ struct ConstantHamiltonianEvolution <: AbstractNoninstantOperation duration # TODO assert larger than zero end -function apply!(regs::Vector{Register}, indices::Vector{Int}, operation::ConstantHamiltonianEvolution; time=nothing) # TODO very significant code repetition with the general purpose apply! +function apply!(regs::Vector{Register}, indices::Base.AbstractVecOrTuple{Int}, operation::ConstantHamiltonianEvolution; time=nothing) # TODO very significant code repetition with the general purpose apply! max_time = maximum((r.accesstimes[i] for (r,i) in zip(regs,indices))) if !isnothing(time) time= v"1.9" && @doset "doctests" get(ENV,"JET_TEST","")=="true" && @doset "jet" -@doset "aqua" +@doset "aqua" \ No newline at end of file diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 7ab6a0fd..505c5e55 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -1,8 +1,10 @@ using Aqua using QuantumSavory +@test Test.detect_ambiguities(QuantumSavory) == Tuple{Method, Method}[] + Aqua.test_all(QuantumSavory, - ambiguities=(;broken=true), - piracies=(;broken=true), - stale_deps=(;ignore=[:NetworkLayout]) # needed by package extension but not a condition of its loading -) + ambiguities=(QuantumSavory; recursive=false), + piracies=(; treat_as_own=[]), + stale_deps=(; ignore=[:NetworkLayout]) # needed by package extension but not a condition of its loading +) \ No newline at end of file From 06c27d5bbf8eca6ebecf3a999257bd749ae6f877 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Sat, 3 Aug 2024 22:11:42 +0200 Subject: [PATCH 02/15] Update test_aqua.jl --- test/test_aqua.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 505c5e55..1b433ac2 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -5,6 +5,6 @@ using QuantumSavory Aqua.test_all(QuantumSavory, ambiguities=(QuantumSavory; recursive=false), - piracies=(; treat_as_own=[]), + piracies=(; treat_as_own=[QuantumSavory.Symbolic]), stale_deps=(; ignore=[:NetworkLayout]) # needed by package extension but not a condition of its loading -) \ No newline at end of file +) From be53e90a34c86f6656a6ffb6a76f30d60d174431 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Sun, 4 Aug 2024 11:49:46 +0200 Subject: [PATCH 03/15] readd consistent_representation --- src/baseops/initialize.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/baseops/initialize.jl b/src/baseops/initialize.jl index 7d5c9b67..08e6e15b 100644 --- a/src/baseops/initialize.jl +++ b/src/baseops/initialize.jl @@ -33,3 +33,8 @@ initialize!(refs::NTuple{N,RegRef}, state; time=nothing) where {N} = initialize! initialize!(reg::Register,i::Int,state; time=nothing) = initialize!([reg],[i],state; time) initialize!(r::RegRef, state; time=nothing) = initialize!(r.reg, r.idx, state; time) initialize!(r::Vector{Register},i::Vector{Int},state::Symbolic; time=nothing) = initialize!(r,i,express(state,consistent_representation(r,i,state)); time) + +function QuantumSymbolics.consistent_representation(regs::Base.AbstractVecOrTuple{Register},idx,state) + reprs = Set([r.reprs[i] for (r,i) in zip(regs,idx)]) + consistent_representation(reprs,state) +end From bddca4f223286c73667adeebceeb76dc9f252226 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Mon, 5 Aug 2024 02:21:34 +0200 Subject: [PATCH 04/15] Update test_aqua.jl --- test/test_aqua.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_aqua.jl b/test/test_aqua.jl index 1b433ac2..e453ce1a 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -8,3 +8,5 @@ Aqua.test_all(QuantumSavory, piracies=(; treat_as_own=[QuantumSavory.Symbolic]), stale_deps=(; ignore=[:NetworkLayout]) # needed by package extension but not a condition of its loading ) + +@test length(Aqua.Piracy.hunt(QuantumOpticsBase)) == 6 From 62367d0e06d902766ca980504ff2d579ec64d5f6 Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Mon, 5 Aug 2024 02:22:07 +0200 Subject: [PATCH 05/15] Update test_aqua.jl --- test/test_aqua.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_aqua.jl b/test/test_aqua.jl index e453ce1a..aa035f27 100644 --- a/test/test_aqua.jl +++ b/test/test_aqua.jl @@ -9,4 +9,4 @@ Aqua.test_all(QuantumSavory, stale_deps=(; ignore=[:NetworkLayout]) # needed by package extension but not a condition of its loading ) -@test length(Aqua.Piracy.hunt(QuantumOpticsBase)) == 6 +@test length(Aqua.Piracy.hunt(QuantumSavory)) == 6 From ef622a216244787b108ae3923c7ed33070768fdb Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Sat, 10 Aug 2024 22:29:29 +0200 Subject: [PATCH 06/15] retrigger tests --- docs/src/register_interface.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/register_interface.md b/docs/src/register_interface.md index abf787c9..5a0c1b57 100644 --- a/docs/src/register_interface.md +++ b/docs/src/register_interface.md @@ -28,7 +28,8 @@ Store a `state` in the given register slots. The `accesstimes` attributes of the slots are reset to the given `time`. -If `state<:Symbolic`, then [`consistent_representation`](@ref) is used to choose an appropriate representation based on the [`AbstractRepresentation`](@ref) properties of the register slots. Then an [`express`](@ref) call is made to transform the symbolic object into the appropriate representation. +If `state<:Symbolic`, then [`consistent_representation`](@ref) is used to choose an appropriate representation based on the [`AbstractRepresentation`](@ref) properties of the +register slots. Then an [`express`](@ref) call is made to transform the symbolic object into the appropriate representation. #### `initialize!(r::RegRef; time)` and `initialize!(reg::Register, i::Int64; time)` From 06f32a85330db8127e3bcdb3c7b839eeec8da26e Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Sun, 11 Aug 2024 02:22:50 +0200 Subject: [PATCH 07/15] Update register_interface.md --- docs/src/register_interface.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/src/register_interface.md b/docs/src/register_interface.md index 5a0c1b57..abf787c9 100644 --- a/docs/src/register_interface.md +++ b/docs/src/register_interface.md @@ -28,8 +28,7 @@ Store a `state` in the given register slots. The `accesstimes` attributes of the slots are reset to the given `time`. -If `state<:Symbolic`, then [`consistent_representation`](@ref) is used to choose an appropriate representation based on the [`AbstractRepresentation`](@ref) properties of the -register slots. Then an [`express`](@ref) call is made to transform the symbolic object into the appropriate representation. +If `state<:Symbolic`, then [`consistent_representation`](@ref) is used to choose an appropriate representation based on the [`AbstractRepresentation`](@ref) properties of the register slots. Then an [`express`](@ref) call is made to transform the symbolic object into the appropriate representation. #### `initialize!(r::RegRef; time)` and `initialize!(reg::Register, i::Int64; time)` From 19633e27833ea7796d29e2d59afb0a6a4bba24b2 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Aug 2024 03:31:24 -0400 Subject: [PATCH 08/15] trigger ci From 24e47a4af9ce169682e7ce57298db63865c87f75 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Aug 2024 11:08:34 -0400 Subject: [PATCH 09/15] trigger ci From 8f5660ff3d8df5e77bf3435058037a7e954ef034 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Aug 2024 11:41:20 -0400 Subject: [PATCH 10/15] bump lower bounds --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 2088201b..cb5c0e5d 100644 --- a/Project.toml +++ b/Project.toml @@ -50,9 +50,9 @@ NetworkLayout = "0.4.4" PrecompileTools = "1" Printf = "1" QuantumClifford = "0.8.20, 0.9" -QuantumInterface = "0.3.4" +QuantumInterface = "0.3.5" QuantumOptics = "1.0.5" -QuantumOpticsBase = "0.4.22, 0.5" +QuantumOpticsBase = "0.5.3" QuantumSymbolics = "0.3" Random = "1" Reexport = "1.2.2" From 0682c366082d8c0ddc29ab1b52945ac79b0538b3 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Aug 2024 11:42:32 -0400 Subject: [PATCH 11/15] bump some more --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index cb5c0e5d..6676dc84 100644 --- a/Project.toml +++ b/Project.toml @@ -49,7 +49,7 @@ Makie = "0.20, 0.21" NetworkLayout = "0.4.4" PrecompileTools = "1" Printf = "1" -QuantumClifford = "0.8.20, 0.9" +QuantumClifford = "0.9.9" QuantumInterface = "0.3.5" QuantumOptics = "1.0.5" QuantumOpticsBase = "0.5.3" From 758ca33681e8fe78b200a3fa5a1193d8d0b2d032 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Aug 2024 11:45:23 -0400 Subject: [PATCH 12/15] and bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 6676dc84..93c13209 100644 --- a/Project.toml +++ b/Project.toml @@ -51,7 +51,7 @@ PrecompileTools = "1" Printf = "1" QuantumClifford = "0.9.9" QuantumInterface = "0.3.5" -QuantumOptics = "1.0.5" +QuantumOptics = "1.1.0" QuantumOpticsBase = "0.5.3" QuantumSymbolics = "0.3" Random = "1" From ecc37395a4e1ab20536edead810ff093427c9631 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Aug 2024 11:59:46 -0400 Subject: [PATCH 13/15] fixes for the change to `observable`'s API --- docs/src/register_interface.md | 4 ++-- .../colorcentermodularcluster/2_real_time_visualization.jl | 2 +- examples/colorcentermodularcluster/3_makie_interactive.jl | 2 +- examples/congestionchain/setup.jl | 4 ++-- examples/firstgenrepeater/4_visualization.jl | 4 ++-- examples/firstgenrepeater/5_clifford_full_example.jl | 4 ++-- examples/firstgenrepeater/6_compare_formalisms.jl | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/src/register_interface.md b/docs/src/register_interface.md index abf787c9..a9419728 100644 --- a/docs/src/register_interface.md +++ b/docs/src/register_interface.md @@ -167,8 +167,8 @@ If `operation<:Symbolic`, then an `express(obs, repr, ::UseAsObservable)` call i ```@raw html
flowchart TB - A["observable(refs::Vector{RegRef}, obs, something=nothing; time)"] - B["observable(regs::Vector{Register}, indices, obs, something=nothing; time)"] + A["observable(refs::Vector{RegRef}, obs; something=nothing, time)"] + B["observable(regs::Vector{Register}, indices, obs; something=nothing, time)"] subgraph TOP [lower from registers to states] direction LR B1["uptotime!"] diff --git a/examples/colorcentermodularcluster/2_real_time_visualization.jl b/examples/colorcentermodularcluster/2_real_time_visualization.jl index 0beb7c05..6c9b4578 100644 --- a/examples/colorcentermodularcluster/2_real_time_visualization.jl +++ b/examples/colorcentermodularcluster/2_real_time_visualization.jl @@ -68,7 +68,7 @@ record(F, "colorcentermodularcluster-02.simdashboard.mp4", step_ts, framerate=FR l = length(neighs) obs = observables[l] regs = [net[i, 2] for i in [v, neighs...]] - real(observable(regs, obs, 0.0; time=now(sim))) + real(observable(regs, obs; something=0.0, time=now(sim))) end linkcolors[] .= fid push!(fids[],mean(fid)) diff --git a/examples/colorcentermodularcluster/3_makie_interactive.jl b/examples/colorcentermodularcluster/3_makie_interactive.jl index c367d829..ee2ddb01 100644 --- a/examples/colorcentermodularcluster/3_makie_interactive.jl +++ b/examples/colorcentermodularcluster/3_makie_interactive.jl @@ -209,7 +209,7 @@ function continue_singlerun!(sim, net, l = length(neighs) obs = observables[l] regs = [net[i, 2] for i in [v, neighs...]] - real(observable(regs, obs, 0.0; time=now(sim))) + real(observable(regs, obs; something=0.0, time=now(sim))) end) linkcolors[] .= fid push!(fids[],mean(fid)) diff --git a/examples/congestionchain/setup.jl b/examples/congestionchain/setup.jl index 7f96beb7..175a213b 100644 --- a/examples/congestionchain/setup.jl +++ b/examples/congestionchain/setup.jl @@ -191,8 +191,8 @@ end reg2 = network[node2] @yield request(reg1[q1]) & request(reg2[q2]) uptotime!((reg1[q1], reg2[q2]), now(sim)) - fXX = real(observable((reg1[q1],reg2[q2]), XX, 0.0; time=now(sim))) - fZZ = real(observable((reg1[q1],reg2[q2]), ZZ, 0.0; time=now(sim))) + fXX = real(observable((reg1[q1],reg2[q2]), XX; something=0.0, time=now(sim))) + fZZ = real(observable((reg1[q1],reg2[q2]), ZZ; something=0.0, time=now(sim))) push!(fidelityXXlog[], fXX) push!(fidelityZZlog[], fZZ) push!(timelog[], now(sim)-last_success) diff --git a/examples/firstgenrepeater/4_visualization.jl b/examples/firstgenrepeater/4_visualization.jl index fcf8def2..c6c014a8 100644 --- a/examples/firstgenrepeater/4_visualization.jl +++ b/examples/firstgenrepeater/4_visualization.jl @@ -56,8 +56,8 @@ step_ts = range(0, 100, step=0.1) record(fig, "firstgenrepeater-07.observable.mp4", step_ts; framerate=10, visible=true) do t run(sim, t) - fXX = real(observable(registers[[1,last]], [2,2], XX, 0.0; time=t)) - fZZ = real(observable(registers[[1,last]], [2,2], ZZ, 0.0; time=t)) + fXX = real(observable(registers[[1,last]], [2,2], XX; something=0.0, time=t)) + fZZ = real(observable(registers[[1,last]], [2,2], ZZ; something=0.0, time=t)) push!(fidXX[],fXX) push!(fidZZ[],fZZ) push!(ts[],t) diff --git a/examples/firstgenrepeater/5_clifford_full_example.jl b/examples/firstgenrepeater/5_clifford_full_example.jl index 5cc9e21c..d9297b55 100644 --- a/examples/firstgenrepeater/5_clifford_full_example.jl +++ b/examples/firstgenrepeater/5_clifford_full_example.jl @@ -56,8 +56,8 @@ step_ts = range(0, 100, step=0.1) record(fig, "firstgenrepeater-08.clifford.mp4", step_ts, framerate=10, visible=true) do t run(sim, t) - fXX = real(observable(registers[[1,last]], [2,2], XX, 0.0; time=t)) - fZZ = real(observable(registers[[1,last]], [2,2], ZZ, 0.0; time=t)) + fXX = real(observable(registers[[1,last]], [2,2], XX; something=0.0, time=t)) + fZZ = real(observable(registers[[1,last]], [2,2], ZZ; something=0.0, time=t)) push!(fidXX[],fXX) push!(fidZZ[],fZZ) push!(ts[],t) diff --git a/examples/firstgenrepeater/6_compare_formalisms.jl b/examples/firstgenrepeater/6_compare_formalisms.jl index 2317caf0..bad1c864 100644 --- a/examples/firstgenrepeater/6_compare_formalisms.jl +++ b/examples/firstgenrepeater/6_compare_formalisms.jl @@ -49,8 +49,8 @@ function monte_carlo_trajectory(; for t in sampled_times run(sim, t) - fXX = real(observable(registers[[1,len]], [2,2], XX, 0.0; time=t)) - fZZ = real(observable(registers[[1,len]], [2,2], ZZ, 0.0; time=t)) + fXX = real(observable(registers[[1,len]], [2,2], XX; something=0.0, time=t)) + fZZ = real(observable(registers[[1,len]], [2,2], ZZ; something=0.0, time=t)) push!(fidXX,fXX) push!(fidZZ,fZZ) end From 602e5ea21a61550a961f0f5b1908085ee029970d Mon Sep 17 00:00:00 2001 From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com> Date: Sun, 11 Aug 2024 19:06:59 +0200 Subject: [PATCH 14/15] fix wrong words --- docs/src/symbolics.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/symbolics.md b/docs/src/symbolics.md index 63c3723a..e35ff03a 100644 --- a/docs/src/symbolics.md +++ b/docs/src/symbolics.md @@ -203,4 +203,4 @@ express(MixedState(X1)/2+SProjector(Z1)/2, CliffordRepr()) !!! warning "Stabilizer state expressions" - The state written as $\frac{|Z₁⟩⊗|Z₁⟩+|Z₂⟩⊗|Z₂⟩}{√2}$ is a well known stabilizer state, namely a Bell state. However, automatically expressing it as a stabilizer is a prohibitively expensive computational operation in general. We do not perform that computation automatically. If you want to ensure that states you define can be automatically converted to tableaux for Clifford simulations, avoid using sumation of kets. On the other hand, in all of our Clifford Monte-Carlo simulations, `⊗` is fully supported, as well as [`SProjector`](@ref), [`MixedState`](@ref), [`StabilizerState`](@ref), and sumation of density matrices. \ No newline at end of file + The state written as $\frac{|Z₁⟩⊗|Z₁⟩+|Z₂⟩⊗|Z₂⟩}{√2}$ is a well known stabilizer state, namely a Bell state. However, automatically expressing it as a stabilizer is a prohibitively expensive computational operation in general. We do not perform that computation automatically. If you want to ensure that states you define can be automatically converted to tableaux for Clifford simulations, avoid using summation of kets. On the other hand, in all of our Clifford Monte-Carlo simulations, `⊗` is fully supported, as well as [`SProjector`](@ref), [`MixedState`](@ref), [`StabilizerState`](@ref), and summation of density matrices. From 5a2b12af061577a64e816b8e16b7e941ed53d456 Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Aug 2024 13:48:32 -0400 Subject: [PATCH 15/15] changelog and jet whitelist --- CHANGELOG.md | 3 ++- test/test_jet.jl | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c517158..be3b3cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # News -## v0.4.2 - dev +## v0.5.0 - 2024-08-11 +- `observable` now takes a default value as a kwarg, i.e., you need to make the substitution `observable(regs, obs, 0.0; time)` ↦ `observable(regs, obs; something=0.0, time)` - Bump QuantumSymbolics and QuantumOpticsBase compat bound and bump julia compat to 1.10. ## v0.4.1 - 2024-06-05 diff --git a/test/test_jet.jl b/test/test_jet.jl index 1db05ca3..529a73ba 100644 --- a/test/test_jet.jl +++ b/test/test_jet.jl @@ -37,5 +37,5 @@ rep = report_package("QuantumSavory"; @show length(JET.get_reports(rep)) @show rep -@test length(JET.get_reports(rep)) <= 129 +@test length(JET.get_reports(rep)) <= 133 @test_broken length(JET.get_reports(rep)) == 0