Skip to content

Commit

Permalink
Gottesman's code (#240)
Browse files Browse the repository at this point in the history
Co-authored-by: Feroz <93876775+Fe-r-oz@users.noreply.github.com>
Co-authored-by: Fe-r-oz <ferozahmad7cf@gmail.com>
  • Loading branch information
3 people authored Mar 18, 2024
1 parent 51b0ecf commit 615fbe5
Show file tree
Hide file tree
Showing 11 changed files with 166 additions and 50 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

# News

## v0.8.21 - 2024-03-15
## v0.8.21 - 2024-03-17

- Implemented the Gottesman code family, also known as [[2^j, 2^j - j - 2, 3]] quantum Hamming codes.
- Bump the `PyQDecoders` dependency, switching to `PythonCall` behind the scenes for reliability.
- Bump the `LDPCDecoders` dependency.

Expand Down
131 changes: 84 additions & 47 deletions docs/src/references.bib
Original file line number Diff line number Diff line change
@@ -1,50 +1,3 @@
@article{mackay2004sparse,
title={Sparse-graph codes for quantum error correction},
author={MacKay, David JC and Mitchison, Graeme and McFadden, Paul L},
journal={IEEE Transactions on Information Theory},
volume={50},
number={10},
pages={2315--2330},
year={2004},
publisher={IEEE},
doi={10.1109/TIT.2004.834737}
}

@article{calderbank1998quantum,
title={Quantum error correction via codes over GF (4)},
author={Calderbank, A Robert and Rains, Eric M and Shor, PM and Sloane, Neil JA},
journal={IEEE Transactions on Information Theory},
volume={44},
number={4},
pages={1369--1387},
year={1998},
publisher={IEEE},
doi={10.1109/18.681315}
}

@inproceedings{steane2007tutorial,
title={A tutorial on quantum error correction},
author={Steane, Andrew M},
booktitle={PROCEEDINGS-INTERNATIONAL SCHOOL OF PHYSICS ENRICO FERMI},
volume={162},
pages={1},
year={2007},
organization={IOS Press; Ohmsha; 1999},
doi={10.3254/978-1-61499-018-5-1}
}

@article{wilde2009logical,
title={Logical operators of quantum codes},
author={Wilde, Mark M},
journal={Physical Review A},
volume={79},
number={6},
pages={062322},
year={2009},
publisher={APS},
doi={10.1103/PhysRevA.79.062322}
}

