QuantumSavory / QuantumClifford.jl

Clifford circuits, graph states, and other quantum Stabilizer formalism tools.
MIT License
103 stars 42 forks source link

add random Clifford circuit codes #298

Open royess opened 1 week ago

royess commented 1 week ago

Add implementations of random Clifford circuit codes, whose connectivity can be all-to-all or brickwork in some dimensions.

Some notes:

  1. While preparing this PR, I found that this notebook have implemented a 1D brickwork random circuit codes. This PR provides more connectivity choices and uses AbstractOperations[] of sparse gates for the generated circuit, which should be more efficient and allow visualization.
  2. I do not include random circuit codes in ecc_decoder_all_setups in this PR. The reason is that to ensure a good code parameter, the code has to contain more than 10 qubits, which exceeds the size that TableDecoder can efficiently handle. Random circuit codes are not CSS and are currently unsupported by PyMatchingDecoder.
  3. For a reference, I did some more tests in royess/qecc-devlog/test_random_circuit.ipynb, including visualizing the encoding circuits and decoding via TableDecoder. In the future, we may consider including these contents as tutorials or documentation.
royess commented 1 week ago

@Krastanov, please help review this PR; thanks! (The failed CI check is related to #245 )

royess commented 1 week ago

You mentioned how it does not work well with many decoders.

Actually, TableDecoder can give a rather low logical error rate, as I tested in this notebook.

However, we need random circuit codes with more than 10 qubits, e.g., 20 qubits, to ensure the randomly generated codes have a distance larger than 0. This will make TableDecoder inefficient and trigger warnings due to #291.

How does it perform with belief propagation and OSD decoders?

BP and BP-OSD in PyQDecoders.jl (as well as earlier mentioned PyMatchingDecoder ) are not applicable to random circuit codes because they are non-CSS.

"Codes of type CircuitCode do not have separate X and Z parity checks, either because they are not a CSS code and thus inherently do not have separate checks, or because its separate checks are not yet implemented in this library."

Stacktrace:
 [1] parity_checks_x(code::CircuitCode)
   @ QuantumClifford.ECC ~/Documents/Repos/QuantumClifford.jl/src/ecc/ECC.jl:41
 [2] QuantumCliffordPyQDecodersExt.PyBeliefPropOSDecoder(c::CircuitCode; maxiter::Nothing, bpmethod::Nothing, errorrate::Nothing, osdmethod::Nothing, osdorder::Int64)
   @ QuantumCliffordPyQDecodersExt ~/Documents/Repos/QuantumClifford.jl/ext/QuantumCliffordPyQDecodersExt/QuantumCliffordPyQDecodersExt.jl:51
 [3] QuantumCliffordPyQDecodersExt.PyBeliefPropOSDecoder(c::CircuitCode)
   @ QuantumCliffordPyQDecodersExt ~/Documents/Repos/QuantumClifford.jl/ext/QuantumCliffordPyQDecodersExt/QuantumCliffordPyQDecodersExt.jl:50
 [4] PyBeliefPropOSDecoder(args::CircuitCode; kwargs::@Kwargs{})
   @ QuantumClifford.ECC ~/Documents/Repos/QuantumClifford.jl/src/ecc/decoder_pipeline.jl:297
 [5] PyBeliefPropOSDecoder(args::CircuitCode)
   @ QuantumClifford.ECC ~/Documents/Repos/QuantumClifford.jl/src/ecc/decoder_pipeline.jl:292
 [6] top-level scope
   @ ./In[27]:14
codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 88.46154% with 6 lines in your changes missing coverage. Please review.

Project coverage is 82.97%. Comparing base (dddaedb) to head (e97a207).

Files Patch % Lines
src/ecc/codes/random_circuit.jl 73.91% 6 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #298 +/- ## ========================================== + Coverage 82.85% 82.97% +0.12% ========================================== Files 60 61 +1 Lines 3971 4023 +52 ========================================== + Hits 3290 3338 +48 - Misses 681 685 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

Krastanov commented 4 days ago

What is the current status?

royess commented 4 days ago

I did not fully comprehend some of your previous review comments and was waiting for your further replies on them.

I will get this PR updated quickly.