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

ECC decoder pipeline #209

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2c4cb47
Added code_evaluation and code_generation methods
Benzillaist Oct 31, 2023
92f6eeb
Added dependencies
Benzillaist Nov 1, 2023
1c0fcdb
Removed pauli frame code
Benzillaist Nov 1, 2023
f77b135
Fixed naming and organization issues +
Benzillaist Nov 5, 2023
6c3434c
minor cleanup
Krastanov Nov 8, 2023
077e287
Fixed bugs preventing the generation of Bicycle and Unicycle codes
Benzillaist Nov 13, 2023
a115ef5
Merge pull request #1 from Benzillaist/testing-simple_branch_codes
Benzillaist Nov 13, 2023
81773e3
Update Project.toml
Benzillaist Dec 19, 2023
cac4133
Update src/ecc/ECC.jl
Benzillaist Dec 19, 2023
2eb3eb4
Update src/ecc/simple_sparse_codes.jl
Benzillaist Dec 19, 2023
49046fe
Update src/ecc/ECC.jl
Benzillaist Dec 19, 2023
f86cd86
Update src/ecc/simple_sparse_codes.jl
Benzillaist Dec 19, 2023
bd823ef
Moved CSS files to codes folder and updated CSS struct
Benzillaist Dec 19, 2023
8a8f89d
Small update to fix Stabilizer creation error
Benzillaist Dec 30, 2023
938ed97
Added decoder pipeline code from LDPCDecoders PR
Benzillaist Dec 30, 2023
38f6972
Added bicycle and unicycle tests, minor consistency changes to CSS st…
Benzillaist Jan 6, 2024
fd62561
Updated compact with relevant libraries
Benzillaist Jan 6, 2024
794ac6e
Added tests for whether Bicycle and Unicycle codes looks good
Benzillaist Jan 6, 2024
d9fb55e
Removed nemo library requirement
Benzillaist Jan 6, 2024
b015992
Updated version of statistics package
Benzillaist Jan 6, 2024
e834c31
some polish
Krastanov Jan 17, 2024
8437690
flesh out `evaluate_decoder`
Krastanov Jan 18, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Manifest.toml
LocalPreferences.toml
*/.*swp
scratch/
*.cov
*.cov
.vscode
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
QuantumInterface = "5717a53b-5d69-4fa3-b976-0bf2f97ca1e5"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
SIMD = "fdea26ae-647d-5447-a871-4b548cad5224"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
SumTypes = "8e1ec7a9-0e02-4297-b0fe-6433085c89f2"