% The basis of the tableaux algorithm
@inproceedings{gottesman1998heisenberg,
Expand Down Expand Up @@ -167,6 +120,18 @@ @article{hein2006entanglement
year={2006}
}

@article{wilde2009logical,
title={Logical operators of quantum codes},
author={Wilde, Mark M},
journal={Physical Review A},
volume={79},
number={6},
pages={062322},
year={2009},
publisher={APS},
doi={10.1103/PhysRevA.79.062322}
}

% Encoding circuits
@article{cleve1997efficient,
Expand Down Expand Up @@ -225,3 +190,75 @@ @article{nahum2017quantum
author = {Nahum, Adam and Ruhman, Jonathan and Vijay, Sagar and Haah, Jeongwan},
year = {2017}
}

% codes
@article{mackay2004sparse,
title={Sparse-graph codes for quantum error correction},
author={MacKay, David JC and Mitchison, Graeme and McFadden, Paul L},
journal={IEEE Transactions on Information Theory},
volume={50},
number={10},
pages={2315--2330},
year={2004},
publisher={IEEE},
doi={10.1109/TIT.2004.834737}
}

@article{calderbank1998quantum,
title={Quantum error correction via codes over GF (4)},
author={Calderbank, A Robert and Rains, Eric M and Shor, PM and Sloane, Neil JA},
journal={IEEE Transactions on Information Theory},
volume={44},
number={4},
pages={1369--1387},
year={1998},
publisher={IEEE},
doi={10.1109/18.681315}
}

@inproceedings{steane2007tutorial,
title={A tutorial on quantum error correction},
author={Steane, Andrew M},
booktitle={PROCEEDINGS-INTERNATIONAL SCHOOL OF PHYSICS ENRICO FERMI},
volume={162},
pages={1},
year={2007},
organization={IOS Press; Ohmsha; 1999},
doi={10.3254/978-1-61499-018-5-1}
}

@article{yu2013all,
author={Yu, Sixia and Bierbrauer, Jürgen and Dong, Ying and Chen, Qing and Oh, C. H.},
journal={IEEE Transactions on Information Theory},
title={All the Stabilizer Codes of Distance 3},
year={2013},
volume={59},
number={8},
pages={5179-5185},
keywords= {Generators;Frequency modulation;Vectors;Educational institutions;Error correction codes;Physics;Indexes;1-error correcting stabilizer codes;optimal codes;quantum error correction;quantum Hamming bound},
doi={10.1109/TIT.2013.2259138}
}

@article{chao2018quantum,
title={Quantum Error Correction with Only Two Extra Qubits.},
author={Rui Chao and Ben W Reichardt},
journal={Physical review letters},
year={2017},
volume={121 5},
pages={
050502
},
url={https://api.semanticscholar.org/CorpusID:206314271}
}

@article{gottesman1996class,
title={Class of quantum error-correcting codes saturating the quantum Hamming bound},
author={Gottesman, Daniel},
journal={Physical Review A},
volume={54},
number={3},
pages={1862},
year={1996},
publisher={APS}
}
7 changes: 7 additions & 0 deletions docs/src/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ For circuit construction routines (for stabilizer measurements for a given code)
- [grassl2002algorithmic](@cite)
- [grassl2011variations](@cite)

For code construction routines:
- [cleve1997efficient](@cite)
- [gottesman1996class](@cite)
- [gottesman1997stabilizer](@cite)
- [yu2013all](@cite)
- [chao2018quantum](@cite)

# References

```@bibliography
Expand Down
4 changes: 2 additions & 2 deletions src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export parity_checks, parity_checks_x, parity_checks_z,
RepCode,
CSS,
Shor9, Steane7, Cleve8, Perfect5, Bitflip3,
Toric,
Toric, Gottesman,
evaluate_decoder,
CommutationCheckECCSetup, NaiveSyndromeECCSetup, ShorSyndromeECCSetup,
TableDecoder,
Expand Down Expand Up @@ -334,5 +334,5 @@ include("codes/steanecode.jl")
include("codes/shorcode.jl")
include("codes/clevecode.jl")
include("codes/toric.jl")

include("codes/gottesman.jl")
end #module
40 changes: 40 additions & 0 deletions src/ecc/codes/gottesman.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""The family of `[[2ʲ, 2ʲ - j - 2, 3]]` Gottesman codes, also known as quantum Hamming codes, as described in [Gottesman's 1997 PhD thesis](@cite gottesman1997stabilizer) and in [gottesman1996class](@cite).
You might be interested in consulting [yu2013all](@cite) and [chao2018quantum](@cite) as well.
The ECC Zoo has an [entry for this family](https://errorcorrectionzoo.org/c/quantum_hamming)
"""
struct Gottesman <: AbstractECC
j::Int
function Gottesman(j)
(j >= 3 && j < 21) || error("In `Gottesman(j)`, `j` must be ≥ 3 in order to obtain a valid code and < 21 to remain tractable")
new(j)
end
end

code_n(c::Gottesman) = 2^c.j

function parity_checks(c::Gottesman)
j = c.j
s = j+2
n = 2^j

H = zero(Stabilizer, s, n)
for i in 1:n
H[1, i] = (true, false)
H[2, i] = (false, true)
end
for i in 0:n-1 # column of H, corresponds to a single qubit error that is detectable)
Xⁱ = i
Zⁱ = i÷2
jeven = j%2 == 0
ieven = i%2 == 0
if (jeven && ieven) || (!jeven && ieven && i < n÷2) || (!jeven && !ieven && i n÷2)
Zⁱ = ~Zⁱ
end
for b in 0:j-1 # which check to consider (row of H), also which bit to extract
H[s-b,i+1] = isone((Zⁱ>>b)&0x1), isone((Xⁱ>>b)&0x1)
end
end
H
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ end
@doset "ecc_decoder_all_setups"
@doset "ecc_encoding"
@doset "ecc_syndromes"
@doset "ecc_gottesman"
@doset "precompile"
@doset "pauliframe"
@doset "allocations"
Expand Down
2 changes: 2 additions & 0 deletions test/test_ecc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ codes = [
Shor9(),
Perfect5(),
Cleve8(),
Gottesman(3),
Gottesman(5),
CSS([0 1 1 0; 1 1 0 0], [1 1 1 1]),
]

Expand Down
3 changes: 3 additions & 0 deletions test/test_ecc_decoder_all_setups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import LDPCDecoders
Shor9(),
Perfect5(),
Cleve8(),
Gottesman(3),
#Gottesman(4), bad threshold
#Gottesman(5), bad threshold
]

noise = 0.001
Expand Down
2 changes: 2 additions & 0 deletions test/test_ecc_encoding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ using QuantumClifford.ECC
:(Shor9()),
:(Perfect5()),
:(Bitflip3()),
:(Gottesman(3)),
:(Gottesman(5)),
:(S"Y_"),
:(S"Z_"),
:(S"X_"),
Expand Down
21 changes: 21 additions & 0 deletions test/test_ecc_gottesman.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Test
using QuantumClifford
using QuantumClifford: mul_left!
using QuantumClifford.ECC
using QuantumClifford.ECC: AbstractECC


@testset "Gottesman codes should correct all single-qubit errors" begin
for j in 3:12
H = parity_checks(Gottesman(j))
syndromes = Set([]) # the set automatically removes repeated entries
for error_type in (single_x, single_y, single_z)
for bit_index in 1:nqubits(H)
syndrome = comm(H, error_type(nqubits(H), bit_index))
@test any(==(0x1), syndrome) # checking the syndrome is not trivially zero
push!(syndromes, syndrome)
end
end
@test length(syndromes) == 3*nqubits(H)
end
end
2 changes: 2 additions & 0 deletions test/test_ecc_syndromes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ codes = [
Shor9(),
Perfect5(),
Cleve8(),
Gottesman(3),
Gottesman(5),
CSS([0 1 1 0; 1 1 0 0], [1 1 1 1]),
Toric(3,3),
Toric(3,6),
Expand Down

2 comments on commit 615fbe5

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/103062

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.8.21 -m "<description of version>" 615fbe5ab244ba382f26b82334fa9412e2ff3de0
git push origin v0.8.21

Please sign in to comment.