diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cefe9081..7251584ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,9 @@ # News -## v0.8.21 - 2024-03-15 +## v0.8.21 - 2024-03-16 +- 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. diff --git a/Project.toml b/Project.toml index b801d39ee..b176efb39 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "QuantumClifford" uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1" authors = ["Stefan Krastanov "] -version = "0.8.21" +version = "0.8.23" [deps] Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa" diff --git a/docs/src/references.bib b/docs/src/references.bib index d260be4d7..d968305ff 100644 --- a/docs/src/references.bib +++ b/docs/src/references.bib @@ -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, @@ -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, @@ -225,3 +190,64 @@ @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} +} \ No newline at end of file diff --git a/src/ecc/ECC.jl b/src/ecc/ECC.jl index 42f1acafd..17c280862 100644 --- a/src/ecc/ECC.jl +++ b/src/ecc/ECC.jl @@ -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, @@ -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 diff --git a/src/ecc/codes/gottesman.jl b/src/ecc/codes/gottesman.jl new file mode 100644 index 000000000..48a6170ea --- /dev/null +++ b/src/ecc/codes/gottesman.jl @@ -0,0 +1,99 @@ +"""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 Gottesman1997). + +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) + rows = c.j + 2 + cols = 2^c.j + + Hx = falses(rows, cols) + Hz = falses(rows, cols) + + Hx[1, :] .= true + Hx[2, :] .= false + + if c.j == 3 + for col in 1:cols + Hx[3, col] = (col % 8 == 1 || col % 8 == 3 || col % 8 == 6) ? 0 : 1 + end + Hx[3, cols] = Hx[3, cols] == 0 ? 1 : 0 + for col in 1:cols + Hx[4, col] = (col % 4 == 1) || (col % 4 == 3) ? 0 : 1 + end + for a in 1:cols + Hx[rows, a] = ((a % 4 == 0) || (a % 4 == 1) ? 0 : 1) ⊻ ((a % 8 == 5) || (a % 8 == 6)) + end + Hx[end, [end-1, end]] .= [0, 1] + + else + for a in 1:cols + Hx[3, a] = (a == 0) || (a % 2 == 0) + end + for row in 4:rows - 1 + for col in 1:cols + k = row - 3 + m = 2^(c.j - k) + n = 2^(c.j - k) + if (col - 1) % (m + n) < m + if col % 2 == 0 + Hx[row, col] = 1 + else + Hx[row, col] = 0 + end + else + if col % 2 == 0 + Hx[row, col] = 0 + else + Hx[row, col] = 1 + end + end + end + end + + if rows % 2 == 1 + for a in 1:cols + Hx[rows, a] = ((a % 4 == 0) || (a % 4 == 1) ? 0 : 1) ⊻ ((a % 8 == 5) || (a % 8 == 6) || (a % 8 == 7)) + end + for a in 1:div(cols, 8) + ci = 8 * a + if ci <= cols + Hx[rows, ci] = 1 - Hx[rows, ci] + end + end + else + for a in 1:cols + Hx[rows, a] = (a % 4 == 0) || (a % 4 == 1) ? 0 : 1 + end + end + end + + Hz[1, :] .= false + Hz[2, :] .= true + + for i in 3:rows + period = 2^(rows - i) + for a in 1:cols + Hz[i, a] = div(a - 1, period) % 2 == 1 + end + end + + extended_Hx = Matrix{Bool}(Hz) + extended_Hz = Matrix{Bool}(Hx) + + num_rows = size(Hx, 1) + + fill_array = fill(UInt8(0), num_rows) + Stabilizer(fill_array, extended_Hz, extended_Hx) +end diff --git a/test/test_ecc.jl b/test/test_ecc.jl index c790fbae7..5cecda473 100644 --- a/test/test_ecc.jl +++ b/test/test_ecc.jl @@ -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]), ] diff --git a/test/test_ecc_decoder_all_setups.jl b/test/test_ecc_decoder_all_setups.jl index 698ee4a61..e23f3ed77 100644 --- a/test/test_ecc_decoder_all_setups.jl +++ b/test/test_ecc_decoder_all_setups.jl @@ -11,6 +11,9 @@ import LDPCDecoders Shor9(), Perfect5(), Cleve8(), + Gottesman(3), + #Gottesman(4), bad threshold + #Gottesman(5), bad threshold ] noise = 0.001 diff --git a/test/test_ecc_encoding.jl b/test/test_ecc_encoding.jl index c80d03bc3..b5500133d 100644 --- a/test/test_ecc_encoding.jl +++ b/test/test_ecc_encoding.jl @@ -15,6 +15,8 @@ using QuantumClifford.ECC :(Shor9()), :(Perfect5()), :(Bitflip3()), + :(Gottesman(3)), + :(Gottesman(5)), :(S"Y_"), :(S"Z_"), :(S"X_"), diff --git a/test/test_ecc_syndromes.jl b/test/test_ecc_syndromes.jl index 64a4035f3..e12fe7d0e 100644 --- a/test/test_ecc_syndromes.jl +++ b/test/test_ecc_syndromes.jl @@ -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),