[weakdeps]
Expand Down Expand Up @@ -53,3 +55,4 @@ QuantumOpticsBase = "0.4"
SIMD = "3.4.0"
SumTypes = "0.4.4, 0.5"
julia = "1.9"
Statistics = "1.9.0"
5 changes: 4 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ doctest = false,
clean = true,
sitename = "QuantumClifford.jl",
format = Documenter.HTML(size_threshold_ignore = ["API.md"]),
modules = [QuantumClifford, QuantumClifford.Experimental.NoisyCircuits, QuantumInterface],
modules = [QuantumClifford, QuantumClifford.Experimental.NoisyCircuits, QuantumClifford.ECC, QuantumInterface],
warnonly = [:missing_docs],
authors = "Stefan Krastanov",
pages = [
Expand All @@ -41,6 +41,9 @@ pages = [
"Circuit Operations" => "noisycircuits_ops.md",
"API" => "noisycircuits_API.md"
],
"ECC compendium" => [
"API" => "ECC_API.md"
],
"All Gates" => "allops.md",
"Visualizations" => "plotting.md",
"API" => "API.md",
Expand Down
6 changes: 6 additions & 0 deletions docs/src/ECC_API copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Full ECC API (autogenerated)

```@autodocs
Modules = [QuantumClifford.ECC]
Private = false
```
2 changes: 2 additions & 0 deletions src/affectedqubits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ affectedqubits(p::PauliOperator) = 1:length(p)
affectedqubits(m::Union{AbstractMeasurement,sMRX,sMRY,sMRZ}) = (m.qubit,)
affectedqubits(v::VerifyOp) = v.indices
affectedqubits(c::CliffordOperator) = 1:nqubits(c)
affectedqubits(c::ClassicalXOR) = ()

affectedbits(o) = ()
affectedbits(m::sMRZ) = (m.bit,)
affectedbits(m::sMZ) = (m.bit,)
affectedbits(c::ClassicalXOR) = (c.bits..., c.store)
18 changes: 13 additions & 5 deletions src/ecc/ECC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ module ECC

using LinearAlgebra
using QuantumClifford
using QuantumClifford: AbstractOperation, AbstractStabilizer
using QuantumClifford: AbstractOperation, AbstractStabilizer, Stabilizer
import QuantumClifford: Stabilizer, MixedDestabilizer
using DocStringExtensions
using Combinatorics: combinations
using SparseArrays
using Statistics: std
using Nemo: ZZ, residue_ring, matrix

abstract type AbstractECC end

export Shor9, Steane7, Cleve8, Perfect5, Bitflip3,
parity_checks, naive_syndrome_circuit, shor_syndrome_circuit, naive_encoding_circuit,
code_n, code_s, code_k, rate, distance,
isdegenerate, faults_matrix
export parity_checks, code_n, code_s, code_k, rate, distance,
isdegenerate, faults_matrix,
naive_syndrome_circuit, shor_syndrome_circuit, naive_encoding_circuit,
CSS, Unicycle, Bicycle,
Shor9, Steane7, Cleve8, Perfect5, Bitflip3,
evaluate_decoder, TableDecoder

"""Parity check tableau of a code."""
function parity_checks end
Expand Down Expand Up @@ -289,11 +294,14 @@ function isdegenerate(H::Stabilizer, d::Int=1)
end

include("circuits.jl")
include("decoder_pipeline.jl")

include("codes/css.jl")
include("codes/bitflipcode.jl")
include("codes/fivequbit.jl")
include("codes/steanecode.jl")
include("codes/shorcode.jl")
include("codes/clevecode.jl")
include("codes/simple_sparse_codes.jl")

end #module
4 changes: 2 additions & 2 deletions src/ecc/circuits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Use the `ancillary_index` and `bit_index` arguments to offset where the correspo
Ancillary qubits

Returns:
- The cat state preparation circuit.
- The ancillary cat state preparation circuit.
- The Shor syndrome measurement circuit.
- The number of ancillary qubits that were added.
- The list of bit indices that store the final measurement results.
Expand All @@ -165,7 +165,7 @@ and stores the measurement result into classical bits starting at `bit_index`.
The final measurement result is the XOR of all the bits.

Returns:
- The cat state preparation circuit.
- The ancillary cat state preparation circuit.
- The Shor syndrome measurement circuit.
- One more than the index of the last added ancillary qubit.
- One more than the index of the last added classical bit.
Expand Down
28 changes: 28 additions & 0 deletions src/ecc/codes/css.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""An arbitrary CSS error correcting code defined by its X and Z checks.

```jldoctest
julia> CSS([0 1 1 0; 1 1 0 0], [1 1 1 1]) |> parity_checks
+ _XX_
+ XX__
+ ZZZZ
```"""
struct CSS <: AbstractECC
Hx::Matrix{Bool}
Hz::Matrix{Bool}
function CSS(Hx, Hz)
n = size(Hx, 2)
if n != size(Hz, 2) error("When constructing a CSS quantum code, the two classical codes are required to have the same block size") end
if size(Hx,1)+size(Hz,1) >= n error("When constructing a CSS quantum code, the total number of checks (rows) in the parity checks of the two classical codes have to be lower than the block size (the number of columns).") end
Benzillaist marked this conversation as resolved.
Show resolved Hide resolved
new(Hx, Hz)
end
end

function parity_checks(c::CSS)
extended_Hx = Matrix{Bool}(vcat(c.Hx, zeros(size(c.Hz))))
Benzillaist marked this conversation as resolved.
Show resolved Hide resolved
extended_Hz = Matrix{Bool}(vcat(zeros(size(c.Hx)), c.Hz))
Stabilizer(fill(0x0, size(c.Hx, 1) + size(c.Hz, 1)), extended_Hx, extended_Hz)
end

code_n(c::CSS) = size(c.Hx,2)

code_s(c::CSS) = size(c.Hx, 1) + size(c.Hz, 1)
Loading
Loading