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

Zoo: [[2^j, 2^-j-2,3]] Gottesman /Quantum Hamming Code #238

Closed
wants to merge 126 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
3bf0779
Update references.bib
Fe-r-oz Feb 28, 2024
f207dc1
Update references.md
Fe-r-oz Feb 28, 2024
7070155
Update references.md
Fe-r-oz Feb 28, 2024
df8d6b8
Update decoder_pipeline.jl
Fe-r-oz Feb 28, 2024
296c634
Update decoder_pipeline.jl
Fe-r-oz Feb 28, 2024
4032b7f
Create code833
Fe-r-oz Mar 1, 2024
55a4955
Create code833
Fe-r-oz Mar 1, 2024
5242529
Delete src/ecc/code833
Fe-r-oz Mar 1, 2024
fe4b153
Rename code833 to code833.jl
Fe-r-oz Mar 1, 2024
568f31d
Update code833.jl
Fe-r-oz Mar 1, 2024
b39260e
Create code422.jl
Fe-r-oz Mar 1, 2024
e0f960c
Create QHammingcode.jl
Fe-r-oz Mar 1, 2024
3f8a37e
Create hypergraphproductcode.jl
Fe-r-oz Mar 1, 2024
2f63447
Merge pull request #1 from Fe-r-oz/Fe-r-oz-patch-1
Fe-r-oz Mar 1, 2024
344e13b
Update hypergraphproductcode.jl
Fe-r-oz Mar 1, 2024
b81d4de
Update QHammingcode.jl
Fe-r-oz Mar 1, 2024
5d48c01
Update hypergraphproductcode.jl
Fe-r-oz Mar 1, 2024
3ca1cc2
Delete src/ecc/codes/code833.jl
Fe-r-oz Mar 1, 2024
7d1b34d
Delete src/ecc/codes/code422.jl
Fe-r-oz Mar 1, 2024
7e6c48e
Delete src/ecc/codes/hypergraphproductcode.jl
Fe-r-oz Mar 1, 2024
0f43554
Update references.bib
Fe-r-oz Mar 1, 2024
0597d35
Update references.md
Fe-r-oz Mar 1, 2024
9f86c77
Rename QHammingcode.jl to qhammingcode.jl
Fe-r-oz Mar 1, 2024
5997735
Update decoder_pipeline.jl
Fe-r-oz Mar 1, 2024
748b866
Update ECC.jl
Fe-r-oz Mar 1, 2024
d3f00c3
Update ECC.jl
Fe-r-oz Mar 1, 2024
ce21699
Update qhammingcode.jl
Fe-r-oz Mar 2, 2024
683933d
Update test_ecc_encoding.jl
Fe-r-oz Mar 2, 2024
48e2d09
Update test_ecc_syndromes.jl
Fe-r-oz Mar 2, 2024
3b12a0a
Update test_ecc_decoder_all_setups.jl
Fe-r-oz Mar 2, 2024
3f784ea
Update test_ecc.jl
Fe-r-oz Mar 2, 2024
2f0afcf
Update qhammingcode.jl
Fe-r-oz Mar 2, 2024
ccf4499
Add files via upload
Fe-r-oz Mar 2, 2024
fa2fc87
Create test_qhamming_code.jl
Fe-r-oz Mar 2, 2024
042ef3e
Delete docs/src/notebooks/quantumhammingcode.ipynb
Fe-r-oz Mar 3, 2024
f091649
Update test/test_ecc_decoder_all_setups.jl
Fe-r-oz Mar 3, 2024
8547a2d
Update ECC.jl
Fe-r-oz Mar 3, 2024
912321b
Update test_ecc.jl
Fe-r-oz Mar 3, 2024
1a1eefd
Update test_ecc_syndromes.jl
Fe-r-oz Mar 3, 2024
d5187f0
Update test_ecc_encoding.jl
Fe-r-oz Mar 3, 2024
6449d6b
Update references.md
Fe-r-oz Mar 3, 2024
72f2f16
Update ECC.jl
Fe-r-oz Mar 3, 2024
845b7b1
Update test_qhamming_code.jl
Fe-r-oz Mar 3, 2024
73b4c1d
Update test_throws.jl
Fe-r-oz Mar 3, 2024
a1901f5
Update qhammingcode.jl
Fe-r-oz Mar 3, 2024
c8bc9f4
Update ECC.jl
Fe-r-oz Mar 4, 2024
17c66eb
Update qhammingcode.jl
Fe-r-oz Mar 4, 2024
d1945e6
Update qhammingcode.jl
Fe-r-oz Mar 5, 2024
6035ff9
Update and rename qhammingcode.jl to eightqubit.jl
Fe-r-oz Mar 5, 2024
31e0a0e
Update eightqubit.jl
Fe-r-oz Mar 5, 2024
6f6704f
Update ECC.jl
Fe-r-oz Mar 5, 2024
84dfb02
Update test_ecc.jl
Fe-r-oz Mar 5, 2024
e4d0759
Update test_throws.jl
Fe-r-oz Mar 5, 2024
412d54a
Update test_qhamming_code.jl
Fe-r-oz Mar 5, 2024
33fb94b
Merge branch 'QuantumSavory:master' into master
Fe-r-oz Mar 6, 2024
8eb5bb7
Update test_ecc_encoding.jl
Fe-r-oz Mar 6, 2024
d1bc220
Update test_ecc_syndromes.jl
Fe-r-oz Mar 6, 2024
fd4d073
Update test_ecc_decoder_all_setups.jl
Fe-r-oz Mar 6, 2024
e3a1fcf
Update references.md
Fe-r-oz Mar 6, 2024
9364f6c
Create sixteenqubit.jl
Fe-r-oz Mar 6, 2024
1c740cf
Update ECC.jl
Fe-r-oz Mar 6, 2024
e40f1ab
added better names of eccs in the zoo, removed the test_hamming_code …
Mar 7, 2024
733a7ad
minor modifications
Mar 7, 2024
a6d1d1b
minor modifications
Mar 7, 2024
5a2913f
minor modifications
Mar 7, 2024
62fdcbe
tweaking decoders parameters for pedagogical nkd16103
Mar 7, 2024
b572c8f
minor tweak
Mar 7, 2024
32e8676
Gottesman aka Quantum Hamming Code Implementation
Mar 8, 2024
e7e9b40
Original Paramters
Mar 8, 2024
04c62e8
Update src/ecc/codes/gottesman.jl
Fe-r-oz Mar 9, 2024
4ab69ae
Update src/ecc/ECC.jl
Fe-r-oz Mar 9, 2024
1b602f4
Update src/ecc/codes/gottesman.jl
Fe-r-oz Mar 9, 2024
cc8c6e2
Update src/ecc/codes/gottesman.jl
Fe-r-oz Mar 9, 2024
bdac20b
Update src/ecc/codes/gottesman.jl
Fe-r-oz Mar 9, 2024
39344e0
sompleting suggested changes
Mar 9, 2024
f547dd4
Update test/test_ecc_decoder_all_setups.jl
Fe-r-oz Mar 9, 2024
a907f56
Update test/test_ecc_decoder_all_setups.jl
Fe-r-oz Mar 9, 2024
ba2f3ff
suggested changes
Mar 9, 2024
0828eaf
undoing extra lines
Mar 9, 2024
bd16194
minor modification
Mar 9, 2024
63b1093
suggested changes
Mar 9, 2024
d52a03b
completing suggested changes
Mar 9, 2024
3dbd5a3
completing suggested changes
Mar 9, 2024
66255aa
undoing extra lines in files
Mar 9, 2024
e39fd21
undoing extra lines
Mar 9, 2024
67a979c
suggested changes
Mar 9, 2024
c54744f
undoing extra lines
Mar 9, 2024
38aa86f
minor modification
Mar 11, 2024
e50a44b
implementation of Gottesman aka Quantum Hamming Code
Mar 11, 2024
3eb22e1
minor modification
Mar 11, 2024
5c3864e
minor modification
Mar 11, 2024
a0698b7
Gottesman aka quantum Hamming code implementation
Mar 11, 2024
1a7e926
Adding documentation for Gottesman codes aka quantum Hamming codes
Mar 11, 2024
90e52f0
Minor Modification
Mar 11, 2024
ead9bbe
Using Precise Naming Convention
Mar 13, 2024
42cd5ea
Merge branch 'master' into pr/Fe-r-oz/238
Krastanov Mar 16, 2024
227b9d6
relax testing requirements for decoding Gottesman code
Krastanov Mar 16, 2024
ff88de8
Update test/test_ecc_syndromes.jl
Fe-r-oz Mar 16, 2024
536f55c
Update src/ecc/codes/gottesmancode.jl
Fe-r-oz Mar 16, 2024
c5c7d60
resetting parameters to default
Mar 16, 2024
6527546
"resetting to default parameters"
Mar 16, 2024
9e1cc0f
adding separate Hx and Hz checks in Gottesman
Mar 16, 2024
3e5d4a7
Minor Modifications
Mar 16, 2024
035c006
minor modifications
Mar 16, 2024
ffb91a9
minor modifications
Mar 16, 2024
fd0408c
adding Hx and Hz checks in Gottesman
Mar 16, 2024
1d10548
utilizing stab_to_gf2
Mar 16, 2024
475fc80
Minor Modification
Mar 16, 2024
b3c8725
updating changelog
Mar 16, 2024
43a24fb
resolving changelog conflicts
Mar 16, 2024
c00a0ed
undoing whitespaces
Mar 16, 2024
074683c
removing whitespaces
Mar 16, 2024
f39e8b3
Update test/test_ecc.jl
Fe-r-oz Mar 16, 2024
51fbc02
minor modification
Mar 16, 2024
80189ef
resolving conflicts
Mar 16, 2024
f87161a
Implementation of non-CSS Gottesman codes aka quantum Hamming codes
Mar 16, 2024
f07fd2c
Implementation of non-CSS Gottesman codes aka quantum Hamming codes
Mar 16, 2024
8831a55
undoing whitespaces
Mar 16, 2024
73fc7d2
undoing whitespaces
Mar 16, 2024
a753f32
undoing whitespaces
Mar 16, 2024
e55dc19
minor modification
Mar 16, 2024
31c38fe
updating changelog
Mar 16, 2024
9a48cb2
cleanup
Krastanov Mar 16, 2024
d564cd3
Adding Checks
Mar 17, 2024
b218e1e
Merge branch 'master' of https://github.com/Fe-r-oz/QuantumClifford.jl
Mar 17, 2024
f11efa5
improving indentation
Mar 17, 2024
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
92 changes: 92 additions & 0 deletions docs/src/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,95 @@ @article{nahum2017quantum
author = {Nahum, Adam and Ruhman, Jonathan and Vijay, Sagar and Haah, Jeongwan},
year = {2017}
}
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved

