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

improvements to the non-clifford functionality #259

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@

# News

## v0.9.4 - dev
## v0.10.0 - dev

- **(breaking)** `StabMixture` was renamed to `GeneralizedStabilizer`.
- **(fix)** `rowdecompose` was not accounting for the phase of the input Pauli string, leading to potential errors in nonclifford functionality.
- `expect` is now implemented for `GeneralizedStabilizer`.
- Constructing a `Destabilizer` out of a full-rank `Stabilizer` does not require a canonicalization anymore, i.e. `stabilizerview(Destabilizer(s))==s` is guaranteed.
- The `maximally_mixed` function is now available for creating maximally mixed multi-qubit states.
- Gate errors are now conveniently supported by the various ECC benchmark setups in the `ECC` module.
- Remove printing of spurious debug info from the PyBP decoder.

Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumClifford"
uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1"
authors = ["Stefan Krastanov <[email protected]> and QuantumSavory community members"]
version = "0.9.4"
version = "0.10.0"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
12 changes: 6 additions & 6 deletions docs/src/stab-algebra-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,12 @@ julia> s=S"-XXX
julia> d = Destabilizer(s)
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z__
+ _X_
+ _XX
+ __X
𝒮𝓉𝒶𝒷━
- XXX
- ZZ_
- Z_Z
+ _ZZ
```

They have convenience methods to extract only the stabilizer and destabilizer
Expand All @@ -642,11 +642,11 @@ pieces:
julia> stabilizerview(d)
- XXX
- ZZ_
- Z_Z
+ _ZZ

julia> destabilizerview(d)
+ Z__
+ _X_
+ _XX
+ __X
```

Expand All @@ -672,12 +672,12 @@ Clifford operations can be applied the same way they are applied to stabilizers.
julia> apply!(d,tCNOT⊗tHadamard)
𝒟ℯ𝓈𝓉𝒶𝒷
- X_Z
+ XXZ
+ _XZ
+ X__
𝒮𝓉𝒶𝒷━
+ _ZX
- _Z_
- Z_X
+ ZZX
```

# Mixed States
Expand Down
11 changes: 9 additions & 2 deletions ext/QuantumCliffordQOpticsExt/QuantumCliffordQOpticsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ Ket(dim=4)
```"""
Ket(s::QuantumClifford.AbstractStabilizer) = stab_to_ket(s)

function stabmix_to_densityop(s::StabMixture)
"""
$TYPEDSIGNATURES

Convert a stabilizer tableau to a density matrix corresponding to the given state.
"""
Operator(s::QuantumClifford.AbstractStabilizer) = dm(Ket(s)) # TODO support mixed stabilizer states

function genstab_to_densityop(s::GeneralizedStabilizer)
ρ₀ = zero(dm(Ket(s.stab)))
for ((Pₗᵇⁱᵗˢ,Pᵣᵇⁱᵗˢ), χ) in s.destabweights
ρ̃ = dm(Ket(s.stab))
Expand All @@ -96,7 +103,7 @@ end
$TYPEDSIGNATURES

"""
Operator(s::StabMixture) = stabmix_to_densityop(s)
Operator(s::GeneralizedStabilizer) = genstab_to_densityop(s)


