Skip to content

Commit

Permalink
Naive Implementation of the Encoding Circuit (#154)
Browse files Browse the repository at this point in the history

Co-authored-by: Stefan Krastanov <[email protected]>
Co-authored-by: Anthony Micciche <[email protected]>
  • Loading branch information
3 people authored Sep 18, 2023
1 parent b6defd2 commit 55fc876
Show file tree
Hide file tree
Showing 23 changed files with 511 additions and 327 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

# News

## v0.8.17 - dev
- **(fix)** Some `affectedqubits` methods were returning single integers instead of a one-tuple.
- The non-public `ECC` module has seen a few improvements (a `naive_encoding_circuit` implementation and a few new codes), as well as some breaking changes to API.

## v0.8.16 - 2023-08-31

- **(breaking)** Changes to the circuit generation in the non-public ECC module. Adding a Shor syndrome measurement circuit.
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]>"]
version = "0.8.16"
version = "0.8.17"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
6 changes: 3 additions & 3 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ ENV["COLUMNS"] = 80
bib = CitationBibliography(joinpath(@__DIR__,"src/references.bib"),style=:authoryear)

makedocs(
bib,
plugins = [bib],
doctest = false,
clean = true,
sitename = "QuantumClifford.jl",
format = Documenter.HTML(),
format = Documenter.HTML(size_threshold_ignore = ["API.md"]),
modules = [QuantumClifford, QuantumClifford.Experimental.NoisyCircuits, QuantumInterface],
strict = Documenter.except(:missing_docs),
warnonly = [:missing_docs],
authors = "Stefan Krastanov",
pages = [
"QuantumClifford.jl" => "index.md",
Expand Down
4 changes: 2 additions & 2 deletions docs/src/ecc_example_sim.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Consider Steane 7-qubit code:

```@example 1
using QuantumClifford
using QuantumClifford.ECC: Steane7, naive_syndrome_circuit, encoding_circuit, parity_checks, code_s, code_n
using QuantumClifford.ECC: Steane7, naive_syndrome_circuit, naive_encoding_circuit, parity_checks, code_s, code_n
using Quantikz
code = Steane7()
Expand All @@ -21,7 +21,7 @@ H = parity_checks(code)

... and the corresponding encoding circuit
```@example 1
ecirc = encoding_circuit(code)
ecirc = naive_encoding_circuit(code)
```

... and the corresponding syndrome measurement circuit (the non-fault tolerant one)
Expand Down
44 changes: 38 additions & 6 deletions docs/src/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,44 @@ @article{gullans2020dynamical
publisher={APS}
}

@misc{hein2006entanglement,
title = {Entanglement in Graph States and its Applications},
url = {http://arxiv.org/abs/quant-ph/0602096},
journaltitle = {arXiv preprint arXiv:quant-ph/0602096},
author = {Hein, M. and Dür, W. and Eisert, J. and Raussendorf, R. and Nest, M. Van den and Briegel, H.-J.},
year = {2006},
@article{hein2006entanglement,
title={Entanglement in graph states and its applications},
author={Hein, Marc and D{\"u}r, Wolfgang and Eisert, Jens and Raussendorf, Robert and Nest, M and Briegel, H-J},
journal={arXiv preprint quant-ph/0602096},
url={https://arxiv.org/abs/quant-ph/0602096},
doi={10.48550/arXiv.quant-ph/0602096},
year={2006}
}

% Encoding circuits
@article{cleve1997efficient,
title={Efficient computations of encodings for quantum error correction},
author={Cleve, Richard and Gottesman, Daniel},
journal={Physical Review A},
volume={56},
number={1},
pages={76},
year={1997},
publisher={APS}
}

@inproceedings{grassl2011variations,
title={Variations on encoding circuits for stabilizer quantum codes},
author={Grassl, Markus},
booktitle={International Conference on Coding and Cryptology},
pages={142--158},
year={2011},
organization={Springer}
}

@article{grassl2002algorithmic,
title={Algorithmic aspects of quantum error-correcting codes},
author={Grassl, Markus},
journal={Mathematics of Quantum Computation},
pages={223--252},
year={2002},
publisher={CRC Press Boca Raton, FL}
}

% Examples of results that employ the tableaux formalism
Expand Down
15 changes: 13 additions & 2 deletions src/QuantumClifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export
sHadamard, sPhase, sInvPhase, SingleQubitOperator, sId1, sX, sY, sZ,
sCNOT, sCPHASE, sSWAP,
sXCX, sXCY, sXCZ, sYCX, sYCY, sYCZ, sZCX, sZCY, sZCZ,
sZCrY,
# Misc Ops
SparseGate,
sMX, sMY, sMZ, PauliMeasurement, Reset, sMRX, sMRY, sMRZ,
Expand Down Expand Up @@ -504,6 +505,11 @@ operators are tracked as well.
When the constructor is called on an incomplete [`Stabilizer`](@ref) it
automatically calculates the destabilizers and logical operators, following
chapter 4 of [gottesman1997stabilizer](@cite).
Under the hood the conversion uses the [`canonicalize_gott!`](@ref) canonicalization.
That canonicalization permutes the columns of the tableau, but we automatically undo the
column permutation in the preparation of a `MixedDestabilizer` so that qubits are not reindexed.
The boolean keyword arguments `undoperm` and `reportperm` can be used to control this behavior
and to report the permutations explicitly.
See also: [`stabilizerview`](@ref), [`destabilizerview`](@ref), [`logicalxview`](@ref), [`logicalzview`](@ref)
"""
Expand All @@ -513,7 +519,7 @@ mutable struct MixedDestabilizer{T<:Tableau} <: AbstractStabilizer
end

# Added a lot of type assertions to help Julia infer types
function MixedDestabilizer(stab::Stabilizer{T}; undoperm=true) where {T}
function MixedDestabilizer(stab::Stabilizer{T}; undoperm=true, reportperm=false) where {T}
rows,n = size(stab)
stab, r, s, permx, permz = canonicalize_gott!(copy(stab))
t = zero(T, n*2, n)
Expand Down Expand Up @@ -550,8 +556,13 @@ function MixedDestabilizer(stab::Stabilizer{T}; undoperm=true) where {T}
end
if undoperm
t = t[:,invperm(permx[permz])]::T
return MixedDestabilizer(t, r+s)::MixedDestabilizer{T}
end
if reportperm
return (MixedDestabilizer(t, r+s)::MixedDestabilizer{T}, r, permx, permz)
else
return MixedDestabilizer(t, r+s)::MixedDestabilizer{T}
end
MixedDestabilizer(t, r+s)::MixedDestabilizer{T}
end

function MixedDestabilizer(d::Destabilizer, r::Int)
Expand Down
4 changes: 2 additions & 2 deletions src/affectedqubits.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""A method giving the qubits acted upon by a given operation. Part of the Noise interface."""
function affectedqubits end
affectedqubits(g::AbstractSingleQubitOperator) = (g.q)
affectedqubits(g::AbstractSingleQubitOperator) = (g.q,)
affectedqubits(g::AbstractTwoQubitOperator) = (g.q1, g.q2)
affectedqubits(g::NoisyGate) = affectedqubits(g.gate)
affectedqubits(g::NoisyGate) = affectedqubits(g.gate,)
affectedqubits(g::SparseGate) = g.indices
affectedqubits(b::BellMeasurement) = map(m->m.qubit, b.measurements)
affectedqubits(r::Reset) = r.indices
Expand Down
1 change: 1 addition & 0 deletions src/canonicalization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,6 @@ function _canonicalize_gott!(stabilizer::Stabilizer; phases::Val{B}=Val(true)) w
end
zperm, s = gott_standard_form_indices((@view xzs[end÷2+1:end,:]),rows,columns,skip=r)
permute!(stabilizer,zperm)
# we have r+s==rows (or we have trailing rows that are zeroed)
stabilizer, r, s, xperm, zperm
end
Loading

0 comments on commit 55fc876

Please sign in to comment.