@article{Fowler_2011,
title={Two-dimensional color-code quantum computation},
volume={83},
ISSN={1094-1622},
url={http://dx.doi.org/10.1103/PhysRevA.83.042310},
DOI={10.1103/physreva.83.042310},
number={4},
journal={Physical Review A},
publisher={American Physical Society (APS)},
author={Fowler, Austin G.},
year={2011},
month=apr }

@misc{bombin2015gauge,
title={Gauge Color Codes: Optimal Transversal Gates and Gauge Fixing in Topological Stabilizer Codes},
author={H. Bombin},
year={2015},
eprint={1311.0879},
archivePrefix={arXiv},
primaryClass={quant-ph}
}

@misc{bravyi1998quantum,
title={Quantum codes on a lattice with boundary},
author={S. B. Bravyi and A. Yu. Kitaev},
year={1998},
eprint={quant-ph/9811052},
archivePrefix={arXiv},
primaryClass={quant-ph}
}

@article{Vasmer_2019,
title={Three-dimensional surface codes: Transversal gates and fault-tolerant architectures},
volume={100},
ISSN={2469-9934},
url={http://dx.doi.org/10.1103/PhysRevA.100.012312},
DOI={10.1103/physreva.100.012312},
number={1},
journal={Physical Review A},
publisher={American Physical Society (APS)},
author={Vasmer, Michael and Browne, Dan E.},
year={2019},
month=jul }

@misc{fahimniya2023faulttolerant,
title={Fault-tolerant hyperbolic Floquet quantum error correcting codes},
author={Ali Fahimniya and Hossein Dehghani and Kishor Bharti and Sheryl Mathew and Alicia J. Kollár and Alexey V. Gorshkov and Michael J. Gullans},
year={2023},
eprint={2309.10033},
archivePrefix={arXiv},
primaryClass={quant-ph}
}

@article{Breuckmann_2021,
title={Quantum Low-Density Parity-Check Codes},
volume={2},
ISSN={2691-3399},
url={http://dx.doi.org/10.1103/PRXQuantum.2.040101},
DOI={10.1103/prxquantum.2.040101},
number={4},
journal={PRX Quantum},
publisher={American Physical Society (APS)},
author={Breuckmann, Nikolas P. and Eberhardt, Jens Niklas},
year={2021},
month=oct }

@article{Krishna_2021,
title={Fault-Tolerant Gates on Hypergraph Product Codes},
volume={11},
ISSN={2160-3308},
url={http://dx.doi.org/10.1103/PhysRevX.11.011023},
DOI={10.1103/physrevx.11.011023},
number={1},
journal={Physical Review X},
publisher={American Physical Society (APS)},
author={Krishna, Anirudh and Poulin, David},
year={2021},
month=feb }

@article{Roffe_2023,
title={Bias-tailored quantum LDPC codes},
volume={7},
ISSN={2521-327X},
url={http://dx.doi.org/10.22331/q-2023-05-15-1005},
DOI={10.22331/q-2023-05-15-1005},
journal={Quantum},
publisher={Verein zur Forderung des Open Access Publizierens in den Quantenwissenschaften},
author={Roffe, Joschka and Cohen, Lawrence Z. and Quintavalle, Armanda O. and Chandra, Daryus and Campbell, Earl T.},
year={2023},
month=may, pages={1005} }

12 changes: 11 additions & 1 deletion docs/src/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,17 @@ For circuit construction routines (for stabilizer measurements for a given code)
- [grassl2002algorithmic](@cite)
- [grassl2011variations](@cite)

Quantum Error Correcting Codes:
- 2D Color Code [Fowler_2011](@cite)
- 3D Color Code [bombin2015gauge](@cite)
- 2D Surface Code [bravyi1998quantum](@cite)
- 3D Surface Code[Vasmer_2019](@cite)
- Floquent Code [fahimniya2023faulttolerant](@cite)
- Quantum Low-Density Parity Check (QLDPC) Code [Breuckmann_2021](@cite)
- Hypergraph Product Code [Krishna_2021](@cite)
- Bias-tailored Quantum LDPC Codes [Roffe_2023](@cite)

# References

```@bibliography
```
```
41 changes: 41 additions & 0 deletions src/ecc/codes/QHammingcode.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#The Gottesman code has the parameters [[2^r, 2^r - r - 2, 3]]
#So, the parity check matrix will be of the form:
#[[I_r, K, -I_r]
#[K^T, I_(2^r - r - 2), 0]
#[0, -K, I_r]]

struct QHamming
r::Int
end

function parity_checks(code::QHamming)
r = code.r
n = 2^r

# Construct the K matrix (refer to Gottesman-Chuang codes for details)
K = zeros(Int, (n - r - 2), r)
for i in 1:n-r-2
j = i + 1
while j <= n
K[i, bit2int(Integer.tobits(j - 1)[end])] = 1
j += 1
end
end

# Parity check matrix
H = [[diagm(ones(Int, r)), K, -diagm(ones(Int, r))]
[K', diagm(ones(Int, n - r - 2)), zeros(Int, n - r - 2)]
[zeros(Int, n - r - 2), -K, diagm(ones(Int, r))]]

return CSS(H)
end

#how to use
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
# Create two different instances of the quantum Hamming code
#code1 = QHamming(5) # r = 5
#code2 = QHamming(7) # r = 7

# Get the parity check matrices for each instance
#H1 = parity_checks(code1)
#H2 = parity_checks(code2)

11 changes: 11 additions & 0 deletions src/ecc/codes/code422.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# TODO [[4,2,2]] qubit code (Simplest Surface Code)
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved

struct code422 <: AbstractECC end

parity_checks(c::code422) = S"XZZX
YXXY"
#not sure about the two lines,I have a hunch it's correct. Need verification.
parity_checks_x(c::code422) = stab_to_gf2(parity_checks(code422()))[1:2,1:end÷2]
parity_checks_z(c::code422) = stab_to_gf2(parity_checks(code422()))[2:end,end÷2+1:end]

distance(c::code422) = 2
14 changes: 14 additions & 0 deletions src/ecc/codes/code833.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# TODO [[8,1,3]] qubit code
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved

struct code833 <: AbstractECC end

parity_checks(c::code833) = S"XXXXXXXX
ZZZZZZZZ
_X_XYZYZ
_XZY_XZY
_YXZXZ_Y"

parity_checks_x(c::code833) = stab_to_gf2(parity_checks(code833()))[1:3,1:end÷2]
parity_checks_z(c::code833) = stab_to_gf2(parity_checks(code833()))[5:end,end÷2+1:end]

distance(c::code833) = 3
63 changes: 63 additions & 0 deletions src/ecc/decoder_pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,66 @@ function PyMatchingDecoder(args...; kwargs...)
end
return ext.PyMatchingDecoder(args...; kwargs...)
end

"using QuantumClifford, Distances, JuMP"
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
# Define a struct named `IterativeDecoder` that inherits from `AbstractSyndromeDecoder`
struct IterativeDecoder <: AbstractSyndromeDecoder
# Stores the stabilizer matrix
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
H
# Number of qubits in the code
n
# Number of data qubits (k = n - rank(H))
k
# Maximum number of iterations allowed in the decoding process
max_iterations
end

# Function to initialize an `IterativeDecoder` object
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
function IterativeDecoder(c)
# Assuming H is already created
n, _ = size(H)
# Calculate number of data qubits based on stabilizer matrix rank
k = n - rank(H)
# Return an `IterativeDecoder` object with default max_iterations (can be adjusted)
return IterativeDecoder(H, n, k, 10)
end

# Function to perform iterative decoding using the Belief Propagation algorithm
function decode(decoder::IterativeDecoder, syndrome_sample)
# Initialize error estimate vector with zeros
error_estimate = zeros(Int, decoder.n)
# Copy syndrome sample to a local variable
syndrome = syndrome_sample

# Loop for the maximum number of iterations
for _ in 1:decoder.max_iterations
# Use LDPCDecoders' belief_propagate function for one BP iteration
error_estimate = belief_propagate(decoder.H, syndrome, max_iterations=1)[:, end]

# Recalculate syndrome based on the updated error estimate using QuantumClifford's comm_all function
syndrome = comm_all(decoder.H, error_estimate)

# Check for stopping criteria: zero syndrome or max iterations reached
if all(syndrome == 0) || _ >= decoder.max_iterations
break
end
end

# Return the final error estimate vector
return error_estimate
end

function test_iterative_decoder()
Fe-r-oz marked this conversation as resolved.
Show resolved Hide resolved
# Create an instance of the decoder
decoder = IterativeDecoder(H)

# Generate a random syndrome sample
n = size(H, 1) # Number of qubits based on H
syndrome = rand(Bool, n)

# Decode the syndrome
decoded_errors = decode(decoder, syndrome)

# Define a test assertion: Check if all decoded errors are zeros (perfect decoding)
@test isall(decoded_errors == 0)
end
Loading