"""
Expand Down
67 changes: 58 additions & 9 deletions src/QuantumClifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export
# Pauli frames
PauliFrame, pftrajectories, pfmeasurements,
# Useful States
bell, ghz,
bell, ghz, maximally_mixed,
single_z, single_x, single_y,
# Graphs
graphstate, graphstate!, graph_gatesequence, graph_gate,
Expand All @@ -81,7 +81,7 @@ export
# petrajectories
petrajectories, applybranches,
# nonclifford
StabMixture, UnitaryPauliChannel, PauliChannel, pcT,
GeneralizedStabilizer, UnitaryPauliChannel, PauliChannel, pcT,
# makie plotting -- defined only when extension is loaded
stabilizerplot, stabilizerplot_axis,
# sum types
Expand All @@ -98,6 +98,22 @@ function __init__()
BIG_INT_MINUS_ONE[] = BigInt(-1)
BIG_INT_TWO[] = BigInt(2)
BIG_INT_FOUR[] = BigInt(4)

# Register error hint for the `project!` method for GeneralizedStabilizer
if isdefined(Base.Experimental, :register_error_hint)
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs
if exc.f === project! && argtypes[1] <: GeneralizedStabilizer
print(io, """
\nThe method `project!` is not appropriate for use with`GeneralizedStabilizer`.
You probably are looking for `projectrand!`.
`project!` in this library is a low-level "linear algebra" method to verify
whether a measurement operator commutes with a set of stabilizers, and to
potentially simplify the tableau and provide the index of the anticommuting
term in that tableau. This linear algebra operation is not defined for
`GeneralStabilizer` as there is no single tableau to provide an index into.""")
end
end
end
end

const NoZeroQubit = ArgumentError("Qubit indices have to be larger than zero, but you are attempting to create a gate acting on a qubit with a non-positive index. Ensure indexing always starts from 1.")
Expand Down Expand Up @@ -442,21 +458,54 @@ tab(s::AbstractStabilizer) = s.tab

"""
A tableau representation of a pure stabilizer state. The tableau tracks the
destabilizers as well, for efficient projections. On initialization there are
destabilizers as well, for efficient projections.

For full-rank tableaux, the stabilizer part of the tableau is guaranteed to be kept the same as the input stabilizer tableau given to the constructor (a guarantee not kept by [`MixedDestabilizer`](@ref)).

On initialization there are
no checks that the provided state is indeed pure. This enables the use of this
data structure for mixed stabilizer state, but a better choice would be to use
data structure for mixed stabilizer state, but usually a better choice would be
[`MixedDestabilizer`](@ref).
""" # TODO clean up and document constructor

```
julia> Destabilizer(S"ZZI XXX")
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z__
+ _X_
𝒮𝓉𝒶𝒷━
+ XXX
+ ZZ_

julia> Destabilizer(S"ZZI XXX IZZ")
𝒟ℯ𝓈𝓉𝒶𝒷
+ X__
+ _Z_
+ __X
𝒮𝓉𝒶𝒷━
+ ZZ_
+ XXX
+ _ZZ
```
"""
struct Destabilizer{T<:Tableau} <: AbstractStabilizer
tab::T
end

function Destabilizer(s::Stabilizer)
row, col = size(s)
row>col && error(DomainError("The input stabilizer has more rows than columns, making it inconsistent or overdetermined."))
mixed_destab = MixedDestabilizer(s)
t = vcat(tab(destabilizerview(mixed_destab)),tab(stabilizerview(mixed_destab)))
Destabilizer(t)
if row<col
mixed_destab = MixedDestabilizer(s)
t = vcat(tab(destabilizerview(mixed_destab)),tab(stabilizerview(mixed_destab)))
return Destabilizer(t)
elseif row==col
maxmix = maximally_mixed(col)
for row in s
project!(maxmix, row)
end
return Destabilizer(maxmix.tab)
else
error(DomainError("The input stabilizer has more rows than columns, making it inconsistent or overdetermined."))
end
end

Base.length(d::Destabilizer) = length(tab(d))÷2
Expand Down
4 changes: 2 additions & 2 deletions src/dense_cliffords.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ ERROR: DimensionMismatch: Input tableau should be of size 2n×n (top half is the
```jldoctest
julia> d = Destabilizer(S"Y")
𝒟ℯ𝓈𝓉𝒶𝒷
+ Z
+ X
𝒮𝓉𝒶𝒷
+ Y

julia> CliffordOperator(d)
X₁ ⟼ + Z
X₁ ⟼ + X
Z₁ ⟼ + Y
```
"""
Expand Down
Loading