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

Error correction methods for creating Bicycle and Unicycle codes + belief decoder code evaluation #195

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 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
f402e31
faults matrix now accounts for rank-deficient ECCs (#196)
amicciche Nov 23, 2023
52db574
Update LICENSE
Krastanov Dec 16, 2023
8e5edff
buildkite test runner
Krastanov Dec 16, 2023
625d019
Update README.md - fix badge
Krastanov Dec 16, 2023
0823b89
add compat downgrader (#204)
Krastanov Dec 16, 2023
8125b9e
bump version
Krastanov Dec 16, 2023
95bf992
split the downgrade workflow
Krastanov Dec 16, 2023
70530ab
Bump dawidd6/action-download-artifact from 2 to 3 (#205)
dependabot[bot] Dec 18, 2023
c8d531f
Bump actions/upload-artifact from 3 to 4 (#206)
dependabot[bot] Dec 18, 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
295ed67
Merge branch 'master' of https://github.com/Benzillaist/QuantumCliffo…
Benzillaist Dec 30, 2023
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
22 changes: 22 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
env:
CODECOV_TOKEN: adb3f22a-231a-4f7b-8ed4-7c6c56453cbe
JULIA_NUM_THREADS: auto

steps:
- label: "CI Buildkite"
plugins:
- JuliaCI/julia#v1:
version: "1"
- QuantumSavory/julia-xvfb#v1:
- JuliaCI/julia-test#v1: ~
- JuliaCI/julia-coverage#v1:
codecov: true
command: |
julia -e '
using Pkg
Pkg.add("QuantumSavory")
Pkg.build("QuantumSavory")
Pkg.test("QuantumSavory")
Pkg.add("BPGates")
Pkg.build("BPGates")
Pkg.test("BPGates")'
2 changes: 1 addition & 1 deletion .github/workflows/benchmark-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v4

# restore records from the artifacts
- uses: dawidd6/action-download-artifact@v2
- uses: dawidd6/action-download-artifact@v3
with:
workflow: benchmark.yml
name: performance-tracking
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: echo ${{ github.event.pull_request.number }} > ./pull-request-number.artifact

# save as artifacts (performance tracking (comment) workflow will use it)
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: performance-tracking
path: ./*.artifact
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.9'
- '1'
os:
- ubuntu-latest
threads:
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/downgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Downgrade
on:
pull_request:
branches: [master, main]
paths-ignore:
- 'docs/**'
push:
branches: [master, main]
paths-ignore:
- 'docs/**'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['1.9']
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
- uses: cjdoris/julia-downgrade-compat-action@v1
with:
skip: Pkg,TOML,InteractiveUtils,Random,LinearAlgebra
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"julia.environmentPath": "c:\\Users\\benku\\Desktop\\College Documents\\Krastanov Independent Study\\QuantumClifford.jl-CSS_Builder"
}
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@

# News

## v0.8.17 - 2023-10-16
## v0.8.19 - 2023-12-16

- Bumping up the lower bounds of many dependencies and adding lower-bound compatibility checks to CI.

## v0.8.18 - 2023-11-22

- `ECC.faults_matrix` detects and warns when encountery codes with redundant checks.

## v0.8.17 - 2023-10-17

- **(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.

Expand Down
16 changes: 0 additions & 16 deletions CONTRIBUTORS

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Abhishek Bhatt
Copyright (c) 2023 Stefan Krastanov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 13 additions & 8 deletions 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.18"
version = "0.8.19"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand All @@ -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 All @@ -38,18 +40,21 @@ QuantumCliffordQuantikzExt = "Quantikz"
CUDA = "4.4.0"
Combinatorics = "1.0"
DataStructures = "0.18"
DocStringExtensions = "0.8, 0.9"
Graphs = "1.4.1"
DocStringExtensions = "0.9"
Graphs = "1.9"
HostCPUFeatures = "0.1.6"
ILog2 = "0.2.3"
InteractiveUtils = "1"
LinearAlgebra = "1"
MacroTools = "0.5.9"
Makie = "0.19.7"
Nemo = "0.34, 0.35, 0.36"
Nemo = "0.38"
Plots = "1.38.0"
PrecompileTools = "1"
PrecompileTools = "1.2"
Quantikz = "1.3.1"
QuantumInterface = "0.3.0"
QuantumOpticsBase = "0.4"
QuantumInterface = "0.3.3"
QuantumOpticsBase = "0.4.18"
Random = "1"
SIMD = "3.4.0"
SumTypes = "0.4.4, 0.5"
SumTypes = "0.5"
julia = "1.9"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<tr>
<td>Continuous integration</td>
<td>
<a href="https://github.com/QuantumSavory/QuantumClifford.jl/actions?query=workflow%3ACI+branch%3Amaster"><img src="https://img.shields.io/github/actions/workflow/status/QuantumSavory/QuantumClifford.jl/ci.yml?branch=master" alt="GitHub Workflow Status"></a>
<a href="https://github.com/QuantumSavory/QuantumClifford.jl/actions?query=workflow%3ACI+branch%3Amaster"><img src="https://github.com/QuantumSavory/QuantumClifford.jl/actions/workflows/ci.yml/badge.svg" alt="GitHub Workflow Status"></a>
<a href="https://buildkite.com/quantumsavory/quantumclifford"><img src="https://badge.buildkite.com/8ef137151415f29c03544c5b7963f6bc6afc1022f29cfc072a.svg" alt="Buildkite Workflow Status"></a>
</td>
</tr><tr></tr>
<tr>
Expand Down
19 changes: 14 additions & 5 deletions src/ecc/ECC.jl
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
module ECC

using LinearAlgebra
using QuantumClifford
using QuantumClifford: AbstractOperation, AbstractStabilizer
using QuantumClifford, SparseArrays
using QuantumClifford: AbstractOperation, AbstractStabilizer, Stabilizer
import QuantumClifford: Stabilizer, MixedDestabilizer
using DocStringExtensions
using Combinatorics: combinations
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
isdegenerate, faults_matrix,
Unicycle, Bicycle,
CSS

"""Parity check tableau of a code."""
function parity_checks end
Expand Down Expand Up @@ -234,10 +238,12 @@ We just gather all our syndrome measurement **and logical observables** from the
and then use them with the fault matrix in the syndrome decoding simulation.
"""
function faults_matrix(c::Stabilizer)
md = MixedDestabilizer(c)
s, n = size(c)
k = n-s
r = rank(md)
k = n - r
k == n-s || @warn "`faults_matrix` was called on an ECC that has redundant rows (is rank-deficient). `faults_matrix` corrected for that, however this is a frequent source of mistakes and inefficiencies. We advise you remove redundant rows from your ECC."
O = falses(2k, 2n)
md = MixedDestabilizer(c)
logviews = [logicalxview(md); logicalzview(md)]
errors = [one(Stabilizer,n; basis=:X);one(Stabilizer,n)]
for i in 1:2k
Expand Down Expand Up @@ -296,4 +302,7 @@ include("codes/steanecode.jl")
include("codes/shorcode.jl")
include("codes/clevecode.jl")

include("codes/css.jl")
include("codes/simple_sparse_codes.jl")

end #module
37 changes: 37 additions & 0 deletions src/ecc/codes/css.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""An arbitrary CSS error correcting code defined by its X and Z checks."""
struct CSS <: AbstractECC
Hx
Hz
"""Creates a CSS code using the two provided matrices where Hx contains the X checks and Hz contains the Z checks."""
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
return new(Hx, Hz)
end
end

function boolean_tableau(c::CSS)
Hx_height, Hx_width = size(c.Hx)
Hz_height, Hz_width = size(x.Hz)
checks_matrix = falses(Hx_height + Hz_height, Hx_width + Hz_width)
checks_matrix[1:Hx_height, 1:Hx_width] = c.Hx
checks_matrix[Hx_height+1:end, Hx_width+1:end] = c.Hz
return CSS(checks_matrix)
end

"""Returns the stabilizer making up the parity check tableau."""
function parity_checks(c::CSS)
extended_Hx = Matrix{Bool}(vcat(c.Hx, zeros(size(c.Hz))))
extended_Hz = Matrix{Bool}(vcat(zeros(size(c.Hx)), c.Hz))
Stabilizer(fill(0x0, size(c.Hx, 2) + size(c.Hz, 2)), extended_Hx, extended_Hz)
end

"""Returns the block length of the code."""
code_n(c::CSS) = size(c.Hx,2)

"""Returns the depth of the parity check matrix"""
code_m(c::CSS) = size(c.Hx, 1) + size(c.Hz, 1)

"""Returns the number of encoded qubits"""
code_k(c::CSS) = (2 * size(c.Hx,2)) - code_m(c)
Loading
Loading