diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index acdab7ae8..747dbde9f 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-27T17:54:29","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.0","generation_timestamp":"2024-10-09T21:59:52","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/dev/API/index.html b/dev/API/index.html index bf14f106d..6be3b7746 100644 --- a/dev/API/index.html +++ b/dev/API/index.html @@ -4,7 +4,7 @@ padding-top: 0 !important; padding-bottom: 0 !important; } -

States

Stabilizer states can be represented with the Stabilizer, Destabilizer, MixedStabilizer, and MixedDestabilizer tableau data structures. You probably want to use MixedDestabilizer which supports the widest set of operations.

Moreover, a MixedDestabilizer can be stored inside a Register together with a set of classical bits in which measurement results can be written.

Lastly, for Pauli frame simulations there is the PauliFrame type, a tableau in which each row represents a different Pauli frame.

There are convenience constructors for common types of states and operators.

Operations

Acting on quantum states can be performed either:

See the full list of operations for a list of implemented operations.

Autogenerated API list

QuantumClifford.QuantumCliffordModule

A module for using the Stabilizer formalism and simulating Clifford circuits.

source
QuantumClifford.continue_statConstant

Returned by applywstatus! if the circuit simulation should continue.

source
QuantumClifford.failure_statConstant

Returned by applywstatus! if the circuit reports a failure.

See also: VerifyOp, BellMeasurement.

source
QuantumClifford.false_success_statConstant

Returned by applywstatus! if the circuit reports a success, but it is a false positive (i.e., there was an undetected error).

See also: VerifyOp, BellMeasurement.

source
QuantumClifford.true_success_statConstant

Returned by applywstatus! if the circuit reports a success and there is no undetected error.

See also: VerifyOp, BellMeasurement.

source
QuantumClifford.AbstractSingleQubitOperatorType

Supertype of all single-qubit symbolic operators.

source
QuantumClifford.AbstractSymbolicOperatorType

Supertype of all symbolic operators. Subtype of AbstractCliffordOperator

source
QuantumClifford.AbstractTwoQubitOperatorType

Supertype of all two-qubit symbolic operators.

source
QuantumClifford.BellMeasurementType

A Bell measurement performing the correlation measurement corresponding to the given pauli projections on the qubits at the selected indices.

source
QuantumClifford.CircuitStatusType

A convenience struct to represent the status of a circuit simulated by mctrajectories

source
QuantumClifford.ClassicalXORType

Applies an XOR gate to classical bits. Currently only implemented for functionality with pauli frames.

source
QuantumClifford.CliffordOperatorType

Clifford Operator specified by the mapping of the basis generators.

julia> tCNOT
+

States

Stabilizer states can be represented with the Stabilizer, Destabilizer, MixedStabilizer, and MixedDestabilizer tableau data structures. You probably want to use MixedDestabilizer which supports the widest set of operations.

Moreover, a MixedDestabilizer can be stored inside a Register together with a set of classical bits in which measurement results can be written.

Lastly, for Pauli frame simulations there is the PauliFrame type, a tableau in which each row represents a different Pauli frame.

There are convenience constructors for common types of states and operators.

Operations

Acting on quantum states can be performed either:

  • In a "linear algebra" language where unitaries, measurements, and other operations have separate interfaces. This is an explicitly deterministic lower-level interface, which provides a great deal of control over how tableaux are manipulated. See the Stabilizer Tableau Algebra Manual as a primer on these approaches.
  • Or in a "circuit" language, where the operators (and measurements and noise) are represented as circuit gates. This is a higher-level interface in which the outcome of an operation can be stochastic. The API for it is centered around the apply! function. Particularly useful for Monte Carlo simulations and Perturbative Expansion Symbolic Results.

See the full list of operations for a list of implemented operations.

Autogenerated API list

QuantumClifford.BellMeasurementType

A Bell measurement performing the correlation measurement corresponding to the given pauli projections on the qubits at the selected indices.

source
QuantumClifford.CliffordOperatorType

Clifford Operator specified by the mapping of the basis generators.

julia> tCNOT
 X₁ ⟼ + XX
 X₂ ⟼ + _X
 Z₁ ⟼ + Z_
@@ -33,12 +33,12 @@
 
 julia> CliffordOperator(d)
 X₁ ⟼ + Z
-Z₁ ⟼ + Y
source
QuantumClifford.DestabilizerType

A tableau representation of a pure stabilizer state. The tableau tracks the destabilizers as well, for efficient projections. On initialization there are no checks that the provided state is indeed pure. This enables the use of this data structure for mixed stabilizer state, but a better choice would be to use MixedDestabilizer.

source
QuantumClifford.MixedDestabilizerType

A tableau representation for mixed stabilizer states that keeps track of the destabilizers in order to provide efficient projection operations.

The rank r of the n-qubit tableau is tracked, either so that it can be used to represent a mixed stabilizer state, or so that it can be used to represent an n-r logical-qubit code over n physical qubits. The "logical" operators are tracked as well.

When the constructor is called on an incomplete Stabilizer it automatically calculates the destabilizers and logical operators, following chapter 4 of (Gottesman, 1997). Under the hood the conversion uses the canonicalize_gott! canonicalization. That canonicalization permutes the columns of the tableau, but we automatically undo the column permutation in the preparation of a MixedDestabilizer so that qubits are not reindexed. The boolean keyword arguments undoperm and reportperm can be used to control this behavior and to report the permutations explicitly.

See also: stabilizerview, destabilizerview, logicalxview, logicalzview

source
QuantumClifford.PauliFrameType
struct PauliFrame{T, S} <: QuantumClifford.AbstractQCState

This is a wrapper around a tableau. This "frame" tableau is not to be viewed as a normal stabilizer tableau, although it does conjugate the same under Clifford operations. Each row in the tableau refers to a single frame. The row represents the Pauli operation by which the frame and the reference differ.

source
QuantumClifford.DestabilizerType

A tableau representation of a pure stabilizer state. The tableau tracks the destabilizers as well, for efficient projections. On initialization there are no checks that the provided state is indeed pure. This enables the use of this data structure for mixed stabilizer state, but a better choice would be to use MixedDestabilizer.

source
QuantumClifford.MixedDestabilizerType

A tableau representation for mixed stabilizer states that keeps track of the destabilizers in order to provide efficient projection operations.

The rank r of the n-qubit tableau is tracked, either so that it can be used to represent a mixed stabilizer state, or so that it can be used to represent an n-r logical-qubit code over n physical qubits. The "logical" operators are tracked as well.

When the constructor is called on an incomplete Stabilizer it automatically calculates the destabilizers and logical operators, following chapter 4 of (Gottesman, 1997). Under the hood the conversion uses the canonicalize_gott! canonicalization. That canonicalization permutes the columns of the tableau, but we automatically undo the column permutation in the preparation of a MixedDestabilizer so that qubits are not reindexed. The boolean keyword arguments undoperm and reportperm can be used to control this behavior and to report the permutations explicitly.

See also: stabilizerview, destabilizerview, logicalxview, logicalzview

source
QuantumClifford.PauliFrameType
struct PauliFrame{T, S} <: QuantumClifford.AbstractQCState

This is a wrapper around a tableau. This "frame" tableau is not to be viewed as a normal stabilizer tableau, although it does conjugate the same under Clifford operations. Each row in the tableau refers to a single frame. The row represents the Pauli operation by which the frame and the reference differ.

source
QuantumClifford.PauliFrameMethod
PauliFrame(
     frames,
     qubits,
     measurements
 ) -> PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}}
-

Prepare an empty set of Pauli frames with the given number of frames and qubits. Preallocates spaces for measurement number of measurements.

source
QuantumClifford.PauliOperatorType

A multi-qubit Pauli operator ($±\{1,i\}\{I,Z,X,Y\}^{\otimes n}$).

A Pauli can be constructed with the P custom string macro or by building up one through products and tensor products of smaller operators.

julia> pauli3 = P"-iXYZ"
+

Prepare an empty set of Pauli frames with the given number of frames and qubits. Preallocates spaces for measurement number of measurements.

source
QuantumClifford.PauliOperatorType

A multi-qubit Pauli operator ($±\{1,i\}\{I,Z,X,Y\}^{\otimes n}$).

A Pauli can be constructed with the P custom string macro or by building up one through products and tensor products of smaller operators.

julia> pauli3 = P"-iXYZ"
 -iXYZ
 
 julia> pauli4 = 1im * pauli3 ⊗ X
@@ -55,7 +55,7 @@
 (true, false)
 
 julia> p[1] = (true, true); p
-+ YYZ
source
QuantumClifford.RegisterType

A register, representing the state of a computer including both a tableaux and an array of classical bits (e.g. for storing measurement results)

source
QuantumClifford.ResetType

Reset the specified qubits to the given state.

Be careful, this operation implies first tracing out the qubits, which can lead to mixed states if these qubits were entangled with the rest of the system.

See also: sMRZ

source
QuantumClifford.SingleQubitOperatorType

A "symbolic" general single-qubit operator which permits faster multiplication than an operator expressed as an explicit tableau.

julia> op = SingleQubitOperator(2, true, true, true, false, true, true) # Tableau components and phases
++ YYZ
source
QuantumClifford.RegisterType

A register, representing the state of a computer including both a tableaux and an array of classical bits (e.g. for storing measurement results)

source
QuantumClifford.ResetType

Reset the specified qubits to the given state.

Be careful, this operation implies first tracing out the qubits, which can lead to mixed states if these qubits were entangled with the rest of the system.

See also: sMRZ

source
QuantumClifford.SingleQubitOperatorType

A "symbolic" general single-qubit operator which permits faster multiplication than an operator expressed as an explicit tableau.

julia> op = SingleQubitOperator(2, true, true, true, false, true, true) # Tableau components and phases
 SingleQubitOperator on qubit 2
 X₁ ⟼ - Y
 Z₁ ⟼ - X
@@ -76,7 +76,7 @@
 
 julia> CliffordOperator(op, 1, compact=true) # You can also extract just the non-trivial part of the tableau
 X₁ ⟼ - Y
-Z₁ ⟼ - X

See also: sHadamard, sPhase, sId1, sX, sY, sZ, CliffordOperator

Or simply consult subtypes(QuantumClifford.AbstractSingleQubitOperator) and subtypes(QuantumClifford.AbstractTwoQubitOperator) for a full list. You can think of the s prefix as "symbolic" or "sparse".

source
QuantumClifford.SparseGateType

A Clifford gate, applying the given cliff operator to the qubits at the selected indices.

apply!(state, cliff, indices) and apply!(state, SparseGate(cliff, indices)) give the same result.

source
QuantumClifford.StabMixtureType
mutable struct StabMixture{T, F}

Represents mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is a pure stabilizer state.

julia> StabMixture(S"-X")
+Z₁ ⟼ - X

See also: sHadamard, sPhase, sId1, sX, sY, sZ, CliffordOperator

Or simply consult subtypes(QuantumClifford.AbstractSingleQubitOperator) and subtypes(QuantumClifford.AbstractTwoQubitOperator) for a full list. You can think of the s prefix as "symbolic" or "sparse".

source
QuantumClifford.SparseGateType

A Clifford gate, applying the given cliff operator to the qubits at the selected indices.

apply!(state, cliff, indices) and apply!(state, SparseGate(cliff, indices)) give the same result.

source
QuantumClifford.StabMixtureType
mutable struct StabMixture{T, F}

Represents mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is a pure stabilizer state.

julia> StabMixture(S"-X")
 A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
 𝒟ℯ𝓈𝓉𝒶𝒷
 + Z
@@ -101,7 +101,7 @@
  0.0+0.353553im | + _ | + Z
  0.0-0.353553im | + Z | + _
  0.853553+0.0im | + _ | + _
- 0.146447+0.0im | + Z | + Z

See also: PauliChannel

source
QuantumClifford.StabilizerType

Stabilizer, i.e. a list of commuting multi-qubit Hermitian Pauli operators.

Instances can be created with the S custom string macro or as direct sum of other stabilizers.

Stabilizers and Destabilizers

In many cases you probably would prefer to use the MixedDestabilizer data structure, as it caries a lot of useful additional information, like tracking rank and destabilizer operators. Stabilizer has mostly a pedagogical value, and it is also used for slightly faster simulation of a particular subset of Clifford operations.

julia> s = S"XXX
+ 0.146447+0.0im | + Z | + Z

See also: PauliChannel

source
QuantumClifford.StabilizerType

Stabilizer, i.e. a list of commuting multi-qubit Hermitian Pauli operators.

Instances can be created with the S custom string macro or as direct sum of other stabilizers.

Stabilizers and Destabilizers

In many cases you probably would prefer to use the MixedDestabilizer data structure, as it caries a lot of useful additional information, like tracking rank and destabilizer operators. Stabilizer has mostly a pedagogical value, and it is also used for slightly faster simulation of a particular subset of Clifford operations.

julia> s = S"XXX
              ZZI
              IZZ"
 + XXX
@@ -134,7 +134,7 @@
 
 julia> s[1,1] = (true, false); s
 + X_
-+ __

There are no automatic checks for correctness (i.e. independence of all rows, commutativity of all rows, hermiticity of all rows). The rank (number of rows) is permitted to be less than the number of qubits (number of columns): canonilization, projection, etc. continue working in that case. To great extent this library uses the Stabilizer data structure simply as a tableau. This might be properly abstracted away in future versions.

See also: PauliOperator, canonicalize!

source
QuantumClifford.UnitaryPauliChannelType

A Pauli channel datastructure, mainly for use with StabMixture.

More convenient to use than PauliChannel when you know your Pauli channel is unitary.

julia> Tgate = UnitaryPauliChannel(
++ __

There are no automatic checks for correctness (i.e. independence of all rows, commutativity of all rows, hermiticity of all rows). The rank (number of rows) is permitted to be less than the number of qubits (number of columns): canonilization, projection, etc. continue working in that case. To great extent this library uses the Stabilizer data structure simply as a tableau. This might be properly abstracted away in future versions.

See also: PauliOperator, canonicalize!

source
QuantumClifford.UnitaryPauliChannelType

A Pauli channel datastructure, mainly for use with StabMixture.

More convenient to use than PauliChannel when you know your Pauli channel is unitary.

julia> Tgate = UnitaryPauliChannel(
            (I, Z),
            ((1+exp(im*π/4))/2, (1-exp(im*π/4))/2)
        )
@@ -149,7 +149,7 @@
  0.853553+0.0im | + _ | + _
  0.0+0.353553im | + _ | + Z
  0.0-0.353553im | + Z | + _
- 0.146447+0.0im | + Z | + Z
source
QuantumClifford.VerifyOpType

A "probe" to verify that the state of the qubits corresponds to a desired good_state, e.g. at the end of the execution of a circuit.

source
QuantumClifford.sMRZType

Measure a qubit in the Z basis and reset to the |0⟩ state.

It does not trace out the qubit!

As described below there is a difference between measuring the qubit (followed by setting it to a given known state) and "tracing out" the qubit. By reset here we mean "measuring and setting to a known state", not "tracing out".

julia> s = MixedDestabilizer(S"XXX ZZI IZZ") # |000⟩+|111⟩
+ 0.146447+0.0im | + Z | + Z
source
QuantumClifford.VerifyOpType

A "probe" to verify that the state of the qubits corresponds to a desired good_state, e.g. at the end of the execution of a circuit.

source
QuantumClifford.sMRZType

Measure a qubit in the Z basis and reset to the |0⟩ state.

It does not trace out the qubit!

As described below there is a difference between measuring the qubit (followed by setting it to a given known state) and "tracing out" the qubit. By reset here we mean "measuring and setting to a known state", not "tracing out".

julia> s = MixedDestabilizer(S"XXX ZZI IZZ") # |000⟩+|111⟩
 𝒟ℯ𝓈𝓉𝒶𝒷
 + Z__
 + _X_
@@ -199,7 +199,7 @@
 𝒮𝓉𝒶𝒷━
 + Z__
 - ZZ_
-- Z_Z

See also: Reset, sMZ

source
QuantumClifford.PauliErrorFunction

A convenient constructor for various types of Pauli errors, that can be used as circuit gates in simulations. Returns more specific types when necessary.

source
QuantumClifford.PauliErrorMethod

"Construct a gate operation that applies a biased Pauli error on all qubits independently, each with probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).

source
QuantumClifford.PauliErrorMethod

"Construct a gate operation that applies a biased Pauli error on qubit q with independent probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).

source
QuantumClifford.applybranchesFunction

Compute all possible new states after the application of the given operator. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Perturbative Expansion interface.

source
QuantumClifford.applynoise!Function

A method modifying a given state by applying the corresponding noise model. It is non-deterministic, part of the Noise interface.

source
QuantumClifford.PauliErrorFunction

A convenient constructor for various types of Pauli errors, that can be used as circuit gates in simulations. Returns more specific types when necessary.

source
QuantumClifford.PauliErrorMethod

"Construct a gate operation that applies a biased Pauli error on all qubits independently, each with probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).

source
QuantumClifford.PauliErrorMethod

"Construct a gate operation that applies a biased Pauli error on qubit q with independent probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).

source
QuantumClifford.applybranchesFunction

Compute all possible new states after the application of the given operator. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Perturbative Expansion interface.

source
QuantumClifford.applynoise!Function

A method modifying a given state by applying the corresponding noise model. It is non-deterministic, part of the Noise interface.

source
QuantumClifford.bellFunction

Prepare one or more Bell pairs (with optional phases).

julia> bell()
 + XX
 + ZZ
 
@@ -217,15 +217,15 @@
 - XX__
 + ZZ__
 - __XX
-- __ZZ
source
QuantumClifford.bigramMethod
bigram(
     state::QuantumClifford.AbstractStabilizer;
     clip
 ) -> Matrix{Int64}
-

Get the bigram of a tableau.

It is the list of endpoints of a tableau in the clipped gauge.

If clip=true (the default) the tableau is converted to the clipped gauge in-place before calculating the bigram. Otherwise, the clip gauge conversion is skipped (for cases where the input is already known to be in the correct gauge).

Introduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in (Li et al., 2019) and (Gullans et al., 2021).

See also: canonicalize_clip!

source
QuantumClifford.canonicalize!Method
canonicalize!(
+

Get the bigram of a tableau.

It is the list of endpoints of a tableau in the clipped gauge.

If clip=true (the default) the tableau is converted to the clipped gauge in-place before calculating the bigram. Otherwise, the clip gauge conversion is skipped (for cases where the input is already known to be in the correct gauge).

Introduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in (Li et al., 2019) and (Gullans et al., 2021).

See also: canonicalize_clip!

source
QuantumClifford.canonicalize!Method
canonicalize!(
     state::QuantumClifford.AbstractStabilizer;
     phases,
     ranks
-) -> Any
+) -> Union{Tuple{QuantumClifford.AbstractStabilizer, Int64, Int64}, QuantumClifford.AbstractStabilizer}
 

Canonicalize a stabilizer (in place).

Assumes the input is a valid stabilizer (all operators commute and have real phases). It permits redundant generators and identity generators.

julia> ghz = S"XXXX
                ZZII
                IZZI
@@ -276,7 +276,7 @@
 + XXXX
 + Z__Z
 + _Z_Z
-+ ____

Based on (Garcia et al., 2012).

See also: canonicalize_rref!, canonicalize_gott!

source
QuantumClifford.canonicalize_clip!Method
canonicalize_clip!(
     state::QuantumClifford.AbstractStabilizer;
     phases
 ) -> QuantumClifford.AbstractStabilizer
@@ -294,32 +294,32 @@
 + _XZX__
 - _ZYX_Z
 - __YZ_X
-- ____Z_

If phases=false is set, the canonicalization does not track the phases in the tableau, leading to a significant speedup.

Introduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in Appendix A of (Li et al., 2019)

See also: canonicalize!, canonicalize_rref!, canonicalize_gott!.

source
QuantumClifford.canonicalize_gott!Method

Inplace Gottesman canonicalization of a tableau.

This uses different canonical form from canonicalize!. It is used in the computation of the logical X and Z operators of a MixedDestabilizer.

It returns the (in place) modified state, the indices of the last pivot of both Gaussian elimination steps, and the permutations that have been used to put the X and Z tableaux in standard form.

Based on (Gottesman, 1997).

See also: canonicalize!, canonicalize_rref!

source
QuantumClifford.canonicalize_gott!Method

Inplace Gottesman canonicalization of a tableau.

This uses different canonical form from canonicalize!. It is used in the computation of the logical X and Z operators of a MixedDestabilizer.

It returns the (in place) modified state, the indices of the last pivot of both Gaussian elimination steps, and the permutations that have been used to put the X and Z tableaux in standard form.

Based on (Gottesman, 1997).

See also: canonicalize!, canonicalize_rref!

source
QuantumClifford.canonicalize_rref!Method
canonicalize_rref!(
     state::QuantumClifford.AbstractStabilizer,
     colindices;
     phases
 ) -> Tuple{QuantumClifford.AbstractStabilizer, Any}
-

Canonicalize a stabilizer (in place) along only some columns.

This uses different canonical form from canonicalize!. It also indexes in reverse in order to make its use in traceout! more efficient. Its use in traceout! is its main application.

It returns the (in place) modified state and the index of the last pivot.

Based on (Audenaert and Plenio, 2005).

See also: canonicalize!, canonicalize_gott!

source
QuantumClifford.centralizerMethod

For a given set of Paulis (in the form of a Tableau), return the subset of Paulis that commute with all Paulis in set.

julia> centralizer(T"XX ZZ _Z")
-+ ZZ
source
QuantumClifford.clifford_cardinalityMethod

The size of the Clifford group 𝒞 over a given number of qubits, possibly modulo the phases.

For n qubits, not accounting for phases is 2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1). There are 4ⁿ different phase configurations.

julia> clifford_cardinality(7)
+
source
QuantumClifford.centralizerMethod

For a given set of Paulis (in the form of a Tableau), return the subset of Paulis that commute with all Paulis in set.

julia> centralizer(T"XX ZZ _Z")
++ ZZ
source
QuantumClifford.clifford_cardinalityMethod

The size of the Clifford group 𝒞 over a given number of qubits, possibly modulo the phases.

For n qubits, not accounting for phases is 2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1). There are 4ⁿ different phase configurations.

julia> clifford_cardinality(7)
 457620995529680351512370381586432000

When not accounting for phases (phases = false) the result is the same as the size of the Symplectic group Sp(2n) ≡ 𝒞ₙ/𝒫ₙ, where 𝒫ₙ is the Pauli group over n qubits.

julia> clifford_cardinality(7, phases=false)
-27930968965434591767112450048000

See also: enumerate_cliffords.

source
QuantumClifford.commFunction

Check whether two operators commute.

0x0 if they commute, 0x1 if they anticommute.

julia> P"XX"*P"ZZ", P"ZZ"*P"XX"
 (- YY, - YY)
 
 julia> comm(P"ZZ", P"XX")
 0x00
 
 julia> comm(P"IZ", P"XX")
-0x01

See also: comm!

source
QuantumClifford.compactify_circuitMethod

Convert a list of gates to a more optimized "sum type" format which permits faster dispatch.

Generally, this should be called on a circuit before it is used in a simulation.

source
QuantumClifford.contractorMethod

Return the subset of Paulis in a Stabilizer that have identity operators on all qubits corresponding to the given subset, without the entries corresponding to subset.

julia> contractor(S"_X X_", [1])
-+ X
source
QuantumClifford.delete_columnsMethod

Return the given stabilizer without all the qubits in the given iterable.

The resulting tableaux is not guaranteed to be valid (to retain its commutation relationships).

julia> delete_columns(S"XYZ YZX ZXY", [1,3])
+0x01

See also: comm!

source
QuantumClifford.compactify_circuitMethod

Convert a list of gates to a more optimized "sum type" format which permits faster dispatch.

Generally, this should be called on a circuit before it is used in a simulation.

source
QuantumClifford.contractorMethod

Return the subset of Paulis in a Stabilizer that have identity operators on all qubits corresponding to the given subset, without the entries corresponding to subset.

julia> contractor(S"_X X_", [1])
++ X
source
QuantumClifford.delete_columnsMethod

Return the given stabilizer without all the qubits in the given iterable.

The resulting tableaux is not guaranteed to be valid (to retain its commutation relationships).

julia> delete_columns(S"XYZ YZX ZXY", [1,3])
 + Y
 + Z
-+ X

See also: traceout!

source
QuantumClifford.enumerate_single_qubit_gatesMethod

Generate a symbolic single-qubit gate given its index. Optionally, set non-trivial phases.

julia> enumerate_single_qubit_gates(6)
 sPhase on qubit 1
 X₁ ⟼ + Y
 Z₁ ⟼ + Z
@@ -327,7 +327,7 @@
 julia> enumerate_single_qubit_gates(6, qubit=2, phases=(true, true))
 SingleQubitOperator on qubit 2
 X₁ ⟼ - Y
-Z₁ ⟼ - Z

See also: enumerate_cliffords.

source
QuantumClifford.fastcolumnFunction

Convert a tableau to a memory layout that is fast for column operations.

In this layout a column of the tableau is stored (mostly) contiguously in memory. Due to bitpacking, e.g., packing 64 bits into a single UInt64, the memory layout is not perfectly contiguous, but it is still optimal given that some bitwrangling is required to extract a given bit.

See also: fastrow

source
QuantumClifford.fastrowFunction

Convert a tableau to a memory layout that is fast for row operations.

In this layout a Pauli string (a row of the tableau) is stored contiguously in memory.

See also: fastrow

source
QuantumClifford.generate!Method

Generate a Pauli operator by using operators from a given the Stabilizer.

It assumes the stabilizer is already canonicalized. It modifies the Pauli operator in place, generating it in reverse, up to a phase. That phase is left in the modified operator, which should be the identity up to a phase. Returns the new operator and the list of indices denoting the elements of stabilizer that were used for the generation.

julia> ghz = S"XXXX
+Z₁ ⟼ - Z

See also: enumerate_cliffords.

source
QuantumClifford.fastcolumnFunction

Convert a tableau to a memory layout that is fast for column operations.

In this layout a column of the tableau is stored (mostly) contiguously in memory. Due to bitpacking, e.g., packing 64 bits into a single UInt64, the memory layout is not perfectly contiguous, but it is still optimal given that some bitwrangling is required to extract a given bit.

See also: fastrow

source
QuantumClifford.fastrowFunction

Convert a tableau to a memory layout that is fast for row operations.

In this layout a Pauli string (a row of the tableau) is stored contiguously in memory.

See also: fastrow

source
QuantumClifford.generate!Method

Generate a Pauli operator by using operators from a given the Stabilizer.

It assumes the stabilizer is already canonicalized. It modifies the Pauli operator in place, generating it in reverse, up to a phase. That phase is left in the modified operator, which should be the identity up to a phase. Returns the new operator and the list of indices denoting the elements of stabilizer that were used for the generation.

julia> ghz = S"XXXX
                ZZII
                IZZI
                IIZZ";
@@ -344,7 +344,7 @@
 true
 
 julia> generate!(P"XII",canonicalize!(S"XII")) === nothing
-false
source
QuantumClifford.ghzFunction

Prepare a GHZ state of n qubits.

julia> ghz()
 + XXX
 + ZZ_
 + _ZZ
@@ -357,7 +357,7 @@
 + XXXX
 + ZZ__
 + _ZZ_
-+ __ZZ
source
QuantumClifford.graphstateMethod

Convert any stabilizer state to a graph state

Graph states are a special type of entangled stabilizer states that can be represented by a graph. For a graph $G=(V,E)$ the corresponding stabilizers are $S_v = X_v \prod_{u ∈ N(v)} Z_u$. Notice that such tableau rows contain only a single X operator. There is a set of single qubit gates that converts any stabilizer state to a graph state.

This function returns the graph state corresponding to a stabilizer and the gates that might be necessary to convert the stabilizer into a state representable as a graph.

For a tableau stab you can convert it with:

graph, hadamard_idx, iphase_idx, flips_idx = graphstate()

where graph is the graph representation of stab, and the rest specifies the single-qubit gates converting stab to graph: hadamard_idx are the qubits that require a Hadamard gate (mapping X ↔ Z), iphase_idx are (different) qubits that require an inverse Phase gate (Y → X), and flips_idx are the qubits that require a phase flip (Pauli Z gate), after the previous two sets of gates.

julia> using Graphs
+true

See also: graph_gatesequence

source
QuantumClifford.graphstateMethod

Convert any stabilizer state to a graph state

Graph states are a special type of entangled stabilizer states that can be represented by a graph. For a graph $G=(V,E)$ the corresponding stabilizers are $S_v = X_v \prod_{u ∈ N(v)} Z_u$. Notice that such tableau rows contain only a single X operator. There is a set of single qubit gates that converts any stabilizer state to a graph state.

This function returns the graph state corresponding to a stabilizer and the gates that might be necessary to convert the stabilizer into a state representable as a graph.

For a tableau stab you can convert it with:

graph, hadamard_idx, iphase_idx, flips_idx = graphstate()

where graph is the graph representation of stab, and the rest specifies the single-qubit gates converting stab to graph: hadamard_idx are the qubits that require a Hadamard gate (mapping X ↔ Z), iphase_idx are (different) qubits that require an inverse Phase gate (Y → X), and flips_idx are the qubits that require a phase flip (Pauli Z gate), after the previous two sets of gates.

julia> using Graphs
 
 julia> s = S" XXX
               ZZ_
@@ -421,15 +421,15 @@
 1-element Vector{Int64}:
  3

The Graphs.jl library provides many graph-theory tools and the MakieGraphs.jl library provides plotting utilities for graphs.

You can directly call the graph constructor on a stabilizer, if you just want the graph and do not care about the Clifford operation necessary to convert an arbitrary state to a state representable as a graph:

julia> collect(edges( Graph(bell()) ))
 1-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:
- Edge 1 => 2

For a version that does not copy the stabilizer, but rather performs transformations in-place, use graphstate!. It would perform canonicalize_gott! on its argument as it finds a way to convert it to a graph state.

source
QuantumClifford.groupifyMethod

Return the full stabilizer group represented by the input generating set (a Stabilizer).

The returned object is exponentially long.

julia> groupify(S"XZ ZX")
+ Edge 1 => 2

For a version that does not copy the stabilizer, but rather performs transformations in-place, use graphstate!. It would perform canonicalize_gott! on its argument as it finds a way to convert it to a graph state.

source
QuantumClifford.groupifyMethod

Return the full stabilizer group represented by the input generating set (a Stabilizer).

The returned object is exponentially long.

julia> groupify(S"XZ ZX")
 + __
 + XZ
 + ZX
-+ YY
source
QuantumClifford.logdotMethod

Logarithm of the inner product between to Stabilizer states.

If the result is nothing, the dot inner product is zero. Otherwise the inner product is 2^(-logdot/2).

The actual inner product can be computed with LinearAlgebra.dot.

Based on (Garcia et al., 2012).

source
QuantumClifford.minimal_generating_setMethod

For a not-necessarily-minimal generating set, return the minimal generating set.

The input has to have only real phases.

julia> minimal_generating_set(S"__ XZ ZX YY")
++ YY
source
QuantumClifford.logdotMethod

Logarithm of the inner product between to Stabilizer states.

If the result is nothing, the dot inner product is zero. Otherwise the inner product is 2^(-logdot/2).

The actual inner product can be computed with LinearAlgebra.dot.

Based on (Garcia et al., 2012).

source
QuantumClifford.minimal_generating_setMethod

For a not-necessarily-minimal generating set, return the minimal generating set.

The input has to have only real phases.

julia> minimal_generating_set(S"__ XZ ZX YY")
 + XZ
-+ ZX
source
QuantumClifford.normalizerMethod

Return all Pauli operators with the same number of qubits as the given Tableau t that commute with all operators in t.

julia> normalizer(T"X")
++ ZX
source
QuantumClifford.normalizerMethod

Return all Pauli operators with the same number of qubits as the given Tableau t that commute with all operators in t.

julia> normalizer(T"X")
 + _
-+ X
source
QuantumClifford.pauligroupMethod

Return the full Pauli group of a given length. Phases are ignored by default, but can be included by setting phases=true.

julia> pauligroup(1)
++ X
source
QuantumClifford.pauligroupMethod

Return the full Pauli group of a given length. Phases are ignored by default, but can be included by setting phases=true.

julia> pauligroup(1)
 + _
 + X
 + Z
@@ -451,32 +451,32 @@
 -i_
 -iX
 -iZ
--iY
source
QuantumClifford.pfmeasurementsMethod
pfmeasurements(frame::PauliFrame) -> Any
-

Returns the measurement results for each frame in the PauliFrame instance.

Relative measurements

The return measurements are relative to the reference measurements, i.e. they only say whether the reference measurements have been flipped in the given frame.

source
QuantumClifford.pfmeasurementsMethod
pfmeasurements(register::Register, frame::PauliFrame) -> Any
-

Takes the references measurements from the given Register and applies the flips as prescribed by the PauliFrame relative measurements. The result is the actual (non-relative) measurement results for each frame.

source
QuantumClifford.pfmeasurementsMethod
pfmeasurements(frame::PauliFrame) -> Any
+

Returns the measurement results for each frame in the PauliFrame instance.

Relative measurements

The return measurements are relative to the reference measurements, i.e. they only say whether the reference measurements have been flipped in the given frame.

source
QuantumClifford.pfmeasurementsMethod
pfmeasurements(register::Register, frame::PauliFrame) -> Any
+

Takes the references measurements from the given Register and applies the flips as prescribed by the PauliFrame relative measurements. The result is the actual (non-relative) measurement results for each frame.

source
QuantumClifford.pftrajectoriesMethod
pftrajectories(
     circuit;
     trajectories,
     threads
 ) -> PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}, Matrix{Bool}}
-

The main method for running Pauli frame simulations of circuits. See the other methods for lower level access.

Multithreading is enabled by default, but can be disabled by setting threads=false. Do not forget to launch Julia with multiple threads enabled, e.g. julia -t4, if you want to use multithreading.

See also: mctrajectories, petrajectories

source
QuantumClifford.pftrajectoriesMethod
pftrajectories(
+

The main method for running Pauli frame simulations of circuits. See the other methods for lower level access.

Multithreading is enabled by default, but can be disabled by setting threads=false. Do not forget to launch Julia with multiple threads enabled, e.g. julia -t4, if you want to use multithreading.

See also: mctrajectories, petrajectories

source
QuantumClifford.pftrajectoriesMethod
pftrajectories(
     register::Register,
     circuit;
     trajectories
 ) -> Tuple{Register, PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}, Matrix{Bool}}}
-

For a given Register and circuit, simulates the reference circuit acting on the register and then also simulate numerous PauliFrame trajectories. Returns the register and the PauliFrame instance.

Use pfmeasurements to get the measurement results.

source
QuantumClifford.phasesMethod

The phases of a given tableau. It is a view, i.e. if you modify this array, the original tableau caries these changes.

source
QuantumClifford.prodphaseMethod

Get the phase of the product of two Pauli operators.

Phase is encoded as F(4) in the low qubits of an UInt8.

julia> P"ZZZ"*P"XXX"
+

For a given Register and circuit, simulates the reference circuit acting on the register and then also simulate numerous PauliFrame trajectories. Returns the register and the PauliFrame instance.

Use pfmeasurements to get the measurement results.

source
QuantumClifford.phasesMethod

The phases of a given tableau. It is a view, i.e. if you modify this array, the original tableau caries these changes.

source
QuantumClifford.prodphaseMethod

Get the phase of the product of two Pauli operators.

Phase is encoded as F(4) in the low qubits of an UInt8.

julia> P"ZZZ"*P"XXX"
 -iYYY
 
 julia> prodphase(P"ZZZ", P"XXX")
 0x03
 
 julia> prodphase(P"XXX", P"ZZZ")
-0x01
source
QuantumClifford.random_brickwork_clifford_circuitMethod

Random brickwork Clifford circuit.

The connectivity of the random circuit is brickwork in some dimensions. Each gate in the circuit is a random 2-qubit Clifford gate.

The brickwork is defined as follows: The qubits are arranged as a lattice, and lattice_size contains side length in each dimension. For example, a chain of length five will have lattice_size = (5,), and a 5×5 lattice will have lattice_size = (5, 5).

In multi-dimensional cases, gate layers act alternatively along each direction. The nearest two layers along the same direction are offset by one qubit, forming a so-called brickwork. The boundary condition is chosen as open.

source
QuantumClifford.random_pauliFunction

A random Pauli operator on n qubits.

Use nophase=false to randomize the phase. Use realphase=false to get operators with phases including ±i.

Optionally, a "flip" probability p can be provided specified, in which case each bit is set to I with probability 1-p and to X or Y or Z with probability p. Useful for simulating unbiased Pauli noise.

See also random_pauli!

source
QuantumClifford.stabilizerplotFunction

A Makie.jl recipe for pictorial representation of a tableau.

Requires a Makie.jl backend to be loaded, e.g. using CairoMakie.

Alternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S"XXX ZZZ").

Consult the documentation for more details on visualization options.

source
QuantumClifford.stabilizerplot_axisFunction

A Makie.jl recipe for pictorial representation of a tableau.

Requires a Makie.jl backend to be loaded, e.g. using CairoMakie.

Alternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S"XXX ZZZ").

Consult the documentation for more details on visualization options.

source
QuantumClifford.random_brickwork_clifford_circuitMethod

Random brickwork Clifford circuit.

The connectivity of the random circuit is brickwork in some dimensions. Each gate in the circuit is a random 2-qubit Clifford gate.

The brickwork is defined as follows: The qubits are arranged as a lattice, and lattice_size contains side length in each dimension. For example, a chain of length five will have lattice_size = (5,), and a 5×5 lattice will have lattice_size = (5, 5).

In multi-dimensional cases, gate layers act alternatively along each direction. The nearest two layers along the same direction are offset by one qubit, forming a so-called brickwork. The boundary condition is chosen as open.

source
QuantumClifford.random_pauliFunction

A random Pauli operator on n qubits.

Use nophase=false to randomize the phase. Use realphase=false to get operators with phases including ±i.

Optionally, a "flip" probability p can be provided specified, in which case each bit is set to I with probability 1-p and to X or Y or Z with probability p. Useful for simulating unbiased Pauli noise.

See also random_pauli!

source
QuantumClifford.stabilizerplotFunction

A Makie.jl recipe for pictorial representation of a tableau.

Requires a Makie.jl backend to be loaded, e.g. using CairoMakie.

Alternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S"XXX ZZZ").

Consult the documentation for more details on visualization options.

source
QuantumClifford.stabilizerplot_axisFunction

A Makie.jl recipe for pictorial representation of a tableau.

Requires a Makie.jl backend to be loaded, e.g. using CairoMakie.

Alternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S"XXX ZZZ").

Consult the documentation for more details on visualization options.

source
QuantumClifford.xbitMethod

Extract as a new bit array the X part of the UInt array of packed qubits of a given Pauli operator.

source
QuantumClifford.zbitMethod

Extract as a new bit array the Z part of the UInt array of packed qubits of a given Pauli operator.

source
QuantumInterface.apply!Function

In QuantumClifford the apply! function is used to apply any quantum operation to a stabilizer state, including unitary Clifford operations, Pauli measurements, and noise. Thus, this function may result in a random/stochastic result (e.g. with measurements or noise).

source
QuantumClifford.xbitMethod

Extract as a new bit array the X part of the UInt array of packed qubits of a given Pauli operator.

source
QuantumClifford.zbitMethod

Extract as a new bit array the Z part of the UInt array of packed qubits of a given Pauli operator.

source
QuantumInterface.apply!Function

In QuantumClifford the apply! function is used to apply any quantum operation to a stabilizer state, including unitary Clifford operations, Pauli measurements, and noise. Thus, this function may result in a random/stochastic result (e.g. with measurements or noise).

source
QuantumInterface.embedMethod

Embed a Pauli operator in a larger Pauli operator.

julia> embed(5, 3, P"-Y")
 - __Y__
 
 julia> embed(5, (3,5), P"-YX")
-- __Y_X
source
QuantumInterface.entanglement_entropyFunction

Get bipartite entanglement entropy of a subsystem

Defined as entropy of the reduced density matrix.

It can be calculated with multiple different algorithms, the most performant one depending on the particular case.

Currently implemented are the :clip (clipped gauge), :graph (graph state), and :rref (Gaussian elimination) algorithms. Benchmark your particular case to choose the best one.

source
QuantumInterface.entanglement_entropyMethod

Get bipartite entanglement entropy by first converting the state to a graph and computing the rank of the adjacency matrix.

Based on "Entanglement in graph states and its applications".

source
QuantumInterface.expectMethod
expect(p::PauliOperator, st::AbstractStabilizer)

Compute the expectation value of a Pauli operator p on a stabilizer state st. This function will allocate a temporary copy of the stabilizer state st.

source
QuantumInterface.entanglement_entropyFunction

Get bipartite entanglement entropy of a subsystem

Defined as entropy of the reduced density matrix.

It can be calculated with multiple different algorithms, the most performant one depending on the particular case.

Currently implemented are the :clip (clipped gauge), :graph (graph state), and :rref (Gaussian elimination) algorithms. Benchmark your particular case to choose the best one.

source
QuantumInterface.entanglement_entropyMethod

Get bipartite entanglement entropy by first converting the state to a graph and computing the rank of the adjacency matrix.

Based on "Entanglement in graph states and its applications".

source
QuantumInterface.expectMethod
expect(p::PauliOperator, st::AbstractStabilizer)

Compute the expectation value of a Pauli operator p on a stabilizer state st. This function will allocate a temporary copy of the stabilizer state st.

source
QuantumInterface.project!Method
project!(
     state::MixedStabilizer,
     pauli::PauliOperator;
     phases
@@ -611,25 +611,25 @@
 julia> project!(ms, P"IIY")[1]
 + X__
 + _Z_
-+ __Y

Similarly to project! on Stabilizer, this function has cubic complexity when the Pauli operator commutes with all rows of the tableau. Most of the time it is better to simply use MixedDestabilizer representation.

Unlike other project! methods, this one does not allow for keep_result=false, as the correct rank or anticommutation index can not be calculated without the expensive (cubic) canonicalization operation required by keep_result=true.

See the "Datastructure Choice" section in the documentation for more details.

See also: projectX!, projectY!, projectZ!.

source
QuantumInterface.reset_qubits!Method
reset_qubits!(
++ __Y

Similarly to project! on Stabilizer, this function has cubic complexity when the Pauli operator commutes with all rows of the tableau. Most of the time it is better to simply use MixedDestabilizer representation.

Unlike other project! methods, this one does not allow for keep_result=false, as the correct rank or anticommutation index can not be calculated without the expensive (cubic) canonicalization operation required by keep_result=true.

See the "Datastructure Choice" section in the documentation for more details.

See also: projectX!, projectY!, projectZ!.

source
QuantumInterface.reset_qubits!Method
reset_qubits!(
     s::Stabilizer,
     newstate,
     qubits;
     phases
-) -> Any
-

Reset a given set of qubits to be in the state newstate. These qubits are traced out first, which could lead to "nonlocal" changes in the tableau.

source
QuantumInterface.tensorFunction

Tensor product between operators or tableaux.

Tensor product between CiffordOperators:

julia> tensor(CliffordOperator(sCNOT), CliffordOperator(sCNOT))
+) -> Union{PauliOperator, Stabilizer}
+

Reset a given set of qubits to be in the state newstate. These qubits are traced out first, which could lead to "nonlocal" changes in the tableau.

source
QuantumInterface.tensorFunction

Tensor product between operators or tableaux.

Tensor product between CiffordOperators:

julia> tensor(CliffordOperator(sCNOT), CliffordOperator(sCNOT))
 X₁ ⟼ + XX__
 X₂ ⟼ + _X__
 X₃ ⟼ + __XX
@@ -656,7 +656,7 @@
 + XZ____
 - _Z____
 + ___XZ_
-- ____Z_

See also tensor_pow.

source
QuantumInterface.tensor_powMethod

Repeated tensor product of an operators or a tableau.

For CliffordOperator:

julia> tensor_pow(CliffordOperator(sHadamard), 3)
 X₁ ⟼ + Z__
 X₂ ⟼ + _Z_
 X₃ ⟼ + __Z
@@ -678,16 +678,21 @@
 + ___XZ____
 + ____Z____
 + ______XZ_
-+ _______Z_

See also tensor.

source

Private API

Private Implementation Details

These functions are used internally by the library and might be drastically modified or deleted without warning or deprecation.

QuantumClifford.TableauType

Internal Tableau type for storing a list of Pauli operators in a compact form. No special semantic meaning is attached to this type, it is just a convenient way to store a list of Pauli operators. E.g. it is not used to represent a stabilizer state, or a stabilizer group, or a Clifford circuit.

source
Base.hcatMethod

Horizontally concatenates tableaux.

julia> hcat(ghz(2), ghz(2))
+) -> Union{Tuple{Union{MixedDestabilizer, MixedStabilizer}, Any}, MixedDestabilizer, MixedStabilizer}
+
source

Private API

Private Implementation Details

These functions are used internally by the library and might be drastically modified or deleted without warning or deprecation.

QuantumClifford.TableauType

Internal Tableau type for storing a list of Pauli operators in a compact form. No special semantic meaning is attached to this type, it is just a convenient way to store a list of Pauli operators. E.g. it is not used to represent a stabilizer state, or a stabilizer group, or a Clifford circuit.

source
Base.hcatMethod

Horizontally concatenates tableaux.

julia> hcat(ghz(2), ghz(2))
 + XXXX
-+ ZZZZ

See also: vcat

source
Base.invMethod
inv(
     c::CliffordOperator;
     phases
 ) -> CliffordOperator{QuantumClifford.Tableau{Vector{UInt8}, Matrix{UInt64}}}
@@ -705,28 +710,28 @@
 
 julia> inv(CliffordOperator(tHadamard))
 X₁ ⟼ + Z
-Z₁ ⟼ + X
source
Base.vcatMethod

Vertically concatenates tableaux.

julia> vcat(ghz(2), ghz(2))
+Z₁ ⟼ + X
source
Base.vcatMethod

Vertically concatenates tableaux.

julia> vcat(ghz(2), ghz(2))
 + XX
 + ZZ
 + XX
-+ ZZ

See also: hcat

source
QuantumClifford._remove_rowcol!Method

Unexported low-level function that removes a row (by shifting all rows up as necessary)

Because MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.

Used on its own, this function will break invariants. Meant to be used with projectremove!.

source
QuantumClifford._rowmove!Method

Unexported low-level function that moves row i to row j.

Used on its own, this function will break invariants. Meant to be used in _remove_rowcol!.

source
QuantumClifford.applynoise_branchesFunction

Compute all possible new states after the application of the given noise model. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Noise interface.

source
QuantumClifford.initZ!Method
initZ!(frame::PauliFrame) -> PauliFrame
-

Inject random Z errors over all frames and qubits for the supplied PauliFrame with probability 0.5.

Calling this after initialization is essential for simulating any non-deterministic circuit. It is done automatically by most PauliFrame constructors.

source
QuantumClifford._remove_rowcol!Method

Unexported low-level function that removes a row (by shifting all rows up as necessary)

Because MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.

Used on its own, this function will break invariants. Meant to be used with projectremove!.

source
QuantumClifford._rowmove!Method

Unexported low-level function that moves row i to row j.

Used on its own, this function will break invariants. Meant to be used in _remove_rowcol!.

source
QuantumClifford.applynoise_branchesFunction

Compute all possible new states after the application of the given noise model. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Noise interface.

source
QuantumClifford.initZ!Method
initZ!(frame::PauliFrame) -> PauliFrame
+

Inject random Z errors over all frames and qubits for the supplied PauliFrame with probability 0.5.

Calling this after initialization is essential for simulating any non-deterministic circuit. It is done automatically by most PauliFrame constructors.

source
QuantumClifford.make_sumtype_methodFunction

``` julia> makesumtypemethod([sCNOT], :apply!, (:s,)) quote function QuantumClifford.apply!(s, g::CompactifiedGate) @cases g begin sCNOT(q1, q2) => apply!(s, sCNOT(q1, q2)) end end end

source
QuantumClifford.make_sumtype_methodFunction

``` julia> makesumtypemethod([sCNOT], :apply!, (:s,)) quote function QuantumClifford.apply!(s, g::CompactifiedGate) @cases g begin sCNOT(q1, q2) => apply!(s, sCNOT(q1, q2)) end end end

source
QuantumClifford.projectremoverand!Method

Unexported low-level function that projects a qubit and returns the result while making the tableau smaller by a qubit.

Because MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.

source
QuantumClifford.remove_column!Method

Unexported low-level function that removes a column (by shifting all columns to the right of the target by one step to the left)

Because Tableau is not mutable we return a new Tableau with the same (modified) xzs array.

source
QuantumClifford.rowdecomposeMethod

Decompose a Pauli $P$ in terms of stabilizer and destabilizer rows from a given tableaux.

For given tableaux of rows destabilizer rows $\{d_i\}$ and stabilizer rows $\{s_i\}$, there are boolean vectors $b$ and $c$ such that $P = i^p \prod_i d_i^{b_i} \prod_i s_i^{c_i}$.

This function returns p, b, c.

julia> s = MixedDestabilizer(ghz(2))
+end)
source
QuantumClifford.projectremoverand!Method

Unexported low-level function that projects a qubit and returns the result while making the tableau smaller by a qubit.

Because MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.

source
QuantumClifford.remove_column!Method

Unexported low-level function that removes a column (by shifting all columns to the right of the target by one step to the left)

Because Tableau is not mutable we return a new Tableau with the same (modified) xzs array.

source
QuantumClifford.rowdecomposeMethod

Decompose a Pauli $P$ in terms of stabilizer and destabilizer rows from a given tableaux.

For given tableaux of rows destabilizer rows $\{d_i\}$ and stabilizer rows $\{s_i\}$, there are boolean vectors $b$ and $c$ such that $P = i^p \prod_i d_i^{b_i} \prod_i s_i^{c_i}$.

This function returns p, b, c.

julia> s = MixedDestabilizer(ghz(2))
 𝒟ℯ𝓈𝓉𝒶𝒷
 + Z_
 + _X
@@ -738,7 +743,7 @@
 (3, Bool[1, 0], Bool[1, 1])
 
 julia> im^3 * P"Z_" * P"XX" * P"ZZ"
-+ XY
source
QuantumClifford.to_cpuFunction

copies the memory content of the object to CPU

You can only use this function if CUDA.jl is imported

For more advanced users to_cpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your CPU architecture, if working with matrices of UInt32 is faster than UInt64, you can use to_cpu(data, UInt32)

julia> using QuantumClifford: to_cpu, to_gpu
++ XY
source
QuantumClifford.to_cpuFunction

copies the memory content of the object to CPU

You can only use this function if CUDA.jl is imported

For more advanced users to_cpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your CPU architecture, if working with matrices of UInt32 is faster than UInt64, you can use to_cpu(data, UInt32)

julia> using QuantumClifford: to_cpu, to_gpu
 
 julia> using CUDA # without this import, to_cpu, to_gpu are just function
 
@@ -761,7 +766,7 @@
 julia> pf_gpu = to_gpu(PauliFrame(1000, 2, 2));
 julia> circuit = [sMZ(1, 1), sHadamard(2), sMZ(2, 2)];
 julia> pftrajectories(pf_gpu, circuit);
-julia> measurements = to_cpu(pf_gpu.measurements);

See also: to_gpu

source
QuantumClifford.to_gpuFunction

copies the memory content of the object to GPU

You can only use this function if CUDA.jl is imported

For more advanced users to_gpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your GPU architecture, if working with matrices of UInt64 is faster than UInt32, you can use to_gpu(data, UInt64)

julia> using QuantumClifford: to_cpu, to_gpu
+julia> measurements = to_cpu(pf_gpu.measurements);

See also: to_gpu

source
QuantumClifford.to_gpuFunction

copies the memory content of the object to GPU

You can only use this function if CUDA.jl is imported

For more advanced users to_gpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your GPU architecture, if working with matrices of UInt64 is faster than UInt32, you can use to_gpu(data, UInt64)

julia> using QuantumClifford: to_cpu, to_gpu
 
 julia> using CUDA # without this import, to_cpu, to_gpu are just function
 
@@ -784,4 +789,4 @@
 julia> pf_gpu = to_gpu(PauliFrame(1000, 2, 2));
 julia> circuit = [sMZ(1, 1), sHadamard(2), sMZ(2, 2)];
 julia> pftrajectories(pf_gpu, circuit);
-julia> measurements = to_cpu(pf_gpu.measurements);

See also: to_cpu

source
+julia> measurements = to_cpu(pf_gpu.measurements);

See also: to_cpu

source
QuantumClifford.trusted_rankFunction

A "trusted" rank which returns rank(state) for Mixed[De]Stabilizer and length(state) for [De]Stabilizer.

source
QuantumClifford.zero!Method

Zero-out a given row of a Tableau

source
QuantumClifford.zero!Method

Zero-out the phases and single-qubit operators in a PauliOperator

source
QuantumClifford.@qubitop1Macro

Macro used to define single qubit symbolic gates and their qubit_kernel methods.

source
QuantumClifford.@qubitop2Macro

Macro used to define 2-qubit symbolic gates and their qubit_kernel methods.

source
QuantumClifford.@valbooldispatchMacro

Turns f(Val(x)) into x ? f(Val(true)) : f(Val(false)) in order to avoid dynamic dispatch

See discourse discussion

source
diff --git a/dev/ECC_API/index.html b/dev/ECC_API/index.html index 5f10f16c4..b4a084d06 100644 --- a/dev/ECC_API/index.html +++ b/dev/ECC_API/index.html @@ -2,7 +2,7 @@ API · QuantumClifford.jl

Full ECC API (autogenerated)

QuantumClifford.ECC.CSSType

An arbitrary CSS error correcting code defined by its X and Z checks.

julia> CSS([0 1 1 0; 1 1 0 0], [1 1 1 1]) |> parity_checks
 + _XX_
 + XX__
-+ ZZZZ
source
QuantumClifford.ECC.ConcatType

Concat(c₁, c₂) is a code concatenation of two quantum codes (Knill and Laflamme, 1996).

The inner code c₁ and the outer code c₂. The construction is the following: replace each qubit in code c₂ with logical qubits encoded by code c₁. The resulting code will have n = n₁ × n₂ qubits and k = k₁ × k₂ logical qubits.

source
QuantumClifford.ECC.QuantumReedMullerType

The family of [[2ᵐ - 1, 1, 3]] CSS Quantum-Reed-Muller codes, as discovered by Steane in his 1999 paper (Steane, 1999).

Quantum codes are constructed from shortened Reed-Muller codes RM(1, m), by removing the first row and column of the generator matrix Gₘ. Similarly, we can define truncated dual codes RM(m - 2, m) using the generator matrix Hₘ (Anderson et al., 2014). The quantum Reed-Muller codes QRM(m) derived from RM(1, m) are CSS codes.

Given that the stabilizers of the quantum code are defined through the generator matrix of the classical code, the minimum distance of the quantum code corresponds to the minimum distance of the dual classical code, which is d = 3, thus it can correct any single qubit error. Since one stabilizer from the original and one from the dual code are removed in the truncation process, the code parameters are [[2ᵐ - 1, 1, 3]].

You might be interested in consulting (Anderson et al., 2014) and (Campbell et al., 2012) as well.

The ECC Zoo has an entry for this family.

source
QuantumClifford.ECC.ShorSyndromeECCSetupType

Configuration for ECC evaluators that simulate the Shor-style syndrome measurement (without a flag qubit).

The simulated circuit includes:

  • perfect noiseless encoding (encoding and its fault tolerance are not being studied here)
  • one round of "memory noise" after the encoding but before the syndrome measurement
  • perfect preparation of entangled ancillary qubits
  • noisy Shor-style syndrome measurement (only two-qubit gate noise)
  • noiseless "logical state measurement" (providing the comparison data when evaluating the decoder)

See also: CommutationCheckECCSetup, NaiveSyndromeECCSetup

source
QuantumClifford.ECC.SurfaceType

The planar surface code refers to the code (Kitaev, 2003) in a 2D lattice with open boundaries.

Illustration of a 3×2 surface code, where qubits are located on the edges:

|---1--(Z)--2---|---3---|
++ ZZZZ
source
QuantumClifford.ECC.ConcatType

Concat(c₁, c₂) is a code concatenation of two quantum codes (Knill and Laflamme, 1996).

The inner code c₁ and the outer code c₂. The construction is the following: replace each qubit in code c₂ with logical qubits encoded by code c₁. The resulting code will have n = n₁ × n₂ qubits and k = k₁ × k₂ logical qubits.

source
QuantumClifford.ECC.QuantumReedMullerType

The family of [[2ᵐ - 1, 1, 3]] CSS Quantum-Reed-Muller codes, as discovered by Steane in his 1999 paper (Steane, 1999).

Quantum codes are constructed from shortened Reed-Muller codes RM(1, m), by removing the first row and column of the generator matrix Gₘ. Similarly, we can define truncated dual codes RM(m - 2, m) using the generator matrix Hₘ (Anderson et al., 2014). The quantum Reed-Muller codes QRM(m) derived from RM(1, m) are CSS codes.

Given that the stabilizers of the quantum code are defined through the generator matrix of the classical code, the minimum distance of the quantum code corresponds to the minimum distance of the dual classical code, which is d = 3, thus it can correct any single qubit error. Since one stabilizer from the original and one from the dual code are removed in the truncation process, the code parameters are [[2ᵐ - 1, 1, 3]].

You might be interested in consulting (Anderson et al., 2014) and (Campbell et al., 2012) as well.

The ECC Zoo has an entry for this family.

source
QuantumClifford.ECC.ShorSyndromeECCSetupType

Configuration for ECC evaluators that simulate the Shor-style syndrome measurement (without a flag qubit).

The simulated circuit includes:

  • perfect noiseless encoding (encoding and its fault tolerance are not being studied here)
  • one round of "memory noise" after the encoding but before the syndrome measurement
  • perfect preparation of entangled ancillary qubits
  • noisy Shor-style syndrome measurement (only two-qubit gate noise)
  • noiseless "logical state measurement" (providing the comparison data when evaluating the decoder)

See also: CommutationCheckECCSetup, NaiveSyndromeECCSetup

source
QuantumClifford.ECC.SurfaceType

The planar surface code refers to the code (Kitaev, 2003) in a 2D lattice with open boundaries.

Illustration of a 3×2 surface code, where qubits are located on the edges:

|---1--(Z)--2---|---3---|
 |  (X)  7       8       o
 |---4---|---5---|---6---|
 |       o       o       o
@@ -13,7 +13,7 @@
 + ZZ____Z_
 + _ZZ____Z
 + ___ZZ_Z_
-+ ____ZZ_Z

More information can be seen in (Fowler et al., 2012).

source
QuantumClifford.ECC.TableDecoderType

A simple look-up table decoder for error correcting codes.

The lookup table contains only weight=1 errors, thus it is small, but at best it provides only for distance=3 decoding.

The size of the lookup table would grow exponentially quickly for higher distances.

source
QuantumClifford.ECC.TableDecoderType

A simple look-up table decoder for error correcting codes.

The lookup table contains only weight=1 errors, thus it is small, but at best it provides only for distance=3 decoding.

The size of the lookup table would grow exponentially quickly for higher distances.

source
QuantumClifford.ECC.ToricType

The Toric code (Kitaev, 2003).

Illustration of a 2x2 toric code, where qubits are located on the edges:

|--1-(Z)-2--|
 | (X) 5     6
 |--3--|--4--|
 |     7     8
@@ -23,7 +23,7 @@
 + X_X___XX
 + ZZ__Z_Z_
 + ZZ___Z_Z
-+ __ZZZ_Z_
source
QuantumClifford.ECC.code_kMethod

The number of logical qubits in a code.

Note that when redundant rows exist in the parity check matrix, the number of logical qubits code_k(c) will be greater than code_n(c) - code_s(c), where the difference equals the redundancy.

source
QuantumClifford.ECC.code_sFunction

The number of stabilizer checks in a code. They might not be all linearly independent, thus code_s >= code_n-code_k. For the number of linearly independent checks you can use LinearAlgebra.rank.

source
QuantumClifford.ECC.evaluate_decoderMethod

Evaluate the performance of an error-correcting circuit.

This method requires you give the circuit that performs both syndrome measurements and (probably noiseless) logical state measurements. The faults matrix that translates an error vector into corresponding logical errors is necessary as well.

This is a relatively barebones method that assumes the user prepares necessary circuits, etc. It is a method that is used internally by more user-frienly methods providing automatic conversion of codes and noise models to the necessary noisy circuits.

source
QuantumClifford.ECC.faults_matrixMethod

Error-to-logical-observable map (a.k.a. fault matrix) of a code.

For a code with n physical qubits and k logical qubits this function returns a 2k × 2n binary matrix O such that O[i,j] is true if the logical observable of index i is flipped by the single physical qubit error of index j. Indexing is such that:

  • O[1:k,:] is the error-to-logical-X-observable map (logical X observable, i.e. triggered by logical Z errors)
  • O[k+1:2k,:] is the error-to-logical-Z-observable map
  • O[:,1:n] is the X-physical-error-to-logical-observable map
  • O[n+1:2n,:] is the Z-physical-error-to-logical-observable map

E.g. for k=1, n=10, then if O[2,5] is true, then the logical Z observable is flipped by a X₅ error; and if O[1,12] is true, then the logical X observable is flipped by a Z₂ error.

Of note is that there is a lot of freedom in choosing the logical operations! A logical operator multiplied by a stabilizer operator is still a logical operator. Similarly there is a different fault matrix for each choice of logical operators. But once the logical operators are picked, the fault matrix is fixed.

Below we show an example that uses the Shor code. While it is not the smallest code, it is a convenient choice to showcase the importance of the fault matrix when dealing with degenerate codes where a correction operation and an error do not need to be the same.

First, consider a single-qubit error, potential correction operations, and their effect on the Shor code:

julia> using QuantumClifford.ECC: faults_matrix, Shor9
++ __ZZZ_Z_
source
QuantumClifford.ECC.code_kMethod

The number of logical qubits in a code.

Note that when redundant rows exist in the parity check matrix, the number of logical qubits code_k(c) will be greater than code_n(c) - code_s(c), where the difference equals the redundancy.

source
QuantumClifford.ECC.code_sFunction

The number of stabilizer checks in a code. They might not be all linearly independent, thus code_s >= code_n-code_k. For the number of linearly independent checks you can use LinearAlgebra.rank.

source
QuantumClifford.ECC.evaluate_decoderMethod

Evaluate the performance of an error-correcting circuit.

This method requires you give the circuit that performs both syndrome measurements and (probably noiseless) logical state measurements. The faults matrix that translates an error vector into corresponding logical errors is necessary as well.

This is a relatively barebones method that assumes the user prepares necessary circuits, etc. It is a method that is used internally by more user-frienly methods providing automatic conversion of codes and noise models to the necessary noisy circuits.

source
QuantumClifford.ECC.faults_matrixMethod

Error-to-logical-observable map (a.k.a. fault matrix) of a code.

For a code with n physical qubits and k logical qubits this function returns a 2k × 2n binary matrix O such that O[i,j] is true if the logical observable of index i is flipped by the single physical qubit error of index j. Indexing is such that:

  • O[1:k,:] is the error-to-logical-X-observable map (logical X observable, i.e. triggered by logical Z errors)
  • O[k+1:2k,:] is the error-to-logical-Z-observable map
  • O[:,1:n] is the X-physical-error-to-logical-observable map
  • O[n+1:2n,:] is the Z-physical-error-to-logical-observable map

E.g. for k=1, n=10, then if O[2,5] is true, then the logical Z observable is flipped by a X₅ error; and if O[1,12] is true, then the logical X observable is flipped by a Z₂ error.

Of note is that there is a lot of freedom in choosing the logical operations! A logical operator multiplied by a stabilizer operator is still a logical operator. Similarly there is a different fault matrix for each choice of logical operators. But once the logical operators are picked, the fault matrix is fixed.

Below we show an example that uses the Shor code. While it is not the smallest code, it is a convenient choice to showcase the importance of the fault matrix when dealing with degenerate codes where a correction operation and an error do not need to be the same.

First, consider a single-qubit error, potential correction operations, and their effect on the Shor code:

julia> using QuantumClifford.ECC: faults_matrix, Shor9
 
 julia> state = MixedDestabilizer(Shor9())
 𝒟ℯ𝓈𝓉𝒶𝒷━━━━━
@@ -146,7 +146,7 @@
 julia> O * stab_to_gf2(bad_Z₆Z₉)
 2-element Vector{Int64}:
  1
- 0

While its use in this situation is rather contrived, the fault matrix is incredibly useful when running large scale simulations in which we want a separate fast error sampling process, (e.g. with Pauli frames) and a syndrome decoding process, without coupling between them. We just gather all our syndrome measurement and logical observables from the Pauli frame simulations, and then use them with the fault matrix in the syndrome decoding simulation.

source
QuantumClifford.ECC.isdegenerateFunction

Check if the code is degenerate with respect to a given set of error or with respect to all "up to d physical-qubit" errors (defaulting to d=1).

julia> using QuantumClifford.ECC
+ 0

While its use in this situation is rather contrived, the fault matrix is incredibly useful when running large scale simulations in which we want a separate fast error sampling process, (e.g. with Pauli frames) and a syndrome decoding process, without coupling between them. We just gather all our syndrome measurement and logical observables from the Pauli frame simulations, and then use them with the fault matrix in the syndrome decoding simulation.

source
QuantumClifford.ECC.isdegenerateFunction

Check if the code is degenerate with respect to a given set of error or with respect to all "up to d physical-qubit" errors (defaulting to d=1).

julia> using QuantumClifford.ECC
 
 julia> isdegenerate(Shor9(), [single_z(9,1), single_z(9,2)])
 true
@@ -158,7 +158,7 @@
 false
 
 julia> isdegenerate(Steane7(), 2)
-true
source
QuantumClifford.ECC.naive_encoding_circuitMethod

Encoding physical qubits into a larger logical code.

The initial physical qubits to be encoded have to be at indices n-k+1:n.

Encoding circuits are not fault-tolerant

Encoding circuits are not fault-tolerant, and thus should not be used in practice. Instead, you should measure the stabilizers of the code and the logical observables, thus projecting into the code space (which can be fault-tolerant).

The canonicalization operation performed on the code may permute the qubits (see canonicalize_gott!). That permutation is corrected for with SWAP gates by default (controlled by the undoperm keyword argument).

Based on (Cleve and Gottesman, 1997) and (Gottesman, 1997), however it seems the published algorithm has some errors. Consult the erratum, as well as the more recent (Grassl, 2002) and (Grassl, 2011), and be aware that this implementation also uses H instead of Z gates.

source
QuantumClifford.ECC.naive_syndrome_circuitFunction

Generate the non-fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.

Use the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts.

Returns the circuit, the number of ancillary qubits that were added, and a list of bit indices that will store the measurement results.

See also: shor_syndrome_circuit

source
QuantumClifford.ECC.shor_syndrome_circuitFunction

Generate the Shor fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.

Use the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts. Ancillary qubits

Returns:

  • 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.

See also: naive_syndrome_circuit

source

Implemented in an extension requiring Hecke.jl

QuantumCliffordHeckeExt.LPCodeType
struct LPCode <: QuantumClifford.ECC.AbstractECC

Lifted product codes ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))

A lifted product code is defined by the hypergraph product of a base matrices A and the conjugate of another base matrix B'. Here, the hypergraph product is taken over a group algebra, of which the base matrices are consisting.

The binary parity check matrix is obtained by applying repr to each element of the matrix resulted from the hypergraph product, which is mathematically a linear map from each group algebra element to a binary matrix.

Constructors

Multiple constructors are available:

  1. Two base matrices of group algebra elements.

  2. Two lifted codes, whose base matrices are for quantum code construction.

  3. Two base matrices of group elements, where each group element will be considered as a group algebra element by assigning a unit coefficient.

  4. Two base matrices of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.

Examples

A [[882, 24, d ≤ 24]] code from Appendix B of (Roffe et al., 2023). We use the 1st constructor to generate the code and check its length and dimension. During the construction, we do arithmetic operations to get the group algebra elements in base matrices A and B. Here x is the generator of the group algebra, i.e., offset-1 cyclic permutation, and GA(1) is the unit element.

julia> import Hecke: group_algebra, GF, abelian_group, gens; import LinearAlgebra: diagind;
+true
source
QuantumClifford.ECC.naive_encoding_circuitMethod

Encoding physical qubits into a larger logical code.

The initial physical qubits to be encoded have to be at indices n-k+1:n.

Encoding circuits are not fault-tolerant

Encoding circuits are not fault-tolerant, and thus should not be used in practice. Instead, you should measure the stabilizers of the code and the logical observables, thus projecting into the code space (which can be fault-tolerant).

The canonicalization operation performed on the code may permute the qubits (see canonicalize_gott!). That permutation is corrected for with SWAP gates by default (controlled by the undoperm keyword argument).

Based on (Cleve and Gottesman, 1997) and (Gottesman, 1997), however it seems the published algorithm has some errors. Consult the erratum, as well as the more recent (Grassl, 2002) and (Grassl, 2011), and be aware that this implementation also uses H instead of Z gates.

source
QuantumClifford.ECC.naive_syndrome_circuitFunction

Generate the non-fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.

Use the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts.

Returns the circuit, the number of ancillary qubits that were added, and a list of bit indices that will store the measurement results.

See also: shor_syndrome_circuit

source
QuantumClifford.ECC.shor_syndrome_circuitFunction

Generate the Shor fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.

Use the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts. Ancillary qubits

Returns:

  • 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.

See also: naive_syndrome_circuit

source

Implemented in an extension requiring Hecke.jl

QuantumCliffordHeckeExt.LPCodeType
struct LPCode <: QuantumClifford.ECC.AbstractECC

Lifted product codes ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))

A lifted product code is defined by the hypergraph product of a base matrices A and the conjugate of another base matrix B'. Here, the hypergraph product is taken over a group algebra, of which the base matrices are consisting.

The binary parity check matrix is obtained by applying repr to each element of the matrix resulted from the hypergraph product, which is mathematically a linear map from each group algebra element to a binary matrix.

Constructors

Multiple constructors are available:

  1. Two base matrices of group algebra elements.

  2. Two lifted codes, whose base matrices are for quantum code construction.

  3. Two base matrices of group elements, where each group element will be considered as a group algebra element by assigning a unit coefficient.

  4. Two base matrices of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.

Examples

A [[882, 24, d ≤ 24]] code from Appendix B of (Roffe et al., 2023). We use the 1st constructor to generate the code and check its length and dimension. During the construction, we do arithmetic operations to get the group algebra elements in base matrices A and B. Here x is the generator of the group algebra, i.e., offset-1 cyclic permutation, and GA(1) is the unit element.

julia> import Hecke: group_algebra, GF, abelian_group, gens; import LinearAlgebra: diagind;
 
 julia> l = 63; GA = group_algebra(GF(2), abelian_group(l)); x = gens(GA)[];
 
@@ -184,7 +184,7 @@
 julia> c2 = LPCode(base_matrix, l .- base_matrix', l);
 
 julia> code_n(c2), code_k(c2)
-(175, 19)

Code subfamilies and convenience constructors for them

  • When the base matrices of the LPCode are 1×1, the code is called a two-block group-algebra code two_block_group_algebra_codes.
  • When the base matrices of the LPCode are 1×1 and their elements are sums of cyclic permutations, the code is called a generalized bicycle code generalized_bicycle_codes.
  • When the two matrices are adjoint to each other, the code is called a bicycle code bicycle_codes.

The representation function

We use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.

We also accept a custom representation function as detailed in LiftedCode.

See also: LiftedCode, two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes.

  • A::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the first base matrix of the code, whose elements are in a group algebra.

  • B::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the second base matrix of the code, whose elements are in the same group algebra as A.

  • GA::Hecke.GroupAlgebra: the group algebra for which elements in A and B are from.

  • repr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.

source
QuantumCliffordHeckeExt.LiftedCodeType
struct LiftedCode <: QuantumClifford.ECC.ClassicalCode

Classical codes lifted over a group algebra, used for lifted product code construction ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))

The parity-check matrix is constructed by applying repr to each element of A, which is mathematically a linear map from a group algebra element to a binary matrix. The size of the parity check matrix will enlarged with each element of A being inflated into a matrix. The procedure is called a lift (Panteleev and Kalachev, Jun 2022).

Constructors

A lifted code can be constructed via the following approaches:

  1. A matrix of group algebra elements.

  2. A matrix of group elements, where a group element will be considered as a group algebra element by assigning a unit coefficient.

  3. A matrix of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.

The default GA is the group algebra of A[1, 1], the default representation repr is the permutation representation.

The representation function repr

We use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.

We also accept a custom representation function (the repr field of the constructor). Whatever the representation, the matrix elements need to be convertible to Integers (e.g. permit lift(ZZ, ...)). Such a customization would be useful to reduce the number of bits required by the code construction.

For example, if we use a D4 group for lifting, our default representation will be 8×8 permutation matrices, where 8 is the group's order. However, we can find a 4×4 matrix representation for the group, e.g. by using the typical 2×2 representation and converting it into binary representation by replacing "1" with the Pauli I, and "-1" with the Pauli X matrix.

See also: LPCode.

  • A::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the base matrix of the code, whose elements are in a group algebra.

  • GA::Hecke.GroupAlgebra: the group algebra for which elements in A are from.

  • repr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.

source
QuantumCliffordHeckeExt.LiftedCodeMethod

LiftedCode constructor using the default GF(2) representation (coefficients converted to a permutation matrix by representation_matrix provided by Hecke).

source
Base.adjointMethod

Compute the adjoint of a group algebra element. The adjoint is defined as the conjugate of the element in the group algebra, i.e. the inverse of the element in the associated group.

source
QuantumClifford.ECC.generalized_bicycle_codesMethod

Generalized bicycle codes, which are a special case of 2GBA codes (and therefore of lifted product codes). Here the group is chosen as the cyclic group of order l, and the base matrices a and b are the sum of the group algebra elements corresponding to the shifts a_shifts and b_shifts.

See also: two_block_group_algebra_codes, bicycle_codes.

A [[254, 28, 14 ≤ d ≤ 20]] code from (A1) in Appendix B of (Panteleev and Kalachev, 2021).

julia> c = generalized_bicycle_codes([0, 15, 20, 28, 66], [0, 58, 59, 100, 121], 127);
+(175, 19)

Code subfamilies and convenience constructors for them

  • When the base matrices of the LPCode are 1×1, the code is called a two-block group-algebra code two_block_group_algebra_codes.
  • When the base matrices of the LPCode are 1×1 and their elements are sums of cyclic permutations, the code is called a generalized bicycle code generalized_bicycle_codes.
  • When the two matrices are adjoint to each other, the code is called a bicycle code bicycle_codes.

The representation function

We use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.

We also accept a custom representation function as detailed in LiftedCode.

See also: LiftedCode, two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes.

  • A::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the first base matrix of the code, whose elements are in a group algebra.

  • B::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the second base matrix of the code, whose elements are in the same group algebra as A.

  • GA::Hecke.GroupAlgebra: the group algebra for which elements in A and B are from.

  • repr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.

source
QuantumCliffordHeckeExt.LiftedCodeType
struct LiftedCode <: QuantumClifford.ECC.ClassicalCode

Classical codes lifted over a group algebra, used for lifted product code construction ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))

The parity-check matrix is constructed by applying repr to each element of A, which is mathematically a linear map from a group algebra element to a binary matrix. The size of the parity check matrix will enlarged with each element of A being inflated into a matrix. The procedure is called a lift (Panteleev and Kalachev, Jun 2022).

Constructors

A lifted code can be constructed via the following approaches:

  1. A matrix of group algebra elements.

  2. A matrix of group elements, where a group element will be considered as a group algebra element by assigning a unit coefficient.

  3. A matrix of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.

The default GA is the group algebra of A[1, 1], the default representation repr is the permutation representation.

The representation function repr

We use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.

We also accept a custom representation function (the repr field of the constructor). Whatever the representation, the matrix elements need to be convertible to Integers (e.g. permit lift(ZZ, ...)). Such a customization would be useful to reduce the number of bits required by the code construction.

For example, if we use a D4 group for lifting, our default representation will be 8×8 permutation matrices, where 8 is the group's order. However, we can find a 4×4 matrix representation for the group, e.g. by using the typical 2×2 representation and converting it into binary representation by replacing "1" with the Pauli I, and "-1" with the Pauli X matrix.

See also: LPCode.

  • A::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the base matrix of the code, whose elements are in a group algebra.

  • GA::Hecke.GroupAlgebra: the group algebra for which elements in A are from.

  • repr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.

source
QuantumCliffordHeckeExt.LiftedCodeMethod

LiftedCode constructor using the default GF(2) representation (coefficients converted to a permutation matrix by representation_matrix provided by Hecke).

source
Base.adjointMethod

Compute the adjoint of a group algebra element. The adjoint is defined as the conjugate of the element in the group algebra, i.e. the inverse of the element in the associated group.

source
QuantumClifford.ECC.generalized_bicycle_codesMethod

Generalized bicycle codes, which are a special case of 2GBA codes (and therefore of lifted product codes). Here the group is chosen as the cyclic group of order l, and the base matrices a and b are the sum of the group algebra elements corresponding to the shifts a_shifts and b_shifts.

See also: two_block_group_algebra_codes, bicycle_codes.

A [[254, 28, 14 ≤ d ≤ 20]] code from (A1) in Appendix B of (Panteleev and Kalachev, 2021).

julia> c = generalized_bicycle_codes([0, 15, 20, 28, 66], [0, 58, 59, 100, 121], 127);
 
 julia> code_n(c), code_k(c)
-(254, 28)
source
+(254, 28)source
QuantumClifford.ECC.two_block_group_algebra_codesMethod

Two-block group algebra (2GBA) codes, which are a special case of lifted product codes from two group algebra elements a and b, used as 1x1 base matrices.

See also: LPCode, generalized_bicycle_codes, bicycle_codes

source
diff --git a/dev/ECC_evaluating/311ab05e.png b/dev/ECC_evaluating/311ab05e.png new file mode 100644 index 000000000..e59a350a9 Binary files /dev/null and b/dev/ECC_evaluating/311ab05e.png differ diff --git a/dev/ECC_evaluating/511e9771.png b/dev/ECC_evaluating/511e9771.png deleted file mode 100644 index 4ce38a4f7..000000000 Binary files a/dev/ECC_evaluating/511e9771.png and /dev/null differ diff --git a/dev/ECC_evaluating/6adaf25c.png b/dev/ECC_evaluating/6adaf25c.png new file mode 100644 index 000000000..5a60c4c39 Binary files /dev/null and b/dev/ECC_evaluating/6adaf25c.png differ diff --git a/dev/ECC_evaluating/a6aa109e.png b/dev/ECC_evaluating/a6aa109e.png deleted file mode 100644 index 552963d56..000000000 Binary files a/dev/ECC_evaluating/a6aa109e.png and /dev/null differ diff --git a/dev/ECC_evaluating/index.html b/dev/ECC_evaluating/index.html index 29d6420e7..25f208cad 100644 --- a/dev/ECC_evaluating/index.html +++ b/dev/ECC_evaluating/index.html @@ -38,7 +38,7 @@ end end -make_decoder_figure(mem_errors, results, "Shor's code with a lookup table decoder")Example block output

Testing out the toric code with a decoder provided by the python package pymatching (provided in julia by the meta package PyQDecoders.jl).

import PyQDecoders
+make_decoder_figure(mem_errors, results, "Shor's code with a lookup table decoder")
Example block output

Testing out the toric code with a decoder provided by the python package pymatching (provided in julia by the meta package PyQDecoders.jl).

import PyQDecoders
 
 mem_errors = 0.001:0.005:0.1
 codes = [Toric(4,4), Toric(6,6)]
@@ -53,4 +53,4 @@
     end
 end
 
-make_decoder_figure(mem_errors, results, "Toric code with a MWPM decoder")
Example block output +make_decoder_figure(mem_errors, results, "Toric code with a MWPM decoder")Example block output diff --git a/dev/allops/index.html b/dev/allops/index.html index 4a47ec8a9..83ae9c94f 100644 --- a/dev/allops/index.html +++ b/dev/allops/index.html @@ -10,4 +10,4 @@ noise = UnbiasedUncorrelatedNoise(ε) noisy_gate = NoisyGate(SparseGate(tCNOT, [2,4]), noise)Example block output

In circuit diagrams the noise is not depicted, but after each application of the gate defined in noisy_gate, a noise operator will also be applied. The example above is of Pauli Depolarization implemented by UnbiasedUncorrelatedNoise.

One can also apply only the noise operator by using NoiseOp which acts only on specified qubits. Or alternatively, one can use NoiseOpAll in order to apply noise to all qubits.

[NoiseOp(noise, [4,5]), NoiseOpAll(noise)]
Example block output

The machinery behind noise processes and different types of noise is detailed in the section on noise

Coincidence Measurements

Global parity measurements involving single-qubit projections and classical communication are implemented with BellMeasurement. One needs to specify the axes of measurement and the qubits being measured. If the parity is trivial, the circuit continues, if the parity is non-trivial, the circuit ends and reports a detected failure. This operator is frequently used in the simulation of entanglement purification.

BellMeasurement([sMX(1), sMY(3), sMZ(4)])
Example block output

There is also NoisyBellMeasurement that takes the bit-flip probability of a single-qubit measurement as a third argument.

Stabilizer Measurements

A measurement over one or more qubits can also be performed, e.g., a direct stabilizer measurement on multiple qubits without the use of ancillary qubits. When applied to multiple qubits, this differs from BellMeasurement as it performs a single projection, unlike BellMeasurement which performs a separate projection for every single qubit involved. This measurement is implemented in PauliMeasurement which requires a Pauli operator on which to project and the index of the classical bit in which to store the result. Alternatively, there are sMX, sMZ, sMY if you are measuring a single qubit.

[PauliMeasurement(P"XYZ", 1), sMZ(2, 2)]
Example block output

Reset Operations

The Reset operations lets you trace out the specified qubits and set their state to a specific tableau.

new_state = random_stabilizer(3)
 qubit_indices = [1,2,3]
-Reset(new_state, qubit_indices)
Example block output

It can be done anywhere in a circuit, not just at the beginning.

+Reset(new_state, qubit_indices)Example block output

It can be done anywhere in a circuit, not just at the beginning.

diff --git a/dev/canonicalization/214d7cb2.png b/dev/canonicalization/214d7cb2.png deleted file mode 100644 index 555b986d4..000000000 Binary files a/dev/canonicalization/214d7cb2.png and /dev/null differ diff --git a/dev/canonicalization/274bc84a.png b/dev/canonicalization/274bc84a.png deleted file mode 100644 index 23f287744..000000000 Binary files a/dev/canonicalization/274bc84a.png and /dev/null differ diff --git a/dev/canonicalization/4278776f.png b/dev/canonicalization/4278776f.png new file mode 100644 index 000000000..394cf26cb Binary files /dev/null and b/dev/canonicalization/4278776f.png differ diff --git a/dev/canonicalization/48014dfb.png b/dev/canonicalization/48014dfb.png new file mode 100644 index 000000000..fe11a537c Binary files /dev/null and b/dev/canonicalization/48014dfb.png differ diff --git a/dev/canonicalization/6adcbad5.png b/dev/canonicalization/6adcbad5.png new file mode 100644 index 000000000..9216cd128 Binary files /dev/null and b/dev/canonicalization/6adcbad5.png differ diff --git a/dev/canonicalization/b9228e67.png b/dev/canonicalization/b9228e67.png deleted file mode 100644 index 44fee7cbe..000000000 Binary files a/dev/canonicalization/b9228e67.png and /dev/null differ diff --git a/dev/canonicalization/bf70ef3e.png b/dev/canonicalization/bf70ef3e.png deleted file mode 100644 index 5d3add5c0..000000000 Binary files a/dev/canonicalization/bf70ef3e.png and /dev/null differ diff --git a/dev/canonicalization/c8ec73dc.png b/dev/canonicalization/c8ec73dc.png new file mode 100644 index 000000000..b84793868 Binary files /dev/null and b/dev/canonicalization/c8ec73dc.png differ diff --git a/dev/canonicalization/index.html b/dev/canonicalization/index.html index 534dda804..04ede1bf3 100644 --- a/dev/canonicalization/index.html +++ b/dev/canonicalization/index.html @@ -2,13 +2,13 @@ Canonicalization · QuantumClifford.jl

Canonicalization operations

Different types of canonicalization operations are implemented. All of them are types of Gaussian elimination.

canonicalize!

First do elimination on all X components and only then perform elimination on the Z components. Based on (Garcia et al., 2012). It is used in logdot for inner products of stabilizer states.

The final tableaux, if square should look like the following

If the tableaux is shorter than a square, the diagonals might not reach all the way to the right.

using QuantumClifford, CairoMakie
 f=Figure()
 stabilizerplot_axis(f[1,1], canonicalize!(random_stabilizer(20,30)))
-f
Example block output

canonicalize_rref!

Cycle between elimination on X and Z for each qubit. Particularly useful for tracing out qubits. Based on (Audenaert and Plenio, 2005). For convenience reasons, the canonicalization starts from the bottom row, and you can specify as a second argument which columns to be canonicalized (useful for tracing out arbitrary qubits, e.g., in traceout!).

The tableau canonicalization is done in recursive steps, each one of which results in something akin to one of these three options

using QuantumClifford, CairoMakie
+f
Example block output

canonicalize_rref!

Cycle between elimination on X and Z for each qubit. Particularly useful for tracing out qubits. Based on (Audenaert and Plenio, 2005). For convenience reasons, the canonicalization starts from the bottom row, and you can specify as a second argument which columns to be canonicalized (useful for tracing out arbitrary qubits, e.g., in traceout!).

The tableau canonicalization is done in recursive steps, each one of which results in something akin to one of these three options

using QuantumClifford, CairoMakie
 f=Figure()
 stabilizerplot_axis(f[1,1], canonicalize_rref!(random_stabilizer(20,30),1:30)[1])
-f
Example block output

canonicalize_gott!

First do elimination on all X components and only then perform elimination on the Z components, but without touching the qubits that were eliminated during the X pass. Unlike other canonicalization operations, qubit columns are reordered, providing for a straight diagonal in each block. Particularly useful as certain blocks of the new created matrix are related to logical operations of the corresponding code, e.g. computing the logical X and Z operators of a MixedDestabilizer. Based on (Gottesman, 1997).

A canonicalized tableau would look like the following (the right-most block does not exist for square tableaux).

using QuantumClifford, CairoMakie
+f
Example block output

canonicalize_gott!

First do elimination on all X components and only then perform elimination on the Z components, but without touching the qubits that were eliminated during the X pass. Unlike other canonicalization operations, qubit columns are reordered, providing for a straight diagonal in each block. Particularly useful as certain blocks of the new created matrix are related to logical operations of the corresponding code, e.g. computing the logical X and Z operators of a MixedDestabilizer. Based on (Gottesman, 1997).

A canonicalized tableau would look like the following (the right-most block does not exist for square tableaux).

using QuantumClifford, CairoMakie
 f=Figure()
 stabilizerplot_axis(f[1,1], canonicalize_gott!(random_stabilizer(30))[1])
-f
Example block output

canonicalize_clip!

Convert to the "clipped" gauge of a stabilizer state resulting in a "river" of non-identity operators around the diagonal.

using QuantumClifford, CairoMakie
+f
Example block output

canonicalize_clip!

Convert to the "clipped" gauge of a stabilizer state resulting in a "river" of non-identity operators around the diagonal.

using QuantumClifford, CairoMakie
 f=Figure()
 stabilizerplot_axis(f[1,1], canonicalize_clip!(random_stabilizer(30)))
-f
Example block output

The properties of the clipped gauge are:

  1. Each qubit is the left/right "endpoint" of exactly two stabilizer rows.
  2. For the same qubit the two endpoints are always different Pauli operators.

This canonicalization is used to derive the bigram a stabilizer state, which is also related to entanglement entropy in the state.

Introduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in Appendix A of (Li et al., 2019).

+fExample block output

The properties of the clipped gauge are:

  1. Each qubit is the left/right "endpoint" of exactly two stabilizer rows.
  2. For the same qubit the two endpoints are always different Pauli operators.

This canonicalization is used to derive the bigram a stabilizer state, which is also related to entanglement entropy in the state.

Introduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in Appendix A of (Li et al., 2019).

diff --git a/dev/commonstates/index.html b/dev/commonstates/index.html index c6ae6447c..6ffd95f3f 100644 --- a/dev/commonstates/index.html +++ b/dev/commonstates/index.html @@ -72,4 +72,4 @@ + XXXX + ZZ__ + _ZZ_ -+ __ZZ ++ __ZZ diff --git a/dev/datastructures/index.html b/dev/datastructures/index.html index fc00d02d8..85510bc39 100644 --- a/dev/datastructures/index.html +++ b/dev/datastructures/index.html @@ -1,2 +1,2 @@ -Datastructure Choice · QuantumClifford.jl

Data Structures Options

Choosing Appropriate Tableau Data Structure

There are four different data structures used to represent stabilizer states. If you will never need projective measurements you probably would want to use Stabilizer. If you require projective measurements, but only on pure states, Destabilizer should be the appropriate data structure. If mixed stabilizer states are involved, MixedStabilizer would be necessary.

Stabilizer is simply a list of Pauli operators in a tableau form. As a data structure it does not enforce the requirements for a pure stabilizer state (the rows of the tableau do not necessarily commute, nor are they forced to be Hermitian; the tableau might be underdetermined, redundant, or contradictory). It is up to the user to ensure that the initial values in the tableau are meaningful and consistent.

canonicalize!, project!, and generate! can accept an under determined (mixed state) Stabilizer instance and operate correctly. canonicalize! can also accept a redundant Stabilizer (i.e. not all rows are independent), leaving as many identity rows at the bottom of the canonicalized tableau as the number of redundant stabilizers in the initial tableau.

canonicalize! takes $\mathcal{O}(n^3)$ steps. generate! expects a canonicalized input and then takes $\mathcal{O}(n^2)$ steps. project! takes $\mathcal{O}(n^3)$ for projecting on commuting operators due to the need to call canonicalize! and generate!. If the projections is on an anticommuting operator (or if keep_result=false) then it takes $\mathcal{O}(n^2)$ steps.

MixedStabilizer provides explicit tracking of the rank of the mixed state and works properly when the projection is on a commuting operator not in the stabilizer (see table below for details). Otherwise it has the same performance as Stabilizer.

The canonicalization can be made unnecessary if we track the destabilizer generators. There are two data structures capable of that.

Destabilizer stores both the destabilizer and stabilizer states. project! called on it never requires a stabilizer canonicalization, hence it runs in $\mathcal{O}(n^2)$. However, project! will raise an exception if you try to project on a commuting state that is not in the stabilizer as that would be an expensive $\mathcal{O}(n^3)$ operation.

MixedDestabilizer tracks both the destabilizer operators and the logical operators in addition to the stabilizer generators. It does not require canonicalization for measurements and its project! operations always takes $\mathcal{O}(n^2)$.

For the operation _, anticom_index, result = project!(...) we have the following behavior:

projectionStabilizerMixedStabilizerDestabilizerMixedDestabilizer
on anticommuting operator anticom_index>0 result===nothingcorrect result in $\mathcal{O}(n^2)$ stepssame as Stabilizersame as Stabilizersame as Stabilizer
on commuting operator in the stabilizer anticom_index==0 result!==nothing$\mathcal{O}(n^3)$; or $\mathcal{O}(n^2)$ if keep_result=false$\mathcal{O}(n^3)$$\mathcal{O}(n^2)$ if the state is pure, throws exception otherwise$\mathcal{O}(n^2)$
on commuting operator out of the stabilizer[1] anticom_index==rank result===nothing$\mathcal{O}(n^3)$, but the user needs to manually include the new operator to the stabilizer; or $\mathcal{O}(n^2)$ if keep_result=false but then result indistinguishable from cell above and anticom_index==0$\mathcal{O}(n^3)$ and rank goes up by onenot applicable if the state is pure, throws exception otherwise$\mathcal{O}(n^2)$ and rank goes up by one

Notice the results when the projection operator commutes with the state but is not generated by the stabilizers of the state (the last row of the table). In that case we have _, anticom_index, result = project!(...) where both anticom_index==rank and result===nothing, with rank being the new rank after projection, one more than the number of rows in the tableau before the measurement.

Bit Packing in Integers and Array Order

We do not use boolean arrays to store information about the qubits as this would be wasteful (7 out of 8 bits in the boolean would be unused). Instead, we use all 8 qubits in a byte and perform bitwise logical operations as necessary. Implementation details of the object in RAM can matter for performance. The library permits any of the standard UInt types to be used for packing the bits, and larger UInt types (like UInt64) are usually faster as they permit working on 64 qubits at a time (instead of 1 if we used a boolean, or 8 if we used a byte).

Moreover, how a tableau is stored in memory can affect performance, as a row-major storage usually permits more efficient use of the CPU cache (for the particular algorithms we use).

Both of these parameters are benchmarked (testing the application of a Pauli operator, which is an $\mathcal{O}(n^2)$ operation; and testing the canonicalization of a Stabilizer, which is an $\mathcal{O}(n^3)$ operation). Row-major UInt64 is the best performing and it is used by default in this library.

  • 1This can occur only if the state being projected is mixed. Both Stabilizer and Destabilizer can be used for mixed states by simply providing fewer stabilizer generators than qubits at initialization. This can be useful for low-level code that tries to avoid the extra memory cost of using MixedStabilizer and MixedDestabilizer but should be avoided otherwise. project! works correctly or raises an explicit warning on all 4 data structures.
+Datastructure Choice · QuantumClifford.jl

Data Structures Options

Choosing Appropriate Tableau Data Structure

There are four different data structures used to represent stabilizer states. If you will never need projective measurements you probably would want to use Stabilizer. If you require projective measurements, but only on pure states, Destabilizer should be the appropriate data structure. If mixed stabilizer states are involved, MixedStabilizer would be necessary.

Stabilizer is simply a list of Pauli operators in a tableau form. As a data structure it does not enforce the requirements for a pure stabilizer state (the rows of the tableau do not necessarily commute, nor are they forced to be Hermitian; the tableau might be underdetermined, redundant, or contradictory). It is up to the user to ensure that the initial values in the tableau are meaningful and consistent.

canonicalize!, project!, and generate! can accept an under determined (mixed state) Stabilizer instance and operate correctly. canonicalize! can also accept a redundant Stabilizer (i.e. not all rows are independent), leaving as many identity rows at the bottom of the canonicalized tableau as the number of redundant stabilizers in the initial tableau.

canonicalize! takes $\mathcal{O}(n^3)$ steps. generate! expects a canonicalized input and then takes $\mathcal{O}(n^2)$ steps. project! takes $\mathcal{O}(n^3)$ for projecting on commuting operators due to the need to call canonicalize! and generate!. If the projections is on an anticommuting operator (or if keep_result=false) then it takes $\mathcal{O}(n^2)$ steps.

MixedStabilizer provides explicit tracking of the rank of the mixed state and works properly when the projection is on a commuting operator not in the stabilizer (see table below for details). Otherwise it has the same performance as Stabilizer.

The canonicalization can be made unnecessary if we track the destabilizer generators. There are two data structures capable of that.

Destabilizer stores both the destabilizer and stabilizer states. project! called on it never requires a stabilizer canonicalization, hence it runs in $\mathcal{O}(n^2)$. However, project! will raise an exception if you try to project on a commuting state that is not in the stabilizer as that would be an expensive $\mathcal{O}(n^3)$ operation.

MixedDestabilizer tracks both the destabilizer operators and the logical operators in addition to the stabilizer generators. It does not require canonicalization for measurements and its project! operations always takes $\mathcal{O}(n^2)$.

For the operation _, anticom_index, result = project!(...) we have the following behavior:

projectionStabilizerMixedStabilizerDestabilizerMixedDestabilizer
on anticommuting operator anticom_index>0 result===nothingcorrect result in $\mathcal{O}(n^2)$ stepssame as Stabilizersame as Stabilizersame as Stabilizer
on commuting operator in the stabilizer anticom_index==0 result!==nothing$\mathcal{O}(n^3)$; or $\mathcal{O}(n^2)$ if keep_result=false$\mathcal{O}(n^3)$$\mathcal{O}(n^2)$ if the state is pure, throws exception otherwise$\mathcal{O}(n^2)$
on commuting operator out of the stabilizer[1] anticom_index==rank result===nothing$\mathcal{O}(n^3)$, but the user needs to manually include the new operator to the stabilizer; or $\mathcal{O}(n^2)$ if keep_result=false but then result indistinguishable from cell above and anticom_index==0$\mathcal{O}(n^3)$ and rank goes up by onenot applicable if the state is pure, throws exception otherwise$\mathcal{O}(n^2)$ and rank goes up by one

Notice the results when the projection operator commutes with the state but is not generated by the stabilizers of the state (the last row of the table). In that case we have _, anticom_index, result = project!(...) where both anticom_index==rank and result===nothing, with rank being the new rank after projection, one more than the number of rows in the tableau before the measurement.

Bit Packing in Integers and Array Order

We do not use boolean arrays to store information about the qubits as this would be wasteful (7 out of 8 bits in the boolean would be unused). Instead, we use all 8 qubits in a byte and perform bitwise logical operations as necessary. Implementation details of the object in RAM can matter for performance. The library permits any of the standard UInt types to be used for packing the bits, and larger UInt types (like UInt64) are usually faster as they permit working on 64 qubits at a time (instead of 1 if we used a boolean, or 8 if we used a byte).

Moreover, how a tableau is stored in memory can affect performance, as a row-major storage usually permits more efficient use of the CPU cache (for the particular algorithms we use).

Both of these parameters are benchmarked (testing the application of a Pauli operator, which is an $\mathcal{O}(n^2)$ operation; and testing the canonicalization of a Stabilizer, which is an $\mathcal{O}(n^3)$ operation). Row-major UInt64 is the best performing and it is used by default in this library.

  • 1This can occur only if the state being projected is mixed. Both Stabilizer and Destabilizer can be used for mixed states by simply providing fewer stabilizer generators than qubits at initialization. This can be useful for low-level code that tries to avoid the extra memory cost of using MixedStabilizer and MixedDestabilizer but should be avoided otherwise. project! works correctly or raises an explicit warning on all 4 data structures.
diff --git a/dev/ecc_example_sim/index.html b/dev/ecc_example_sim/index.html index 6681460d9..4bdbea7d3 100644 --- a/dev/ecc_example_sim/index.html +++ b/dev/ecc_example_sim/index.html @@ -20,7 +20,7 @@ errors = [PauliError(i,errprob) for i in 1:code_n(code)] fullcircuit = [ecirc..., errors..., scirc...]Example block output

And running this noisy simulation:

frames = pftrajectories(fullcircuit; trajectories=nframes)
 pfmeasurements(frames)
4×6 Matrix{Bool}:
- 1  1  0  1  1  0
- 0  1  0  0  0  0
- 0  1  0  0  1  0
- 0  0  0  0  0  0
+ 0 0 0 0 0 0 + 0 0 0 0 0 0 + 0 0 0 0 0 0 + 0 0 0 0 0 0 diff --git a/dev/ghz4graph.png b/dev/ghz4graph.png index 1624c6d71..ad3b87cc8 100644 Binary files a/dev/ghz4graph.png and b/dev/ghz4graph.png differ diff --git a/dev/graphs/index.html b/dev/graphs/index.html index 2743d177f..3968c64a8 100644 --- a/dev/graphs/index.html +++ b/dev/graphs/index.html @@ -43,4 +43,4 @@ + XZZ_ + ZX_Z + Z_XZ -+ _ZZX

Graphs are represented with the Graphs.jl package and plotting can be done both in Plots.jl and Makie.jl (with GraphMakie).

++ _ZZX

Graphs are represented with the Graphs.jl package and plotting can be done both in Plots.jl and Makie.jl (with GraphMakie).

diff --git a/dev/index.html b/dev/index.html index 4d4b9cbe1..d799f0bc8 100644 --- a/dev/index.html +++ b/dev/index.html @@ -15,4 +15,4 @@ julia> tCNOT * S"-XX +ZZ" - X_ -+ _Z

Circuit Simulation

The circuit simulation component of QuantumClifford.jl enables Monte Carlo (or symbolic) simulations of noisy Clifford circuits. It provides three main simulation methods: mctrajectories, pftrajectories, and petrajectories. These methods offer varying levels of efficiency, accuracy, and insight.

Monte Carlo Simulations with Stabilizer Tableaux (mctrajectories)

The mctrajectories method runs Monte Carlo simulations using a Stabilizer tableau representation for the quantum states.

Monte Carlo Simulations with Pauli Frames (pftrajectories)

The pftrajectories method runs Monte Carlo simulations of Pauli frames over a single reference Stabilizer tableau simulation. This approach is much more efficient but supports a smaller class of circuits.

Symbolic Depth-First Traversal of Quantum Trajectories (petrajectories)

The petrajectories method performs a depth-first traversal of the most probable quantum trajectories, providing a fixed-order approximation of the circuit's behavior. This approach gives symbolic expressions for various figures of merit instead of just a numeric value.

++ _Z

Circuit Simulation

The circuit simulation component of QuantumClifford.jl enables Monte Carlo (or symbolic) simulations of noisy Clifford circuits. It provides three main simulation methods: mctrajectories, pftrajectories, and petrajectories. These methods offer varying levels of efficiency, accuracy, and insight.

Monte Carlo Simulations with Stabilizer Tableaux (mctrajectories)

The mctrajectories method runs Monte Carlo simulations using a Stabilizer tableau representation for the quantum states.

Monte Carlo Simulations with Pauli Frames (pftrajectories)

The pftrajectories method runs Monte Carlo simulations of Pauli frames over a single reference Stabilizer tableau simulation. This approach is much more efficient but supports a smaller class of circuits.

Symbolic Depth-First Traversal of Quantum Trajectories (petrajectories)

The petrajectories method performs a depth-first traversal of the most probable quantum trajectories, providing a fixed-order approximation of the circuit's behavior. This approach gives symbolic expressions for various figures of merit instead of just a numeric value.

diff --git a/dev/mixed/index.html b/dev/mixed/index.html index d5b2d0347..c1fd1ac9d 100644 --- a/dev/mixed/index.html +++ b/dev/mixed/index.html @@ -57,4 +57,4 @@ + XXX + ZZ_ 𝒵ₗ━━━ -+ Z_Z

Destabilizer and MixedStabilizer do not use any column swaps on instantiation as they do not track the logical operators.

++ Z_Z

Destabilizer and MixedStabilizer do not use any column swaps on instantiation as they do not track the logical operators.

diff --git a/dev/noise/index.html b/dev/noise/index.html index c52bc502c..243036966 100644 --- a/dev/noise/index.html +++ b/dev/noise/index.html @@ -1,2 +1,2 @@ -Noise Processes · QuantumClifford.jl
+Noise Processes · QuantumClifford.jl
diff --git a/dev/noisycircuits/index.html b/dev/noisycircuits/index.html index b3cd02769..5722d7762 100644 --- a/dev/noisycircuits/index.html +++ b/dev/noisycircuits/index.html @@ -1,2 +1,2 @@ -Simulation of Noisy Circuits · QuantumClifford.jl

Simulation of Noisy Clifford Circuits

Unstable

This is unfinished experimental functionality that will change significantly.

We have experimental support for simulation of noisy Clifford circuits which can be imported with using QuantumClifford.Experimental.NoisyCircuits.

Both Monte Carlo and Perturbative Expansion approaches are supported. When performing a perturbative expansion in the noise parameter, the expansion can optionally be performed symbolically, to arbitrary high orders.

Multiple notebooks with examples are also available. For instance, see this tutorial on entanglement purification for many examples.

+Simulation of Noisy Circuits · QuantumClifford.jl

Simulation of Noisy Clifford Circuits

Unstable

This is unfinished experimental functionality that will change significantly.

We have experimental support for simulation of noisy Clifford circuits which can be imported with using QuantumClifford.Experimental.NoisyCircuits.

Both Monte Carlo and Perturbative Expansion approaches are supported. When performing a perturbative expansion in the noise parameter, the expansion can optionally be performed symbolically, to arbitrary high orders.

Multiple notebooks with examples are also available. For instance, see this tutorial on entanglement purification for many examples.

diff --git a/dev/noisycircuits_API/index.html b/dev/noisycircuits_API/index.html index 668cc95d6..d7b96a80e 100644 --- a/dev/noisycircuits_API/index.html +++ b/dev/noisycircuits_API/index.html @@ -1,2 +1,2 @@ -API · QuantumClifford.jl

Full API (autogenerated)

Unstable

This is experimental functionality with an unstable API.

+API · QuantumClifford.jl

Full API (autogenerated)

Unstable

This is experimental functionality with an unstable API.

diff --git a/dev/noisycircuits_mc/index.html b/dev/noisycircuits_mc/index.html index 79d1ebb84..42e68723a 100644 --- a/dev/noisycircuits_mc/index.html +++ b/dev/noisycircuits_mc/index.html @@ -15,7 +15,7 @@ # then a Bell measurement # followed by checking whether the final result indeed corresponds to the correct Bell pair. circuit = [n,g1,g2,m,v]Example block output

And we can run a Monte Carlo simulation of that circuit with mctrajectories.

mctrajectories(initial_state, circuit, trajectories=500)
Dict{CircuitStatus, Float64} with 4 entries:
-  failure:CircuitStatus(3)       => 4.0
   continue:CircuitStatus(0)      => 0.0
   false_success:CircuitStatus(2) => 9.0
-  true_success:CircuitStatus(1)  => 487.0

For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification for many examples.

Interface for custom operations

If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.

applywstatus!(s::T, g::Operation)::Tuple{T,Symbol} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation. Predefined statuses are kept in the registered_statuses list, but you can add more. Be sure to expand this list if you want the trajectory simulators using your custom statuses to output all trajectories.

There is also applynoise! which is convenient wait to create a noise model that can then be plugged into the NoisyGate struct, letting you reuse the predefined perfect gates and measurements. However, you can also just make up your own noise operator simply by implementing applywstatus! for it.

You can also consult the list of implemented operators.

+ failure:CircuitStatus(3) => 4.0 + true_success:CircuitStatus(1) => 487.0

For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification for many examples.

Interface for custom operations

If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.

applywstatus!(s::T, g::Operation)::Tuple{T,Symbol} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation. Predefined statuses are kept in the registered_statuses list, but you can add more. Be sure to expand this list if you want the trajectory simulators using your custom statuses to output all trajectories.

There is also applynoise! which is convenient wait to create a noise model that can then be plugged into the NoisyGate struct, letting you reuse the predefined perfect gates and measurements. However, you can also just make up your own noise operator simply by implementing applywstatus! for it.

You can also consult the list of implemented operators.

diff --git a/dev/noisycircuits_ops/index.html b/dev/noisycircuits_ops/index.html index fe17db79b..fc0917d66 100644 --- a/dev/noisycircuits_ops/index.html +++ b/dev/noisycircuits_ops/index.html @@ -10,4 +10,4 @@ gate3 = SparseGate(tSWAP, [1,3]) cg = ConditionalGate(gate1, gate2, 2) dg = DecisionGate([gate1,gate2,gate3], bit_register->1) # it will always perform gate1 -[sMX(4,1), sMZ(5,2), cg, dg]Example block output

TODO: Split ConditionalGate into quantum conditional and classical conditional

+[sMX(4,1), sMZ(5,2), cg, dg]Example block output

TODO: Split ConditionalGate into quantum conditional and classical conditional

diff --git a/dev/noisycircuits_perturb/index.html b/dev/noisycircuits_perturb/index.html index 8d6cd82af..bbc313272 100644 --- a/dev/noisycircuits_perturb/index.html +++ b/dev/noisycircuits_perturb/index.html @@ -18,6 +18,6 @@ circuit = [n,g1,g2,m,v] petrajectories(initial_state, circuit)
Dict{CircuitStatus, Float64} with 3 entries:
-  failure:CircuitStatus(3)       => 0.0129373
   false_success:CircuitStatus(2) => 0.019406
-  true_success:CircuitStatus(1)  => 0.967065

For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification.

Symbolic expansions

The perturbative expansion method works with symbolic variables as well. One can use any of the symbolic libraries available in Julia and simply plug symbolic parameters in lieu of numeric parameters. A detailed example is available as a Jupyter notebook.

Interface for custom operations

If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.

applyop_branches!(s::T, g::Operation; max_order=1)::Vector{Tuple{T,Symbol,Real,Int}} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation, the Real is the probability for that branch, and the Int is the order of that branch.

There is also applynoise_branches! which is convenient for use in NoisyGate, but you can also just make up your own noise operator simply by implementing applyop_branches! for it.

You can also consult the list of implemented operators.

+ failure:CircuitStatus(3) => 0.0129373 + true_success:CircuitStatus(1) => 0.967065

For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification.

Symbolic expansions

The perturbative expansion method works with symbolic variables as well. One can use any of the symbolic libraries available in Julia and simply plug symbolic parameters in lieu of numeric parameters. A detailed example is available as a Jupyter notebook.

Interface for custom operations

If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.

applyop_branches!(s::T, g::Operation; max_order=1)::Vector{Tuple{T,Symbol,Real,Int}} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation, the Real is the probability for that branch, and the Int is the order of that branch.

There is also applynoise_branches! which is convenient for use in NoisyGate, but you can also just make up your own noise operator simply by implementing applyop_branches! for it.

You can also consult the list of implemented operators.

diff --git a/dev/objects.inv b/dev/objects.inv index 5210cfae1..266587022 100644 Binary files a/dev/objects.inv and b/dev/objects.inv differ diff --git a/dev/plotting/c43513c3.svg b/dev/plotting/0edf497c.svg similarity index 98% rename from dev/plotting/c43513c3.svg rename to dev/plotting/0edf497c.svg index d45151a9a..1fddce013 100644 --- a/dev/plotting/c43513c3.svg +++ b/dev/plotting/0edf497c.svg @@ -1,23 +1,23 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + Visualizations · QuantumClifford.jl

Visualizations

Stabilizers have a plot recipe that can be used with Plots.jl or Makie.jl. It simply displays the corresponding parity check matrix (extracted with stab_to_gf2) as a bitmap image. Circuits can be visualized with Quantikz.jl.

Importing the aforementioned packages together with QuantumClifford is necessary to enable the plotting functionality (implemented as package extensions).

Plots.jl

In Plots.jl we have a simple recipe plot(s::Stabilizer; xzcomponents=...) where xzcomponents=:split plots the tableau heatmap in a wide form, X bits on the left, Z bits on the right; or xzcomponents=:together plots them overlapping, with different colors for I, X, Z, and Y.

using QuantumClifford, Plots
-plot(random_stabilizer(20,30), xzcomponents=:split)
Example block output
using QuantumClifford, Plots
-plot(canonicalize!(random_stabilizer(20,30)))
Example block output
using QuantumClifford, Plots
-plot(canonicalize_gott!(random_stabilizer(30))[1], xzcomponents=:split)
Example block output
using QuantumClifford, Plots
-plot(canonicalize_gott!(random_stabilizer(30))[1]; xzcomponents=:together)
Example block output
using QuantumClifford, Plots
-plot(canonicalize_rref!(random_stabilizer(20,30),1:30)[1]; xzcomponents=:together)
Example block output

Makie.jl

Makie's heatmap can be directly called on Stabilizer.

using QuantumClifford, CairoMakie
+plot(random_stabilizer(20,30), xzcomponents=:split)
Example block output
using QuantumClifford, Plots
+plot(canonicalize!(random_stabilizer(20,30)))
Example block output
using QuantumClifford, Plots
+plot(canonicalize_gott!(random_stabilizer(30))[1], xzcomponents=:split)
Example block output
using QuantumClifford, Plots
+plot(canonicalize_gott!(random_stabilizer(30))[1]; xzcomponents=:together)
Example block output
using QuantumClifford, Plots
+plot(canonicalize_rref!(random_stabilizer(20,30),1:30)[1]; xzcomponents=:together)
Example block output

Makie.jl

Makie's heatmap can be directly called on Stabilizer.

using QuantumClifford, CairoMakie
 s = S"IIXZ
       ZZIZ
       YYIZ
@@ -47,4 +47,4 @@
 f=Figure()
 stabilizerplot_axis(f[1,1],random_stabilizer(100))
 f
Example block output

Quantikz.jl

With the Quantikz library you can visualize gates or sequences of gates.

using QuantumClifford, Quantikz
-circuit = [sCNOT(1,2), SparseGate(random_clifford(4), [1,4,5,6]), sMZ(4)]
Example block output
+circuit = [sCNOT(1,2), SparseGate(random_clifford(4), [1,4,5,6]), sMZ(4)]Example block output diff --git a/dev/references/index.html b/dev/references/index.html index aeae4a03e..82b0a9a77 100644 --- a/dev/references/index.html +++ b/dev/references/index.html @@ -1,2 +1,2 @@ -Suggested Readings & References · QuantumClifford.jl

Suggested reading

For the basis of the tableaux methods first read (Gottesman, 1998) followed by the more efficient approach described in (Aaronson and Gottesman, 2004).

The tableaux can be canonicalized (i.e. Gaussian elimination can be performed on them) in a number of different ways, and considering the different approaches provides useful insight. The following methods are implemented in this library:

For the use of these methods in error correction and the subtle overlap between the two fields consider these resources. They are also useful in defining some of the specific constraints in commutation between rows in the tableaux:

These publications describe the uniform sampling of random stabilizer states:

For circuit construction routines (for stabilizer measurements for a given code):

For quantum code construction routines:

For classical code construction routines:

References

  • Aaronson, S. and Gottesman, D. (2004). Improved simulation of stabilizer circuits. Physical Review A 70, 052328.
  • Abbe, E.; Shpilka, A. and Ye, M. (2020). Reed–Muller codes: Theory and algorithms. IEEE Transactions on Information Theory 67, 3251–3277.
  • Anderson, J. T.; Duclos-Cianci, G. and Poulin, D. (2014). Fault-tolerant conversion between the steane and reed-muller quantum codes. Physical review letters 113, 080501.
  • Audenaert, K. M. and Plenio, M. B. (2005). Entanglement on mixed stabilizer states: normal forms and reduction procedures. New Journal of Physics 7, 170.
  • Bose, R. C. and Ray-Chaudhuri, D. K. (1960). Further results on error correcting binary group codes. Information and Control 3, 279–290.
  • Bose, R. C. and Ray-Chaudhuri, D. K. (1960). On a class of error correcting binary group codes. Information and control 3, 68–79.
  • Bravyi, S. and Maslov, D. (2021). Hadamard-free circuits expose the structure of the Clifford group. IEEE Transactions on Information Theory 67, 4546–4563.
  • Brown, W. and Fawzi, O. (Jul 2013). Short Random Circuits Define Good Quantum Error Correcting Codes. In: 2013 IEEE International Symposium on Information Theory; pp. 346–350.
  • Calderbank, A. R.; Rains, E. M.; Shor, P. and Sloane, N. J. (1998). Quantum error correction via codes over GF (4). IEEE Transactions on Information Theory 44, 1369–1387.
  • Campbell, E. T.; Anwar, H. and Browne, D. E. (2012). Magic-state distillation in all prime dimensions using quantum reed-muller codes. Physical Review X 2, 041021.
  • Chao, R. and Reichardt, B. W. (2017). Quantum Error Correction with Only Two Extra Qubits. Physical review letters 121 5, 050502.
  • Cleve, R. and Gottesman, D. (1997). Efficient computations of encodings for quantum error correction. Physical Review A 56, 76.
  • Djordjevic, I. B. (2021). Quantum information processing, quantum computing, and quantum error correction: an engineering approach (Academic Press).
  • Fowler, A. G.; Mariantoni, M.; Martinis, J. M. and Cleland, A. N. (2012). Surface codes: Towards practical large-scale quantum computation. Physical Review A 86, 032324.
  • Garcia, H. J.; Markov, I. L. and Cross, A. W. (2012). Efficient inner-product algorithm for stabilizer states, arXiv preprint arXiv:1210.6646.
  • Gottesman, D. (1996). Class of quantum error-correcting codes saturating the quantum Hamming bound. Physical Review A 54, 1862.
  • Gottesman, D. (1997). Stabilizer codes and quantum error correction. Ph.D. Thesis, California Institute of Technology.
  • Gottesman, D. (1998). The Heisenberg representation of quantum computers. In: International Conference on Group Theoretic Methods in Physics (Citeseer).
  • Grassl, M. (2002). Algorithmic aspects of quantum error-correcting codes. Mathematics of Quantum Computation, 223–252.
  • Grassl, M. (2011). Variations on encoding circuits for stabilizer quantum codes. In: International Conference on Coding and Cryptology (Springer); pp. 142–158.
  • Gullans, M. J.; Krastanov, S.; Huse, D. A.; Jiang, L. and Flammia, S. T. (2021). Quantum Coding with Low-Depth Random Circuits. Physical Review X 11, 031066.
  • Hocquenghem, A. (1959). Codes correcteurs d'erreurs. Chiffers 2, 147–156.
  • Knill, E. and Laflamme, R. (1996). Concatenated quantum codes, arXiv preprint quant-ph/9608012.
  • Koenig, R. and Smolin, J. A. (2014). How to efficiently select an arbitrary Clifford group element. Journal of Mathematical Physics 55, 122202.
  • Krastanov, S.; de la Cerda, A. S. and Narang, P. (2020). Heterogeneous Multipartite Entanglement Purification for Size-Constrained Quantum Devices, arXiv preprint arXiv:2011.11640.
  • Li, Y.; Chen, X. and Fisher, M. P. (2019). Measurement-driven entanglement transition in hybrid quantum circuits. Physical Review B 100, 134306.
  • Lin, S. and Costello, D. (2024). Error Control Coding (Pearson).
  • MacKay, D. J.; Mitchison, G. and McFadden, P. L. (2004). Sparse-graph codes for quantum error correction. IEEE Transactions on Information Theory 50, 2315–2330.
  • Muller, D. E. (1954). Application of Boolean algebra to switching circuit design and to error detection. Transactions of the IRE professional group on electronic computers, 6–12.
  • Nahum, A.; Ruhman, J.; Vijay, S. and Haah, J. (2017). Quantum Entanglement Growth under Random Unitary Dynamics. Physical Review X 7, 031016.
  • Panteleev, P. and Kalachev, G. (2021). Degenerate Quantum LDPC Codes With Good Finite Length Performance. Quantum 5, 585, arXiv:1904.02703 [quant-ph].
  • Panteleev, P. and Kalachev, G. (Jun 2022). Asymptotically Good Quantum and Locally Testable Classical LDPC Codes. In: Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (ACM, Rome Italy); pp. 375–388.
  • Raaphorst, S. (2003). Reed-muller codes. Carleton University, May 9.
  • Raveendran, N.; Rengaswamy, N.; Rozpędek, F.; Raina, A.; Jiang, L. and Vasić, B. (2022). Finite Rate QLDPC-GKP Coding Scheme That Surpasses the CSS Hamming Bound. Quantum 6, 767.
  • Reed, I. S. (1954). A class of multiple-error-correcting codes and the decoding scheme. IEEE Transactions on Information Theory 4, 38–49.
  • Roffe, J.; Cohen, L. Z.; Quintavalle, A. O.; Chandra, D. and Campbell, E. T. (2023). Bias-Tailored Quantum LDPC Codes. Quantum 7, 1005.
  • Steane, A. M. (1999). Quantum reed-muller codes. IEEE Transactions on Information Theory 45, 1701–1703.
  • Steane, A. M. (2007). A tutorial on quantum error correction. In: PROCEEDINGS-INTERNATIONAL SCHOOL OF PHYSICS ENRICO FERMI, Vol. 162 (IOS Press; Ohmsha; 1999); p. 1.
  • Van Den Berg, E. (2021). A simple method for sampling random Clifford operators. In: 2021 IEEE International Conference on Quantum Computing and Engineering (QCE) (IEEE); pp. 54–59.
  • Wilde, M. M. (2009). Logical operators of quantum codes. Physical Review A 79, 062322.
  • Yu, S.; Bierbrauer, J.; Dong, Y.; Chen, Q. and Oh, C. H. (2013). All the Stabilizer Codes of Distance 3. IEEE Transactions on Information Theory 59, 5179–5185.
+Suggested Readings & References · QuantumClifford.jl

Suggested reading

For the basis of the tableaux methods first read (Gottesman, 1998) followed by the more efficient approach described in (Aaronson and Gottesman, 2004).

The tableaux can be canonicalized (i.e. Gaussian elimination can be performed on them) in a number of different ways, and considering the different approaches provides useful insight. The following methods are implemented in this library:

For the use of these methods in error correction and the subtle overlap between the two fields consider these resources. They are also useful in defining some of the specific constraints in commutation between rows in the tableaux:

These publications describe the uniform sampling of random stabilizer states:

For circuit construction routines (for stabilizer measurements for a given code):

For quantum code construction routines:

For classical code construction routines:

References

  • Aaronson, S. and Gottesman, D. (2004). Improved simulation of stabilizer circuits. Physical Review A 70, 052328.
  • Abbe, E.; Shpilka, A. and Ye, M. (2020). Reed–Muller codes: Theory and algorithms. IEEE Transactions on Information Theory 67, 3251–3277.
  • Anderson, J. T.; Duclos-Cianci, G. and Poulin, D. (2014). Fault-tolerant conversion between the steane and reed-muller quantum codes. Physical review letters 113, 080501.
  • Audenaert, K. M. and Plenio, M. B. (2005). Entanglement on mixed stabilizer states: normal forms and reduction procedures. New Journal of Physics 7, 170.
  • Bose, R. C. and Ray-Chaudhuri, D. K. (1960). Further results on error correcting binary group codes. Information and Control 3, 279–290.
  • Bose, R. C. and Ray-Chaudhuri, D. K. (1960). On a class of error correcting binary group codes. Information and control 3, 68–79.
  • Bravyi, S. and Maslov, D. (2021). Hadamard-free circuits expose the structure of the Clifford group. IEEE Transactions on Information Theory 67, 4546–4563.
  • Brown, W. and Fawzi, O. (Jul 2013). Short Random Circuits Define Good Quantum Error Correcting Codes. In: 2013 IEEE International Symposium on Information Theory; pp. 346–350.
  • Calderbank, A. R.; Rains, E. M.; Shor, P. and Sloane, N. J. (1998). Quantum error correction via codes over GF (4). IEEE Transactions on Information Theory 44, 1369–1387.
  • Campbell, E. T.; Anwar, H. and Browne, D. E. (2012). Magic-state distillation in all prime dimensions using quantum reed-muller codes. Physical Review X 2, 041021.
  • Chao, R. and Reichardt, B. W. (2017). Quantum Error Correction with Only Two Extra Qubits. Physical review letters 121 5, 050502.
  • Cleve, R. and Gottesman, D. (1997). Efficient computations of encodings for quantum error correction. Physical Review A 56, 76.
  • Djordjevic, I. B. (2021). Quantum information processing, quantum computing, and quantum error correction: an engineering approach (Academic Press).
  • Fowler, A. G.; Mariantoni, M.; Martinis, J. M. and Cleland, A. N. (2012). Surface codes: Towards practical large-scale quantum computation. Physical Review A 86, 032324.
  • Garcia, H. J.; Markov, I. L. and Cross, A. W. (2012). Efficient inner-product algorithm for stabilizer states, arXiv preprint arXiv:1210.6646.
  • Gottesman, D. (1996). Class of quantum error-correcting codes saturating the quantum Hamming bound. Physical Review A 54, 1862.
  • Gottesman, D. (1997). Stabilizer codes and quantum error correction. Ph.D. Thesis, California Institute of Technology.
  • Gottesman, D. (1998). The Heisenberg representation of quantum computers. In: International Conference on Group Theoretic Methods in Physics (Citeseer).
  • Grassl, M. (2002). Algorithmic aspects of quantum error-correcting codes. Mathematics of Quantum Computation, 223–252.
  • Grassl, M. (2011). Variations on encoding circuits for stabilizer quantum codes. In: International Conference on Coding and Cryptology (Springer); pp. 142–158.
  • Gullans, M. J.; Krastanov, S.; Huse, D. A.; Jiang, L. and Flammia, S. T. (2021). Quantum Coding with Low-Depth Random Circuits. Physical Review X 11, 031066.
  • Hocquenghem, A. (1959). Codes correcteurs d'erreurs. Chiffers 2, 147–156.
  • Knill, E. and Laflamme, R. (1996). Concatenated quantum codes, arXiv preprint quant-ph/9608012.
  • Koenig, R. and Smolin, J. A. (2014). How to efficiently select an arbitrary Clifford group element. Journal of Mathematical Physics 55, 122202.
  • Krastanov, S.; de la Cerda, A. S. and Narang, P. (2020). Heterogeneous Multipartite Entanglement Purification for Size-Constrained Quantum Devices, arXiv preprint arXiv:2011.11640.
  • Li, Y.; Chen, X. and Fisher, M. P. (2019). Measurement-driven entanglement transition in hybrid quantum circuits. Physical Review B 100, 134306.
  • Lin, S. and Costello, D. (2024). Error Control Coding (Pearson).
  • MacKay, D. J.; Mitchison, G. and McFadden, P. L. (2004). Sparse-graph codes for quantum error correction. IEEE Transactions on Information Theory 50, 2315–2330.
  • Muller, D. E. (1954). Application of Boolean algebra to switching circuit design and to error detection. Transactions of the IRE professional group on electronic computers, 6–12.
  • Nahum, A.; Ruhman, J.; Vijay, S. and Haah, J. (2017). Quantum Entanglement Growth under Random Unitary Dynamics. Physical Review X 7, 031016.
  • Panteleev, P. and Kalachev, G. (2021). Degenerate Quantum LDPC Codes With Good Finite Length Performance. Quantum 5, 585, arXiv:1904.02703 [quant-ph].
  • Panteleev, P. and Kalachev, G. (Jun 2022). Asymptotically Good Quantum and Locally Testable Classical LDPC Codes. In: Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (ACM, Rome Italy); pp. 375–388.
  • Raaphorst, S. (2003). Reed-muller codes. Carleton University, May 9.
  • Raveendran, N.; Rengaswamy, N.; Rozpędek, F.; Raina, A.; Jiang, L. and Vasić, B. (2022). Finite Rate QLDPC-GKP Coding Scheme That Surpasses the CSS Hamming Bound. Quantum 6, 767.
  • Reed, I. S. (1954). A class of multiple-error-correcting codes and the decoding scheme. IEEE Transactions on Information Theory 4, 38–49.
  • Roffe, J.; Cohen, L. Z.; Quintavalle, A. O.; Chandra, D. and Campbell, E. T. (2023). Bias-Tailored Quantum LDPC Codes. Quantum 7, 1005.
  • Steane, A. M. (1999). Quantum reed-muller codes. IEEE Transactions on Information Theory 45, 1701–1703.
  • Steane, A. M. (2007). A tutorial on quantum error correction. In: PROCEEDINGS-INTERNATIONAL SCHOOL OF PHYSICS ENRICO FERMI, Vol. 162 (IOS Press; Ohmsha; 1999); p. 1.
  • Van Den Berg, E. (2021). A simple method for sampling random Clifford operators. In: 2021 IEEE International Conference on Quantum Computing and Engineering (QCE) (IEEE); pp. 54–59.
  • Wilde, M. M. (2009). Logical operators of quantum codes. Physical Review A 79, 062322.
  • Yu, S.; Bierbrauer, J.; Dong, Y.; Chen, Q. and Oh, C. H. (2013). All the Stabilizer Codes of Distance 3. IEEE Transactions on Information Theory 59, 5179–5185.
diff --git a/dev/search_index.js b/dev/search_index.js index 38fb9b2fc..d75abe61a 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"references/#Suggested-reading","page":"Suggested Readings & References","title":"Suggested reading","text":"","category":"section"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For the basis of the tableaux methods first read (Gottesman, 1998) followed by the more efficient approach described in (Aaronson and Gottesman, 2004).","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"The tableaux can be canonicalized (i.e. Gaussian elimination can be performed on them) in a number of different ways, and considering the different approaches provides useful insight. The following methods are implemented in this library:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"The default one: (Garcia et al., 2012)\nUseful when in need of tracing out a set of qubits: (Audenaert and Plenio, 2005)\nUseful when defining logical operators of codes: (Gottesman, 1997)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For the use of these methods in error correction and the subtle overlap between the two fields consider these resources. They are also useful in defining some of the specific constraints in commutation between rows in the tableaux:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Steane, 2007)\n(Calderbank et al., 1998)\n(MacKay et al., 2004)\n(Wilde, 2009)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"These publications describe the uniform sampling of random stabilizer states:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Koenig and Smolin, 2014)\n(Bravyi and Maslov, 2021)\n(Van Den Berg, 2021)\n(Li et al., 2019)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For circuit construction routines (for stabilizer measurements for a given code):","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Cleve and Gottesman, 1997)\n(Gottesman, 1997) (and its erratum)\n(Grassl, 2002)\n(Grassl, 2011)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For quantum code construction routines:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Cleve and Gottesman, 1997)\n(Gottesman, 1996)\n(Gottesman, 1997)\n(Yu et al., 2013)\n(Chao and Reichardt, 2017)\n(Kitaev, 2003)\n(Fowler et al., 2012)\n(Knill and Laflamme, 1996)\n(Steane, 1999)\n(Campbell et al., 2012)\n(Anderson et al., 2014)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For classical code construction routines:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Muller, 1954)\n(Reed, 1954)\n(Raaphorst, 2003)\n(Abbe et al., 2020)\n(Djordjevic, 2021)\n(Hocquenghem, 1959)\n(Bose and Ray-Chaudhuri, 1960)\n(Bose and Ray-Chaudhuri, 1960)\n(Lin and Costello, 2024)","category":"page"},{"location":"references/#References","page":"Suggested Readings & References","title":"References","text":"","category":"section"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"Aaronson, S. and Gottesman, D. (2004). Improved simulation of stabilizer circuits. Physical Review A 70, 052328.\n\n\n\nAbbe, E.; Shpilka, A. and Ye, M. (2020). Reed–Muller codes: Theory and algorithms. IEEE Transactions on Information Theory 67, 3251–3277.\n\n\n\nAnderson, J. T.; Duclos-Cianci, G. and Poulin, D. (2014). Fault-tolerant conversion between the steane and reed-muller quantum codes. Physical review letters 113, 080501.\n\n\n\nAudenaert, K. M. and Plenio, M. B. (2005). Entanglement on mixed stabilizer states: normal forms and reduction procedures. New Journal of Physics 7, 170.\n\n\n\nBose, R. C. and Ray-Chaudhuri, D. K. (1960). Further results on error correcting binary group codes. Information and Control 3, 279–290.\n\n\n\nBose, R. C. and Ray-Chaudhuri, D. K. (1960). On a class of error correcting binary group codes. Information and control 3, 68–79.\n\n\n\nBravyi, S. and Maslov, D. (2021). Hadamard-free circuits expose the structure of the Clifford group. IEEE Transactions on Information Theory 67, 4546–4563.\n\n\n\nBrown, W. and Fawzi, O. (Jul 2013). Short Random Circuits Define Good Quantum Error Correcting Codes. In: 2013 IEEE International Symposium on Information Theory; pp. 346–350.\n\n\n\nCalderbank, A. R.; Rains, E. M.; Shor, P. and Sloane, N. J. (1998). Quantum error correction via codes over GF (4). IEEE Transactions on Information Theory 44, 1369–1387.\n\n\n\nCampbell, E. T.; Anwar, H. and Browne, D. E. (2012). Magic-state distillation in all prime dimensions using quantum reed-muller codes. Physical Review X 2, 041021.\n\n\n\nChao, R. and Reichardt, B. W. (2017). Quantum Error Correction with Only Two Extra Qubits. Physical review letters 121 5, 050502.\n\n\n\nCleve, R. and Gottesman, D. (1997). Efficient computations of encodings for quantum error correction. Physical Review A 56, 76.\n\n\n\nDjordjevic, I. B. (2021). Quantum information processing, quantum computing, and quantum error correction: an engineering approach (Academic Press).\n\n\n\nFowler, A. G.; Mariantoni, M.; Martinis, J. M. and Cleland, A. N. (2012). Surface codes: Towards practical large-scale quantum computation. Physical Review A 86, 032324.\n\n\n\nGarcia, H. J.; Markov, I. L. and Cross, A. W. (2012). Efficient inner-product algorithm for stabilizer states, arXiv preprint arXiv:1210.6646.\n\n\n\nGottesman, D. (1996). Class of quantum error-correcting codes saturating the quantum Hamming bound. Physical Review A 54, 1862.\n\n\n\nGottesman, D. (1997). Stabilizer codes and quantum error correction. Ph.D. Thesis, California Institute of Technology.\n\n\n\nGottesman, D. (1998). The Heisenberg representation of quantum computers. In: International Conference on Group Theoretic Methods in Physics (Citeseer).\n\n\n\nGrassl, M. (2002). Algorithmic aspects of quantum error-correcting codes. Mathematics of Quantum Computation, 223–252.\n\n\n\nGrassl, M. (2011). Variations on encoding circuits for stabilizer quantum codes. In: International Conference on Coding and Cryptology (Springer); pp. 142–158.\n\n\n\nGullans, M. J.; Krastanov, S.; Huse, D. A.; Jiang, L. and Flammia, S. T. (2021). Quantum Coding with Low-Depth Random Circuits. Physical Review X 11, 031066.\n\n\n\nHocquenghem, A. (1959). Codes correcteurs d'erreurs. Chiffers 2, 147–156.\n\n\n\nKitaev, A. (2003). Fault-tolerant quantum computation by anyons. Annals of Physics 303, 2–30.\n\n\n\nKnill, E. and Laflamme, R. (1996). Concatenated quantum codes, arXiv preprint quant-ph/9608012.\n\n\n\nKoenig, R. and Smolin, J. A. (2014). How to efficiently select an arbitrary Clifford group element. Journal of Mathematical Physics 55, 122202.\n\n\n\nKrastanov, S.; de la Cerda, A. S. and Narang, P. (2020). Heterogeneous Multipartite Entanglement Purification for Size-Constrained Quantum Devices, arXiv preprint arXiv:2011.11640.\n\n\n\nLi, Y.; Chen, X. and Fisher, M. P. (2019). Measurement-driven entanglement transition in hybrid quantum circuits. Physical Review B 100, 134306.\n\n\n\nLin, S. and Costello, D. (2024). Error Control Coding (Pearson).\n\n\n\nMacKay, D. J.; Mitchison, G. and McFadden, P. L. (2004). Sparse-graph codes for quantum error correction. IEEE Transactions on Information Theory 50, 2315–2330.\n\n\n\nMuller, D. E. (1954). Application of Boolean algebra to switching circuit design and to error detection. Transactions of the IRE professional group on electronic computers, 6–12.\n\n\n\nNahum, A.; Ruhman, J.; Vijay, S. and Haah, J. (2017). Quantum Entanglement Growth under Random Unitary Dynamics. Physical Review X 7, 031016.\n\n\n\nPanteleev, P. and Kalachev, G. (2021). Degenerate Quantum LDPC Codes With Good Finite Length Performance. Quantum 5, 585, arXiv:1904.02703 [quant-ph].\n\n\n\nPanteleev, P. and Kalachev, G. (Jun 2022). Asymptotically Good Quantum and Locally Testable Classical LDPC Codes. In: Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (ACM, Rome Italy); pp. 375–388.\n\n\n\nRaaphorst, S. (2003). Reed-muller codes. Carleton University, May 9.\n\n\n\nRaveendran, N.; Rengaswamy, N.; Rozpędek, F.; Raina, A.; Jiang, L. and Vasić, B. (2022). Finite Rate QLDPC-GKP Coding Scheme That Surpasses the CSS Hamming Bound. Quantum 6, 767.\n\n\n\nReed, I. S. (1954). A class of multiple-error-correcting codes and the decoding scheme. IEEE Transactions on Information Theory 4, 38–49.\n\n\n\nRoffe, J.; Cohen, L. Z.; Quintavalle, A. O.; Chandra, D. and Campbell, E. T. (2023). Bias-Tailored Quantum LDPC Codes. Quantum 7, 1005.\n\n\n\nSteane, A. M. (1999). Quantum reed-muller codes. IEEE Transactions on Information Theory 45, 1701–1703.\n\n\n\nSteane, A. M. (2007). A tutorial on quantum error correction. In: PROCEEDINGS-INTERNATIONAL SCHOOL OF PHYSICS ENRICO FERMI, Vol. 162 (IOS Press; Ohmsha; 1999); p. 1.\n\n\n\nVan Den Berg, E. (2021). A simple method for sampling random Clifford operators. In: 2021 IEEE International Conference on Quantum Computing and Engineering (QCE) (IEEE); pp. 54–59.\n\n\n\nWilde, M. M. (2009). Logical operators of quantum codes. Physical Review A 79, 062322.\n\n\n\nYu, S.; Bierbrauer, J.; Dong, Y.; Chen, Q. and Oh, C. H. (2013). All the Stabilizer Codes of Distance 3. IEEE Transactions on Information Theory 59, 5179–5185.\n\n\n\n","category":"page"},{"location":"noise/#noise","page":"Noise Processes","title":"Noise Processes","text":"","category":"section"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"DocTestSetup = quote\n using QuantumClifford\n using StableRNGs\n rng = StableRNG(42)\nend","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"As seen in the list of possible gates, the simulator is capable of modeling different types of noise. If that is your goal, please consider using the available Monte Carlo simulator or the Symbolic Perturbative Expansion system.","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"The implemented types of noise include:","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"UnbiasedUncorrelatedNoise\nPauliNoise","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"The low-level functionality to work with noise is applynoise!, but most of the time you would probably just want to use PauliError, NoisyGate, NoiseOp and NoiseOpAll.","category":"page"},{"location":"ecc_example_sim/#noisycircuits_pf_ecc_example","page":"ECC example","title":"ECC example with Pauli Frames","text":"","category":"section"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"DocTestSetup = quote\n using QuantumClifford\n using Quantikz\nend","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"warning: The documentation is incomplete\nWaiting for a better documentation than the small example below. Check out also the page on ECC performance evaluators","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"Consider Steane 7-qubit code:","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"using QuantumClifford\nusing QuantumClifford.ECC: Steane7, naive_syndrome_circuit, naive_encoding_circuit, parity_checks, code_s, code_n\nusing Quantikz\n\ncode = Steane7()\nH = parity_checks(code)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"... and the corresponding encoding circuit","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"ecirc = naive_encoding_circuit(code)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"... and the corresponding syndrome measurement circuit (the non-fault tolerant one)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"scirc, _ = naive_syndrome_circuit(code)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"The most straightforward way to start sampling syndromes is to set up a table of Pauli frames.","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"circuit = [ecirc..., scirc...]\nnframes = 4\nframes = pftrajectories(circuit; trajectories=nframes) # run the sims\npfmeasurements(frames) # extract the measurements","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"The pftrajectories function is multithreaded. If you want more low-level control over these Pauli frame simulations, check out the PauliFrame structure, the other methods of pftrajectories, and the circuit compactifaction function compactify_circuit.","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"If you want to model Pauli errors, use:","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"The helper PauliError for unbiased Pauli noise operation acting on a given qubit\nThe lower level NoiseOp (for a single qubit) or NoiseOpAll (for all qubits) parameterized with a particular noise type, e.g. UnbiasedUncorrelatedNoise","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"errprob = 0.1\nerrors = [PauliError(i,errprob) for i in 1:code_n(code)]\nfullcircuit = [ecirc..., errors..., scirc...]","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"And running this noisy simulation:","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"frames = pftrajectories(fullcircuit; trajectories=nframes)\npfmeasurements(frames)","category":"page"},{"location":"stab-algebra-manual/#Stabilizer-Tableau-Algebra-Manual","page":"Manual","title":"Stabilizer Tableau Algebra Manual","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"DocTestSetup = quote\n using QuantumClifford\nend","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The library consists of two main parts: Tools for working with the algebra of Stabilizer tableaux and tools specifically for efficient Circuit Simulation. This chapter discusses the former \"lower level\" Stabilizer tableau algebra tools.","category":"page"},{"location":"stab-algebra-manual/#Pauli-Operators","page":"Manual","title":"Pauli Operators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The PauliOperator object represents multi-qubit Pauli operator (1iIZXY^otimes n). It is stored in memory as a phase (a single byte where 0x0,0x1,0x2,0x3 corresponds to 1i-1-i) and two bit-arrays, for X and for Z components.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"You can create them with a P string.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"-iXZ\"\n-iXZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Or by specifying phase and X/Z components:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> PauliOperator(0x0,Bool[0,1,0],Bool[0,0,1])\n+ _XZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Both underscore and I can be used for identity.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"I_XYZ\"\n+ __XYZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Multiplication with scalars or other Pauli operators works as expected, as well as tensor products of Pauli operators.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> -1im*P\"X\"\n-iX\n\njulia> P\"X\" * P\"Z\"\n-iY\n\njulia> P\"X\" ⊗ P\"Z\"\n+ XZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"One can check for commutativity with comm.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> comm(P\"X\",P\"Z\")\n0x01\n\njulia> comm(P\"XX\",P\"ZZ\")\n0x00","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"And check the phase of a product with prodphase.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> prodphase(P\"X\", P\"Z\")\n0x03\n\njulia> prodphase(P\"X\", P\"iZ\")\n0x00\n\njulia> prodphase(P\"X\",P\"Y\")\n0x01","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Indexing operations are available.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> p = P\"IXYZ\";\n\njulia> p[1], p[2], p[3], p[4]\n((false, false), (true, false), (true, true), (false, true))\n\njulia> p = P\"III\";\n\njulia> p[2] = (true, true);\n\njulia> p\n+ _Y_","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Including fancy indexing:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"IXYZ\"[[2,3]]\n+ XY\n\njulia> P\"IXYZ\"[[false,true,true,false]]\n+ XY","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The operator is represented in memory by bit arrays (much denser than using byte arrays).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> p = P\"-IXYZ\";\n\njulia> p.nqubits, p.xz\n(4, UInt64[0x0000000000000006, 0x000000000000000c])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Views that give just the X or Z components of the xz bitarray are available through xview and zview.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> xview(P\"XYZI\")\n1-element view(::Vector{UInt64}, 1:1) with eltype UInt64:\n 0x0000000000000003","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The convenience methods xbit and zbit give you Bool (GF2) vectors.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> xbit(P\"XYZI\")\n4-element Vector{Bool}:\n 1\n 1\n 0\n 0","category":"page"},{"location":"stab-algebra-manual/#Stabilizers","page":"Manual","title":"Stabilizers","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"A Stabilizer object is a tableau of Pauli operators. When the tableau is meant to represent a (pure or mixed) stabilizer state, all of these operators should commute (but that is not enforced, rather Stabilizer is a generic tableau data structure). It is stored in memory as a phase list and a bit-matrix for X and Z components. It can be instantiated by an S string, or with a number of different constructors.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"tip: Stabilizers and Destabilizers\nIn many cases you probably would prefer to use the MixedDestabilizer data structure, as it caries a lot of useful additional information, like tracking rank and destabilizer operators. Stabilizer has mostly a pedagogical value, and it is also used for slightly faster simulation of a particular subset of Clifford operations. See also the data structures discussion page.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> S\"-XX\n +ZZ\"\n- XX\n+ ZZ\n\njulia> Stabilizer([P\"-XX\",P\"+ZZ\"])\n- XX\n+ ZZ\n\njulia> Stabilizer([0x2, 0x0],\n Bool[1 1;\n 0 0],\n Bool[0 0;\n 1 1])\n- XX\n+ ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Direct sums can be performed,","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> S\"-XX\" ⊗ S\"ZZ\"\n- XX__\n+ __ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Indexing operations are available, including fancy indexing. Be careful about how phase information gets transferred during sub-indexing.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XYZ\n -ZIX\n +XIZ\";\n\njulia> s[1]\n- XYZ\n\njulia> s[1,2]\n(true, true)\n\njulia> s[[3,1]]\n+ X_Z\n- XYZ\n\njulia> s[[3,1],[2]]\n+ _\n- Y","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Consistency at creation is not verified so nonsensical stabilizers can be created, both in terms of content and shape.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> S\"iX\n +Z\"\n+iX\n+ Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Similarly to the Pauli operators, a bit array representation is used.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZI\n -IZZ\"\n- XXX\n+ ZZ_\n- _ZZ\n\njulia> phases(s), tab(s).xzs\n(UInt8[0x02, 0x00, 0x02], UInt64[0x0000000000000007 0x0000000000000000 0x0000000000000000; 0x0000000000000000 0x0000000000000003 0x0000000000000006])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"And there are convenience functions that can extract the corresponding binary check matrix.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> stab_to_gf2(s)\n3×6 Matrix{Bool}:\n 1 1 1 0 0 0\n 0 0 0 1 1 0\n 0 0 0 0 1 1","category":"page"},{"location":"stab-algebra-manual/#Canonicalization-of-Stabilizers","page":"Manual","title":"Canonicalization of Stabilizers","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Canonicalization (akin to Gaussian elimination over F(2,2)) is implemented in the canonicalize! function. Besides the default canonicalization prescription, alternative ones are available as described in the canonicalization page.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZX\n +III\";\n\njulia> canonicalize!(s)\n+ YY_\n+ ZZX\n+ ___","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"If phases are inconsequential, the operations can be faster by not tracking and updating them.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZX\n +III\";\n\njulia> canonicalize!(s; phases=false)\n- YY_\n+ ZZX\n+ ___","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"These operations are in place (as customarily signified by \"!\").","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZX\n +III\";\n\njulia> canonicalize!(s; phases=false);\n\njulia> s\n- YY_\n+ ZZX\n+ ___","category":"page"},{"location":"stab-algebra-manual/#Projective-Measurements","page":"Manual","title":"Projective Measurements","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The project! function is used to perform generic projective measurements.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"tip: Single qubit projections\nIf you know your Pauli measurement operator acts on a single qubit, there are much faster projection functions available, discussed in the next section. Namely projectX!, projectY!, and projectZ!.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"To observe the effect of different projections, we will start with a GHZ state.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZI\n -IZZ\";","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The project! function returns the new stabilizer, the index where the anticommutation was detected, and the result of the projection (nothing being an undetermined result). For instance here we project on an operator that does not commute with all stabilizer generators.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"ZII\")[1]\n+ Z__\n+ ZZ_\n- _ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Importantly, when there is an undetermined result, we return nothing and leave the phase of the new stabilizer the same as the phase of the projection operator. If you want to perform a Monte Carlo simulation, you need to randomize the phase of the stabilizer at the anticommuting index yourself. For instance, one can do:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> newstate, anticomindex, result = project!(copy(s), P\"XII\")\n if isnothing(result)\n phases(newstate)[anticomindex] = rand([0x0,0x2])\n end\n result, anticomindex\n(nothing, 2)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Of course, this is a rather cumbersome way to run a simulation, so we also provide projectrand! which does the necessary randomization automatically, for cases where you do not need the fine grained control of project!.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"We can project on a commuting operator, hence no anticommuting terms (the index is zero), and the result is perfectly determined (-1, or in our convention to represent the phase, 0x2).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"-ZZI\")\n(Stabilizer 3×3, 0, 0x02)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"When the projection is consistent with the stabilizer (i.e. the measurement result is not nothing), this would trigger an expensive canonicalization procedure in order to calculate the measurement result (unless we are using more advanced data structures to represent the state, which are discussed later). If all you want to know is whether the projection is consistent with the stabilizer, but you do not care about the measurement result, you can skip the canonicalization and calculation of the result.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"-ZZI\", keep_result=false)\n(Stabilizer 3×3, 0, nothing)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Lastly, in either case, you can skip the calculation of the phases as well, if they are unimportant.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"ZZI\", phases=false)\n(Stabilizer 3×3, 0, 0x00)","category":"page"},{"location":"stab-algebra-manual/#Sparse-single-qubit-measurements","page":"Manual","title":"Sparse single-qubit measurements","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"In many circumstances only a single-qubit operator is being measured. In that case one should use the projectX!, projectY!, and projectZ! functions as they are much faster thanks to tracking only a single qubit. They have versions that randomize the phase as necessary as well: projectXrand!, projectYrand!, and projectZrand!.","category":"page"},{"location":"stab-algebra-manual/#Gate-like-interface","page":"Manual","title":"Gate-like interface","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"If you do not need all this boilerplate, and especially if you want to perform the randomization automatically, you can use the gate-like \"symbolic\" objects sMX, sMY, and sMZ, that perform the measurement and the necessary randomization of phase. If the measurement result is to be stored, you can use the Register structure that stores both stabilizer tableaux and bit values.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> state = Register(ghz(3), [false,false])\nRegister{Vector{UInt8}, Matrix{UInt64}}(Rank 3 stabilizer\n+ Z__\n+ _X_\n+ __X\n═════\n+ XXX\n+ ZZ_\n+ Z_Z\n═════\n, Bool[0, 0])\n\njulia> apply!(state, sMX(3,2)) # which qubit is measured and in which bit it is stored\nRegister{Vector{UInt8}, Matrix{UInt64}}(Rank 3 stabilizer\n+ Z__\n+ _X_\n+ Z_Z\n═════\n+ XXX\n+ ZZ_\n- __X\n═════\n, Bool[0, 1])\n\njulia> bitview(state)\n2-element Vector{Bool}:\n 0\n 1","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Or you can use the projectXrand!, projectYrand!, and projectZrand! if you prefer a function-call interface.","category":"page"},{"location":"stab-algebra-manual/#Partial-Traces","page":"Manual","title":"Partial Traces","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Partial trace (using traceout!) over even a single qubit might cause many of them to decohere due to entanglement.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> ghz = S\"XXX\n ZZ_\n _ZZ\";\n\njulia> traceout!(ghz, [1])\n+ _ZZ\n+ ___\n+ ___","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"This is somewhat more elegant when the datastructure being used explicitly supports mixed states.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> ghz = MixedStabilizer(S\"XXX\n ZZ_\n _ZZ\");\n\njulia> traceout!(ghz, [1])\n+ _ZZ","category":"page"},{"location":"stab-algebra-manual/#Generating-a-Pauli-Operator-with-Stabilizer-Generators","page":"Manual","title":"Generating a Pauli Operator with Stabilizer Generators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The generate! function attempts to generate a Pauli operator by multiplying together the operators belonging to a given stabilizer (or reports their independence). This particular function requires the stabilizer to be already canonicalized.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZI\n -IZZ\";\n\njulia> s = canonicalize!(s)\n- XXX\n- Z_Z\n- _ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"It modifies the Pauli operator in place, reducing it to identity if possible. The leftover phase is present to indicate if the phase itself could not have been canceled. The list of indices specifies which rows of the stabilizer were used to generated the desired Pauli operator.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> generate!(P\"XYY\", s)\n(- ___, [1, 3])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Phases can be neglected, for higher performance.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> generate!(P\"XYY\", s, phases=false)\n(+ ___, [1, 3])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"If the Pauli operator can not be generated by the stabilizer, nothing value is returned.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> generate!(P\"ZZZ\", s)\n\njulia> generate!(P\"XZX\", s)\n\njulia> generate!(P\"YYY\", s)","category":"page"},{"location":"stab-algebra-manual/#Clifford-Operators","page":"Manual","title":"Clifford Operators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The CliffordOperator structure represents a linear mapping between stabilizers (which should also preserve commutation relationships, but that is not checked at instantiation). These are n-qubit dense tableaux, representing an operation on n-qubit states. For single- or two-qubit gates, it is much more efficient to use small sparse symbolic clifford operators. A number of predefined Clifford operators are available, their name prefixed with t to mark them as dense tableaux.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> tHadamard\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\njulia> tPhase\nX₁ ⟼ + Y\nZ₁ ⟼ + Z\n\njulia> tCNOT\nX₁ ⟼ + XX\nX₂ ⟼ + _X\nZ₁ ⟼ + Z_\nZ₂ ⟼ + ZZ\n\njulia> tId1\nX₁ ⟼ + X\nZ₁ ⟼ + Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Chaining and tensor products are possible. Same for qubit permutations.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> tHadamard ⊗ tPhase\nX₁ ⟼ + Z_\nX₂ ⟼ + _Y\nZ₁ ⟼ + X_\nZ₂ ⟼ + _Z\n\njulia> tHadamard * tPhase\nX₁ ⟼ - Y\nZ₁ ⟼ + X\n\njulia> permute(tCNOT, [2,1])\nX₁ ⟼ + X_\nX₂ ⟼ + XX\nZ₁ ⟼ + ZZ\nZ₂ ⟼ + _Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"You can create custom Clifford operators with C-strings or with a list of Pauli operators.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> C\"-ZZ\n +_Z\n -X_\n +XX\"\nX₁ ⟼ - ZZ\nX₂ ⟼ + _Z\nZ₁ ⟼ - X_\nZ₂ ⟼ + XX\n\njulia> CliffordOperator([P\"-ZZ\", P\"_Z\", P\"-X_\", P\"XX\"])\nX₁ ⟼ - ZZ\nX₂ ⟼ + _Z\nZ₁ ⟼ - X_\nZ₂ ⟼ + XX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Naturally, the operators can be applied to stabilizer states. This includes high performance in-place operations (and the phase can be neglected with phases=false for faster computation).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> tCNOT * S\"X_\"\n+ XX\n\njulia> s = S\"X_\";\n\njulia> apply!(s,tCNOT)\n+ XX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Sparse applications where a small Clifford operator is applied only on a particular subset of a larger stabilizer is also possible, but in such circumstances it is useful to consider using symbolic operators too.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"Z_YX\";\n\njulia> apply!(s, tCNOT, [4,2]) # Apply the CNOT on qubits 4 and 2\n+ ZXYX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Pauli operators act as Clifford operators too (but they are rather boring, as they only change signs).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"XII\" * S\"ZXX\"\n- ZXX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Internally, the CliffordOperator structure simply stores the tableau representation of the operation.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The apply! function is efficiently multithreaded for CliffordOperators. To start multithreaded Julia, use julia -t where specifies the number of threads.","category":"page"},{"location":"stab-algebra-manual/#Symbolic-Clifford-Operators","page":"Manual","title":"Symbolic Clifford Operators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Much faster implementations for a number of common Clifford operators are available. They are stored as special named structs, instead of as a full tableau. These are the subtypes of AbstractSingleQubitOperator and AbstractTwoQubitOperator. Currently these are:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"using QuantumClifford # hide\nusing InteractiveUtils # hide\nsubtypes(QuantumClifford.AbstractSingleQubitOperator)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"subtypes(QuantumClifford.AbstractTwoQubitOperator)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Generally, they have the prefix s for symbolic/small/sparse. They are used slightly differently, as one needs to specify the qubits on which they act while instantiating them:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> sHadamard(2)\nsHadamard on qubit 2\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\njulia> sHadamard(2)*S\"XXX\"\n+ XZX\n\njulia> sCNOT(2,3)*S\"XYY\"\n- XXZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The apply! function is efficiently multithreaded for these symbolic operators as well. To start multithreaded Julia, use julia -t where specifies the number of threads.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Symbolic projectors on single qubits also exist: sMX, sMY, sMZ. When used with the Register state representation, they can store the measurement results in the corresponding classical register.","category":"page"},{"location":"stab-algebra-manual/#Destabilizers","page":"Manual","title":"Destabilizers","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Slightly abusing the name: What we call \"destabilizers\" here is a stabilizer and its destabilizing operators saved together. They are implemented with the Destabilizer object and are initialized from a stabilizer.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s=S\"-XXX\n -ZZI\n +IZZ\";\n\njulia> d = Destabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n- XXX\n- ZZ_\n- Z_Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"They have convenience methods to extract only the stabilizer and destabilizer pieces:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> stabilizerview(d)\n- XXX\n- ZZ_\n- Z_Z\n\njulia> destabilizerview(d)\n+ Z__\n+ _X_\n+ __X","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Importantly commuting projections are much faster when tracking the destabilizer as canonicalization is not necessary (an mathcalO(n^2) complexity because it avoids the expensive mathcalO(n^3) canonicalization operation).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(d,P\"ZZI\")\n(Destablizer 3×3, 0, 0x02)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Non-commuting projections are just as fast as when using only stabilizers.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(d,P\"ZZZ\")\n(Destablizer 3×3, 1, nothing)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Clifford operations can be applied the same way they are applied to stabilizers.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> apply!(d,tCNOT⊗tHadamard)\n𝒟ℯ𝓈𝓉𝒶𝒷\n- X_Z\n+ XXZ\n+ X__\n𝒮𝓉𝒶𝒷━\n+ _ZX\n- _Z_\n- Z_X","category":"page"},{"location":"stab-algebra-manual/#Mixed-States","page":"Manual","title":"Mixed States","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Both the Stabilizer and Destabilizer structures have more general forms that enable work with mixed stabilizer states. They are the MixedStabilizer and MixedDestabilizer structures, described in Mixed States. More information that can be seen in the data structures page, which expands upon the algorithms available for each structure.","category":"page"},{"location":"stab-algebra-manual/#Random-States-and-Circuits","page":"Manual","title":"Random States and Circuits","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"random_clifford, random_stabilizer, and enumerate_cliffords can be used for the generation of random states.","category":"page"},{"location":"tutandpub/#tutandpub","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"","category":"section"},{"location":"tutandpub/","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"This list has a number of notebooks with tutorials, examples, and reproduction of published results (some of these results originally obtained with this very library).","category":"page"},{"location":"tutandpub/#On-the-topic-of-explicit-use-of-the-Tableaux-formalism-for-Stabilizer-states","page":"Tutorials and Publications","title":"On the topic of explicit use of the Tableaux formalism for Stabilizer states","text":"","category":"section"},{"location":"tutandpub/","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"Quantum coding with low-depth random circuits reproducing results from (Gullans et al., 2021). view on nbviewer.jupyter.org","category":"page"},{"location":"tutandpub/#On-the-Monte-Carlo-and-Perturbative-Expansions-for-**Noisy**-Clifford-circuits","page":"Tutorials and Publications","title":"On the Monte Carlo and Perturbative Expansions for Noisy Clifford circuits","text":"","category":"section"},{"location":"tutandpub/","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"In-depth study of multi-partite entanglement purification circuits reproducing results from (Krastanov et al., 2020). view on nbviewer.jupyter.org\nComparing the Monte Carlo and Perturbative method for noisy circuit simulations. view on nbviewer.jupyter.org\nShowcasing symbolic perturbative expansions of noisy circuits. view on nbviewer.jupyter.org","category":"page"},{"location":"noisycircuits_API/#Full-API-(autogenerated)","page":"API","title":"Full API (autogenerated)","text":"","category":"section"},{"location":"noisycircuits_API/","page":"API","title":"API","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_API/","page":"API","title":"API","text":"Modules = [QuantumClifford.Experimental.NoisyCircuits]\nPrivate = false","category":"page"},{"location":"noisycircuits_API/#QuantumClifford.Experimental.NoisyCircuits.ConditionalGate","page":"API","title":"QuantumClifford.Experimental.NoisyCircuits.ConditionalGate","text":"A conditional gate that either performs truegate or falsegate, depending on the value of controlbit.\n\n\n\n\n\n","category":"type"},{"location":"noisycircuits_API/#QuantumClifford.Experimental.NoisyCircuits.DecisionGate","page":"API","title":"QuantumClifford.Experimental.NoisyCircuits.DecisionGate","text":"A conditional gate that performs one of the gates, depending on the output of decisionfunction applied to the entire classical bit register.\n\n\n\n\n\n","category":"type"},{"location":"noisycircuits_API/#QuantumClifford.Experimental.NoisyCircuits.NoisyBellMeasurement","page":"API","title":"QuantumClifford.Experimental.NoisyCircuits.NoisyBellMeasurement","text":"A Bell measurement in which each of the measured qubits has a chance to have flipped.\n\n\n\n\n\n","category":"type"},{"location":"noisycircuits_perturb/#noisycircuits_perturb","page":"Perturbative Expansions","title":"Perturbative expansions for simulating noisy Clifford circuits","text":"","category":"section"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\n using Quantikz\nend","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"Import with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"This module enables the simulation of noisy Clifford circuits through a perturbative expansion in the noise parameter (assuming the noise is small). Instead of simulating many Monte Carlo trajectories, only the leading order trajectories are exhaustively enumerated and simulated.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"Here is an example of a purification circuit (the same circuit seen in the Monte Carlo example)","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\ngood_bell_state = S\"XX\n ZZ\"\ncanonicalize_rref!(good_bell_state)\ninitial_state = MixedDestabilizer(good_bell_state⊗good_bell_state)\n\ng1 = sCNOT(1,3) # CNOT between qubit 1 and qubit 3 (both with Alice)\ng2 = sCNOT(2,4) # CNOT between qubit 2 and qubit 4 (both with Bob)\nm = BellMeasurement([sMX(3),sMX(4)]) # Bell measurement on qubit 3 and 4\nv = VerifyOp(good_bell_state,[1,2]) # Verify that qubit 1 and 2 indeed form a good Bell pair\nepsilon = 0.01 # The error rate\nn = NoiseOpAll(UnbiasedUncorrelatedNoise(epsilon))\n\n# This circuit performs a depolarization at rate `epsilon` to all qubits,\n# then bilater CNOT operations\n# then a Bell measurement\n# followed by checking whether the final result indeed corresponds to the correct Bell pair.\ncircuit = [n,g1,g2,m,v]\n\npetrajectories(initial_state, circuit)","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification.","category":"page"},{"location":"noisycircuits_perturb/#Symbolic-expansions","page":"Perturbative Expansions","title":"Symbolic expansions","text":"","category":"section"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"The perturbative expansion method works with symbolic variables as well. One can use any of the symbolic libraries available in Julia and simply plug symbolic parameters in lieu of numeric parameters. A detailed example is available as a Jupyter notebook.","category":"page"},{"location":"noisycircuits_perturb/#Interface-for-custom-operations","page":"Perturbative Expansions","title":"Interface for custom operations","text":"","category":"section"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"applyop_branches!(s::T, g::Operation; max_order=1)::Vector{Tuple{T,Symbol,Real,Int}} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation, the Real is the probability for that branch, and the Int is the order of that branch.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"There is also applynoise_branches! which is convenient for use in NoisyGate, but you can also just make up your own noise operator simply by implementing applyop_branches! for it.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"You can also consult the list of implemented operators.","category":"page"},{"location":"graphs/#Graph-States","page":"Graph States","title":"Graph States","text":"","category":"section"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"warning: The `graphstate` API is not considered stable\ngraphstate returns a lot of information about encoding a given stabilizer state in a graph. A different API is being designed that streamlines the work with graph states.","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Conversion to and from graph states is possible.","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Consider a GHZ state:","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"using QuantumClifford # hide\nghz(4)","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"It can be converted to a graph state with graphstate","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"graphstate(ghz(4))[1]","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"using Random; Random.seed!(1); using QuantumClifford, GraphMakie, CairoMakie;\nf = Figure(size=(200,200))\na = Axis(f[1,1])\ngraphplot!(a,graphstate(ghz(4))[1])\nhidedecorations!(a); hidespines!(a)\na.aspect = DataAspect()\nsave(\"ghz4graph.png\", f); nothing","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"(Image: )","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Notice that the initial GHZ state was not in the typical graph state form. We can see that explicitly by converting back and forth between the two forms:","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"julia> using Graphs, QuantumClifford\n\njulia> ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ\n\njulia> Stabilizer(Graph(ghz(4)))\n+ XZZZ\n+ ZX__\n+ Z_X_\n+ Z__X","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"There is a set of single-qubit operations that can convert any stabilizer tableau into a state representable as a graph. These transformations are performed implicitly by the Graph constructor when converting from a Stabilizer. If you need the explicit transformation you can use the graphstate function that specifies which qubits require a Hadamard, Inverse Phase, or Phase Flip gate. The graph_gatesequence or graph_gate helper functions can be used to generate the exact operations:","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"julia> s = ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ\n\njulia> g, h_idx, ip_idx, z_idx = graphstate(s);\n\njulia> gate = graph_gate(h_idx, ip_idx, z_idx, nqubits(s))\nX₁ ⟼ + X___\nX₂ ⟼ + _Z__\nX₃ ⟼ + __Z_\nX₄ ⟼ + ___Z\nZ₁ ⟼ + Z___\nZ₂ ⟼ + _X__\nZ₃ ⟼ + __X_\nZ₄ ⟼ + ___X\n\njulia> canonicalize!(apply!(s,gate)) == canonicalize!(Stabilizer(g))\ntrue","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"These converters also provides for a convenient way to create graph and cluster states, by using the helper constructors provided in Graphs.jl.","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"julia> Stabilizer(grid([4,1])) # Linear cluster state\n+ XZ__\n+ ZXZ_\n+ _ZXZ\n+ __ZX\n\njulia> Stabilizer(grid([2,2])) # Small 2D cluster state\n+ XZZ_\n+ ZX_Z\n+ Z_XZ\n+ _ZZX","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Graphs are represented with the Graphs.jl package and plotting can be done both in Plots.jl and Makie.jl (with GraphMakie).","category":"page"},{"location":"ECC_API/#Full-ECC-API-(autogenerated)","page":"API","title":"Full ECC API (autogenerated)","text":"","category":"section"},{"location":"ECC_API/","page":"API","title":"API","text":"Modules = [QuantumClifford.ECC]\nPrivate = false","category":"page"},{"location":"ECC_API/#QuantumClifford.ECC.CSS","page":"API","title":"QuantumClifford.ECC.CSS","text":"An arbitrary CSS error correcting code defined by its X and Z checks.\n\njulia> CSS([0 1 1 0; 1 1 0 0], [1 1 1 1]) |> parity_checks\n+ _XX_\n+ XX__\n+ ZZZZ\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.CircuitCode","page":"API","title":"QuantumClifford.ECC.CircuitCode","text":"CircuitCode is defined by a given encoding circuit circ.\n\nn: qubit number\ncirc: the encoding circuit\nencode_qubits: the qubits to be encoded\n\nSee also: random_all_to_all_circuit_code, random_brickwork_circuit_code\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Cleve8","page":"API","title":"QuantumClifford.ECC.Cleve8","text":"A pedagogical example of a quantum error correcting [8,3] code used in (Cleve and Gottesman, 1997).\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.CommutationCheckECCSetup","page":"API","title":"QuantumClifford.ECC.CommutationCheckECCSetup","text":"Configuration for ECC evaluator that does not simulate any ECC circuits, rather it simply checks the commutation of the parity check and the Pauli error.\n\nThis is much faster than any other simulation method, but it is incapable of noisy-circuit simulations and thus useless for fault-tolerance studies.\n\nSee also: NaiveSyndromeECCSetup, ShorSyndromeECCSetup\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Concat","page":"API","title":"QuantumClifford.ECC.Concat","text":"Concat(c₁, c₂) is a code concatenation of two quantum codes (Knill and Laflamme, 1996).\n\nThe inner code c₁ and the outer code c₂. The construction is the following: replace each qubit in code c₂ with logical qubits encoded by code c₁. The resulting code will have n = n₁ × n₂ qubits and k = k₁ × k₂ logical qubits.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Gottesman","page":"API","title":"QuantumClifford.ECC.Gottesman","text":"The family of [[2ʲ, 2ʲ - j - 2, 3]] Gottesman codes, also known as quantum Hamming codes, as described in Gottesman's 1997 PhD thesis and in (Gottesman, 1996).\n\nYou might be interested in consulting (Yu et al., 2013) and (Chao and Reichardt, 2017) as well.\n\nThe ECC Zoo has an entry for this family\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.NaiveSyndromeECCSetup","page":"API","title":"QuantumClifford.ECC.NaiveSyndromeECCSetup","text":"Configuration for ECC evaluator that runs the simplest syndrome measurement circuit.\n\nThe circuit is being simulated (as opposed to doing only a quick commutation check). This circuit would give poor performance if there is non-zero gate noise.\n\nSee also: CommutationCheckECCSetup, ShorSyndromeECCSetup\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.QuantumReedMuller","page":"API","title":"QuantumClifford.ECC.QuantumReedMuller","text":"The family of [[2ᵐ - 1, 1, 3]] CSS Quantum-Reed-Muller codes, as discovered by Steane in his 1999 paper (Steane, 1999).\n\nQuantum codes are constructed from shortened Reed-Muller codes RM(1, m), by removing the first row and column of the generator matrix Gₘ. Similarly, we can define truncated dual codes RM(m - 2, m) using the generator matrix Hₘ (Anderson et al., 2014). The quantum Reed-Muller codes QRM(m) derived from RM(1, m) are CSS codes. \n\nGiven that the stabilizers of the quantum code are defined through the generator matrix of the classical code, the minimum distance of the quantum code corresponds to the minimum distance of the dual classical code, which is d = 3, thus it can correct any single qubit error. Since one stabilizer from the original and one from the dual code are removed in the truncation process, the code parameters are [[2ᵐ - 1, 1, 3]].\n\nYou might be interested in consulting (Anderson et al., 2014) and (Campbell et al., 2012) as well.\n\nThe ECC Zoo has an entry for this family.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.ShorSyndromeECCSetup","page":"API","title":"QuantumClifford.ECC.ShorSyndromeECCSetup","text":"Configuration for ECC evaluators that simulate the Shor-style syndrome measurement (without a flag qubit).\n\nThe simulated circuit includes:\n\nperfect noiseless encoding (encoding and its fault tolerance are not being studied here)\none round of \"memory noise\" after the encoding but before the syndrome measurement\nperfect preparation of entangled ancillary qubits\nnoisy Shor-style syndrome measurement (only two-qubit gate noise)\nnoiseless \"logical state measurement\" (providing the comparison data when evaluating the decoder)\n\nSee also: CommutationCheckECCSetup, NaiveSyndromeECCSetup\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Surface","page":"API","title":"QuantumClifford.ECC.Surface","text":"The planar surface code refers to the code (Kitaev, 2003) in a 2D lattice with open boundaries.\n\nIllustration of a 3×2 surface code, where qubits are located on the edges:\n\n|---1--(Z)--2---|---3---|\n| (X) 7 8 o\n|---4---|---5---|---6---|\n| o o o\n| | | |\n\nThe surface code has open boundary conditions, unlike the toric code. To this end, we remove qubits (denoted by \"o\") and parity checks on the right and bottom sides.\n\nFaces like (1,4,7) have X checks, and crosses like (1,2,7) have Z checks. Due to the removal of the bottom and right sides, we have some 3-qubit checks on the boundaries.\n\njulia> parity_checks(Surface(3,2))\n+ X__X__X_\n+ _X__X_XX\n+ __X__X_X\n+ ZZ____Z_\n+ _ZZ____Z\n+ ___ZZ_Z_\n+ ____ZZ_Z\n\nMore information can be seen in (Fowler et al., 2012).\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.TableDecoder","page":"API","title":"QuantumClifford.ECC.TableDecoder","text":"A simple look-up table decoder for error correcting codes.\n\nThe lookup table contains only weight=1 errors, thus it is small, but at best it provides only for distance=3 decoding.\n\nThe size of the lookup table would grow exponentially quickly for higher distances.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Toric","page":"API","title":"QuantumClifford.ECC.Toric","text":"The Toric code (Kitaev, 2003).\n\nIllustration of a 2x2 toric code, where qubits are located on the edges:\n\n|--1-(Z)-2--|\n| (X) 5 6\n|--3--|--4--|\n| 7 8\n| | |\n\nIt is important to note that the toric code has periodic boundary conditions, which means that the top and bottom sides are essentially glued together, as are the left and right sides.\n\nFaces like (1,3,5,6) have X checks, and crosses like (1,2,5,7) have Z checks.\n\njulia> parity_checks(Toric(2,2))\n+ X_X_XX__\n+ _X_XXX__\n+ X_X___XX\n+ ZZ__Z_Z_\n+ ZZ___Z_Z\n+ __ZZZ_Z_\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.BeliefPropDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.BeliefPropDecoder","text":"A simple Belief Propagation decoder built around tools from LDPCDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.BitFlipDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.BitFlipDecoder","text":"An Iterative Bitflip decoder built around tools from LDPCDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.LPCode-Tuple","page":"API","title":"QuantumClifford.ECC.LPCode","text":"Lifted product codes ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nImplemented as a package extension with Hecke. Check the QuantumClifford documentation for more details on that extension.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.LiftedCode-Tuple","page":"API","title":"QuantumClifford.ECC.LiftedCode","text":"Classical codes lifted over a group algebra, used for lifted product code construction ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nImplemented as a package extension with Hecke. Check the QuantumClifford documentation for more details on that extension.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.PyBeliefPropDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.PyBeliefPropDecoder","text":"A Belief Propagation decoder built around tools from the python package ldpc available from the julia package PyQDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.PyBeliefPropOSDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.PyBeliefPropOSDecoder","text":"A Belief Propagation decoder with ordered statistics decoding, built around tools from the python package ldpc available from the julia package PyQDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.PyMatchingDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.PyMatchingDecoder","text":"A perfect matching decoder built around tools from the python package pymatching available from the julia package PyQDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.bicycle_codes","page":"API","title":"QuantumClifford.ECC.bicycle_codes","text":"Implemented in a package extension with Hecke.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.code_k-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.ECC.code_k","text":"The number of logical qubits in a code.\n\nNote that when redundant rows exist in the parity check matrix, the number of logical qubits code_k(c) will be greater than code_n(c) - code_s(c), where the difference equals the redundancy.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.code_n","page":"API","title":"QuantumClifford.ECC.code_n","text":"The number of physical qubits in a code.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.code_s","page":"API","title":"QuantumClifford.ECC.code_s","text":"The number of stabilizer checks in a code. They might not be all linearly independent, thus code_s >= code_n-code_k. For the number of linearly independent checks you can use LinearAlgebra.rank.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.distance","page":"API","title":"QuantumClifford.ECC.distance","text":"The distance of a code.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.evaluate_decoder-Tuple{QuantumClifford.ECC.AbstractSyndromeDecoder, QuantumClifford.ECC.AbstractECCSetup, Int64}","page":"API","title":"QuantumClifford.ECC.evaluate_decoder","text":"Evaluate the performance of a given decoder (e.g. TableDecoder) and a given style of running an ECC code (e.g. ShorSyndromeECCSetup)\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.evaluate_decoder-Tuple{QuantumClifford.ECC.AbstractSyndromeDecoder, Vararg{Any, 5}}","page":"API","title":"QuantumClifford.ECC.evaluate_decoder","text":"Evaluate the performance of an error-correcting circuit.\n\nThis method requires you give the circuit that performs both syndrome measurements and (probably noiseless) logical state measurements. The faults matrix that translates an error vector into corresponding logical errors is necessary as well.\n\nThis is a relatively barebones method that assumes the user prepares necessary circuits, etc. It is a method that is used internally by more user-frienly methods providing automatic conversion of codes and noise models to the necessary noisy circuits.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.faults_matrix-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.ECC.faults_matrix","text":"Error-to-logical-observable map (a.k.a. fault matrix) of a code.\n\nFor a code with n physical qubits and k logical qubits this function returns a 2k × 2n binary matrix O such that O[i,j] is true if the logical observable of index i is flipped by the single physical qubit error of index j. Indexing is such that:\n\nO[1:k,:] is the error-to-logical-X-observable map (logical X observable, i.e. triggered by logical Z errors)\nO[k+1:2k,:] is the error-to-logical-Z-observable map\nO[:,1:n] is the X-physical-error-to-logical-observable map\nO[n+1:2n,:] is the Z-physical-error-to-logical-observable map\n\nE.g. for k=1, n=10, then if O[2,5] is true, then the logical Z observable is flipped by a X₅ error; and if O[1,12] is true, then the logical X observable is flipped by a Z₂ error.\n\nOf note is that there is a lot of freedom in choosing the logical operations! A logical operator multiplied by a stabilizer operator is still a logical operator. Similarly there is a different fault matrix for each choice of logical operators. But once the logical operators are picked, the fault matrix is fixed.\n\nBelow we show an example that uses the Shor code. While it is not the smallest code, it is a convenient choice to showcase the importance of the fault matrix when dealing with degenerate codes where a correction operation and an error do not need to be the same.\n\nFirst, consider a single-qubit error, potential correction operations, and their effect on the Shor code:\n\njulia> using QuantumClifford.ECC: faults_matrix, Shor9\n\njulia> state = MixedDestabilizer(Shor9())\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n+ _X_______\n+ __X______\n+ ____X____\n+ _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n+ ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n+ XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\njulia> err_Z₁ = single_z(9,1) # the error we will simulate\n+ Z________\n\njulia> cor_Z₂ = single_z(9,2) # the correction operation we will perform\n+ _Z_______\n\njulia> err_Z₁ * state # observe that one of the syndrome bits is now flipped\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n+ _X_______\n+ __X______\n+ ____X____\n+ _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n+ ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n- XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\njulia> cor_Z₂ * err_Z₁ * state # we are back to a good code state\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n- _X_______\n+ __X______\n+ ____X____\n+ _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n+ ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n+ XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\njulia> bad_Z₆Z₉ = single_z(9,6) * single_z(9,9) # a different \"correction\" operation\n+ _____Z__Z\n\njulia> bad_Z₆Z₉ * err_Z₁ * state # the syndrome is trivial, but now we have a logical error\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n+ _X_______\n+ __X______\n+ ____X____\n- _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n- ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n+ XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\nThe success of cor_Z₂ and the failure of bad_Z₆Z₉ can be immediately seen through the fault matrix, as the wrong \"correction\" does not result in the same logical flips ad the error:\n\njulia> O = faults_matrix(Shor9())\n2×18 BitMatrix:\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1\n 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0\n\njulia> O * stab_to_gf2(err_Z₁)\n2-element Vector{Int64}:\n 0\n 0\n\njulia> O * stab_to_gf2(cor_Z₂)\n2-element Vector{Int64}:\n 0\n 0\n\njulia> O * stab_to_gf2(bad_Z₆Z₉)\n2-element Vector{Int64}:\n 1\n 0\n\nWhile its use in this situation is rather contrived, the fault matrix is incredibly useful when running large scale simulations in which we want a separate fast error sampling process, (e.g. with Pauli frames) and a syndrome decoding process, without coupling between them. We just gather all our syndrome measurement and logical observables from the Pauli frame simulations, and then use them with the fault matrix in the syndrome decoding simulation.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.generalized_bicycle_codes","page":"API","title":"QuantumClifford.ECC.generalized_bicycle_codes","text":"Implemented in a package extension with Hecke.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.iscss-Union{Tuple{Type{T}}, Tuple{T}} where T<:QuantumClifford.ECC.AbstractECC","page":"API","title":"QuantumClifford.ECC.iscss","text":"Check if the code is CSS.\n\nReturn nothing if unknown from the type.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.isdegenerate","page":"API","title":"QuantumClifford.ECC.isdegenerate","text":"Check if the code is degenerate with respect to a given set of error or with respect to all \"up to d physical-qubit\" errors (defaulting to d=1).\n\njulia> using QuantumClifford.ECC\n\njulia> isdegenerate(Shor9(), [single_z(9,1), single_z(9,2)])\ntrue\n\njulia> isdegenerate(Shor9(), [single_z(9,1), single_x(9,1)])\nfalse\n\njulia> isdegenerate(Steane7(), 1)\nfalse\n\njulia> isdegenerate(Steane7(), 2)\ntrue\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.naive_encoding_circuit-Tuple{Any}","page":"API","title":"QuantumClifford.ECC.naive_encoding_circuit","text":"Encoding physical qubits into a larger logical code.\n\nThe initial physical qubits to be encoded have to be at indices n-k+1:n.\n\ninfo: Encoding circuits are not fault-tolerant\nEncoding circuits are not fault-tolerant, and thus should not be used in practice. Instead, you should measure the stabilizers of the code and the logical observables, thus projecting into the code space (which can be fault-tolerant).\n\nThe canonicalization operation performed on the code may permute the qubits (see canonicalize_gott!). That permutation is corrected for with SWAP gates by default (controlled by the undoperm keyword argument).\n\nBased on (Cleve and Gottesman, 1997) and (Gottesman, 1997), however it seems the published algorithm has some errors. Consult the erratum, as well as the more recent (Grassl, 2002) and (Grassl, 2011), and be aware that this implementation also uses H instead of Z gates.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.naive_syndrome_circuit","page":"API","title":"QuantumClifford.ECC.naive_syndrome_circuit","text":"Generate the non-fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.\n\nUse the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts.\n\nReturns the circuit, the number of ancillary qubits that were added, and a list of bit indices that will store the measurement results.\n\nSee also: shor_syndrome_circuit\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.parity_checks","page":"API","title":"QuantumClifford.ECC.parity_checks","text":"Parity check tableau of a code.\n\nSee also: parity_checks_x and parity_checks_z\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.parity_checks_x-Tuple{QuantumClifford.ECC.AbstractECC}","page":"API","title":"QuantumClifford.ECC.parity_checks_x","text":"Parity check boolean matrix of a code (only the X entries in the tableau, i.e. the checks for Z errors).\n\nOnly CSS codes have this method.\n\nSee also: parity_checks\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.parity_checks_z-Tuple{QuantumClifford.ECC.AbstractECC}","page":"API","title":"QuantumClifford.ECC.parity_checks_z","text":"Parity check boolean matrix of a code (only the Z entries in the tableau, i.e. the checks for X errors).\n\nOnly CSS codes have this method.\n\nSee also: parity_checks\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.random_all_to_all_circuit_code","page":"API","title":"QuantumClifford.ECC.random_all_to_all_circuit_code","text":"Random all-to-all Clifford circuit code (Brown and Fawzi, Jul 2013).\n\nThe code of n qubits is generated by an all-to-all random Clifford circuit of ngates gates that encodes a subset of qubits encode_qubits into logical qubits.\n\nBecause of the random picking, the size of encode_qubits is the only thing that matters for the code, referred to as k.\n\nSee also: random_all_to_all_clifford_circuit, CircuitCode\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.random_brickwork_circuit_code","page":"API","title":"QuantumClifford.ECC.random_brickwork_circuit_code","text":"Random brickwork Clifford circuit code (Brown and Fawzi, Jul 2013).\n\nThe code is generated by a brickwork random Clifford circuit of nlayers layers that encodes a subset of qubits encode_qubits into logical qubits.\n\nSee also: random_brickwork_clifford_circuit, CircuitCode\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.rate-Tuple{Any}","page":"API","title":"QuantumClifford.ECC.rate","text":"The rate of a code.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.shor_syndrome_circuit","page":"API","title":"QuantumClifford.ECC.shor_syndrome_circuit","text":"Generate the Shor fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.\n\nUse the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts. Ancillary qubits\n\nReturns:\n\nThe ancillary cat state preparation circuit.\nThe Shor syndrome measurement circuit.\nThe number of ancillary qubits that were added.\nThe list of bit indices that store the final measurement results.\n\nSee also: naive_syndrome_circuit\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.two_block_group_algebra_codes","page":"API","title":"QuantumClifford.ECC.two_block_group_algebra_codes","text":"Implemented in a package extension with Hecke.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#Implemented-in-an-extension-requiring-Hecke.jl","page":"API","title":"Implemented in an extension requiring Hecke.jl","text":"","category":"section"},{"location":"ECC_API/","page":"API","title":"API","text":"Modules = [QuantumCliffordHeckeExt]\nPrivate = true","category":"page"},{"location":"ECC_API/#QuantumCliffordHeckeExt.LPCode","page":"API","title":"QuantumCliffordHeckeExt.LPCode","text":"struct LPCode <: QuantumClifford.ECC.AbstractECC\n\nLifted product codes ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nA lifted product code is defined by the hypergraph product of a base matrices A and the conjugate of another base matrix B'. Here, the hypergraph product is taken over a group algebra, of which the base matrices are consisting.\n\nThe binary parity check matrix is obtained by applying repr to each element of the matrix resulted from the hypergraph product, which is mathematically a linear map from each group algebra element to a binary matrix.\n\nConstructors\n\nMultiple constructors are available:\n\nTwo base matrices of group algebra elements.\nTwo lifted codes, whose base matrices are for quantum code construction.\nTwo base matrices of group elements, where each group element will be considered as a group algebra element by assigning a unit coefficient.\nTwo base matrices of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.\n\nExamples\n\nA [[882, 24, d ≤ 24]] code from Appendix B of (Roffe et al., 2023). We use the 1st constructor to generate the code and check its length and dimension. During the construction, we do arithmetic operations to get the group algebra elements in base matrices A and B. Here x is the generator of the group algebra, i.e., offset-1 cyclic permutation, and GA(1) is the unit element.\n\njulia> import Hecke: group_algebra, GF, abelian_group, gens; import LinearAlgebra: diagind;\n\njulia> l = 63; GA = group_algebra(GF(2), abelian_group(l)); x = gens(GA)[];\n\njulia> A = zeros(GA, 7, 7);\n\njulia> A[diagind(A)] .= x^27;\n\njulia> A[diagind(A, -1)] .= x^54;\n\njulia> A[diagind(A, 6)] .= x^54;\n\njulia> A[diagind(A, -2)] .= GA(1);\n\njulia> A[diagind(A, 5)] .= GA(1);\n\njulia> B = reshape([1 + x + x^6], (1, 1));\n\njulia> c1 = LPCode(A, B);\n\njulia> code_n(c1), code_k(c1)\n(882, 24)\n\nA [[175, 19, d ≤ 0]] code from Eq. (18) in Appendix A of (Raveendran et al., 2022), following the 4th constructor.\n\njulia> base_matrix = [0 0 0 0; 0 1 2 5; 0 6 3 1]; l = 7;\n\njulia> c2 = LPCode(base_matrix, l .- base_matrix', l);\n\njulia> code_n(c2), code_k(c2)\n(175, 19)\n\nCode subfamilies and convenience constructors for them\n\nWhen the base matrices of the LPCode are 1×1, the code is called a two-block group-algebra code two_block_group_algebra_codes.\nWhen the base matrices of the LPCode are 1×1 and their elements are sums of cyclic permutations, the code is called a generalized bicycle code generalized_bicycle_codes.\nWhen the two matrices are adjoint to each other, the code is called a bicycle code bicycle_codes.\n\nThe representation function\n\nWe use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.\n\nWe also accept a custom representation function as detailed in LiftedCode.\n\nSee also: LiftedCode, two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes.\n\nA::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the first base matrix of the code, whose elements are in a group algebra.\nB::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the second base matrix of the code, whose elements are in the same group algebra as A.\nGA::Hecke.GroupAlgebra: the group algebra for which elements in A and B are from.\nrepr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumCliffordHeckeExt.LiftedCode","page":"API","title":"QuantumCliffordHeckeExt.LiftedCode","text":"struct LiftedCode <: QuantumClifford.ECC.ClassicalCode\n\nClassical codes lifted over a group algebra, used for lifted product code construction ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nThe parity-check matrix is constructed by applying repr to each element of A, which is mathematically a linear map from a group algebra element to a binary matrix. The size of the parity check matrix will enlarged with each element of A being inflated into a matrix. The procedure is called a lift (Panteleev and Kalachev, Jun 2022).\n\nConstructors\n\nA lifted code can be constructed via the following approaches:\n\nA matrix of group algebra elements.\nA matrix of group elements, where a group element will be considered as a group algebra element by assigning a unit coefficient.\nA matrix of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.\n\nThe default GA is the group algebra of A[1, 1], the default representation repr is the permutation representation.\n\nThe representation function repr\n\nWe use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.\n\nWe also accept a custom representation function (the repr field of the constructor). Whatever the representation, the matrix elements need to be convertible to Integers (e.g. permit lift(ZZ, ...)). Such a customization would be useful to reduce the number of bits required by the code construction.\n\nFor example, if we use a D4 group for lifting, our default representation will be 8×8 permutation matrices, where 8 is the group's order. However, we can find a 4×4 matrix representation for the group, e.g. by using the typical 2×2 representation and converting it into binary representation by replacing \"1\" with the Pauli I, and \"-1\" with the Pauli X matrix.\n\nSee also: LPCode.\n\nA::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the base matrix of the code, whose elements are in a group algebra.\nGA::Hecke.GroupAlgebra: the group algebra for which elements in A are from.\nrepr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumCliffordHeckeExt.LiftedCode-Tuple{Matrix{Hecke.GroupAlgebraElem{Nemo.FqFieldElem, <:Hecke.GroupAlgebra}}}","page":"API","title":"QuantumCliffordHeckeExt.LiftedCode","text":"LiftedCode constructor using the default GF(2) representation (coefficients converted to a permutation matrix by representation_matrix provided by Hecke).\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#Base.adjoint-Union{Tuple{Hecke.GroupAlgebraElem{T}}, Tuple{T}} where T","page":"API","title":"Base.adjoint","text":"Compute the adjoint of a group algebra element. The adjoint is defined as the conjugate of the element in the group algebra, i.e. the inverse of the element in the associated group.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.bicycle_codes-Tuple{Array{Int64}, Int64}","page":"API","title":"QuantumClifford.ECC.bicycle_codes","text":"Bicycle codes are a special case of generalized bicycle codes, where a and b are conjugate to each other. The order of the cyclic group is l, and the shifts a_shifts and b_shifts are reverse to each other.\n\nSee also: two_block_group_algebra_codes, generalized_bicycle_codes.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.generalized_bicycle_codes-Tuple{Array{Int64}, Array{Int64}, Int64}","page":"API","title":"QuantumClifford.ECC.generalized_bicycle_codes","text":"Generalized bicycle codes, which are a special case of 2GBA codes (and therefore of lifted product codes). Here the group is chosen as the cyclic group of order l, and the base matrices a and b are the sum of the group algebra elements corresponding to the shifts a_shifts and b_shifts.\n\nSee also: two_block_group_algebra_codes, bicycle_codes.\n\nA [[254, 28, 14 ≤ d ≤ 20]] code from (A1) in Appendix B of (Panteleev and Kalachev, 2021).\n\njulia> c = generalized_bicycle_codes([0, 15, 20, 28, 66], [0, 58, 59, 100, 121], 127);\n\njulia> code_n(c), code_k(c)\n(254, 28)\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.two_block_group_algebra_codes-Tuple{Hecke.GroupAlgebraElem, Hecke.GroupAlgebraElem}","page":"API","title":"QuantumClifford.ECC.two_block_group_algebra_codes","text":"Two-block group algebra (2GBA) codes, which are a special case of lifted product codes from two group algebra elements a and b, used as 1x1 base matrices.\n\nSee also: LPCode, generalized_bicycle_codes, bicycle_codes\n\n\n\n\n\n","category":"method"},{"location":"allops/#all-operations","page":"All Gates","title":"Operations - Gates, Measurements, and More","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"DocTestSetup = quote\n using QuantumClifford\n using StableRNGs\n rng = StableRNG(42)\nend","category":"page"},{"location":"allops/#Operations","page":"All Gates","title":"Operations","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Acting on quantum states can be performed either:","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"In a \"linear algebra\" language where unitaries, measurements, and other operations have separate interfaces. This is an explicitly deterministic lower-level interface, which provides a great deal of control over how tableaux are manipulated. See the Stabilizer Tableau Algebra Manual as a primer on these approaches.\nOr in a \"circuit\" language, where the operators (and measurements and noise) are represented as circuit gates. This is a higher-level interface in which the outcome of an operation can be stochastic. The API for it is centered around the apply! function. Particularly useful for Monte Carlo simulations and Perturbative Expansion Symbolic Results.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"In the circuit language, all operations can be applied on a state with the apply! function. Whether they are deterministic and their computational complexity is listed in the table below. A list of lower-level \"linear algebra style\" functions for more control over how an operation is performed is also given.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Type Deterministic 𝒪(nˣ) Low-level functions\nAbstractOperation \n├─ AbstractCliffordOperator \n│ ├─ AbstractSymbolicOperator \n│ │ ├─ AbstractSingleQubitOperator \n│ │ │ ├─ SingleQubitOperator ✔️ n \n│ │ │ ├─ sHadamard ✔️ n \n│ │ │ ├─ sId1 ✔️ n \n│ │ │ ├─ sInvPhase ✔️ n \n│ │ │ ├─ sPhase ✔️ n \n│ │ │ ├─ sX ✔️ n \n│ │ │ ├─ sY ✔️ n \n│ │ │ └─ sZ ✔️ n \n│ │ └─ AbstractTwoQubitOperator \n│ │ ├─ sCNOT ✔️ n \n│ │ ├─ sCPHASE ✔️ n \n│ │ └─ sSWAP ✔️ n \n│ │ \n│ ├─ CliffordOperator ✔️ n³ \n│ ├─ PauliOperator ✔️ n² \n│ └─ SparseGate ✔️ kn² \n├─ AbstractMeasurement \n│ ├─ PauliMeasurement ❌ n² project!, projectrand!\n│ ├─ sMX ❌ n² projectX!\n│ ├─ sMY ❌ n² projectY!\n│ └─ sMZ ❌ n² projectZ!\n│ \n├─ BellMeasurement ❌ n² \n├─ NoiseOp ❌ ? applynoise!\n├─ NoiseOpAll ❌ ? applynoise!\n├─ NoisyGate ❌ ? applynoise!\n└─ Reset ✔️ kn² reset_qubits!","category":"page"},{"location":"allops/#Details-of-Operations-Supported-by-[apply!](@ref)","page":"All Gates","title":"Details of Operations Supported by apply!","text":"","category":"section"},{"location":"allops/#Unitary-Gates","page":"All Gates","title":"Unitary Gates","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"We distinguish between symbolic gates like sCNOT that have specialized (fast) apply! methods (usually just for single and two qubit gates) and general tableau representation of gates like CliffordOperator that can represent any multi-qubit gate.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Predefined unitary gates are available, like sCNOT, sHadamard, etc.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\n[sCNOT(2,4),sHadamard(2),sCPHASE(1,3),sSWAP(2,4)]","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Any arbitrary tableaux can be used as a gate too. ","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"They can be specified by giving a Clifford operator tableaux and the indices on which it acts (particularly useful for gates acting on a small part of a circuit):","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\nSparseGate(tCNOT, [2,4])","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"The Clifford operator tableaux can be completely arbitrary.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"SparseGate(random_clifford(3), [2,4,5])","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"If the Clifford operator acts on all qubits, we do not need to specify indices, just use the operator.","category":"page"},{"location":"allops/#Noisy-Gates","page":"All Gates","title":"Noisy Gates","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Each gate can be followed by noise applied to the qubits on which it has acted. This is done by wrapping the given gate into a NoisyGate","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"ε = 0.03 # X/Y/Z error probability\nnoise = UnbiasedUncorrelatedNoise(ε)\nnoisy_gate = NoisyGate(SparseGate(tCNOT, [2,4]), noise)","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"In circuit diagrams the noise is not depicted, but after each application of the gate defined in noisy_gate, a noise operator will also be applied. The example above is of Pauli Depolarization implemented by UnbiasedUncorrelatedNoise.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"One can also apply only the noise operator by using NoiseOp which acts only on specified qubits. Or alternatively, one can use NoiseOpAll in order to apply noise to all qubits.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"[NoiseOp(noise, [4,5]), NoiseOpAll(noise)]","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"The machinery behind noise processes and different types of noise is detailed in the section on noise","category":"page"},{"location":"allops/#Coincidence-Measurements","page":"All Gates","title":"Coincidence Measurements","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Global parity measurements involving single-qubit projections and classical communication are implemented with BellMeasurement. One needs to specify the axes of measurement and the qubits being measured. If the parity is trivial, the circuit continues, if the parity is non-trivial, the circuit ends and reports a detected failure. This operator is frequently used in the simulation of entanglement purification.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"BellMeasurement([sMX(1), sMY(3), sMZ(4)])","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"There is also NoisyBellMeasurement that takes the bit-flip probability of a single-qubit measurement as a third argument.","category":"page"},{"location":"allops/#Stabilizer-Measurements","page":"All Gates","title":"Stabilizer Measurements","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"A measurement over one or more qubits can also be performed, e.g., a direct stabilizer measurement on multiple qubits without the use of ancillary qubits. When applied to multiple qubits, this differs from BellMeasurement as it performs a single projection, unlike BellMeasurement which performs a separate projection for every single qubit involved. This measurement is implemented in PauliMeasurement which requires a Pauli operator on which to project and the index of the classical bit in which to store the result. Alternatively, there are sMX, sMZ, sMY if you are measuring a single qubit.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"[PauliMeasurement(P\"XYZ\", 1), sMZ(2, 2)]","category":"page"},{"location":"allops/#Reset-Operations","page":"All Gates","title":"Reset Operations","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"The Reset operations lets you trace out the specified qubits and set their state to a specific tableau.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"new_state = random_stabilizer(3)\nqubit_indices = [1,2,3]\nReset(new_state, qubit_indices)","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"It can be done anywhere in a circuit, not just at the beginning.","category":"page"},{"location":"noisycircuits/#Simulation-of-Noisy-Clifford-Circuits","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Clifford Circuits","text":"","category":"section"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\nend","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"warning: Unstable\nThis is unfinished experimental functionality that will change significantly.","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"We have experimental support for simulation of noisy Clifford circuits which can be imported with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"Both Monte Carlo and Perturbative Expansion approaches are supported. When performing a perturbative expansion in the noise parameter, the expansion can optionally be performed symbolically, to arbitrary high orders.","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"Multiple notebooks with examples are also available. For instance, see this tutorial on entanglement purification for many examples.","category":"page"},{"location":"ECC_evaluating/#ecc_evaluating","page":"Evaluating codes and decoders","title":"Evaluating an ECC code and decoders","text":"","category":"section"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.ECC\nend\nCurrentModule = QuantumClifford.ECC","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"warning: The documentation is incomplete\nWhile waiting for a better documentation than the small example below, consider looking into evaluate_decoder, TableDecoder, BeliefPropDecoder, PyBeliefPropDecoder, PyMatchingDecoder, CommutationCheckECCSetup, NaiveSyndromeECCSetup, ShorSyndromeECCSetup","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"This is a quick and durty example on how to use some of the decoders.","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"A function to plot the results of ","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"using CairoMakie\n\nfunction make_decoder_figure(phys_errors, results, title=\"\")\n minlim = min(minimum(phys_errors),minimum(results[results.!=0]))\n maxlim = min(1, max(maximum(phys_errors),maximum(results[results.!=0])))\n\n fresults = copy(results)\n fresults[results.==0] .= NaN\n\n f = Figure()\n a = Axis(f[1,1],\n xscale=log10, yscale=log10,\n limits=(minlim,maxlim,minlim,maxlim),\n aspect=DataAspect(),\n xlabel=\"physical error rate\",\n ylabel=\"logical error rate\",\n title=title)\n lines!(a, [minlim,maxlim],[minlim,maxlim], color=:black)\n for (i,sresults) in enumerate(eachslice(fresults, dims=1))\n scatter!(a, phys_errors, sresults[:,1], marker=:+, color=Cycled(i))\n scatter!(a, phys_errors, sresults[:,2], marker=:x, color=Cycled(i))\n end\n f\nend","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"Testing out a lookup table decoder on a small code.","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"using QuantumClifford\nusing QuantumClifford.ECC\n\nmem_errors = 0.001:0.0005:0.01\ncodes = [Shor9()]\nresults = zeros(length(codes), length(mem_errors), 2)\n\nfor (ic, c) in pairs(codes)\n for (i,m) in pairs(mem_errors)\n setup = CommutationCheckECCSetup(m)\n decoder = TableDecoder(c)\n r = evaluate_decoder(decoder, setup, 10000)\n results[ic,i,:] .= r\n end\nend\n\nmake_decoder_figure(mem_errors, results, \"Shor's code with a lookup table decoder\")","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"Testing out the toric code with a decoder provided by the python package pymatching (provided in julia by the meta package PyQDecoders.jl).","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"import PyQDecoders\n\nmem_errors = 0.001:0.005:0.1\ncodes = [Toric(4,4), Toric(6,6)]\nresults = zeros(length(codes), length(mem_errors), 2)\n\nfor (ic, c) in pairs(codes)\n for (i,m) in pairs(mem_errors)\n setup = ShorSyndromeECCSetup(m, 0)\n decoder = PyMatchingDecoder(c)\n r = evaluate_decoder(decoder, setup, 1000)\n results[ic,i,:] .= r\n end\nend\n\nmake_decoder_figure(mem_errors, results, \"Toric code with a MWPM decoder\")","category":"page"},{"location":"canonicalization/#Canonicalization-operations","page":"Canonicalization","title":"Canonicalization operations","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Different types of canonicalization operations are implemented. All of them are types of Gaussian elimination.","category":"page"},{"location":"canonicalization/#[canonicalize!](@ref)","page":"Canonicalization","title":"canonicalize!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"First do elimination on all X components and only then perform elimination on the Z components. Based on (Garcia et al., 2012). It is used in logdot for inner products of stabilizer states.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"The final tableaux, if square should look like the following (Image: )","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"If the tableaux is shorter than a square, the diagonals might not reach all the way to the right.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize!(random_stabilizer(20,30)))\nf","category":"page"},{"location":"canonicalization/#[canonicalize_rref!](@ref)","page":"Canonicalization","title":"canonicalize_rref!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Cycle between elimination on X and Z for each qubit. Particularly useful for tracing out qubits. Based on (Audenaert and Plenio, 2005). For convenience reasons, the canonicalization starts from the bottom row, and you can specify as a second argument which columns to be canonicalized (useful for tracing out arbitrary qubits, e.g., in traceout!).","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"The tableau canonicalization is done in recursive steps, each one of which results in something akin to one of these three options (Image: )","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize_rref!(random_stabilizer(20,30),1:30)[1])\nf","category":"page"},{"location":"canonicalization/#[canonicalize_gott!](@ref)","page":"Canonicalization","title":"canonicalize_gott!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"First do elimination on all X components and only then perform elimination on the Z components, but without touching the qubits that were eliminated during the X pass. Unlike other canonicalization operations, qubit columns are reordered, providing for a straight diagonal in each block. Particularly useful as certain blocks of the new created matrix are related to logical operations of the corresponding code, e.g. computing the logical X and Z operators of a MixedDestabilizer. Based on (Gottesman, 1997).","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"A canonicalized tableau would look like the following (the right-most block does not exist for square tableaux). (Image: )","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize_gott!(random_stabilizer(30))[1])\nf","category":"page"},{"location":"canonicalization/#[canonicalize_clip!](@ref)","page":"Canonicalization","title":"canonicalize_clip!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Convert to the \"clipped\" gauge of a stabilizer state resulting in a \"river\" of non-identity operators around the diagonal.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize_clip!(random_stabilizer(30)))\nf","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"The properties of the clipped gauge are:","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Each qubit is the left/right \"endpoint\" of exactly two stabilizer rows.\nFor the same qubit the two endpoints are always different Pauli operators.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"This canonicalization is used to derive the bigram a stabilizer state, which is also related to entanglement entropy in the state.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Introduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in Appendix A of (Li et al., 2019).","category":"page"},{"location":"noisycircuits_mc/#noisycircuits_mc","page":"Monte Carlo","title":"Monte Carlo simulations of noisy Clifford circuits","text":"","category":"section"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\n using Quantikz\nend","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"Import with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"This module enables the simulation of noisy Clifford circuits through a Monte Carlo method where the same circuit is evaluated multiple times with random errors interspersed through it as prescribed by a given error model.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"Below is an example of a purification circuit. We first prepare the circuit we desire to use, including a noise model. Quantikz.jl was is used to visualize the circuit.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\ngood_bell_state = S\"XX\n ZZ\"\ninitial_state = MixedDestabilizer(good_bell_state⊗good_bell_state)\n\ng1 = sCNOT(1,3) # CNOT between qubit 1 and qubit 3 (both with Alice)\ng2 = sCNOT(2,4) # CNOT between qubit 2 and qubit 4 (both with Bob)\nm = BellMeasurement([sMX(3),sMX(4)]) # Bell measurement on qubit 3 and 4\nv = VerifyOp(good_bell_state,[1,2]) # Verify that qubit 1 and 2 indeed form a good Bell pair\nepsilon = 0.01 # The error rate\nn = NoiseOpAll(UnbiasedUncorrelatedNoise(epsilon))\n\n# This circuit performs a depolarization at rate `epsilon` to all qubits,\n# then bilater CNOT operations\n# then a Bell measurement\n# followed by checking whether the final result indeed corresponds to the correct Bell pair.\ncircuit = [n,g1,g2,m,v]","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"And we can run a Monte Carlo simulation of that circuit with mctrajectories.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"mctrajectories(initial_state, circuit, trajectories=500)","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification for many examples.","category":"page"},{"location":"noisycircuits_mc/#Interface-for-custom-operations","page":"Monte Carlo","title":"Interface for custom operations","text":"","category":"section"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"applywstatus!(s::T, g::Operation)::Tuple{T,Symbol} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation. Predefined statuses are kept in the registered_statuses list, but you can add more. Be sure to expand this list if you want the trajectory simulators using your custom statuses to output all trajectories.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"There is also applynoise! which is convenient wait to create a noise model that can then be plugged into the NoisyGate struct, letting you reuse the predefined perfect gates and measurements. However, you can also just make up your own noise operator simply by implementing applywstatus! for it.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"You can also consult the list of implemented operators.","category":"page"},{"location":"commonstates/#Useful-States-and-Operators","page":"Useful States","title":"Useful States and Operators","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"DocTestSetup = quote\n using QuantumClifford\n using StableRNGs\n rng = StableRNG(42)\nend","category":"page"},{"location":"commonstates/#States","page":"Useful States","title":"States","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Stabilizer states can be represented with the Stabilizer, Destabilizer, MixedStabilizer, and MixedDestabilizer tableau data structures. You probably want to use MixedDestabilizer which supports the widest set of operations.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Moreover, a MixedDestabilizer can be stored inside a Register together with a set of classical bits in which measurement results can be written.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Below are convenience constructors for common types of states and operators, already implemented in this library.","category":"page"},{"location":"commonstates/#Pauli-Operators","page":"Useful States","title":"Pauli Operators","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Single qubit PauliOperator is implemented in [single_z] and [single_x].","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> single_z(4,2)\n+ _Z__\n\njulia> single_x(4,3)\n+ __X_","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"All identity operators use zero.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> zero(PauliOperator, 3)\n+ ___\n\njulia> zero(P\"XYZXYZ\")\n+ ______","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Random Pauli operators are implemented as well (with or without a random phase).","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> using StableRNGs; rng = StableRNG(42);\n\njulia> random_pauli(rng, 4)\n+ ZYY_\n\njulia> random_pauli(rng, 4; nophase=false)\n- YZ_X","category":"page"},{"location":"commonstates/#Stabilizer-States","page":"Useful States","title":"Stabilizer States","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"An all-identity stabilizer can be created with zero.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> zero(Stabilizer, 3)\n+ ___\n+ ___\n+ ___\n\njulia> zero(Stabilizer, 2, 3)\n+ ___\n+ ___\n\njulia> zero(S\"XIZ\n YZX\")\n+ ___\n+ ___","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Diagonal stabilizers in different bases are available as well, through one.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> one(Stabilizer, 3)\n+ Z__\n+ _Z_\n+ __Z\n\njulia> one(Stabilizer, 3; basis=:Y)\n+ Y__\n+ _Y_\n+ __Y\n\njulia> one(S\"XX\n ZZ\")\n+ Z_\n+ _Z","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"A random stabilizer (or destabilizers or Clifford operators) can be created as well. We use the algorithm described in (Bravyi and Maslov, 2021).","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> random_stabilizer(rng, 2,5)\n+ YZXZZ\n- XZYYY","category":"page"},{"location":"commonstates/#Mixed-States","page":"Useful States","title":"Mixed States","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Similarly, one can create a diagonal mixed state.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> one(MixedDestabilizer, 2, 3)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ X__\n+ _X_\n𝒳ₗ━━━\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ _Z_\n𝒵ₗ━━━\n+ __Z","category":"page"},{"location":"commonstates/#Enumerating-all-Clifford-Operations","page":"Useful States","title":"Enumerating all Clifford Operations","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"The algorithm from (Koenig and Smolin, 2014) can be used to enumerate all Clifford operations on a given number of qubits through enumerate_cliffords. Or one can use random_clifford, random_stabilizer to directly sample from that set.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> length(enumerate_cliffords(1))\n6\n\njulia> length(enumerate_cliffords(2))\n720","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"To also enumerate possible phases, you can use enumerate_phases.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> length(collect(enumerate_phases(tCNOT)))\n16\n\njulia> length(collect(enumerate_phases(enumerate_cliffords(2))))\n11520","category":"page"},{"location":"commonstates/#Common-entangled-states","page":"Useful States","title":"Common entangled states","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Bell states and GHZ states have convenience constructors:","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> bell()\n+ XX\n+ ZZ\n\njulia> bell(2)\n+ XX__\n+ ZZ__\n+ __XX\n+ __ZZ\n\njulia> ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ","category":"page"},{"location":"API/#Full-API","page":"API","title":"Full API","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"","category":"page"},{"location":"API/#States","page":"API","title":"States","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"Stabilizer states can be represented with the Stabilizer, Destabilizer, MixedStabilizer, and MixedDestabilizer tableau data structures. You probably want to use MixedDestabilizer which supports the widest set of operations.","category":"page"},{"location":"API/","page":"API","title":"API","text":"Moreover, a MixedDestabilizer can be stored inside a Register together with a set of classical bits in which measurement results can be written.","category":"page"},{"location":"API/","page":"API","title":"API","text":"Lastly, for Pauli frame simulations there is the PauliFrame type, a tableau in which each row represents a different Pauli frame.","category":"page"},{"location":"API/","page":"API","title":"API","text":"There are convenience constructors for common types of states and operators.","category":"page"},{"location":"API/#Operations","page":"API","title":"Operations","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"Acting on quantum states can be performed either:","category":"page"},{"location":"API/","page":"API","title":"API","text":"In a \"linear algebra\" language where unitaries, measurements, and other operations have separate interfaces. This is an explicitly deterministic lower-level interface, which provides a great deal of control over how tableaux are manipulated. See the Stabilizer Tableau Algebra Manual as a primer on these approaches.\nOr in a \"circuit\" language, where the operators (and measurements and noise) are represented as circuit gates. This is a higher-level interface in which the outcome of an operation can be stochastic. The API for it is centered around the apply! function. Particularly useful for Monte Carlo simulations and Perturbative Expansion Symbolic Results.","category":"page"},{"location":"API/","page":"API","title":"API","text":"See the full list of operations for a list of implemented operations.","category":"page"},{"location":"API/#Autogenerated-API-list","page":"API","title":"Autogenerated API list","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"Modules = [QuantumClifford]\nPrivate = false","category":"page"},{"location":"API/#QuantumClifford.QuantumClifford","page":"API","title":"QuantumClifford.QuantumClifford","text":"A module for using the Stabilizer formalism and simulating Clifford circuits.\n\n\n\n\n\n","category":"module"},{"location":"API/#QuantumClifford.continue_stat","page":"API","title":"QuantumClifford.continue_stat","text":"Returned by applywstatus! if the circuit simulation should continue.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.failure_stat","page":"API","title":"QuantumClifford.failure_stat","text":"Returned by applywstatus! if the circuit reports a failure.\n\nSee also: VerifyOp, BellMeasurement.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.false_success_stat","page":"API","title":"QuantumClifford.false_success_stat","text":"Returned by applywstatus! if the circuit reports a success, but it is a false positive (i.e., there was an undetected error).\n\nSee also: VerifyOp, BellMeasurement.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.true_success_stat","page":"API","title":"QuantumClifford.true_success_stat","text":"Returned by applywstatus! if the circuit reports a success and there is no undetected error.\n\nSee also: VerifyOp, BellMeasurement.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.AbstractSingleQubitOperator","page":"API","title":"QuantumClifford.AbstractSingleQubitOperator","text":"Supertype of all single-qubit symbolic operators.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.AbstractSymbolicOperator","page":"API","title":"QuantumClifford.AbstractSymbolicOperator","text":"Supertype of all symbolic operators. Subtype of AbstractCliffordOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.AbstractTwoQubitOperator","page":"API","title":"QuantumClifford.AbstractTwoQubitOperator","text":"Supertype of all two-qubit symbolic operators.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.BellMeasurement","page":"API","title":"QuantumClifford.BellMeasurement","text":"A Bell measurement performing the correlation measurement corresponding to the given pauli projections on the qubits at the selected indices.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.CircuitStatus","page":"API","title":"QuantumClifford.CircuitStatus","text":"A convenience struct to represent the status of a circuit simulated by mctrajectories\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.ClassicalXOR","page":"API","title":"QuantumClifford.ClassicalXOR","text":"Applies an XOR gate to classical bits. Currently only implemented for functionality with pauli frames.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.CliffordOperator","page":"API","title":"QuantumClifford.CliffordOperator","text":"Clifford Operator specified by the mapping of the basis generators.\n\njulia> tCNOT\nX₁ ⟼ + XX\nX₂ ⟼ + _X\nZ₁ ⟼ + Z_\nZ₂ ⟼ + ZZ\n\njulia> phase_gate = C\"Y\n Z\"\nX₁ ⟼ + Y\nZ₁ ⟼ + Z\n\njulia> stab = S\"XI\n IZ\";\n\n\njulia> entangled = tCNOT*stab\n+ XX\n+ ZZ\n\njulia> CliffordOperator(T\"YY\")\nERROR: DimensionMismatch: Input tableau should be of size 2n×n (top half is the X mappings and the bottom half are the Z mappings).\n[...]\n\nDestabilizer can also be converted.\n\njulia> d = Destabilizer(S\"Y\")\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z\n𝒮𝓉𝒶𝒷\n+ Y\n\njulia> CliffordOperator(d)\nX₁ ⟼ + Z\nZ₁ ⟼ + Y\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Destabilizer","page":"API","title":"QuantumClifford.Destabilizer","text":"A tableau representation of a pure stabilizer state. The tableau tracks the destabilizers as well, for efficient projections. On initialization there are no checks that the provided state is indeed pure. This enables the use of this data structure for mixed stabilizer state, but a better choice would be to use MixedDestabilizer.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.MixedDestabilizer","page":"API","title":"QuantumClifford.MixedDestabilizer","text":"A tableau representation for mixed stabilizer states that keeps track of the destabilizers in order to provide efficient projection operations.\n\nThe rank r of the n-qubit tableau is tracked, either so that it can be used to represent a mixed stabilizer state, or so that it can be used to represent an n-r logical-qubit code over n physical qubits. The \"logical\" operators are tracked as well.\n\nWhen the constructor is called on an incomplete Stabilizer it automatically calculates the destabilizers and logical operators, following chapter 4 of (Gottesman, 1997). Under the hood the conversion uses the canonicalize_gott! canonicalization. That canonicalization permutes the columns of the tableau, but we automatically undo the column permutation in the preparation of a MixedDestabilizer so that qubits are not reindexed. The boolean keyword arguments undoperm and reportperm can be used to control this behavior and to report the permutations explicitly.\n\nSee also: stabilizerview, destabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.MixedStabilizer","page":"API","title":"QuantumClifford.MixedStabilizer","text":"A slight improvement of the Stabilizer data structure that enables more naturally and completely the treatment of mixed states, in particular when the project! function is used.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.NoiseOp","page":"API","title":"QuantumClifford.NoiseOp","text":"An operator that applies the given noise model to the qubits at the selected indices.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.NoiseOpAll","page":"API","title":"QuantumClifford.NoiseOpAll","text":"An operator that applies the given noise model to all qubits.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.NoisyGate","page":"API","title":"QuantumClifford.NoisyGate","text":"A gate consisting of the given noise applied after the given perfect Clifford gate.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliChannel","page":"API","title":"QuantumClifford.PauliChannel","text":"A Pauli channel datastructure, mainly for use with StabMixture\n\nSee also: UnitaryPauliChannel\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliFrame","page":"API","title":"QuantumClifford.PauliFrame","text":"struct PauliFrame{T, S} <: QuantumClifford.AbstractQCState\n\nThis is a wrapper around a tableau. This \"frame\" tableau is not to be viewed as a normal stabilizer tableau, although it does conjugate the same under Clifford operations. Each row in the tableau refers to a single frame. The row represents the Pauli operation by which the frame and the reference differ.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliFrame-Tuple{Any, Any, Any}","page":"API","title":"QuantumClifford.PauliFrame","text":"PauliFrame(\n frames,\n qubits,\n measurements\n) -> PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}}\n\n\nPrepare an empty set of Pauli frames with the given number of frames and qubits. Preallocates spaces for measurement number of measurements.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliMeasurement","page":"API","title":"QuantumClifford.PauliMeasurement","text":"A Stabilizer measurement on the entirety of the quantum register.\n\nprojectrand!(state, pauli) and apply!(state, PauliMeasurement(pauli)) give the same (possibly non-deterministic) result. Particularly useful when acting on Register.\n\nSee also: apply!, projectrand!.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliNoise","page":"API","title":"QuantumClifford.PauliNoise","text":"Pauli noise model with probabilities px, py, and pz respectively for the three types of Pauli errors.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliNoise-Tuple{Any}","page":"API","title":"QuantumClifford.PauliNoise","text":"Constructs an unbiased Pauli noise model with total probability of error p.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliOperator","page":"API","title":"QuantumClifford.PauliOperator","text":"A multi-qubit Pauli operator (1iIZXY^otimes n).\n\nA Pauli can be constructed with the P custom string macro or by building up one through products and tensor products of smaller operators.\n\njulia> pauli3 = P\"-iXYZ\"\n-iXYZ\n\njulia> pauli4 = 1im * pauli3 ⊗ X\n+ XYZX\n\njulia> Z*X\n+iY\n\nWe use a typical F(2,2) encoding internally. The X and Z bits are stored in a single concatenated padded array of UInt chunks of a bit array.\n\njulia> p = P\"-IZXY\";\n\n\njulia> p.xz\n2-element Vector{UInt64}:\n 0x000000000000000c\n 0x000000000000000a\n\nYou can access the X and Z bits through getters and setters or through the xview, zview, xbit, and zbit functions.\n\njulia> p = P\"XYZ\"; p[1]\n(true, false)\n\njulia> p[1] = (true, true); p\n+ YYZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Register","page":"API","title":"QuantumClifford.Register","text":"A register, representing the state of a computer including both a tableaux and an array of classical bits (e.g. for storing measurement results)\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Reset","page":"API","title":"QuantumClifford.Reset","text":"Reset the specified qubits to the given state.\n\nBe careful, this operation implies first tracing out the qubits, which can lead to mixed states if these qubits were entangled with the rest of the system.\n\nSee also: sMRZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.SingleQubitOperator","page":"API","title":"QuantumClifford.SingleQubitOperator","text":"A \"symbolic\" general single-qubit operator which permits faster multiplication than an operator expressed as an explicit tableau.\n\njulia> op = SingleQubitOperator(2, true, true, true, false, true, true) # Tableau components and phases\nSingleQubitOperator on qubit 2\nX₁ ⟼ - Y\nZ₁ ⟼ - X\n\njulia> typeof(op)\nSingleQubitOperator\n\njulia> t_op = CliffordOperator(op, 3) # Transforming it back into an explicit tableau representation (specifying the size)\nX₁ ⟼ + X__\nX₂ ⟼ - _Y_\nX₃ ⟼ + __X\nZ₁ ⟼ + Z__\nZ₂ ⟼ - _X_\nZ₃ ⟼ + __Z\n\njulia> typeof(t_op)\nCliffordOperator{QuantumClifford.Tableau{Vector{UInt8}, Matrix{UInt64}}}\n\njulia> CliffordOperator(op, 1, compact=true) # You can also extract just the non-trivial part of the tableau\nX₁ ⟼ - Y\nZ₁ ⟼ - X\n\nSee also: sHadamard, sPhase, sId1, sX, sY, sZ, CliffordOperator\n\nOr simply consult subtypes(QuantumClifford.AbstractSingleQubitOperator) and subtypes(QuantumClifford.AbstractTwoQubitOperator) for a full list. You can think of the s prefix as \"symbolic\" or \"sparse\".\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.SparseGate","page":"API","title":"QuantumClifford.SparseGate","text":"A Clifford gate, applying the given cliff operator to the qubits at the selected indices.\n\napply!(state, cliff, indices) and apply!(state, SparseGate(cliff, indices)) give the same result.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.StabMixture","page":"API","title":"QuantumClifford.StabMixture","text":"mutable struct StabMixture{T, F}\n\nRepresents mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is a pure stabilizer state.\n\njulia> StabMixture(S\"-X\")\nA mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z\n𝒮𝓉𝒶𝒷\n- X\nwith ϕᵢⱼ | Pᵢ | Pⱼ:\n 1.0+0.0im | + _ | + _\n\njulia> pcT\nA unitary Pauli channel P = ∑ ϕᵢ Pᵢ with the following branches:\nwith ϕᵢ | Pᵢ\n 0.853553+0.353553im | + _\n 0.146447-0.353553im | + Z\n\njulia> apply!(StabMixture(S\"-X\"), pcT)\nA mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z\n𝒮𝓉𝒶𝒷\n- X\nwith ϕᵢⱼ | Pᵢ | Pⱼ:\n 0.0+0.353553im | + _ | + Z\n 0.0-0.353553im | + Z | + _\n 0.853553+0.0im | + _ | + _\n 0.146447+0.0im | + Z | + Z\n\nSee also: PauliChannel\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Stabilizer","page":"API","title":"QuantumClifford.Stabilizer","text":"Stabilizer, i.e. a list of commuting multi-qubit Hermitian Pauli operators.\n\nInstances can be created with the S custom string macro or as direct sum of other stabilizers.\n\ntip: Stabilizers and Destabilizers\nIn many cases you probably would prefer to use the MixedDestabilizer data structure, as it caries a lot of useful additional information, like tracking rank and destabilizer operators. Stabilizer has mostly a pedagogical value, and it is also used for slightly faster simulation of a particular subset of Clifford operations.\n\njulia> s = S\"XXX\n ZZI\n IZZ\"\n+ XXX\n+ ZZ_\n+ _ZZ\n\njulia> s⊗s\n+ XXX___\n+ ZZ____\n+ _ZZ___\n+ ___XXX\n+ ___ZZ_\n+ ____ZZ\n\nIt has an indexing API, looking like a list of PauliOperators.\n\njulia> s[2]\n+ ZZ_\n\nPauli operators can act directly on the a stabilizer.\n\njulia> P\"YYY\" * s\n- XXX\n+ ZZ_\n+ _ZZ\n\nThere are a number of ways to create a Stabilizer, including:\n\ngenerate Stabilizers from a list of Pauli operators\n\njulia> Stabilizer([P\"XX\", P\"ZZ\"])\n+ XX\n+ ZZ\n\ngenerate Stabilizers from boolean matrices\n\njulia> a = [true true; false false]; b = [false true; true true];\n\njulia> Stabilizer(a, b)\n+ XY\n+ ZZ\n\njulia> Stabilizer([0x0, 0x2], a, b)\n+ XY\n- ZZ\n\ninitialize an empty Stabilizer and fill it through indexing\n\njulia> s = zero(Stabilizer, 2)\n+ __\n+ __\n\njulia> s[1,1] = (true, false); s\n+ X_\n+ __\n\nThere are no automatic checks for correctness (i.e. independence of all rows, commutativity of all rows, hermiticity of all rows). The rank (number of rows) is permitted to be less than the number of qubits (number of columns): canonilization, projection, etc. continue working in that case. To great extent this library uses the Stabilizer data structure simply as a tableau. This might be properly abstracted away in future versions.\n\nSee also: PauliOperator, canonicalize!\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Stabilizer-Tuple{Graphs.SimpleGraphs.SimpleGraph}","page":"API","title":"QuantumClifford.Stabilizer","text":"Convert a graph representing a stabilizer state to an explicit Stabilizer.\n\nSee also: graphstate\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.UnbiasedUncorrelatedNoise","page":"API","title":"QuantumClifford.UnbiasedUncorrelatedNoise","text":"Depolarization noise model with total probability of error p.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.UnitaryPauliChannel","page":"API","title":"QuantumClifford.UnitaryPauliChannel","text":"A Pauli channel datastructure, mainly for use with StabMixture.\n\nMore convenient to use than PauliChannel when you know your Pauli channel is unitary.\n\njulia> Tgate = UnitaryPauliChannel(\n (I, Z),\n ((1+exp(im*π/4))/2, (1-exp(im*π/4))/2)\n )\nA unitary Pauli channel P = ∑ ϕᵢ Pᵢ with the following branches:\nwith ϕᵢ | Pᵢ\n 0.853553+0.353553im | + _\n 0.146447-0.353553im | + Z\n\njulia> PauliChannel(Tgate)\nPauli channel ρ ↦ ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† with the following branches:\nwith ϕᵢⱼ | Pᵢ | Pⱼ:\n 0.853553+0.0im | + _ | + _\n 0.0+0.353553im | + _ | + Z\n 0.0-0.353553im | + Z | + _\n 0.146447+0.0im | + Z | + Z\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.VerifyOp","page":"API","title":"QuantumClifford.VerifyOp","text":"A \"probe\" to verify that the state of the qubits corresponds to a desired good_state, e.g. at the end of the execution of a circuit.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCNOT","page":"API","title":"QuantumClifford.sCNOT","text":"A \"symbolic\" CNOT. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCPHASE","page":"API","title":"QuantumClifford.sCPHASE","text":"A \"symbolic\" CPHASE. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCXYZ","page":"API","title":"QuantumClifford.sCXYZ","text":"A \"symbolic\" single-qubit CXYZ. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCZYX","page":"API","title":"QuantumClifford.sCZYX","text":"A \"symbolic\" single-qubit CZYX. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sHadamard","page":"API","title":"QuantumClifford.sHadamard","text":"A \"symbolic\" single-qubit Hadamard. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sHadamardXY","page":"API","title":"QuantumClifford.sHadamardXY","text":"A \"symbolic\" single-qubit HadamardXY. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sHadamardYZ","page":"API","title":"QuantumClifford.sHadamardYZ","text":"A \"symbolic\" single-qubit HadamardYZ. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sId1","page":"API","title":"QuantumClifford.sId1","text":"A \"symbolic\" single-qubit Identity operation.\n\nSee also: SingleQubitOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvPhase","page":"API","title":"QuantumClifford.sInvPhase","text":"A \"symbolic\" single-qubit InvPhase. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvSQRTX","page":"API","title":"QuantumClifford.sInvSQRTX","text":"A \"symbolic\" single-qubit InvSQRTX. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvSQRTY","page":"API","title":"QuantumClifford.sInvSQRTY","text":"A \"symbolic\" single-qubit InvSQRTY. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvZCrY","page":"API","title":"QuantumClifford.sInvZCrY","text":"A \"symbolic\" InvZCrY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMRX","page":"API","title":"QuantumClifford.sMRX","text":"Measure a qubit in the X basis and reset to the |+⟩ state.\n\nSee also: sMRZ, Reset, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMRY","page":"API","title":"QuantumClifford.sMRY","text":"Measure a qubit in the Y basis and reset to the |i₊⟩ state.\n\nSee also: sMRZ, Reset, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMRZ","page":"API","title":"QuantumClifford.sMRZ","text":"Measure a qubit in the Z basis and reset to the |0⟩ state.\n\nwarning: It does not trace out the qubit!\nAs described below there is a difference between measuring the qubit (followed by setting it to a given known state) and \"tracing out\" the qubit. By reset here we mean \"measuring and setting to a known state\", not \"tracing out\".\n\njulia> s = MixedDestabilizer(S\"XXX ZZI IZZ\") # |000⟩+|111⟩\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ ZZ_\n+ Z_Z\n\njulia> traceout!(copy(s), 1) # = I⊗(|00⟩⟨00| + |11⟩⟨11|)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ _X_\n𝒳ₗ━━━\n+ _XX\n+ Z__\n𝒮𝓉𝒶𝒷━\n+ _ZZ\n𝒵ₗ━━━\n+ Z_Z\n+ XXX\n\njulia> projectZ!(traceout!(copy(s), 1), 1)[1] # = |000⟩⟨000|+|011⟩⟨011| or |100⟩⟨100|+|111⟩⟨111| (use projectZrand! to actually get a random result)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ _X_\n+ XXX\n𝒳ₗ━━━\n+ _XX\n𝒮𝓉𝒶𝒷━\n+ _ZZ\n+ Z__\n𝒵ₗ━━━\n+ Z_Z\n\njulia> projectZ!(copy(s), 1)[1] # = |000⟩ or |111⟩ (use projectZrand! to actually get a random result)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ XXX\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ ZZ_\n+ Z_Z\n\njulia> apply!(Register(copy(s)), sMRZ(1)) |> quantumstate # |000⟩ or |011⟩, depending on randomization\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ XXX\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n- ZZ_\n- Z_Z\n\nSee also: Reset, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMX","page":"API","title":"QuantumClifford.sMX","text":"Symbolic single qubit X measurement. See also Register, projectXrand!, sMY, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMY","page":"API","title":"QuantumClifford.sMY","text":"Symbolic single qubit Y measurement. See also Register, projectYrand!, sMX, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMZ","page":"API","title":"QuantumClifford.sMZ","text":"Symbolic single qubit Z measurement. See also Register, projectZrand!, sMX, sMY\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sPhase","page":"API","title":"QuantumClifford.sPhase","text":"A \"symbolic\" single-qubit Phase. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sSQRTX","page":"API","title":"QuantumClifford.sSQRTX","text":"A \"symbolic\" single-qubit SQRTX. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sSQRTY","page":"API","title":"QuantumClifford.sSQRTY","text":"A \"symbolic\" single-qubit SQRTY. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sSWAP","page":"API","title":"QuantumClifford.sSWAP","text":"A \"symbolic\" SWAP. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sX","page":"API","title":"QuantumClifford.sX","text":"A \"symbolic\" single-qubit X. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sXCX","page":"API","title":"QuantumClifford.sXCX","text":"A \"symbolic\" XCX. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sXCY","page":"API","title":"QuantumClifford.sXCY","text":"A \"symbolic\" XCY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sXCZ","page":"API","title":"QuantumClifford.sXCZ","text":"A \"symbolic\" XCZ. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sY","page":"API","title":"QuantumClifford.sY","text":"A \"symbolic\" single-qubit Y. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sYCX","page":"API","title":"QuantumClifford.sYCX","text":"A \"symbolic\" YCX. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sYCY","page":"API","title":"QuantumClifford.sYCY","text":"A \"symbolic\" YCY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sYCZ","page":"API","title":"QuantumClifford.sYCZ","text":"A \"symbolic\" YCZ. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZ","page":"API","title":"QuantumClifford.sZ","text":"A \"symbolic\" single-qubit Z. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCX","page":"API","title":"QuantumClifford.sZCX","text":"A \"symbolic\" ZCX. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCY","page":"API","title":"QuantumClifford.sZCY","text":"A \"symbolic\" ZCY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCZ","page":"API","title":"QuantumClifford.sZCZ","text":"A \"symbolic\" ZCZ. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCrY","page":"API","title":"QuantumClifford.sZCrY","text":"A \"symbolic\" ZCrY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliError","page":"API","title":"QuantumClifford.PauliError","text":"A convenient constructor for various types of Pauli errors, that can be used as circuit gates in simulations. Returns more specific types when necessary.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.PauliError-NTuple{4, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies a biased Pauli error on all qubits independently, each with probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliError-Tuple{Any, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies an unbiased Pauli error on all qubits, each with independent probability p.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliError-Tuple{Int64, Any, Any, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies a biased Pauli error on qubit q with independent probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliError-Tuple{Int64, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies an unbiased Pauli error on qubit q with probability p.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.affectedqubits","page":"API","title":"QuantumClifford.affectedqubits","text":"A method giving the qubits acted upon by a given operation. Part of the Noise interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.applybranches","page":"API","title":"QuantumClifford.applybranches","text":"Compute all possible new states after the application of the given operator. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Perturbative Expansion interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.applynoise!","page":"API","title":"QuantumClifford.applynoise!","text":"A method modifying a given state by applying the corresponding noise model. It is non-deterministic, part of the Noise interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.applywstatus!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.applywstatus!","text":"Used for mctrajectories.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.bell","page":"API","title":"QuantumClifford.bell","text":"Prepare one or more Bell pairs (with optional phases).\n\njulia> bell()\n+ XX\n+ ZZ\n\njulia> bell(2)\n+ XX__\n+ ZZ__\n+ __XX\n+ __ZZ\n\njulia> bell((true, false))\n- XX\n+ ZZ\n\njulia> bell([true, false, true, true])\n- XX__\n+ ZZ__\n- __XX\n- __ZZ\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.bigram-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.bigram","text":"bigram(\n state::QuantumClifford.AbstractStabilizer;\n clip\n) -> Matrix{Int64}\n\n\nGet the bigram of a tableau.\n\nIt is the list of endpoints of a tableau in the clipped gauge.\n\nIf clip=true (the default) the tableau is converted to the clipped gauge in-place before calculating the bigram. Otherwise, the clip gauge conversion is skipped (for cases where the input is already known to be in the correct gauge).\n\nIntroduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in (Li et al., 2019) and (Gullans et al., 2021).\n\nSee also: canonicalize_clip!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.bitview","page":"API","title":"QuantumClifford.bitview","text":"A view of the classical bits stored with the state\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.canonicalize!-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.canonicalize!","text":"canonicalize!(\n state::QuantumClifford.AbstractStabilizer;\n phases,\n ranks\n) -> Any\n\n\nCanonicalize a stabilizer (in place).\n\nAssumes the input is a valid stabilizer (all operators commute and have real phases). It permits redundant generators and identity generators.\n\njulia> ghz = S\"XXXX\n ZZII\n IZZI\n IIZZ\";\n\n\njulia> canonicalize!(ghz)\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> canonicalize!(S\"XXXX\n IZZI\n IIZZ\")\n+ XXXX\n+ _Z_Z\n+ __ZZ\n\nNot all rows in the tableau in the next example are independent:\n\njulia> canonicalize!(S\"XXXX\n ZZII\n IZZI\n IZIZ\n IIZZ\")\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n+ ____\n\nIn cases of lower rank, more advanced tableau structures might be better. For instance the MixedStabilizer or MixedDestabilizer structures (you can read more about them in the Data Structures section of the documentation).\n\nIf phases=false is set, the canonicalization does not track the phases in the tableau, leading to significant (constant factor) speedup.\n\njulia> s = S\"-ZX\n XZ\"\n- ZX\n+ XZ\n\njulia> canonicalize!(copy(s), phases=false)\n- XZ\n+ ZX\n\njulia> canonicalize!(copy(s))\n+ XZ\n- ZX\n\nIf ranks=true is set, the last pivot indices for the X and Z stage of the canonicalization are returned as well.\n\njulia> s = S\"XXXX\n ZZII\n IZIZ\n ZIIZ\";\n\n\njulia> _, ix, iz = canonicalize!(s, ranks=true); ix, iz\n(1, 3)\n\njulia> s\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ ____\n\nBased on (Garcia et al., 2012).\n\nSee also: canonicalize_rref!, canonicalize_gott!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_clip!-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.canonicalize_clip!","text":"canonicalize_clip!(\n state::QuantumClifford.AbstractStabilizer;\n phases\n) -> QuantumClifford.AbstractStabilizer\n\n\nFix the clipped gauge of a stabilizer (in place).\n\nAssumes the input is a valid full-rank stabilizer (all operators commute and have real phases).\n\njulia> s = S\"- X_ZX_X\n + XXYZ__\n - YZ_Z_X\n - XZX__Y\n + _Z_Y_Y\n - ____Z_\";\n\n\njulia> canonicalize_clip!(s)\n- X_XY__\n+ YZY___\n+ _XZX__\n- _ZYX_Z\n- __YZ_X\n- ____Z_\n\nIf phases=false is set, the canonicalization does not track the phases in the tableau, leading to a significant speedup.\n\nIntroduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in Appendix A of (Li et al., 2019)\n\nSee also: canonicalize!, canonicalize_rref!, canonicalize_gott!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_gott!-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.canonicalize_gott!","text":"Inplace Gottesman canonicalization of a tableau.\n\nThis uses different canonical form from canonicalize!. It is used in the computation of the logical X and Z operators of a MixedDestabilizer.\n\nIt returns the (in place) modified state, the indices of the last pivot of both Gaussian elimination steps, and the permutations that have been used to put the X and Z tableaux in standard form.\n\nBased on (Gottesman, 1997).\n\nSee also: canonicalize!, canonicalize_rref!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_rref!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.canonicalize_rref!","text":"canonicalize_rref!(\n state::QuantumClifford.AbstractStabilizer,\n colindices;\n phases\n) -> Tuple{QuantumClifford.AbstractStabilizer, Any}\n\n\nCanonicalize a stabilizer (in place) along only some columns.\n\nThis uses different canonical form from canonicalize!. It also indexes in reverse in order to make its use in traceout! more efficient. Its use in traceout! is its main application.\n\nIt returns the (in place) modified state and the index of the last pivot.\n\nBased on (Audenaert and Plenio, 2005).\n\nSee also: canonicalize!, canonicalize_gott!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_rref!-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.canonicalize_rref!","text":"canonicalize_rref!(\n state::QuantumClifford.AbstractStabilizer;\n phases\n) -> Tuple{QuantumClifford.AbstractStabilizer, Any}\n\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.centralizer-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.centralizer","text":"For a given set of Paulis (in the form of a Tableau), return the subset of Paulis that commute with all Paulis in set.\n\njulia> centralizer(T\"XX ZZ _Z\")\n+ ZZ\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.clifford_cardinality-Tuple{Int64}","page":"API","title":"QuantumClifford.clifford_cardinality","text":"The size of the Clifford group 𝒞 over a given number of qubits, possibly modulo the phases.\n\nFor n qubits, not accounting for phases is 2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1). There are 4ⁿ different phase configurations.\n\njulia> clifford_cardinality(7)\n457620995529680351512370381586432000\n\nWhen not accounting for phases (phases = false) the result is the same as the size of the Symplectic group Sp(2n) ≡ 𝒞ₙ/𝒫ₙ, where 𝒫ₙ is the Pauli group over n qubits.\n\njulia> clifford_cardinality(7, phases=false)\n27930968965434591767112450048000\n\nSee also: enumerate_cliffords.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.comm","page":"API","title":"QuantumClifford.comm","text":"Check whether two operators commute.\n\n0x0 if they commute, 0x1 if they anticommute.\n\njulia> P\"XX\"*P\"ZZ\", P\"ZZ\"*P\"XX\"\n(- YY, - YY)\n\njulia> comm(P\"ZZ\", P\"XX\")\n0x00\n\njulia> comm(P\"IZ\", P\"XX\")\n0x01\n\nSee also: comm!\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.comm!","page":"API","title":"QuantumClifford.comm!","text":"An in-place version of comm, storing its output in the given buffer.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.compactify_circuit-Tuple{Any}","page":"API","title":"QuantumClifford.compactify_circuit","text":"Convert a list of gates to a more optimized \"sum type\" format which permits faster dispatch.\n\nGenerally, this should be called on a circuit before it is used in a simulation.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.contractor-Tuple{Stabilizer, Any}","page":"API","title":"QuantumClifford.contractor","text":"Return the subset of Paulis in a Stabilizer that have identity operators on all qubits corresponding to the given subset, without the entries corresponding to subset.\n\njulia> contractor(S\"_X X_\", [1])\n+ X\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.delete_columns-Tuple{Stabilizer, Any}","page":"API","title":"QuantumClifford.delete_columns","text":"Return the given stabilizer without all the qubits in the given iterable.\n\nThe resulting tableaux is not guaranteed to be valid (to retain its commutation relationships).\n\njulia> delete_columns(S\"XYZ YZX ZXY\", [1,3])\n+ Y\n+ Z\n+ X\n\nSee also: traceout!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.destabilizerview-Tuple{Destabilizer}","page":"API","title":"QuantumClifford.destabilizerview","text":"A view of the subtableau corresponding to the destabilizer. See also tab, stabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_cliffords-Tuple{Any, Any}","page":"API","title":"QuantumClifford.enumerate_cliffords","text":"Give the i-th n-qubit Clifford operation, where i∈{1..2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1)}\n\nThe algorithm is detailed in (Koenig and Smolin, 2014).\n\nSee also: symplecticGS, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_cliffords-Tuple{Any}","page":"API","title":"QuantumClifford.enumerate_cliffords","text":"Give all n-qubit Clifford operations.\n\nThe algorithm is detailed in (Koenig and Smolin, 2014).\n\nSee also: symplecticGS, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_phases-Tuple{CliffordOperator}","page":"API","title":"QuantumClifford.enumerate_phases","text":"Given an operator, return all operators that have the same tableau but different phases.\n\njulia> length(collect(enumerate_phases(tCNOT)))\n16\n\nSee also: enumerate_cliffords, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_phases-Tuple{Union{Base.Generator, AbstractVector}}","page":"API","title":"QuantumClifford.enumerate_phases","text":"Given a set of operators, return all operators that have the same tableaux but different phases.\n\njulia> length(collect(enumerate_phases(enumerate_cliffords(2))))\n11520\n\nSee also: enumerate_cliffords, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_single_qubit_gates-Tuple{Any}","page":"API","title":"QuantumClifford.enumerate_single_qubit_gates","text":"Generate a symbolic single-qubit gate given its index. Optionally, set non-trivial phases.\n\njulia> enumerate_single_qubit_gates(6)\nsPhase on qubit 1\nX₁ ⟼ + Y\nZ₁ ⟼ + Z\n\njulia> enumerate_single_qubit_gates(6, qubit=2, phases=(true, true))\nSingleQubitOperator on qubit 2\nX₁ ⟼ - Y\nZ₁ ⟼ - Z\n\nSee also: enumerate_cliffords.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.fastcolumn","page":"API","title":"QuantumClifford.fastcolumn","text":"Convert a tableau to a memory layout that is fast for column operations.\n\nIn this layout a column of the tableau is stored (mostly) contiguously in memory. Due to bitpacking, e.g., packing 64 bits into a single UInt64, the memory layout is not perfectly contiguous, but it is still optimal given that some bitwrangling is required to extract a given bit.\n\nSee also: fastrow\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.fastrow","page":"API","title":"QuantumClifford.fastrow","text":"Convert a tableau to a memory layout that is fast for row operations.\n\nIn this layout a Pauli string (a row of the tableau) is stored contiguously in memory.\n\nSee also: fastrow\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.generate!-Tuple{PauliOperator, Stabilizer}","page":"API","title":"QuantumClifford.generate!","text":"Generate a Pauli operator by using operators from a given the Stabilizer.\n\nIt assumes the stabilizer is already canonicalized. It modifies the Pauli operator in place, generating it in reverse, up to a phase. That phase is left in the modified operator, which should be the identity up to a phase. Returns the new operator and the list of indices denoting the elements of stabilizer that were used for the generation.\n\njulia> ghz = S\"XXXX\n ZZII\n IZZI\n IIZZ\";\n\n\njulia> canonicalize!(ghz)\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> generate!(P\"-ZIZI\", ghz)\n(- ____, [2, 4])\n\nWhen the Pauli operator can not be generated by the given tableau, nothing is returned.\n\njulia> generate!(P\"XII\",canonicalize!(S\"ZII\")) === nothing\ntrue\n\njulia> generate!(P\"XII\",canonicalize!(S\"XII\")) === nothing\nfalse\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_H_to_G-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_H_to_G","text":"For a given F(2,2) parity check matrix, return the generator matrix.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_gausselim!-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_gausselim!","text":"Gaussian elimination over the binary field.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_invert-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_invert","text":"Invert a binary matrix.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_isinvertible-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_isinvertible","text":"Check whether a binary matrix is invertible.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.ghz","page":"API","title":"QuantumClifford.ghz","text":"Prepare a GHZ state of n qubits.\n\njulia> ghz()\n+ XXX\n+ ZZ_\n+ _ZZ\n\njulia> ghz(2)\n+ XX\n+ ZZ\n\njulia> ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.graph_gate-NTuple{4, Any}","page":"API","title":"QuantumClifford.graph_gate","text":"A helper function converting the gate indices from graphstate into a Clifford operator.\n\njulia> s = S\" XXX\n YZ_\n -_ZZ\";\n\n\njulia> graph, h_idx, ip_idx, z_idx = graphstate(s);\n\n\njulia> gate = graph_gate(h_idx, ip_idx, z_idx, nqubits(s));\n\n\njulia> apply!(s, gate) # This is now a graph state (notice you need to multiply row 1 by row 2)\n+ YYZ\n+ XZ_\n+ _ZX\n\njulia> canonicalize!(s) == canonicalize!(Stabilizer(graph))\ntrue\n\nSee also: graph_gatesequence\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.graph_gatesequence-Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}","page":"API","title":"QuantumClifford.graph_gatesequence","text":"A helper function converting the gate indices from graphstate into a sequence of gates.\n\njulia> s = S\" XXX\n YZ_\n -_ZZ\";\n\n\njulia> graph, h_idx, ip_idx, z_idx = graphstate(s);\n\n\njulia> gates = graph_gatesequence(h_idx, ip_idx, z_idx);\n\n\njulia> for gate in vcat(gates...) apply!(s, gate) end\n\n\njulia> s # This is now a graph state (notice you need to multiply row 1 by row 2)\n+ YYZ\n+ XZ_\n+ _ZX\n\njulia> canonicalize!(s) == canonicalize!(Stabilizer(graph))\ntrue\n\nSee also: graph_gatesequence\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.graphstate!-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.graphstate!","text":"An in-place version of graphstate.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.graphstate-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.graphstate","text":"Convert any stabilizer state to a graph state\n\nGraph states are a special type of entangled stabilizer states that can be represented by a graph. For a graph G=(VE) the corresponding stabilizers are S_v = X_v prod_u N(v) Z_u. Notice that such tableau rows contain only a single X operator. There is a set of single qubit gates that converts any stabilizer state to a graph state.\n\nThis function returns the graph state corresponding to a stabilizer and the gates that might be necessary to convert the stabilizer into a state representable as a graph.\n\nFor a tableau stab you can convert it with:\n\ngraph, hadamard_idx, iphase_idx, flips_idx = graphstate()\n\nwhere graph is the graph representation of stab, and the rest specifies the single-qubit gates converting stab to graph: hadamard_idx are the qubits that require a Hadamard gate (mapping X ↔ Z), iphase_idx are (different) qubits that require an inverse Phase gate (Y → X), and flips_idx are the qubits that require a phase flip (Pauli Z gate), after the previous two sets of gates.\n\njulia> using Graphs\n\njulia> s = S\" XXX\n ZZ_\n -_ZZ\";\n\n\njulia> g, h_idx, ip_idx, z_idx = graphstate(s);\n\n\njulia> collect(edges(g))\n2-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:\n Edge 1 => 2\n Edge 1 => 3\n\njulia> h_idx\n2-element Vector{Int64}:\n 2\n 3\n\njulia> ip_idx\nInt64[]\n\njulia> z_idx\n1-element Vector{Int64}:\n 3\n\nThe Graphs.jl library provides many graph-theory tools and the MakieGraphs.jl library provides plotting utilities for graphs.\n\nYou can directly call the graph constructor on a stabilizer, if you just want the graph and do not care about the Clifford operation necessary to convert an arbitrary state to a state representable as a graph:\n\njulia> collect(edges( Graph(bell()) ))\n1-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:\n Edge 1 => 2\n\nFor a version that does not copy the stabilizer, but rather performs transformations in-place, use graphstate!. It would perform canonicalize_gott! on its argument as it finds a way to convert it to a graph state.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.groupify-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.groupify","text":"Return the full stabilizer group represented by the input generating set (a Stabilizer).\n\nThe returned object is exponentially long.\n\njulia> groupify(S\"XZ ZX\")\n+ __\n+ XZ\n+ ZX\n+ YY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.logdot-Tuple{QuantumClifford.AbstractStabilizer, QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.logdot","text":"Logarithm of the inner product between to Stabilizer states.\n\nIf the result is nothing, the dot inner product is zero. Otherwise the inner product is 2^(-logdot/2).\n\nThe actual inner product can be computed with LinearAlgebra.dot.\n\nBased on (Garcia et al., 2012).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.logicalxview-Tuple{MixedDestabilizer}","page":"API","title":"QuantumClifford.logicalxview","text":"A view of the subtableau corresponding to the logical X operators. See also tab, stabilizerview, destabilizerview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.logicalzview-Tuple{MixedDestabilizer}","page":"API","title":"QuantumClifford.logicalzview","text":"A view of the subtableau corresponding to the logical Z operators. See also tab, stabilizerview, destabilizerview, logicalxview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.mctrajectories-Tuple{Any, Any}","page":"API","title":"QuantumClifford.mctrajectories","text":"Run multiple Monte Carlo trajectories and report the aggregate final statuses of each.\n\nSee also: pftrajectories, petrajectories\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.mctrajectory!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.mctrajectory!","text":"Run a single Monte Carlo sample, starting with (and modifying) state by applying the given circuit. Uses apply! under the hood.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.minimal_generating_set-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.minimal_generating_set","text":"For a not-necessarily-minimal generating set, return the minimal generating set.\n\nThe input has to have only real phases.\n\njulia> minimal_generating_set(S\"__ XZ ZX YY\")\n+ XZ\n+ ZX\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.normalizer-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.normalizer","text":"Return all Pauli operators with the same number of qubits as the given Tableau t that commute with all operators in t.\n\njulia> normalizer(T\"X\")\n+ _\n+ X\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pauligroup-Tuple{Int64}","page":"API","title":"QuantumClifford.pauligroup","text":"Return the full Pauli group of a given length. Phases are ignored by default, but can be included by setting phases=true.\n\njulia> pauligroup(1)\n+ _\n+ X\n+ Z\n+ Y\n\njulia> pauligroup(1, phases=true)\n+ _\n+ X\n+ Z\n+ Y\n- _\n- X\n- Z\n- Y\n+i_\n+iX\n+iZ\n+iY\n-i_\n-iX\n-iZ\n-iY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.petrajectories-Tuple{Any, Any}","page":"API","title":"QuantumClifford.petrajectories","text":"Run a perturbative expansion to a given order. This is the main public function for the perturbative expansion approach.\n\nSee also: pftrajectories, mctrajectories\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurements-Tuple{PauliFrame}","page":"API","title":"QuantumClifford.pfmeasurements","text":"pfmeasurements(frame::PauliFrame) -> Any\n\n\nReturns the measurement results for each frame in the PauliFrame instance.\n\nwarning: Relative measurements\nThe return measurements are relative to the reference measurements, i.e. they only say whether the reference measurements have been flipped in the given frame.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurements-Tuple{Register, PauliFrame}","page":"API","title":"QuantumClifford.pfmeasurements","text":"pfmeasurements(register::Register, frame::PauliFrame) -> Any\n\n\nTakes the references measurements from the given Register and applies the flips as prescribed by the PauliFrame relative measurements. The result is the actual (non-relative) measurement results for each frame.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurements-Tuple{Register}","page":"API","title":"QuantumClifford.pfmeasurements","text":"pfmeasurements(register::Register) -> Vector{Bool}\n\n\nReturns the measurements stored in the bits of the given Register.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pftrajectories","page":"API","title":"QuantumClifford.pftrajectories","text":"Perform a \"Pauli frame\" style simulation of a quantum circuit.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.pftrajectories-Tuple{Any}","page":"API","title":"QuantumClifford.pftrajectories","text":"pftrajectories(\n circuit;\n trajectories,\n threads\n) -> PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}, Matrix{Bool}}\n\n\nThe main method for running Pauli frame simulations of circuits. See the other methods for lower level access.\n\nMultithreading is enabled by default, but can be disabled by setting threads=false. Do not forget to launch Julia with multiple threads enabled, e.g. julia -t4, if you want to use multithreading.\n\nSee also: mctrajectories, petrajectories\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pftrajectories-Tuple{PauliFrame, Any}","page":"API","title":"QuantumClifford.pftrajectories","text":"pftrajectories(state::PauliFrame, circuit) -> PauliFrame\n\n\nEvolve each frame stored in PauliFrame by the given circuit.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pftrajectories-Tuple{Register, Any}","page":"API","title":"QuantumClifford.pftrajectories","text":"pftrajectories(\n register::Register,\n circuit;\n trajectories\n) -> Tuple{Register, PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}, Matrix{Bool}}}\n\n\nFor a given Register and circuit, simulates the reference circuit acting on the register and then also simulate numerous PauliFrame trajectories. Returns the register and the PauliFrame instance.\n\nUse pfmeasurements to get the measurement results.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.phases-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.phases","text":"The phases of a given tableau. It is a view, i.e. if you modify this array, the original tableau caries these changes.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.prodphase-Union{Tuple{T}, Tuple{AbstractVector{T}, AbstractVector{T}}} where T<:Unsigned","page":"API","title":"QuantumClifford.prodphase","text":"Get the phase of the product of two Pauli operators.\n\nPhase is encoded as F(4) in the low qubits of an UInt8.\n\njulia> P\"ZZZ\"*P\"XXX\"\n-iYYY\n\njulia> prodphase(P\"ZZZ\", P\"XXX\")\n0x03\n\njulia> prodphase(P\"XXX\", P\"ZZZ\")\n0x01\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectXrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectXrand!","text":"projectXrand!(state, qubit) -> Tuple{Register, UInt8}\n\n\nProject qubit of state along the X axis and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectX!, projectZrand!, projectYrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectYrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectYrand!","text":"projectYrand!(state, qubit) -> Tuple{Register, UInt8}\n\n\nProject qubit of state along the Y axis and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectY!, projectXrand!, projectZrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectZrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectZrand!","text":"projectZrand!(state, qubit) -> Tuple{Register, UInt8}\n\n\nProject qubit of state along the Z axis and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectZ!, projectXrand!, projectYrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectrand!","text":"projectrand!(state, pauli) -> Tuple{Register, Any}\n\n\nMeasure pauli operator on state and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectXrand!, projectZrand!, projectYrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.puttableau!-Union{Tuple{M2}, Tuple{M1}, Tuple{T}, Tuple{V2}, Tuple{V1}, Tuple{B}, Tuple{QuantumClifford.Tableau{V1, M1}, QuantumClifford.Tableau{V2, M2}, Int64, Int64}} where {B, V1, V2, T<:Unsigned, M1<:AbstractMatrix{T}, M2<:AbstractMatrix{T}}","page":"API","title":"QuantumClifford.puttableau!","text":"Put source tableau in target tableau at given row and column. Assumes target location is zeroed out.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.quantumstate","page":"API","title":"QuantumClifford.quantumstate","text":"Only the quantum part of the state (excluding classical bits)\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.random_all_to_all_clifford_circuit-Tuple{Random.AbstractRNG, Int64, Int64}","page":"API","title":"QuantumClifford.random_all_to_all_clifford_circuit","text":"Random all-to-all Clifford circuit.\n\nThe circuit contains nqubits qubits and ngates gates. The connectivity is all to all. Each gate in the circuit is a random 2-qubit Clifford gate on randomly picked two qubits.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_brickwork_clifford_circuit-Tuple{Random.AbstractRNG, Tuple{Vararg{Int64, N}} where N, Int64}","page":"API","title":"QuantumClifford.random_brickwork_clifford_circuit","text":"Random brickwork Clifford circuit.\n\nThe connectivity of the random circuit is brickwork in some dimensions. Each gate in the circuit is a random 2-qubit Clifford gate.\n\nThe brickwork is defined as follows: The qubits are arranged as a lattice, and lattice_size contains side length in each dimension. For example, a chain of length five will have lattice_size = (5,), and a 5×5 lattice will have lattice_size = (5, 5).\n\nIn multi-dimensional cases, gate layers act alternatively along each direction. The nearest two layers along the same direction are offset by one qubit, forming a so-called brickwork. The boundary condition is chosen as open.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_clifford-Tuple{Random.AbstractRNG, Int64}","page":"API","title":"QuantumClifford.random_clifford","text":"A random Clifford operator generated by the Bravyi-Maslov Algorithm 2 from (Bravyi and Maslov, 2021).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_clifford1-Tuple{Random.AbstractRNG, Any}","page":"API","title":"QuantumClifford.random_clifford1","text":"Random symbolic single-qubit Clifford applied to qubit at index qubit.\n\nSee also: SingleQubitOperator, random_clifford\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_destabilizer-Tuple{Random.AbstractRNG, Int64}","page":"API","title":"QuantumClifford.random_destabilizer","text":"A random Stabilizer/Destabilizer tableau generated by the Bravyi-Maslov Algorithm 2 from (Bravyi and Maslov, 2021).\n\nrandom_destabilizer(n) gives a n-qubit tableau of rank n. random_destabilizer(r,n) gives a n-qubit tableau of rank r.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_pauli","page":"API","title":"QuantumClifford.random_pauli","text":"A random Pauli operator on n qubits.\n\nUse nophase=false to randomize the phase. Use realphase=false to get operators with phases including ±i.\n\nOptionally, a \"flip\" probability p can be provided specified, in which case each bit is set to I with probability 1-p and to X or Y or Z with probability p. Useful for simulating unbiased Pauli noise.\n\nSee also random_pauli!\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.random_pauli!","page":"API","title":"QuantumClifford.random_pauli!","text":"An in-place version of random_pauli\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.random_stabilizer-Tuple{Random.AbstractRNG, Int64}","page":"API","title":"QuantumClifford.random_stabilizer","text":"A random Stabilizer tableau generated by the Bravyi-Maslov Algorithm 2 from (Bravyi and Maslov, 2021).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.single_x-Tuple{Any, Any}","page":"API","title":"QuantumClifford.single_x","text":"A multiqubit operator corresponding to all identities except for Pauli X at i. See also: sX, sMX\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.single_y-Tuple{Any, Any}","page":"API","title":"QuantumClifford.single_y","text":"A multiqubit operator corresponding to all identities except for Pauli Y at i. See also: sY, sMY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.single_z-Tuple{Any, Any}","page":"API","title":"QuantumClifford.single_z","text":"A multiqubit operator corresponding to all identities except for Pauli Z at i. See also: sY, sMY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.stab_to_gf2-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.stab_to_gf2","text":"The F(2,2) matrix of a given tableau, represented as the concatenation of two binary matrices, one for X and one for Z.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.stabilizerplot","page":"API","title":"QuantumClifford.stabilizerplot","text":"A Makie.jl recipe for pictorial representation of a tableau.\n\nRequires a Makie.jl backend to be loaded, e.g. using CairoMakie.\n\nAlternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S\"XXX ZZZ\").\n\nConsult the documentation for more details on visualization options.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.stabilizerplot_axis","page":"API","title":"QuantumClifford.stabilizerplot_axis","text":"A Makie.jl recipe for pictorial representation of a tableau.\n\nRequires a Makie.jl backend to be loaded, e.g. using CairoMakie.\n\nAlternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S\"XXX ZZZ\").\n\nConsult the documentation for more details on visualization options.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.stabilizerview-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.stabilizerview","text":"A view of the subtableau corresponding to the stabilizer. See also tab, destabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.symplecticGS-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.symplecticGS","text":"Perform the Symplectic Gram-Schmidt procedure that gives a Clifford operator canonically related to a given Pauli operator.\n\nThe algorithm is detailed in (Koenig and Smolin, 2014).\n\njulia> symplecticGS(P\"X\", padded_n=3)\nX₁ ⟼ + X__\nX₂ ⟼ + _X_\nX₃ ⟼ + __X\nZ₁ ⟼ + Z__\nZ₂ ⟼ + _Z_\nZ₃ ⟼ + __Z\n\njulia> symplecticGS(P\"Z\")\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\nSee also: enumerate_cliffords, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.tab-Union{Tuple{Stabilizer{T}}, Tuple{T}} where T","page":"API","title":"QuantumClifford.tab","text":"Extract the underlying tableau structure.\n\njulia> s = S\"X\"\n+ X\n\njulia> tab(s)\n+ X\n\njulia> tab(Destabilizer(s))\n+ Z\n+ X\n\njulia> tab(MixedDestabilizer(s))\n+ Z\n+ X\n\njulia> tab(tHadamard)\n+ Z\n+ X\n\njulia> typeof(tab(tHadamard))\nQuantumClifford.Tableau{Vector{UInt8}, Matrix{UInt64}}\n\nSee also: stabilizerview, destabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.xbit-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.xbit","text":"Extract as a new bit array the X part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.xview-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.xview","text":"Get a view of the X part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.zbit-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.zbit","text":"Extract as a new bit array the Z part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.zview-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.zview","text":"Get a view of the Y part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.apply!","page":"API","title":"QuantumInterface.apply!","text":"In QuantumClifford the apply! function is used to apply any quantum operation to a stabilizer state, including unitary Clifford operations, Pauli measurements, and noise. Thus, this function may result in a random/stochastic result (e.g. with measurements or noise).\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumInterface.embed-Tuple{Int64, Int64, PauliOperator}","page":"API","title":"QuantumInterface.embed","text":"Embed a Pauli operator in a larger Pauli operator.\n\njulia> embed(5, 3, P\"-Y\")\n- __Y__\n\njulia> embed(5, (3,5), P\"-YX\")\n- __Y_X\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.entanglement_entropy","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy of a subsystem\n\nDefined as entropy of the reduced density matrix.\n\nIt can be calculated with multiple different algorithms, the most performant one depending on the particular case.\n\nCurrently implemented are the :clip (clipped gauge), :graph (graph state), and :rref (Gaussian elimination) algorithms. Benchmark your particular case to choose the best one.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumInterface.entanglement_entropy-Tuple{QuantumClifford.AbstractStabilizer, AbstractVector, Val{:graph}}","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy by first converting the state to a graph and computing the rank of the adjacency matrix.\n\nBased on \"Entanglement in graph states and its applications\".\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.entanglement_entropy-Tuple{QuantumClifford.AbstractStabilizer, AbstractVector, Val{:rref}}","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy by converting to RREF form (i.e., partial trace form).\n\nThe state will be partially canonicalized in an RREF form.\n\nSee also: canonicalize_rref!, traceout!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.entanglement_entropy-Tuple{QuantumClifford.AbstractStabilizer, UnitRange, Val{:clip}}","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy of a contiguous subsystem by passing through the clipped gauge.\n\nIf clip=false is set the canonicalization step is skipped, useful if the input state is already in the clipped gauge.\n\nSee also: bigram, canonicalize_clip!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.expect-Tuple{PauliOperator, QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumInterface.expect","text":"expect(p::PauliOperator, st::AbstractStabilizer)\n\nCompute the expectation value of a Pauli operator p on a stabilizer state st. This function will allocate a temporary copy of the stabilizer state st.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.nqubits-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumInterface.nqubits","text":"The number of qubits of a given state.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.project!-Tuple{Any, PauliOperator}","page":"API","title":"QuantumInterface.project!","text":"project!(\n state,\n pauli::PauliOperator;\n keep_result,\n phases\n) -> Tuple{MixedStabilizer, Any, Any}\n\n\nProject the state of a Stabilizer on the two eigenspaces of a Pauli operator.\n\nAssumes the input is a valid stabilizer. The projection is done inplace on that stabilizer and it does not modify the projection operator.\n\nIt returns\n\na stabilizer that might not be in canonical form\nthe index of the row where the non-commuting operator was (that row is now equal to pauli; its phase is not updated and for a faithful measurement simulation it needs to be randomized by the user)\nand the result of the projection if there was no non-commuting operator (nothing otherwise)\n\nIf keep_result==false that result of the projection in case of anticommutation is not computed, sparing a canonicalization operation. This canonicalization operation is the only one potentially of cubic complexity. The rest of the calculations are of quadratic complexity.\n\nIf you need to measure a single qubit instead of a multiqubit Pauli operator, the faster projectX!, projectY!, and projectZ! are available.\n\nFor less boilerplate and automatic randomization of the phase use projectrand!.\n\nHere is an example of a projection destroying entanglement:\n\njulia> ghz = S\"XXXX\n ZZII\n IZZI\n IIZZ\";\n\n\njulia> canonicalize!(ghz)\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> state, anticom_index, result = project!(ghz, P\"ZIII\");\n\n\njulia> state\n+ Z___\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> canonicalize!(state)\n+ Z___\n+ _Z__\n+ __Z_\n+ ___Z\n\njulia> anticom_index, result\n(1, nothing)\n\nAnd an example of projection consistent with the stabilizer state.\n\njulia> s = S\"ZII\n IXI\n IIY\";\n\n\njulia> canonicalize!(s)\n+ _X_\n+ __Y\n+ Z__\n\njulia> state, anticom_index, result = project!(s, P\"-ZII\");\n\n\njulia> state\n+ _X_\n+ __Y\n+ Z__\n\njulia> anticom_index, result\n(0, 0x02)\n\nWhile not the best choice, Stabilizer can be used for mixed states, simply by providing an incomplete tableau. In that case it is possible to attempt to project on an operator that can not be generated by the provided stabilizer operators. In that case we have anticom_index==rank and result===nothing, where rank is the the new rank of the tableau, one more than the number of rows in the initial tableau. However, if keep_result was set to false, then anticom_index would stay at zero.\n\njulia> s = S\"XZI\n IZI\";\n\n\njulia> project!(s, P\"IIX\")[1]\n+ X__\n+ _Z_\n\nIf we had used MixedStabilizer we would have added the projector to the list of stabilizers.\n\njulia> s = one(MixedStabilizer, 2, 3)\n+ Z__\n+ _Z_\n\njulia> project!(s, P\"IIX\")[1]\n+ Z__\n+ _Z_\n+ __X\n\nHowever, MixedDestabilizer would be an even better choice as it has mathcalO(n^2) complexity instead of the mathcalO(n^3) complexity of *Stabilizer.\n\njulia> s = one(MixedDestabilizer, 2, 3)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ X__\n+ _X_\n𝒳ₗ━━━\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ _Z_\n𝒵ₗ━━━\n+ __Z\n\njulia> project!(s, P\"IIX\")[1]\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ X__\n+ _X_\n+ __Z\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ _Z_\n+ __X\n\nSee the \"Datastructure Choice\" section in the documentation for more details.\n\nSee also: projectX!, projectY!, projectZ!, projectrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.project!-Tuple{MixedStabilizer, PauliOperator}","page":"API","title":"QuantumInterface.project!","text":"project!(\n state::MixedStabilizer,\n pauli::PauliOperator;\n phases\n) -> Tuple{MixedStabilizer, Any, Any}\n\n\nWhen using project! on MixedStabilizer it automates some of the extra steps we encounter when implicitly using the Stabilizer datastructure to represent mixed states. Namely, it helps when the projector is not among the list of stabilizers:\n\njulia> s = S\"XZI\n IZI\";\n\n\njulia> ms = MixedStabilizer(s)\n+ X__\n+ _Z_\n\njulia> project!(ms, P\"IIY\")[1]\n+ X__\n+ _Z_\n+ __Y\n\nSimilarly to project! on Stabilizer, this function has cubic complexity when the Pauli operator commutes with all rows of the tableau. Most of the time it is better to simply use MixedDestabilizer representation.\n\nUnlike other project! methods, this one does not allow for keep_result=false, as the correct rank or anticommutation index can not be calculated without the expensive (cubic) canonicalization operation required by keep_result=true.\n\nSee the \"Datastructure Choice\" section in the documentation for more details.\n\nSee also: projectX!, projectY!, projectZ!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.projectX!-Tuple{MixedDestabilizer, Int64}","page":"API","title":"QuantumInterface.projectX!","text":"Measure a given qubit in the X basis. A faster special-case version of project!.\n\nSee also: project!, projectXrand!, projectY!, projectZ!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.projectY!-Tuple{MixedDestabilizer, Int64}","page":"API","title":"QuantumInterface.projectY!","text":"Measure a given qubit in the Y basis. A faster special-case version of project!.\n\nSee also: project!, projectYrand!, projectX!, projectZ!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.projectZ!-Tuple{MixedDestabilizer, Int64}","page":"API","title":"QuantumInterface.projectZ!","text":"Measure a given qubit in the Z basis. A faster special-case version of project!.\n\nSee also: project!, projectZrand!, projectY!, projectX!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.reset_qubits!-Tuple{MixedDestabilizer, QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumInterface.reset_qubits!","text":"reset_qubits!(\n s::MixedDestabilizer,\n newstate::QuantumClifford.AbstractStabilizer,\n qubits;\n phases\n) -> MixedDestabilizer\n\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.reset_qubits!-Tuple{MixedStabilizer, Any, Any}","page":"API","title":"QuantumInterface.reset_qubits!","text":"reset_qubits!(\n s::MixedStabilizer,\n newstate,\n qubits;\n phases\n) -> MixedStabilizer\n\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.reset_qubits!-Tuple{Stabilizer, Any, Any}","page":"API","title":"QuantumInterface.reset_qubits!","text":"reset_qubits!(\n s::Stabilizer,\n newstate,\n qubits;\n phases\n) -> Any\n\n\nReset a given set of qubits to be in the state newstate. These qubits are traced out first, which could lead to \"nonlocal\" changes in the tableau.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.tensor","page":"API","title":"QuantumInterface.tensor","text":"Tensor product between operators or tableaux. \n\nTensor product between CiffordOperators:\n\njulia> tensor(CliffordOperator(sCNOT), CliffordOperator(sCNOT))\nX₁ ⟼ + XX__\nX₂ ⟼ + _X__\nX₃ ⟼ + __XX\nX₄ ⟼ + ___X\nZ₁ ⟼ + Z___\nZ₂ ⟼ + ZZ__\nZ₃ ⟼ + __Z_\nZ₄ ⟼ + __ZZ\n\nTensor product between PauliOperators:\n\njulia> tensor(P\"-IXYZ\", P\"iIXYZ\")\n-i_XYZ_XYZ\n\nTensor product between Tableaux:\n\njulia> s = S\"-XX\n +ZZ\";\n\njulia> tensor(s, s, s)\n- XX____\n+ ZZ____\n- __XX__\n+ __ZZ__\n- ____XX\n+ ____ZZ\n\njulia> s = S\"+XZI\n -IZI\";\n\njulia> tensor(s, s)\n+ XZ____\n- _Z____\n+ ___XZ_\n- ____Z_\n\nSee also tensor_pow.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumInterface.tensor_pow-Tuple{Union{QuantumClifford.AbstractCliffordOperator, QuantumClifford.AbstractStabilizer}, Any}","page":"API","title":"QuantumInterface.tensor_pow","text":"Repeated tensor product of an operators or a tableau.\n\nFor CliffordOperator:\n\njulia> tensor_pow(CliffordOperator(sHadamard), 3)\nX₁ ⟼ + Z__\nX₂ ⟼ + _Z_\nX₃ ⟼ + __Z\nZ₁ ⟼ + X__\nZ₂ ⟼ + _X_\nZ₃ ⟼ + __X\n\nFor PauliOperator:\n\njulia> tensor_pow(P\"IXYZ\", 2)\n+ _XYZ_XYZ\n\nFor Tableaux:\n\njulia> tensor_pow(S\"Z\", 4)\n+ Z___\n+ _Z__\n+ __Z_\n+ ___Z\n\njulia> s = S\"+XZI\n +IZI\";\n\njulia> tensor_pow(s, 3)\n+ XZ_______\n+ _Z_______\n+ ___XZ____\n+ ____Z____\n+ ______XZ_\n+ _______Z_\n\nSee also tensor.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.traceout!-Tuple{Stabilizer, Any}","page":"API","title":"QuantumInterface.traceout!","text":"traceout!(s::Stabilizer, qubits; phases, rank) -> Any\n\n\nTrace out a qubit.\n\nSee also: delete_columns\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.traceout!-Tuple{Union{MixedDestabilizer, MixedStabilizer}, Any}","page":"API","title":"QuantumInterface.traceout!","text":"traceout!(\n s::Union{MixedDestabilizer, MixedStabilizer},\n qubits;\n phases,\n rank\n) -> Any\n\n\n\n\n\n\n","category":"method"},{"location":"API/#Private-API","page":"API","title":"Private API","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"danger: Private Implementation Details\nThese functions are used internally by the library and might be drastically modified or deleted without warning or deprecation.","category":"page"},{"location":"API/","page":"API","title":"API","text":"Modules = [QuantumClifford]\nPrivate = true\nPublic = false","category":"page"},{"location":"API/#QuantumClifford.AbstractMeasurement","page":"API","title":"QuantumClifford.AbstractMeasurement","text":"Supertype of all symbolic single-qubit measurements.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.SymbolicDataType","page":"API","title":"QuantumClifford.SymbolicDataType","text":"An intermediary when we want to create a new concrete type in a macro.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Tableau","page":"API","title":"QuantumClifford.Tableau","text":"Internal Tableau type for storing a list of Pauli operators in a compact form. No special semantic meaning is attached to this type, it is just a convenient way to store a list of Pauli operators. E.g. it is not used to represent a stabilizer state, or a stabilizer group, or a Clifford circuit.\n\n\n\n\n\n","category":"type"},{"location":"API/#Base.hcat-Tuple{Vararg{QuantumClifford.Tableau}}","page":"API","title":"Base.hcat","text":"Horizontally concatenates tableaux.\n\njulia> hcat(ghz(2), ghz(2))\n+ XXXX\n+ ZZZZ\n\nSee also: vcat\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.inv-Tuple{CliffordOperator}","page":"API","title":"Base.inv","text":"inv(\n c::CliffordOperator;\n phases\n) -> CliffordOperator{QuantumClifford.Tableau{Vector{UInt8}, Matrix{UInt64}}}\n\n\nInverse of a CliffordOperator\n\njulia> inv(CliffordOperator(sCNOT))\nX₁ ⟼ + XX\nX₂ ⟼ + _X\nZ₁ ⟼ + Z_\nZ₂ ⟼ + ZZ\n\njulia> inv(CliffordOperator(sCNOT(2, 1), 2))\nX₁ ⟼ + X_\nX₂ ⟼ + XX\nZ₁ ⟼ + ZZ\nZ₂ ⟼ + _Z\n\njulia> inv(CliffordOperator(tHadamard))\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.permute!-Tuple{QuantumClifford.AbstractStabilizer, AbstractVector}","page":"API","title":"Base.permute!","text":"Permute the qubits (i.e., columns) of the state in place.\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.permute!-Tuple{QuantumClifford.Tableau, AbstractVector}","page":"API","title":"Base.permute!","text":"Permute the qubits (i.e., columns) of the tableau in place.\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.vcat-Tuple{Vararg{QuantumClifford.Tableau}}","page":"API","title":"Base.vcat","text":"Vertically concatenates tableaux.\n\njulia> vcat(ghz(2), ghz(2))\n+ XX\n+ ZZ\n+ XX\n+ ZZ\n\nSee also: hcat\n\n\n\n\n\n","category":"method"},{"location":"API/#LinearAlgebra.dot-Tuple{QuantumClifford.AbstractStabilizer, QuantumClifford.AbstractStabilizer}","page":"API","title":"LinearAlgebra.dot","text":"The inner product of two Stabilizers.\n\nBased on (Garcia et al., 2012).\n\njulia> using LinearAlgebra\n\njulia> dot(S\"Z\", S\"Z\")\n1.0\n\njulia> dot(S\"Z\", S\"Y\")\n0.7071067811865476\n\nSee also: logdot\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._apply_nonthread!-Tuple{QuantumClifford.AbstractStabilizer, CliffordOperator, AbstractVector{Int64}}","page":"API","title":"QuantumClifford._apply_nonthread!","text":"Nonvectorized version of apply! used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._apply_nonthread!-Tuple{QuantumClifford.AbstractStabilizer, CliffordOperator}","page":"API","title":"QuantumClifford._apply_nonthread!","text":"Nonvectorized version of apply! used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._mul_left_nonvec!-Union{Tuple{T}, Tuple{AbstractVector{T}, AbstractVector{T}}} where T<:Unsigned","page":"API","title":"QuantumClifford._mul_left_nonvec!","text":"Nonvectorized version of mul_left! used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._remove_rowcol!-Tuple{MixedDestabilizer, Any, Any}","page":"API","title":"QuantumClifford._remove_rowcol!","text":"Unexported low-level function that removes a row (by shifting all rows up as necessary)\n\nBecause MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.\n\nUsed on its own, this function will break invariants. Meant to be used with projectremove!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._rowmove!-Union{Tuple{B}, Tuple{QuantumClifford.Tableau, Any, Any}} where B","page":"API","title":"QuantumClifford._rowmove!","text":"Unexported low-level function that moves row i to row j.\n\nUsed on its own, this function will break invariants. Meant to be used in _remove_rowcol!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._stim_prodphase-Union{Tuple{T}, Tuple{AbstractVector{T}, AbstractVector{T}}} where T<:Unsigned","page":"API","title":"QuantumClifford._stim_prodphase","text":"The quantumlib/Stim implementation, which performs the prodphase and mul_left! together. Used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.apply_single_x!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.apply_single_x!","text":"Apply a Pauli X to the i-th qubit of state s. You should use apply!(stab,sX(i)) instead of this.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.apply_single_y!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.apply_single_y!","text":"Apply a Pauli Y to the i-th qubit of state s. You should use apply!(stab,sY(i)) instead of this.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.apply_single_z!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.apply_single_z!","text":"Apply a Pauli Z to the i-th qubit of state s. You should use apply!(stab,sZ(i)) instead of this.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.applynoise_branches","page":"API","title":"QuantumClifford.applynoise_branches","text":"Compute all possible new states after the application of the given noise model. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Noise interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.colswap!-Tuple{QuantumClifford.Tableau, Any, Any}","page":"API","title":"QuantumClifford.colswap!","text":"Swap two columns of a stabilizer in place.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.destab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.destab_looks_good","text":"Check basic consistency requirements of a destabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_cliffords_slow-Tuple{Any, Any}","page":"API","title":"QuantumClifford.enumerate_cliffords_slow","text":"The O(n^4) implementation from (Koenig and Smolin, 2014) – their algorithm seems wrong as ⟨w'₁|wₗ⟩=bₗ which is not always zero.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.fill_tril-Tuple{Any, Any, Any}","page":"API","title":"QuantumClifford.fill_tril","text":"Assign (symmetric) random ints to off diagonals of matrix.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.get_all_subtypes-Tuple{Any}","page":"API","title":"QuantumClifford.get_all_subtypes","text":"Returns a tuple of all concrete subtypes and all UnionAll non-abstract subtypes of a given type.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_H_standard_form_indices-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_H_standard_form_indices","text":"The permutation of columns which turns a binary matrix into standard form. It is assumed the matrix has already undergone Gaussian elimination.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.initZ!-Tuple{PauliFrame}","page":"API","title":"QuantumClifford.initZ!","text":"initZ!(frame::PauliFrame) -> PauliFrame\n\n\nInject random Z errors over all frames and qubits for the supplied PauliFrame with probability 0.5.\n\nCalling this after initialization is essential for simulating any non-deterministic circuit. It is done automatically by most PauliFrame constructors.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_sumtype-Tuple{Any}","page":"API","title":"QuantumClifford.make_sumtype","text":"julia> make_sumtype([sCNOT])\nquote\n @sum_type CompactifiedGate :hidden begin\n sCNOT(::Int64, ::Int64)\n end\nend\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_sumtype_method","page":"API","title":"QuantumClifford.make_sumtype_method","text":"``` julia> makesumtypemethod([sCNOT], :apply!, (:s,)) quote function QuantumClifford.apply!(s, g::CompactifiedGate) @cases g begin sCNOT(q1, q2) => apply!(s, sCNOT(q1, q2)) end end end\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.make_sumtype_variant_constructor-Tuple{Any}","page":"API","title":"QuantumClifford.make_sumtype_variant_constructor","text":"julia> make_sumtype_variant_constructor(sCNOT)\n:(CompactifiedGate(g::sCNOT) = begin\n (CompactifiedGate').sCNOT(g.q1, g.q2)\nend)\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_variant-Tuple{Union{DataType, QuantumClifford.SymbolicDataType}}","page":"API","title":"QuantumClifford.make_variant","text":"julia> make_variant(sCNOT)\n:(sCNOT(::Int64, ::Int64))\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_variant_deconstruct","page":"API","title":"QuantumClifford.make_variant_deconstruct","text":"julia> make_variant_deconstruct(sCNOT, :apply!, (:s,))\n:(sCNOT(q1, q2) => apply!(s, sCNOT(q1, q2)))\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.mixed_destab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.mixed_destab_looks_good","text":"Check basic consistency requirements of a mixed destabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.mixed_stab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.mixed_stab_looks_good","text":"Check basic consistency requirements of a mixed stabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurement","page":"API","title":"QuantumClifford.pfmeasurement","text":"For a given simulated state, e.g. a PauliFrame instance, returns the measurement results.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.precise_inv-Tuple{Any}","page":"API","title":"QuantumClifford.precise_inv","text":"Inverting a binary matrix: uses floating point for small matrices and Nemo for large matrices.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.project_cond!-Union{Tuple{PHASES}, Tuple{RESET}, Tuple{IS}, Tuple{MixedDestabilizer, Int64, Val{IS}, Val{RESET}}} where {IS, RESET, PHASES}","page":"API","title":"QuantumClifford.project_cond!","text":"Internal method used to implement projectX!, projectZ!, and projectY!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectremoverand!-Union{Tuple{F}, Tuple{MixedDestabilizer, F, Any}} where F<:Union{typeof(projectX!), typeof(projectY!), typeof(projectZ!)}","page":"API","title":"QuantumClifford.projectremoverand!","text":"Unexported low-level function that projects a qubit and returns the result while making the tableau smaller by a qubit.\n\nBecause MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.quantum_mallows-Tuple{Any, Any}","page":"API","title":"QuantumClifford.quantum_mallows","text":"Sample (h, S) from the distribution P_n(h, S) from Bravyi and Maslov Algorithm 1.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.remove_column!-Union{Tuple{M}, Tuple{T}, Tuple{V}, Tuple{QuantumClifford.Tableau{V, M}, Int64}} where {V, T<:Unsigned, M<:AbstractMatrix{T}}","page":"API","title":"QuantumClifford.remove_column!","text":"Unexported low-level function that removes a column (by shifting all columns to the right of the target by one step to the left)\n\nBecause Tableau is not mutable we return a new Tableau with the same (modified) xzs array.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.rowdecompose-Tuple{Any, Union{Destabilizer, MixedDestabilizer}}","page":"API","title":"QuantumClifford.rowdecompose","text":"Decompose a Pauli P in terms of stabilizer and destabilizer rows from a given tableaux.\n\nFor given tableaux of rows destabilizer rows d_i and stabilizer rows s_i, there are boolean vectors b and c such that P = i^p prod_i d_i^b_i prod_i s_i^c_i.\n\nThis function returns p, b, c.\n\njulia> s = MixedDestabilizer(ghz(2))\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z_\n+ _X\n𝒮𝓉𝒶𝒷\n+ XX\n+ ZZ\n\njulia> phase, destab_rows, stab_rows = QuantumClifford.rowdecompose(P\"XY\", s)\n(3, Bool[1, 0], Bool[1, 1])\n\njulia> im^3 * P\"Z_\" * P\"XX\" * P\"ZZ\"\n+ XY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.sample_geometric_2-Tuple{Any, Integer}","page":"API","title":"QuantumClifford.sample_geometric_2","text":"This function samples a number from 1 to n where n >= 1 probability of outputting i is proportional to 2^i\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.stab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.stab_looks_good","text":"Check basic consistency requirements of a stabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.to_cpu","page":"API","title":"QuantumClifford.to_cpu","text":"copies the memory content of the object to CPU\n\nYou can only use this function if CUDA.jl is imported\n\nFor more advanced users to_cpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your CPU architecture, if working with matrices of UInt32 is faster than UInt64, you can use to_cpu(data, UInt32)\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> stab = S\"- X_Z\\n+ _ZZ\\n+ __Z\"\n- X_Z\n+ _ZZ\n+ __Z\n\njulia> stab_gpu = to_gpu(stab);\n\njulia> apply!(stab_gpu, sHadamard(1));\n\njulia> stab_result_cpu = to_cpu(stab_gpu)\n- Z_Z\n+ _ZZ\n+ __Z\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> pf_gpu = to_gpu(PauliFrame(1000, 2, 2));\njulia> circuit = [sMZ(1, 1), sHadamard(2), sMZ(2, 2)];\njulia> pftrajectories(pf_gpu, circuit);\njulia> measurements = to_cpu(pf_gpu.measurements);\n\nSee also: to_gpu\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.to_gpu","page":"API","title":"QuantumClifford.to_gpu","text":"copies the memory content of the object to GPU\n\nYou can only use this function if CUDA.jl is imported\n\nFor more advanced users to_gpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your GPU architecture, if working with matrices of UInt64 is faster than UInt32, you can use to_gpu(data, UInt64)\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> stab = S\"- X_Z\\n+ _ZZ\\n+ __Z\"\n- X_Z\n+ _ZZ\n+ __Z\n\njulia> stab_gpu = to_gpu(stab);\n\njulia> apply!(stab_gpu, sHadamard(1));\n\njulia> stab_result_cpu = to_cpu(stab_gpu)\n- Z_Z\n+ _ZZ\n+ __Z\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> pf_gpu = to_gpu(PauliFrame(1000, 2, 2));\njulia> circuit = [sMZ(1, 1), sHadamard(2), sMZ(2, 2)];\njulia> pftrajectories(pf_gpu, circuit);\njulia> measurements = to_cpu(pf_gpu.measurements);\n\nSee also: to_cpu\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.trusted_rank","page":"API","title":"QuantumClifford.trusted_rank","text":"A \"trusted\" rank which returns rank(state) for Mixed[De]Stabilizer and length(state) for [De]Stabilizer.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.zero!-Tuple{QuantumClifford.Tableau, Any}","page":"API","title":"QuantumClifford.zero!","text":"Zero-out a given row of a Tableau\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.zero!-Union{Tuple{PauliOperator{Tₚ, Tᵥ}}, Tuple{Tᵥ}, Tuple{Tᵥₑ}, Tuple{Tₚ}} where {Tₚ, Tᵥₑ<:Unsigned, Tᵥ<:AbstractVector{Tᵥₑ}}","page":"API","title":"QuantumClifford.zero!","text":"Zero-out the phases and single-qubit operators in a PauliOperator\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.@qubitop1-Tuple{Any, Any}","page":"API","title":"QuantumClifford.@qubitop1","text":"Macro used to define single qubit symbolic gates and their qubit_kernel methods.\n\n\n\n\n\n","category":"macro"},{"location":"API/#QuantumClifford.@qubitop2-Tuple{Any, Any}","page":"API","title":"QuantumClifford.@qubitop2","text":"Macro used to define 2-qubit symbolic gates and their qubit_kernel methods.\n\n\n\n\n\n","category":"macro"},{"location":"API/#QuantumClifford.@valbooldispatch-Tuple{Any, Vararg{Any}}","page":"API","title":"QuantumClifford.@valbooldispatch","text":"Turns f(Val(x)) into x ? f(Val(true)) : f(Val(false)) in order to avoid dynamic dispatch\n\nSee discourse discussion\n\n\n\n\n\n","category":"macro"},{"location":"mixed/#Mixed-Stabilizer-States","page":"Mixed States","title":"Mixed Stabilizer States","text":"","category":"section"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"DocTestSetup = quote\n using QuantumClifford\nend","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"The Stabilizer and Destabilizer have some support for mixed states (by being initialized with an incomplete list of stabilizer generators), but for most purposes one would use the Mixed* data structures.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"Mixed stabilizer states are implemented with MixedStabilizer and MixedDestabilizer, the latter of which is the preferred data structure for most tasks as it is much faster by virtue of tracking the destabilizer generators.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"julia> s = S\"XXX\n IZZ\";\n\njulia> Destabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ _ZZ","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"Unlike Destabilizer, MixedDestabilizer also tracks the logical operation generators.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"julia> m = MixedDestabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n𝒳ₗ━━━\n+ _XX\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ _ZZ\n𝒵ₗ━━━\n+ Z_Z\n\njulia> stabilizerview(m)\n+ XXX\n+ _ZZ\n\njulia> destabilizerview(m)\n+ Z__\n+ _X_\n\njulia> logicalxview(m)\n+ _XX\n\njulia> logicalzview(m)\n+ Z_Z","category":"page"},{"location":"mixed/#Gottesman-Canonicalization","page":"Mixed States","title":"Gottesman Canonicalization","text":"","category":"section"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"To obtain the logical operators we perform a different type of canonicalization, described in Gottesman's thesis and implemented in canonicalize_gott!. Unlike canonicalize! which uses only row operations, canonicalize_gott! performs column swaps as well. MixedDestabilizer undoes those swaps by default when instantiated, but that behavior can be turned off, if you prefer to work with the canonicalized tableau.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"julia> s = S\"XXX\n ZIZ\";\n\njulia> MixedDestabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ __X\n𝒳ₗ━━━\n+ _X_\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ Z_Z\n𝒵ₗ━━━\n+ ZZ_\n\njulia> MixedDestabilizer(s; undoperm=false)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n𝒳ₗ━━━\n+ __X\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ ZZ_\n𝒵ₗ━━━\n+ Z_Z","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"Destabilizer and MixedStabilizer do not use any column swaps on instantiation as they do not track the logical operators.","category":"page"},{"location":"datastructures/#Data-Structures-Options","page":"Datastructure Choice","title":"Data Structures Options","text":"","category":"section"},{"location":"datastructures/#Choosing-Appropriate-Data-Structure","page":"Datastructure Choice","title":"Choosing Appropriate Tableau Data Structure","text":"","category":"section"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"There are four different data structures used to represent stabilizer states. If you will never need projective measurements you probably would want to use Stabilizer. If you require projective measurements, but only on pure states, Destabilizer should be the appropriate data structure. If mixed stabilizer states are involved, MixedStabilizer would be necessary.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Stabilizer is simply a list of Pauli operators in a tableau form. As a data structure it does not enforce the requirements for a pure stabilizer state (the rows of the tableau do not necessarily commute, nor are they forced to be Hermitian; the tableau might be underdetermined, redundant, or contradictory). It is up to the user to ensure that the initial values in the tableau are meaningful and consistent.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"canonicalize!, project!, and generate! can accept an under determined (mixed state) Stabilizer instance and operate correctly. canonicalize! can also accept a redundant Stabilizer (i.e. not all rows are independent), leaving as many identity rows at the bottom of the canonicalized tableau as the number of redundant stabilizers in the initial tableau.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"canonicalize! takes mathcalO(n^3) steps. generate! expects a canonicalized input and then takes mathcalO(n^2) steps. project! takes mathcalO(n^3) for projecting on commuting operators due to the need to call canonicalize! and generate!. If the projections is on an anticommuting operator (or if keep_result=false) then it takes mathcalO(n^2) steps.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"MixedStabilizer provides explicit tracking of the rank of the mixed state and works properly when the projection is on a commuting operator not in the stabilizer (see table below for details). Otherwise it has the same performance as Stabilizer.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"The canonicalization can be made unnecessary if we track the destabilizer generators. There are two data structures capable of that.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Destabilizer stores both the destabilizer and stabilizer states. project! called on it never requires a stabilizer canonicalization, hence it runs in mathcalO(n^2). However, project! will raise an exception if you try to project on a commuting state that is not in the stabilizer as that would be an expensive mathcalO(n^3) operation.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"MixedDestabilizer tracks both the destabilizer operators and the logical operators in addition to the stabilizer generators. It does not require canonicalization for measurements and its project! operations always takes mathcalO(n^2).","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"For the operation _, anticom_index, result = project!(...) we have the following behavior:","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"projection Stabilizer MixedStabilizer Destabilizer MixedDestabilizer\non anticommuting operator anticom_index>0 result===nothing correct result in mathcalO(n^2) steps same as Stabilizer same as Stabilizer same as Stabilizer\non commuting operator in the stabilizer anticom_index==0 result!==nothing mathcalO(n^3); or mathcalO(n^2) if keep_result=false mathcalO(n^3) mathcalO(n^2) if the state is pure, throws exception otherwise mathcalO(n^2)\non commuting operator out of the stabilizer[1] anticom_index==rank result===nothing mathcalO(n^3), but the user needs to manually include the new operator to the stabilizer; or mathcalO(n^2) if keep_result=false but then result indistinguishable from cell above and anticom_index==0 mathcalO(n^3) and rank goes up by one not applicable if the state is pure, throws exception otherwise mathcalO(n^2) and rank goes up by one","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Notice the results when the projection operator commutes with the state but is not generated by the stabilizers of the state (the last row of the table). In that case we have _, anticom_index, result = project!(...) where both anticom_index==rank and result===nothing, with rank being the new rank after projection, one more than the number of rows in the tableau before the measurement. ","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"[1]: This can occur only if the state being projected is mixed. Both Stabilizer and Destabilizer can be used for mixed states by simply providing fewer stabilizer generators than qubits at initialization. This can be useful for low-level code that tries to avoid the extra memory cost of using MixedStabilizer and MixedDestabilizer but should be avoided otherwise. project! works correctly or raises an explicit warning on all 4 data structures.","category":"page"},{"location":"datastructures/#Bit-Packing-in-Integers-and-Array-Order","page":"Datastructure Choice","title":"Bit Packing in Integers and Array Order","text":"","category":"section"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"We do not use boolean arrays to store information about the qubits as this would be wasteful (7 out of 8 bits in the boolean would be unused). Instead, we use all 8 qubits in a byte and perform bitwise logical operations as necessary. Implementation details of the object in RAM can matter for performance. The library permits any of the standard UInt types to be used for packing the bits, and larger UInt types (like UInt64) are usually faster as they permit working on 64 qubits at a time (instead of 1 if we used a boolean, or 8 if we used a byte).","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Moreover, how a tableau is stored in memory can affect performance, as a row-major storage usually permits more efficient use of the CPU cache (for the particular algorithms we use).","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Both of these parameters are benchmarked (testing the application of a Pauli operator, which is an mathcalO(n^2) operation; and testing the canonicalization of a Stabilizer, which is an mathcalO(n^3) operation). Row-major UInt64 is the best performing and it is used by default in this library.","category":"page"},{"location":"noisycircuits_ops/#noisycircuits_ops","page":"Circuit Operations","title":"Operators in Circuit Simulations","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\n using Quantikz\nend","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Import with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Too see a condensed list of all operations check out the API docs.","category":"page"},{"location":"noisycircuits_ops/#Unitary-Gates","page":"Circuit Operations","title":"Unitary Gates","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"We distinguish between symbolic gates like sCNOT that have specialized (fast) apply! methods (usually just for single and two qubit gates) and general tableau representation of gates like CliffordOperator that can represent any multi-qubit gate.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Predefined unitary gates are available, like sCNOT, sHadamard, etc.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\n[sCNOT(2,4),sHadamard(2),sCPHASE(1,3),sSWAP(2,4)]","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Any arbitrary tableaux can be used as a gate too. ","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"They can be specified by giving a Clifford operator tableaux and the indices on which it acts (particularly useful for gates acting on a small part of a circuit):","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\nSparseGate(tCNOT, [2,4])","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"The Clifford operator tableaux can be completely arbitrary.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"SparseGate(random_clifford(3), [2,4,5])","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"If the Clifford operator acts on all qubits, we do not need to specify indices, just use the operator.","category":"page"},{"location":"noisycircuits_ops/#Noisy-Gates","page":"Circuit Operations","title":"Noisy Gates","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Each gate can be followed by noise applied to the qubits on which it has acted. This is done by wrapping the given gate into a NoisyGate","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"ε = 0.03 # X/Y/Z error probability\nnoise = UnbiasedUncorrelatedNoise(ε)\nnoisy_gate = NoisyGate(SparseGate(tCNOT, [2,4]), noise)","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"In circuit diagrams the noise is not depicted, but after each application of the gate defined in noisy_gate, a noise operator will also be applied. The example above is of Pauli Depolarization implemented by UnbiasedUncorrelatedNoise.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"One can also apply only the noise operator by using NoiseOp which acts only on specified qubits. Or alternatively, one can use NoiseOpAll in order to apply noise to all qubits.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"[NoiseOp(noise, [4,5]), NoiseOpAll(noise)]","category":"page"},{"location":"noisycircuits_ops/#Coincidence-Measurements","page":"Circuit Operations","title":"Coincidence Measurements","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Global parity measurements involving single-qubit projections and classical communication are implemented with BellMeasurement. One needs to specify the axes of measurement and the qubits being measured. If the parity is trivial, the circuit continues, if the parity is non-trivial, the circuit ends and reports a detected failure. This operator is frequently used in the simulation of entanglement purification.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"BellMeasurement([sMX(1), sMY(3), sMZ(4)])","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"There is also NoisyBellMeasurement that takes the bit-flip probability of a single-qubit measurement as a third argument.","category":"page"},{"location":"noisycircuits_ops/#Stabilizer-Measurements","page":"Circuit Operations","title":"Stabilizer Measurements","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"A measurement over one or more qubits can also be performed, e.g., a direct stabilizer measurement on multiple qubits without the use of ancillary qubits. When applied to multiple qubits, this differs from BellMeasurement as it performs a single projection, unlike BellMeasurement which performs a separate projection for every single qubit involved. This measurement is implemented in PauliMeasurement which requires a Pauli operator on which to project and the index of the classical bit in which to store the result. Alternatively, there are sMX, sMZ, sMY if you are measuring a single qubit.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"[PauliMeasurement(P\"XYZ\", 1), sMZ(2, 2)]","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"TODO: SparseMeasurement, NoisyMeasurement","category":"page"},{"location":"noisycircuits_ops/#Verification-Operations","page":"Circuit Operations","title":"Verification Operations","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"At the end of many circuits one might want to check whether they performed correctly. The VerifyOp operation corresponds to an unphysical perfect tomographic operation, checking whether the state of the qubits at the given indices is indeed what is expected. If it is, the operation reports a success, otherwise it reports an undetected error.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"desired_state = random_stabilizer(5)\nqubit_indices = [1,2,3,4,7]\nVerifyOp(desired_state, qubit_indices)","category":"page"},{"location":"noisycircuits_ops/#Reset-Operations","page":"Circuit Operations","title":"Reset Operations","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"The Reset operations lets you trace out the specified qubits and set their state to a specific tableau.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"new_state = random_stabilizer(3)\nqubit_indices = [1,2,3]\nReset(new_state, qubit_indices)","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"It can be done anywhere in a circuit, not just at the beginning.","category":"page"},{"location":"noisycircuits_ops/#Gates-Conditioned-on-Classical-Bits","page":"Circuit Operations","title":"Gates Conditioned on Classical Bits","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"ConditionalGate is a conditional gate that performs one of two provided gates, depending on the value of a given classical bit.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"DecisionGate is a conditional gate that performs one of the supplied gates, depending on the output of decisionfunction applied to the entire classical bit register.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"gate1 = SparseGate(tCNOT, [1,2])\ngate2 = sCPHASE(1,2)\ngate3 = SparseGate(tSWAP, [1,3])\ncg = ConditionalGate(gate1, gate2, 2)\ndg = DecisionGate([gate1,gate2,gate3], bit_register->1) # it will always perform gate1\n[sMX(4,1), sMZ(5,2), cg, dg]","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"TODO: Split ConditionalGate into quantum conditional and classical conditional","category":"page"},{"location":"plotting/#Visualizations","page":"Visualizations","title":"Visualizations","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Stabilizers have a plot recipe that can be used with Plots.jl or Makie.jl. It simply displays the corresponding parity check matrix (extracted with stab_to_gf2) as a bitmap image. Circuits can be visualized with Quantikz.jl.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Importing the aforementioned packages together with QuantumClifford is necessary to enable the plotting functionality (implemented as package extensions).","category":"page"},{"location":"plotting/#Plots.jl","page":"Visualizations","title":"Plots.jl","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"In Plots.jl we have a simple recipe plot(s::Stabilizer; xzcomponents=...) where xzcomponents=:split plots the tableau heatmap in a wide form, X bits on the left, Z bits on the right; or xzcomponents=:together plots them overlapping, with different colors for I, X, Z, and Y.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(random_stabilizer(20,30), xzcomponents=:split)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize!(random_stabilizer(20,30)))","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize_gott!(random_stabilizer(30))[1], xzcomponents=:split)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize_gott!(random_stabilizer(30))[1]; xzcomponents=:together)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize_rref!(random_stabilizer(20,30),1:30)[1]; xzcomponents=:together)","category":"page"},{"location":"plotting/#Makie.jl","page":"Visualizations","title":"Makie.jl","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Makie's heatmap can be directly called on Stabilizer.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\ns = S\"IIXZ\n ZZIZ\n YYIZ\n IIIZ\n ZZXZ\"\nf, ax, p = CairoMakie.heatmap(s)\nhidedecorations!(ax); hidespines!(ax); # remove ticks and spines\nax.aspect = DataAspect(); # set a one-to-one aspect ratio\nf","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"A full Makie recipe is available as well (supporting xzcomponents)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\ns = S\"IIXZ\n ZZIZ\n YYIZ\n IIIZ\n ZZXZ\"\nf, ax, p = stabilizerplot(s, xzcomponents=:together)\nhidedecorations!(ax); hidespines!(ax)\nax.aspect = DataAspect()\nf","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"You can easily add colorbars (and change the colormap) as well:","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\nfig = Figure()\nax, p = stabilizerplot(fig[1, 1], s, colormap=cgrad(:heat, 4, categorical = true))\nhidedecorations!(ax)\nhidespines!(ax)\nxlims!(ax, 0.5, size(s,2)+0.5) # otherwise there is padding\nylims!(ax, 0.5, size(s,1)+0.5) # otherwise there is padding\n# set the aspect ratio of the plot\nax.aspect = DataAspect()\n# set the aspect ratio of the layout\ncolsize!(fig.layout, 1, Aspect(1, size(s,2)/size(s,1))) \nColorbar(fig[1, 2], p, ticks = (0:3, [\"I\", \"X\", \"Z\", \"Y\"]))\nfig","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Or set a completely custom set of colors:","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"fig = Figure()\nax, p = stabilizerplot(fig[1, 1], s, colormap=cgrad([:lightgray,RGBf(1,0.4,0.4),RGBf(0.3,1,0.5),RGBf(0.4,0.4,1)], 4, categorical = true))\nhidedecorations!(ax)\nhidespines!(ax)\nxlims!(ax, 0.5, size(s,2)+0.5)\nylims!(ax, 0.5, size(s,1)+0.5)\nax.aspect = DataAspect()\ncolsize!(fig.layout, 1, Aspect(1, size(s,2)/size(s,1))) \nColorbar(fig[2, 1], p, ticks = (0:3, [\"I\", \"X\", \"Z\", \"Y\"]), vertical = false, flipaxis = false)\nfig","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"You might have noticed, Makie recipes do not let you edit the axes or figure, rather they only permit you to set the plot content. Which is why we use hidedecorations!, hidesplines!, and DataAspect to further modify the plot. However, these defaults are also available in stabilizerplot_axis.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1],random_stabilizer(100))\nf","category":"page"},{"location":"plotting/#Quantikz.jl","page":"Visualizations","title":"Quantikz.jl","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"With the Quantikz library you can visualize gates or sequences of gates.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Quantikz\ncircuit = [sCNOT(1,2), SparseGate(random_clifford(4), [1,4,5,6]), sMZ(4)]","category":"page"},{"location":"#QuantumClifford.jl","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"DocTestSetup = quote\n using QuantumClifford\nend","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"QuantumClifford.jl is a Julia library for simulation of Clifford circuits, which are a subclass of quantum circuits that can be efficiently simulated on a classical computer.","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"This library uses the tableaux formalism[1] with the destabilizer improvements[2]. Pauli frames are supported for faster repeated simulation of noisy circuits. Various symbolic and algebraic tools for manipulating, converting, and visualizing states and circuits are also implemented. ","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"[1]: (Gottesman, 1998)","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"[2]: (Aaronson and Gottesman, 2004)","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The library consists of two main parts: Tools for working with the algebra of Stabilizer Tableaux and tools specifically for efficient Circuit Simulation.","category":"page"},{"location":"#Stabilizer-Tableau-Algebra","page":"QuantumClifford.jl","title":"Stabilizer Tableau Algebra","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The Stabilizer Tableau Algebra component of QuantumClifford.jl efficiently handles pure and mixed stabilizer states of thousands of qubits, along with support for sparse or dense Clifford operations acting upon them. It provides operations such as canonicalization, projection, generation , and partial traces. The code is vectorized and multithreaded, offering fast, in-place, and allocation-free implementations. Tools for conversion to graph states and for visualization of tableaux are available.","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"See the Stabilizer Tableau Algebra manual or the curated list of useful functions.","category":"page"},{"location":"#Example-Usage","page":"QuantumClifford.jl","title":"Example Usage","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"julia> using QuantumClifford\n\njulia> P\"X\" * P\"Z\"\n-iY\n\njulia> P\"X\" ⊗ P\"Z\"\n+ XZ\n\njulia> S\"-XX\n +ZZ\"\n- XX\n+ ZZ\n\njulia> tCNOT * S\"-XX\n +ZZ\"\n- X_\n+ _Z","category":"page"},{"location":"#Circuit-Simulation","page":"QuantumClifford.jl","title":"Circuit Simulation","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The circuit simulation component of QuantumClifford.jl enables Monte Carlo (or symbolic) simulations of noisy Clifford circuits. It provides three main simulation methods: mctrajectories, pftrajectories, and petrajectories. These methods offer varying levels of efficiency, accuracy, and insight.","category":"page"},{"location":"#Monte-Carlo-Simulations-with-Stabilizer-Tableaux-(mctrajectories)","page":"QuantumClifford.jl","title":"Monte Carlo Simulations with Stabilizer Tableaux (mctrajectories)","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The mctrajectories method runs Monte Carlo simulations using a Stabilizer tableau representation for the quantum states.","category":"page"},{"location":"#Monte-Carlo-Simulations-with-Pauli-Frames-(pftrajectories)","page":"QuantumClifford.jl","title":"Monte Carlo Simulations with Pauli Frames (pftrajectories)","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The pftrajectories method runs Monte Carlo simulations of Pauli frames over a single reference Stabilizer tableau simulation. This approach is much more efficient but supports a smaller class of circuits.","category":"page"},{"location":"#Symbolic-Depth-First-Traversal-of-Quantum-Trajectories-(petrajectories)","page":"QuantumClifford.jl","title":"Symbolic Depth-First Traversal of Quantum Trajectories (petrajectories)","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The petrajectories method performs a depth-first traversal of the most probable quantum trajectories, providing a fixed-order approximation of the circuit's behavior. This approach gives symbolic expressions for various figures of merit instead of just a numeric value.","category":"page"}] +[{"location":"references/#Suggested-reading","page":"Suggested Readings & References","title":"Suggested reading","text":"","category":"section"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For the basis of the tableaux methods first read (Gottesman, 1998) followed by the more efficient approach described in (Aaronson and Gottesman, 2004).","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"The tableaux can be canonicalized (i.e. Gaussian elimination can be performed on them) in a number of different ways, and considering the different approaches provides useful insight. The following methods are implemented in this library:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"The default one: (Garcia et al., 2012)\nUseful when in need of tracing out a set of qubits: (Audenaert and Plenio, 2005)\nUseful when defining logical operators of codes: (Gottesman, 1997)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For the use of these methods in error correction and the subtle overlap between the two fields consider these resources. They are also useful in defining some of the specific constraints in commutation between rows in the tableaux:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Steane, 2007)\n(Calderbank et al., 1998)\n(MacKay et al., 2004)\n(Wilde, 2009)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"These publications describe the uniform sampling of random stabilizer states:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Koenig and Smolin, 2014)\n(Bravyi and Maslov, 2021)\n(Van Den Berg, 2021)\n(Li et al., 2019)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For circuit construction routines (for stabilizer measurements for a given code):","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Cleve and Gottesman, 1997)\n(Gottesman, 1997) (and its erratum)\n(Grassl, 2002)\n(Grassl, 2011)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For quantum code construction routines:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Cleve and Gottesman, 1997)\n(Gottesman, 1996)\n(Gottesman, 1997)\n(Yu et al., 2013)\n(Chao and Reichardt, 2017)\n(Kitaev, 2003)\n(Fowler et al., 2012)\n(Knill and Laflamme, 1996)\n(Steane, 1999)\n(Campbell et al., 2012)\n(Anderson et al., 2014)","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"For classical code construction routines:","category":"page"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"(Muller, 1954)\n(Reed, 1954)\n(Raaphorst, 2003)\n(Abbe et al., 2020)\n(Djordjevic, 2021)\n(Hocquenghem, 1959)\n(Bose and Ray-Chaudhuri, 1960)\n(Bose and Ray-Chaudhuri, 1960)\n(Lin and Costello, 2024)","category":"page"},{"location":"references/#References","page":"Suggested Readings & References","title":"References","text":"","category":"section"},{"location":"references/","page":"Suggested Readings & References","title":"Suggested Readings & References","text":"Aaronson, S. and Gottesman, D. (2004). Improved simulation of stabilizer circuits. Physical Review A 70, 052328.\n\n\n\nAbbe, E.; Shpilka, A. and Ye, M. (2020). Reed–Muller codes: Theory and algorithms. IEEE Transactions on Information Theory 67, 3251–3277.\n\n\n\nAnderson, J. T.; Duclos-Cianci, G. and Poulin, D. (2014). Fault-tolerant conversion between the steane and reed-muller quantum codes. Physical review letters 113, 080501.\n\n\n\nAudenaert, K. M. and Plenio, M. B. (2005). Entanglement on mixed stabilizer states: normal forms and reduction procedures. New Journal of Physics 7, 170.\n\n\n\nBose, R. C. and Ray-Chaudhuri, D. K. (1960). Further results on error correcting binary group codes. Information and Control 3, 279–290.\n\n\n\nBose, R. C. and Ray-Chaudhuri, D. K. (1960). On a class of error correcting binary group codes. Information and control 3, 68–79.\n\n\n\nBravyi, S. and Maslov, D. (2021). Hadamard-free circuits expose the structure of the Clifford group. IEEE Transactions on Information Theory 67, 4546–4563.\n\n\n\nBrown, W. and Fawzi, O. (Jul 2013). Short Random Circuits Define Good Quantum Error Correcting Codes. In: 2013 IEEE International Symposium on Information Theory; pp. 346–350.\n\n\n\nCalderbank, A. R.; Rains, E. M.; Shor, P. and Sloane, N. J. (1998). Quantum error correction via codes over GF (4). IEEE Transactions on Information Theory 44, 1369–1387.\n\n\n\nCampbell, E. T.; Anwar, H. and Browne, D. E. (2012). Magic-state distillation in all prime dimensions using quantum reed-muller codes. Physical Review X 2, 041021.\n\n\n\nChao, R. and Reichardt, B. W. (2017). Quantum Error Correction with Only Two Extra Qubits. Physical review letters 121 5, 050502.\n\n\n\nCleve, R. and Gottesman, D. (1997). Efficient computations of encodings for quantum error correction. Physical Review A 56, 76.\n\n\n\nDjordjevic, I. B. (2021). Quantum information processing, quantum computing, and quantum error correction: an engineering approach (Academic Press).\n\n\n\nFowler, A. G.; Mariantoni, M.; Martinis, J. M. and Cleland, A. N. (2012). Surface codes: Towards practical large-scale quantum computation. Physical Review A 86, 032324.\n\n\n\nGarcia, H. J.; Markov, I. L. and Cross, A. W. (2012). Efficient inner-product algorithm for stabilizer states, arXiv preprint arXiv:1210.6646.\n\n\n\nGottesman, D. (1996). Class of quantum error-correcting codes saturating the quantum Hamming bound. Physical Review A 54, 1862.\n\n\n\nGottesman, D. (1997). Stabilizer codes and quantum error correction. Ph.D. Thesis, California Institute of Technology.\n\n\n\nGottesman, D. (1998). The Heisenberg representation of quantum computers. In: International Conference on Group Theoretic Methods in Physics (Citeseer).\n\n\n\nGrassl, M. (2002). Algorithmic aspects of quantum error-correcting codes. Mathematics of Quantum Computation, 223–252.\n\n\n\nGrassl, M. (2011). Variations on encoding circuits for stabilizer quantum codes. In: International Conference on Coding and Cryptology (Springer); pp. 142–158.\n\n\n\nGullans, M. J.; Krastanov, S.; Huse, D. A.; Jiang, L. and Flammia, S. T. (2021). Quantum Coding with Low-Depth Random Circuits. Physical Review X 11, 031066.\n\n\n\nHocquenghem, A. (1959). Codes correcteurs d'erreurs. Chiffers 2, 147–156.\n\n\n\nKitaev, A. (2003). Fault-tolerant quantum computation by anyons. Annals of Physics 303, 2–30.\n\n\n\nKnill, E. and Laflamme, R. (1996). Concatenated quantum codes, arXiv preprint quant-ph/9608012.\n\n\n\nKoenig, R. and Smolin, J. A. (2014). How to efficiently select an arbitrary Clifford group element. Journal of Mathematical Physics 55, 122202.\n\n\n\nKrastanov, S.; de la Cerda, A. S. and Narang, P. (2020). Heterogeneous Multipartite Entanglement Purification for Size-Constrained Quantum Devices, arXiv preprint arXiv:2011.11640.\n\n\n\nLi, Y.; Chen, X. and Fisher, M. P. (2019). Measurement-driven entanglement transition in hybrid quantum circuits. Physical Review B 100, 134306.\n\n\n\nLin, S. and Costello, D. (2024). Error Control Coding (Pearson).\n\n\n\nMacKay, D. J.; Mitchison, G. and McFadden, P. L. (2004). Sparse-graph codes for quantum error correction. IEEE Transactions on Information Theory 50, 2315–2330.\n\n\n\nMuller, D. E. (1954). Application of Boolean algebra to switching circuit design and to error detection. Transactions of the IRE professional group on electronic computers, 6–12.\n\n\n\nNahum, A.; Ruhman, J.; Vijay, S. and Haah, J. (2017). Quantum Entanglement Growth under Random Unitary Dynamics. Physical Review X 7, 031016.\n\n\n\nPanteleev, P. and Kalachev, G. (2021). Degenerate Quantum LDPC Codes With Good Finite Length Performance. Quantum 5, 585, arXiv:1904.02703 [quant-ph].\n\n\n\nPanteleev, P. and Kalachev, G. (Jun 2022). Asymptotically Good Quantum and Locally Testable Classical LDPC Codes. In: Proceedings of the 54th Annual ACM SIGACT Symposium on Theory of Computing (ACM, Rome Italy); pp. 375–388.\n\n\n\nRaaphorst, S. (2003). Reed-muller codes. Carleton University, May 9.\n\n\n\nRaveendran, N.; Rengaswamy, N.; Rozpędek, F.; Raina, A.; Jiang, L. and Vasić, B. (2022). Finite Rate QLDPC-GKP Coding Scheme That Surpasses the CSS Hamming Bound. Quantum 6, 767.\n\n\n\nReed, I. S. (1954). A class of multiple-error-correcting codes and the decoding scheme. IEEE Transactions on Information Theory 4, 38–49.\n\n\n\nRoffe, J.; Cohen, L. Z.; Quintavalle, A. O.; Chandra, D. and Campbell, E. T. (2023). Bias-Tailored Quantum LDPC Codes. Quantum 7, 1005.\n\n\n\nSteane, A. M. (1999). Quantum reed-muller codes. IEEE Transactions on Information Theory 45, 1701–1703.\n\n\n\nSteane, A. M. (2007). A tutorial on quantum error correction. In: PROCEEDINGS-INTERNATIONAL SCHOOL OF PHYSICS ENRICO FERMI, Vol. 162 (IOS Press; Ohmsha; 1999); p. 1.\n\n\n\nVan Den Berg, E. (2021). A simple method for sampling random Clifford operators. In: 2021 IEEE International Conference on Quantum Computing and Engineering (QCE) (IEEE); pp. 54–59.\n\n\n\nWilde, M. M. (2009). Logical operators of quantum codes. Physical Review A 79, 062322.\n\n\n\nYu, S.; Bierbrauer, J.; Dong, Y.; Chen, Q. and Oh, C. H. (2013). All the Stabilizer Codes of Distance 3. IEEE Transactions on Information Theory 59, 5179–5185.\n\n\n\n","category":"page"},{"location":"noise/#noise","page":"Noise Processes","title":"Noise Processes","text":"","category":"section"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"DocTestSetup = quote\n using QuantumClifford\n using StableRNGs\n rng = StableRNG(42)\nend","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"As seen in the list of possible gates, the simulator is capable of modeling different types of noise. If that is your goal, please consider using the available Monte Carlo simulator or the Symbolic Perturbative Expansion system.","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"The implemented types of noise include:","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"UnbiasedUncorrelatedNoise\nPauliNoise","category":"page"},{"location":"noise/","page":"Noise Processes","title":"Noise Processes","text":"The low-level functionality to work with noise is applynoise!, but most of the time you would probably just want to use PauliError, NoisyGate, NoiseOp and NoiseOpAll.","category":"page"},{"location":"ecc_example_sim/#noisycircuits_pf_ecc_example","page":"ECC example","title":"ECC example with Pauli Frames","text":"","category":"section"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"DocTestSetup = quote\n using QuantumClifford\n using Quantikz\nend","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"warning: The documentation is incomplete\nWaiting for a better documentation than the small example below. Check out also the page on ECC performance evaluators","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"Consider Steane 7-qubit code:","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"using QuantumClifford\nusing QuantumClifford.ECC: Steane7, naive_syndrome_circuit, naive_encoding_circuit, parity_checks, code_s, code_n\nusing Quantikz\n\ncode = Steane7()\nH = parity_checks(code)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"... and the corresponding encoding circuit","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"ecirc = naive_encoding_circuit(code)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"... and the corresponding syndrome measurement circuit (the non-fault tolerant one)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"scirc, _ = naive_syndrome_circuit(code)","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"The most straightforward way to start sampling syndromes is to set up a table of Pauli frames.","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"circuit = [ecirc..., scirc...]\nnframes = 4\nframes = pftrajectories(circuit; trajectories=nframes) # run the sims\npfmeasurements(frames) # extract the measurements","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"The pftrajectories function is multithreaded. If you want more low-level control over these Pauli frame simulations, check out the PauliFrame structure, the other methods of pftrajectories, and the circuit compactifaction function compactify_circuit.","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"If you want to model Pauli errors, use:","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"The helper PauliError for unbiased Pauli noise operation acting on a given qubit\nThe lower level NoiseOp (for a single qubit) or NoiseOpAll (for all qubits) parameterized with a particular noise type, e.g. UnbiasedUncorrelatedNoise","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"errprob = 0.1\nerrors = [PauliError(i,errprob) for i in 1:code_n(code)]\nfullcircuit = [ecirc..., errors..., scirc...]","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"And running this noisy simulation:","category":"page"},{"location":"ecc_example_sim/","page":"ECC example","title":"ECC example","text":"frames = pftrajectories(fullcircuit; trajectories=nframes)\npfmeasurements(frames)","category":"page"},{"location":"stab-algebra-manual/#Stabilizer-Tableau-Algebra-Manual","page":"Manual","title":"Stabilizer Tableau Algebra Manual","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"DocTestSetup = quote\n using QuantumClifford\nend","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The library consists of two main parts: Tools for working with the algebra of Stabilizer tableaux and tools specifically for efficient Circuit Simulation. This chapter discusses the former \"lower level\" Stabilizer tableau algebra tools.","category":"page"},{"location":"stab-algebra-manual/#Pauli-Operators","page":"Manual","title":"Pauli Operators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The PauliOperator object represents multi-qubit Pauli operator (1iIZXY^otimes n). It is stored in memory as a phase (a single byte where 0x0,0x1,0x2,0x3 corresponds to 1i-1-i) and two bit-arrays, for X and for Z components.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"You can create them with a P string.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"-iXZ\"\n-iXZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Or by specifying phase and X/Z components:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> PauliOperator(0x0,Bool[0,1,0],Bool[0,0,1])\n+ _XZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Both underscore and I can be used for identity.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"I_XYZ\"\n+ __XYZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Multiplication with scalars or other Pauli operators works as expected, as well as tensor products of Pauli operators.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> -1im*P\"X\"\n-iX\n\njulia> P\"X\" * P\"Z\"\n-iY\n\njulia> P\"X\" ⊗ P\"Z\"\n+ XZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"One can check for commutativity with comm.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> comm(P\"X\",P\"Z\")\n0x01\n\njulia> comm(P\"XX\",P\"ZZ\")\n0x00","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"And check the phase of a product with prodphase.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> prodphase(P\"X\", P\"Z\")\n0x03\n\njulia> prodphase(P\"X\", P\"iZ\")\n0x00\n\njulia> prodphase(P\"X\",P\"Y\")\n0x01","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Indexing operations are available.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> p = P\"IXYZ\";\n\njulia> p[1], p[2], p[3], p[4]\n((false, false), (true, false), (true, true), (false, true))\n\njulia> p = P\"III\";\n\njulia> p[2] = (true, true);\n\njulia> p\n+ _Y_","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Including fancy indexing:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"IXYZ\"[[2,3]]\n+ XY\n\njulia> P\"IXYZ\"[[false,true,true,false]]\n+ XY","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The operator is represented in memory by bit arrays (much denser than using byte arrays).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> p = P\"-IXYZ\";\n\njulia> p.nqubits, p.xz\n(4, UInt64[0x0000000000000006, 0x000000000000000c])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Views that give just the X or Z components of the xz bitarray are available through xview and zview.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> xview(P\"XYZI\")\n1-element view(::Vector{UInt64}, 1:1) with eltype UInt64:\n 0x0000000000000003","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The convenience methods xbit and zbit give you Bool (GF2) vectors.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> xbit(P\"XYZI\")\n4-element Vector{Bool}:\n 1\n 1\n 0\n 0","category":"page"},{"location":"stab-algebra-manual/#Stabilizers","page":"Manual","title":"Stabilizers","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"A Stabilizer object is a tableau of Pauli operators. When the tableau is meant to represent a (pure or mixed) stabilizer state, all of these operators should commute (but that is not enforced, rather Stabilizer is a generic tableau data structure). It is stored in memory as a phase list and a bit-matrix for X and Z components. It can be instantiated by an S string, or with a number of different constructors.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"tip: Stabilizers and Destabilizers\nIn many cases you probably would prefer to use the MixedDestabilizer data structure, as it caries a lot of useful additional information, like tracking rank and destabilizer operators. Stabilizer has mostly a pedagogical value, and it is also used for slightly faster simulation of a particular subset of Clifford operations. See also the data structures discussion page.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> S\"-XX\n +ZZ\"\n- XX\n+ ZZ\n\njulia> Stabilizer([P\"-XX\",P\"+ZZ\"])\n- XX\n+ ZZ\n\njulia> Stabilizer([0x2, 0x0],\n Bool[1 1;\n 0 0],\n Bool[0 0;\n 1 1])\n- XX\n+ ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Direct sums can be performed,","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> S\"-XX\" ⊗ S\"ZZ\"\n- XX__\n+ __ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Indexing operations are available, including fancy indexing. Be careful about how phase information gets transferred during sub-indexing.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XYZ\n -ZIX\n +XIZ\";\n\njulia> s[1]\n- XYZ\n\njulia> s[1,2]\n(true, true)\n\njulia> s[[3,1]]\n+ X_Z\n- XYZ\n\njulia> s[[3,1],[2]]\n+ _\n- Y","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Consistency at creation is not verified so nonsensical stabilizers can be created, both in terms of content and shape.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> S\"iX\n +Z\"\n+iX\n+ Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Similarly to the Pauli operators, a bit array representation is used.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZI\n -IZZ\"\n- XXX\n+ ZZ_\n- _ZZ\n\njulia> phases(s), tab(s).xzs\n(UInt8[0x02, 0x00, 0x02], UInt64[0x0000000000000007 0x0000000000000000 0x0000000000000000; 0x0000000000000000 0x0000000000000003 0x0000000000000006])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"And there are convenience functions that can extract the corresponding binary check matrix.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> stab_to_gf2(s)\n3×6 Matrix{Bool}:\n 1 1 1 0 0 0\n 0 0 0 1 1 0\n 0 0 0 0 1 1","category":"page"},{"location":"stab-algebra-manual/#Canonicalization-of-Stabilizers","page":"Manual","title":"Canonicalization of Stabilizers","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Canonicalization (akin to Gaussian elimination over F(2,2)) is implemented in the canonicalize! function. Besides the default canonicalization prescription, alternative ones are available as described in the canonicalization page.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZX\n +III\";\n\njulia> canonicalize!(s)\n+ YY_\n+ ZZX\n+ ___","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"If phases are inconsequential, the operations can be faster by not tracking and updating them.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZX\n +III\";\n\njulia> canonicalize!(s; phases=false)\n- YY_\n+ ZZX\n+ ___","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"These operations are in place (as customarily signified by \"!\").","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZX\n +III\";\n\njulia> canonicalize!(s; phases=false);\n\njulia> s\n- YY_\n+ ZZX\n+ ___","category":"page"},{"location":"stab-algebra-manual/#Projective-Measurements","page":"Manual","title":"Projective Measurements","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The project! function is used to perform generic projective measurements.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"tip: Single qubit projections\nIf you know your Pauli measurement operator acts on a single qubit, there are much faster projection functions available, discussed in the next section. Namely projectX!, projectY!, and projectZ!.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"To observe the effect of different projections, we will start with a GHZ state.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZI\n -IZZ\";","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The project! function returns the new stabilizer, the index where the anticommutation was detected, and the result of the projection (nothing being an undetermined result). For instance here we project on an operator that does not commute with all stabilizer generators.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"ZII\")[1]\n+ Z__\n+ ZZ_\n- _ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Importantly, when there is an undetermined result, we return nothing and leave the phase of the new stabilizer the same as the phase of the projection operator. If you want to perform a Monte Carlo simulation, you need to randomize the phase of the stabilizer at the anticommuting index yourself. For instance, one can do:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> newstate, anticomindex, result = project!(copy(s), P\"XII\")\n if isnothing(result)\n phases(newstate)[anticomindex] = rand([0x0,0x2])\n end\n result, anticomindex\n(nothing, 2)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Of course, this is a rather cumbersome way to run a simulation, so we also provide projectrand! which does the necessary randomization automatically, for cases where you do not need the fine grained control of project!.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"We can project on a commuting operator, hence no anticommuting terms (the index is zero), and the result is perfectly determined (-1, or in our convention to represent the phase, 0x2).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"-ZZI\")\n(Stabilizer 3×3, 0, 0x02)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"When the projection is consistent with the stabilizer (i.e. the measurement result is not nothing), this would trigger an expensive canonicalization procedure in order to calculate the measurement result (unless we are using more advanced data structures to represent the state, which are discussed later). If all you want to know is whether the projection is consistent with the stabilizer, but you do not care about the measurement result, you can skip the canonicalization and calculation of the result.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"-ZZI\", keep_result=false)\n(Stabilizer 3×3, 0, nothing)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Lastly, in either case, you can skip the calculation of the phases as well, if they are unimportant.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(copy(s), P\"ZZI\", phases=false)\n(Stabilizer 3×3, 0, 0x00)","category":"page"},{"location":"stab-algebra-manual/#Sparse-single-qubit-measurements","page":"Manual","title":"Sparse single-qubit measurements","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"In many circumstances only a single-qubit operator is being measured. In that case one should use the projectX!, projectY!, and projectZ! functions as they are much faster thanks to tracking only a single qubit. They have versions that randomize the phase as necessary as well: projectXrand!, projectYrand!, and projectZrand!.","category":"page"},{"location":"stab-algebra-manual/#Gate-like-interface","page":"Manual","title":"Gate-like interface","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"If you do not need all this boilerplate, and especially if you want to perform the randomization automatically, you can use the gate-like \"symbolic\" objects sMX, sMY, and sMZ, that perform the measurement and the necessary randomization of phase. If the measurement result is to be stored, you can use the Register structure that stores both stabilizer tableaux and bit values.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> state = Register(ghz(3), [false,false])\nRegister{Vector{UInt8}, Matrix{UInt64}}(Rank 3 stabilizer\n+ Z__\n+ _X_\n+ __X\n═════\n+ XXX\n+ ZZ_\n+ Z_Z\n═════\n, Bool[0, 0])\n\njulia> apply!(state, sMX(3,2)) # which qubit is measured and in which bit it is stored\nRegister{Vector{UInt8}, Matrix{UInt64}}(Rank 3 stabilizer\n+ Z__\n+ _X_\n+ Z_Z\n═════\n+ XXX\n+ ZZ_\n- __X\n═════\n, Bool[0, 1])\n\njulia> bitview(state)\n2-element Vector{Bool}:\n 0\n 1","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Or you can use the projectXrand!, projectYrand!, and projectZrand! if you prefer a function-call interface.","category":"page"},{"location":"stab-algebra-manual/#Partial-Traces","page":"Manual","title":"Partial Traces","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Partial trace (using traceout!) over even a single qubit might cause many of them to decohere due to entanglement.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> ghz = S\"XXX\n ZZ_\n _ZZ\";\n\njulia> traceout!(ghz, [1])\n+ _ZZ\n+ ___\n+ ___","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"This is somewhat more elegant when the datastructure being used explicitly supports mixed states.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> ghz = MixedStabilizer(S\"XXX\n ZZ_\n _ZZ\");\n\njulia> traceout!(ghz, [1])\n+ _ZZ","category":"page"},{"location":"stab-algebra-manual/#Generating-a-Pauli-Operator-with-Stabilizer-Generators","page":"Manual","title":"Generating a Pauli Operator with Stabilizer Generators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The generate! function attempts to generate a Pauli operator by multiplying together the operators belonging to a given stabilizer (or reports their independence). This particular function requires the stabilizer to be already canonicalized.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"-XXX\n +ZZI\n -IZZ\";\n\njulia> s = canonicalize!(s)\n- XXX\n- Z_Z\n- _ZZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"It modifies the Pauli operator in place, reducing it to identity if possible. The leftover phase is present to indicate if the phase itself could not have been canceled. The list of indices specifies which rows of the stabilizer were used to generated the desired Pauli operator.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> generate!(P\"XYY\", s)\n(- ___, [1, 3])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Phases can be neglected, for higher performance.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> generate!(P\"XYY\", s, phases=false)\n(+ ___, [1, 3])","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"If the Pauli operator can not be generated by the stabilizer, nothing value is returned.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> generate!(P\"ZZZ\", s)\n\njulia> generate!(P\"XZX\", s)\n\njulia> generate!(P\"YYY\", s)","category":"page"},{"location":"stab-algebra-manual/#Clifford-Operators","page":"Manual","title":"Clifford Operators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The CliffordOperator structure represents a linear mapping between stabilizers (which should also preserve commutation relationships, but that is not checked at instantiation). These are n-qubit dense tableaux, representing an operation on n-qubit states. For single- or two-qubit gates, it is much more efficient to use small sparse symbolic clifford operators. A number of predefined Clifford operators are available, their name prefixed with t to mark them as dense tableaux.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> tHadamard\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\njulia> tPhase\nX₁ ⟼ + Y\nZ₁ ⟼ + Z\n\njulia> tCNOT\nX₁ ⟼ + XX\nX₂ ⟼ + _X\nZ₁ ⟼ + Z_\nZ₂ ⟼ + ZZ\n\njulia> tId1\nX₁ ⟼ + X\nZ₁ ⟼ + Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Chaining and tensor products are possible. Same for qubit permutations.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> tHadamard ⊗ tPhase\nX₁ ⟼ + Z_\nX₂ ⟼ + _Y\nZ₁ ⟼ + X_\nZ₂ ⟼ + _Z\n\njulia> tHadamard * tPhase\nX₁ ⟼ - Y\nZ₁ ⟼ + X\n\njulia> permute(tCNOT, [2,1])\nX₁ ⟼ + X_\nX₂ ⟼ + XX\nZ₁ ⟼ + ZZ\nZ₂ ⟼ + _Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"You can create custom Clifford operators with C-strings or with a list of Pauli operators.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> C\"-ZZ\n +_Z\n -X_\n +XX\"\nX₁ ⟼ - ZZ\nX₂ ⟼ + _Z\nZ₁ ⟼ - X_\nZ₂ ⟼ + XX\n\njulia> CliffordOperator([P\"-ZZ\", P\"_Z\", P\"-X_\", P\"XX\"])\nX₁ ⟼ - ZZ\nX₂ ⟼ + _Z\nZ₁ ⟼ - X_\nZ₂ ⟼ + XX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Naturally, the operators can be applied to stabilizer states. This includes high performance in-place operations (and the phase can be neglected with phases=false for faster computation).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> tCNOT * S\"X_\"\n+ XX\n\njulia> s = S\"X_\";\n\njulia> apply!(s,tCNOT)\n+ XX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Sparse applications where a small Clifford operator is applied only on a particular subset of a larger stabilizer is also possible, but in such circumstances it is useful to consider using symbolic operators too.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s = S\"Z_YX\";\n\njulia> apply!(s, tCNOT, [4,2]) # Apply the CNOT on qubits 4 and 2\n+ ZXYX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Pauli operators act as Clifford operators too (but they are rather boring, as they only change signs).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> P\"XII\" * S\"ZXX\"\n- ZXX","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Internally, the CliffordOperator structure simply stores the tableau representation of the operation.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The apply! function is efficiently multithreaded for CliffordOperators. To start multithreaded Julia, use julia -t where specifies the number of threads.","category":"page"},{"location":"stab-algebra-manual/#Symbolic-Clifford-Operators","page":"Manual","title":"Symbolic Clifford Operators","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Much faster implementations for a number of common Clifford operators are available. They are stored as special named structs, instead of as a full tableau. These are the subtypes of AbstractSingleQubitOperator and AbstractTwoQubitOperator. Currently these are:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"using QuantumClifford # hide\nusing InteractiveUtils # hide\nsubtypes(QuantumClifford.AbstractSingleQubitOperator)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"subtypes(QuantumClifford.AbstractTwoQubitOperator)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Generally, they have the prefix s for symbolic/small/sparse. They are used slightly differently, as one needs to specify the qubits on which they act while instantiating them:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> sHadamard(2)\nsHadamard on qubit 2\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\njulia> sHadamard(2)*S\"XXX\"\n+ XZX\n\njulia> sCNOT(2,3)*S\"XYY\"\n- XXZ","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"The apply! function is efficiently multithreaded for these symbolic operators as well. To start multithreaded Julia, use julia -t where specifies the number of threads.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Symbolic projectors on single qubits also exist: sMX, sMY, sMZ. When used with the Register state representation, they can store the measurement results in the corresponding classical register.","category":"page"},{"location":"stab-algebra-manual/#Destabilizers","page":"Manual","title":"Destabilizers","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Slightly abusing the name: What we call \"destabilizers\" here is a stabilizer and its destabilizing operators saved together. They are implemented with the Destabilizer object and are initialized from a stabilizer.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> s=S\"-XXX\n -ZZI\n +IZZ\";\n\njulia> d = Destabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n- XXX\n- ZZ_\n- Z_Z","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"They have convenience methods to extract only the stabilizer and destabilizer pieces:","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> stabilizerview(d)\n- XXX\n- ZZ_\n- Z_Z\n\njulia> destabilizerview(d)\n+ Z__\n+ _X_\n+ __X","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Importantly commuting projections are much faster when tracking the destabilizer as canonicalization is not necessary (an mathcalO(n^2) complexity because it avoids the expensive mathcalO(n^3) canonicalization operation).","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(d,P\"ZZI\")\n(Destablizer 3×3, 0, 0x02)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Non-commuting projections are just as fast as when using only stabilizers.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> project!(d,P\"ZZZ\")\n(Destablizer 3×3, 1, nothing)","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Clifford operations can be applied the same way they are applied to stabilizers.","category":"page"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"julia> apply!(d,tCNOT⊗tHadamard)\n𝒟ℯ𝓈𝓉𝒶𝒷\n- X_Z\n+ XXZ\n+ X__\n𝒮𝓉𝒶𝒷━\n+ _ZX\n- _Z_\n- Z_X","category":"page"},{"location":"stab-algebra-manual/#Mixed-States","page":"Manual","title":"Mixed States","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"Both the Stabilizer and Destabilizer structures have more general forms that enable work with mixed stabilizer states. They are the MixedStabilizer and MixedDestabilizer structures, described in Mixed States. More information that can be seen in the data structures page, which expands upon the algorithms available for each structure.","category":"page"},{"location":"stab-algebra-manual/#Random-States-and-Circuits","page":"Manual","title":"Random States and Circuits","text":"","category":"section"},{"location":"stab-algebra-manual/","page":"Manual","title":"Manual","text":"random_clifford, random_stabilizer, and enumerate_cliffords can be used for the generation of random states.","category":"page"},{"location":"tutandpub/#tutandpub","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"","category":"section"},{"location":"tutandpub/","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"This list has a number of notebooks with tutorials, examples, and reproduction of published results (some of these results originally obtained with this very library).","category":"page"},{"location":"tutandpub/#On-the-topic-of-explicit-use-of-the-Tableaux-formalism-for-Stabilizer-states","page":"Tutorials and Publications","title":"On the topic of explicit use of the Tableaux formalism for Stabilizer states","text":"","category":"section"},{"location":"tutandpub/","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"Quantum coding with low-depth random circuits reproducing results from (Gullans et al., 2021). view on nbviewer.jupyter.org","category":"page"},{"location":"tutandpub/#On-the-Monte-Carlo-and-Perturbative-Expansions-for-**Noisy**-Clifford-circuits","page":"Tutorials and Publications","title":"On the Monte Carlo and Perturbative Expansions for Noisy Clifford circuits","text":"","category":"section"},{"location":"tutandpub/","page":"Tutorials and Publications","title":"Tutorials and Publications","text":"In-depth study of multi-partite entanglement purification circuits reproducing results from (Krastanov et al., 2020). view on nbviewer.jupyter.org\nComparing the Monte Carlo and Perturbative method for noisy circuit simulations. view on nbviewer.jupyter.org\nShowcasing symbolic perturbative expansions of noisy circuits. view on nbviewer.jupyter.org","category":"page"},{"location":"noisycircuits_API/#Full-API-(autogenerated)","page":"API","title":"Full API (autogenerated)","text":"","category":"section"},{"location":"noisycircuits_API/","page":"API","title":"API","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_API/","page":"API","title":"API","text":"Modules = [QuantumClifford.Experimental.NoisyCircuits]\nPrivate = false","category":"page"},{"location":"noisycircuits_API/#QuantumClifford.Experimental.NoisyCircuits.ConditionalGate","page":"API","title":"QuantumClifford.Experimental.NoisyCircuits.ConditionalGate","text":"A conditional gate that either performs truegate or falsegate, depending on the value of controlbit.\n\n\n\n\n\n","category":"type"},{"location":"noisycircuits_API/#QuantumClifford.Experimental.NoisyCircuits.DecisionGate","page":"API","title":"QuantumClifford.Experimental.NoisyCircuits.DecisionGate","text":"A conditional gate that performs one of the gates, depending on the output of decisionfunction applied to the entire classical bit register.\n\n\n\n\n\n","category":"type"},{"location":"noisycircuits_API/#QuantumClifford.Experimental.NoisyCircuits.NoisyBellMeasurement","page":"API","title":"QuantumClifford.Experimental.NoisyCircuits.NoisyBellMeasurement","text":"A Bell measurement in which each of the measured qubits has a chance to have flipped.\n\n\n\n\n\n","category":"type"},{"location":"noisycircuits_perturb/#noisycircuits_perturb","page":"Perturbative Expansions","title":"Perturbative expansions for simulating noisy Clifford circuits","text":"","category":"section"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\n using Quantikz\nend","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"Import with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"This module enables the simulation of noisy Clifford circuits through a perturbative expansion in the noise parameter (assuming the noise is small). Instead of simulating many Monte Carlo trajectories, only the leading order trajectories are exhaustively enumerated and simulated.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"Here is an example of a purification circuit (the same circuit seen in the Monte Carlo example)","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\ngood_bell_state = S\"XX\n ZZ\"\ncanonicalize_rref!(good_bell_state)\ninitial_state = MixedDestabilizer(good_bell_state⊗good_bell_state)\n\ng1 = sCNOT(1,3) # CNOT between qubit 1 and qubit 3 (both with Alice)\ng2 = sCNOT(2,4) # CNOT between qubit 2 and qubit 4 (both with Bob)\nm = BellMeasurement([sMX(3),sMX(4)]) # Bell measurement on qubit 3 and 4\nv = VerifyOp(good_bell_state,[1,2]) # Verify that qubit 1 and 2 indeed form a good Bell pair\nepsilon = 0.01 # The error rate\nn = NoiseOpAll(UnbiasedUncorrelatedNoise(epsilon))\n\n# This circuit performs a depolarization at rate `epsilon` to all qubits,\n# then bilater CNOT operations\n# then a Bell measurement\n# followed by checking whether the final result indeed corresponds to the correct Bell pair.\ncircuit = [n,g1,g2,m,v]\n\npetrajectories(initial_state, circuit)","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification.","category":"page"},{"location":"noisycircuits_perturb/#Symbolic-expansions","page":"Perturbative Expansions","title":"Symbolic expansions","text":"","category":"section"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"The perturbative expansion method works with symbolic variables as well. One can use any of the symbolic libraries available in Julia and simply plug symbolic parameters in lieu of numeric parameters. A detailed example is available as a Jupyter notebook.","category":"page"},{"location":"noisycircuits_perturb/#Interface-for-custom-operations","page":"Perturbative Expansions","title":"Interface for custom operations","text":"","category":"section"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"applyop_branches!(s::T, g::Operation; max_order=1)::Vector{Tuple{T,Symbol,Real,Int}} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation, the Real is the probability for that branch, and the Int is the order of that branch.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"There is also applynoise_branches! which is convenient for use in NoisyGate, but you can also just make up your own noise operator simply by implementing applyop_branches! for it.","category":"page"},{"location":"noisycircuits_perturb/","page":"Perturbative Expansions","title":"Perturbative Expansions","text":"You can also consult the list of implemented operators.","category":"page"},{"location":"graphs/#Graph-States","page":"Graph States","title":"Graph States","text":"","category":"section"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"warning: The `graphstate` API is not considered stable\ngraphstate returns a lot of information about encoding a given stabilizer state in a graph. A different API is being designed that streamlines the work with graph states.","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Conversion to and from graph states is possible.","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Consider a GHZ state:","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"using QuantumClifford # hide\nghz(4)","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"It can be converted to a graph state with graphstate","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"graphstate(ghz(4))[1]","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"using Random; Random.seed!(1); using QuantumClifford, GraphMakie, CairoMakie;\nf = Figure(size=(200,200))\na = Axis(f[1,1])\ngraphplot!(a,graphstate(ghz(4))[1])\nhidedecorations!(a); hidespines!(a)\na.aspect = DataAspect()\nsave(\"ghz4graph.png\", f); nothing","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"(Image: )","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Notice that the initial GHZ state was not in the typical graph state form. We can see that explicitly by converting back and forth between the two forms:","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"julia> using Graphs, QuantumClifford\n\njulia> ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ\n\njulia> Stabilizer(Graph(ghz(4)))\n+ XZZZ\n+ ZX__\n+ Z_X_\n+ Z__X","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"There is a set of single-qubit operations that can convert any stabilizer tableau into a state representable as a graph. These transformations are performed implicitly by the Graph constructor when converting from a Stabilizer. If you need the explicit transformation you can use the graphstate function that specifies which qubits require a Hadamard, Inverse Phase, or Phase Flip gate. The graph_gatesequence or graph_gate helper functions can be used to generate the exact operations:","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"julia> s = ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ\n\njulia> g, h_idx, ip_idx, z_idx = graphstate(s);\n\njulia> gate = graph_gate(h_idx, ip_idx, z_idx, nqubits(s))\nX₁ ⟼ + X___\nX₂ ⟼ + _Z__\nX₃ ⟼ + __Z_\nX₄ ⟼ + ___Z\nZ₁ ⟼ + Z___\nZ₂ ⟼ + _X__\nZ₃ ⟼ + __X_\nZ₄ ⟼ + ___X\n\njulia> canonicalize!(apply!(s,gate)) == canonicalize!(Stabilizer(g))\ntrue","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"These converters also provides for a convenient way to create graph and cluster states, by using the helper constructors provided in Graphs.jl.","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"julia> Stabilizer(grid([4,1])) # Linear cluster state\n+ XZ__\n+ ZXZ_\n+ _ZXZ\n+ __ZX\n\njulia> Stabilizer(grid([2,2])) # Small 2D cluster state\n+ XZZ_\n+ ZX_Z\n+ Z_XZ\n+ _ZZX","category":"page"},{"location":"graphs/","page":"Graph States","title":"Graph States","text":"Graphs are represented with the Graphs.jl package and plotting can be done both in Plots.jl and Makie.jl (with GraphMakie).","category":"page"},{"location":"ECC_API/#Full-ECC-API-(autogenerated)","page":"API","title":"Full ECC API (autogenerated)","text":"","category":"section"},{"location":"ECC_API/","page":"API","title":"API","text":"Modules = [QuantumClifford.ECC]\nPrivate = false","category":"page"},{"location":"ECC_API/#QuantumClifford.ECC.CSS","page":"API","title":"QuantumClifford.ECC.CSS","text":"An arbitrary CSS error correcting code defined by its X and Z checks.\n\njulia> CSS([0 1 1 0; 1 1 0 0], [1 1 1 1]) |> parity_checks\n+ _XX_\n+ XX__\n+ ZZZZ\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.CircuitCode","page":"API","title":"QuantumClifford.ECC.CircuitCode","text":"CircuitCode is defined by a given encoding circuit circ.\n\nn: qubit number\ncirc: the encoding circuit\nencode_qubits: the qubits to be encoded\n\nSee also: random_all_to_all_circuit_code, random_brickwork_circuit_code\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Cleve8","page":"API","title":"QuantumClifford.ECC.Cleve8","text":"A pedagogical example of a quantum error correcting [8,3] code used in (Cleve and Gottesman, 1997).\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.CommutationCheckECCSetup","page":"API","title":"QuantumClifford.ECC.CommutationCheckECCSetup","text":"Configuration for ECC evaluator that does not simulate any ECC circuits, rather it simply checks the commutation of the parity check and the Pauli error.\n\nThis is much faster than any other simulation method, but it is incapable of noisy-circuit simulations and thus useless for fault-tolerance studies.\n\nSee also: NaiveSyndromeECCSetup, ShorSyndromeECCSetup\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Concat","page":"API","title":"QuantumClifford.ECC.Concat","text":"Concat(c₁, c₂) is a code concatenation of two quantum codes (Knill and Laflamme, 1996).\n\nThe inner code c₁ and the outer code c₂. The construction is the following: replace each qubit in code c₂ with logical qubits encoded by code c₁. The resulting code will have n = n₁ × n₂ qubits and k = k₁ × k₂ logical qubits.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Gottesman","page":"API","title":"QuantumClifford.ECC.Gottesman","text":"The family of [[2ʲ, 2ʲ - j - 2, 3]] Gottesman codes, also known as quantum Hamming codes, as described in Gottesman's 1997 PhD thesis and in (Gottesman, 1996).\n\nYou might be interested in consulting (Yu et al., 2013) and (Chao and Reichardt, 2017) as well.\n\nThe ECC Zoo has an entry for this family\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.NaiveSyndromeECCSetup","page":"API","title":"QuantumClifford.ECC.NaiveSyndromeECCSetup","text":"Configuration for ECC evaluator that runs the simplest syndrome measurement circuit.\n\nThe circuit is being simulated (as opposed to doing only a quick commutation check). This circuit would give poor performance if there is non-zero gate noise.\n\nSee also: CommutationCheckECCSetup, ShorSyndromeECCSetup\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.QuantumReedMuller","page":"API","title":"QuantumClifford.ECC.QuantumReedMuller","text":"The family of [[2ᵐ - 1, 1, 3]] CSS Quantum-Reed-Muller codes, as discovered by Steane in his 1999 paper (Steane, 1999).\n\nQuantum codes are constructed from shortened Reed-Muller codes RM(1, m), by removing the first row and column of the generator matrix Gₘ. Similarly, we can define truncated dual codes RM(m - 2, m) using the generator matrix Hₘ (Anderson et al., 2014). The quantum Reed-Muller codes QRM(m) derived from RM(1, m) are CSS codes. \n\nGiven that the stabilizers of the quantum code are defined through the generator matrix of the classical code, the minimum distance of the quantum code corresponds to the minimum distance of the dual classical code, which is d = 3, thus it can correct any single qubit error. Since one stabilizer from the original and one from the dual code are removed in the truncation process, the code parameters are [[2ᵐ - 1, 1, 3]].\n\nYou might be interested in consulting (Anderson et al., 2014) and (Campbell et al., 2012) as well.\n\nThe ECC Zoo has an entry for this family.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.ShorSyndromeECCSetup","page":"API","title":"QuantumClifford.ECC.ShorSyndromeECCSetup","text":"Configuration for ECC evaluators that simulate the Shor-style syndrome measurement (without a flag qubit).\n\nThe simulated circuit includes:\n\nperfect noiseless encoding (encoding and its fault tolerance are not being studied here)\none round of \"memory noise\" after the encoding but before the syndrome measurement\nperfect preparation of entangled ancillary qubits\nnoisy Shor-style syndrome measurement (only two-qubit gate noise)\nnoiseless \"logical state measurement\" (providing the comparison data when evaluating the decoder)\n\nSee also: CommutationCheckECCSetup, NaiveSyndromeECCSetup\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Surface","page":"API","title":"QuantumClifford.ECC.Surface","text":"The planar surface code refers to the code (Kitaev, 2003) in a 2D lattice with open boundaries.\n\nIllustration of a 3×2 surface code, where qubits are located on the edges:\n\n|---1--(Z)--2---|---3---|\n| (X) 7 8 o\n|---4---|---5---|---6---|\n| o o o\n| | | |\n\nThe surface code has open boundary conditions, unlike the toric code. To this end, we remove qubits (denoted by \"o\") and parity checks on the right and bottom sides.\n\nFaces like (1,4,7) have X checks, and crosses like (1,2,7) have Z checks. Due to the removal of the bottom and right sides, we have some 3-qubit checks on the boundaries.\n\njulia> parity_checks(Surface(3,2))\n+ X__X__X_\n+ _X__X_XX\n+ __X__X_X\n+ ZZ____Z_\n+ _ZZ____Z\n+ ___ZZ_Z_\n+ ____ZZ_Z\n\nMore information can be seen in (Fowler et al., 2012).\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.TableDecoder","page":"API","title":"QuantumClifford.ECC.TableDecoder","text":"A simple look-up table decoder for error correcting codes.\n\nThe lookup table contains only weight=1 errors, thus it is small, but at best it provides only for distance=3 decoding.\n\nThe size of the lookup table would grow exponentially quickly for higher distances.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.Toric","page":"API","title":"QuantumClifford.ECC.Toric","text":"The Toric code (Kitaev, 2003).\n\nIllustration of a 2x2 toric code, where qubits are located on the edges:\n\n|--1-(Z)-2--|\n| (X) 5 6\n|--3--|--4--|\n| 7 8\n| | |\n\nIt is important to note that the toric code has periodic boundary conditions, which means that the top and bottom sides are essentially glued together, as are the left and right sides.\n\nFaces like (1,3,5,6) have X checks, and crosses like (1,2,5,7) have Z checks.\n\njulia> parity_checks(Toric(2,2))\n+ X_X_XX__\n+ _X_XXX__\n+ X_X___XX\n+ ZZ__Z_Z_\n+ ZZ___Z_Z\n+ __ZZZ_Z_\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumClifford.ECC.BeliefPropDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.BeliefPropDecoder","text":"A simple Belief Propagation decoder built around tools from LDPCDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.BitFlipDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.BitFlipDecoder","text":"An Iterative Bitflip decoder built around tools from LDPCDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.LPCode-Tuple","page":"API","title":"QuantumClifford.ECC.LPCode","text":"Lifted product codes ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nImplemented as a package extension with Hecke. Check the QuantumClifford documentation for more details on that extension.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.LiftedCode-Tuple","page":"API","title":"QuantumClifford.ECC.LiftedCode","text":"Classical codes lifted over a group algebra, used for lifted product code construction ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nImplemented as a package extension with Hecke. Check the QuantumClifford documentation for more details on that extension.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.PyBeliefPropDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.PyBeliefPropDecoder","text":"A Belief Propagation decoder built around tools from the python package ldpc available from the julia package PyQDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.PyBeliefPropOSDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.PyBeliefPropOSDecoder","text":"A Belief Propagation decoder with ordered statistics decoding, built around tools from the python package ldpc available from the julia package PyQDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.PyMatchingDecoder-Tuple","page":"API","title":"QuantumClifford.ECC.PyMatchingDecoder","text":"A perfect matching decoder built around tools from the python package pymatching available from the julia package PyQDecoders.jl.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.bicycle_codes","page":"API","title":"QuantumClifford.ECC.bicycle_codes","text":"Implemented in a package extension with Hecke.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.code_k-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.ECC.code_k","text":"The number of logical qubits in a code.\n\nNote that when redundant rows exist in the parity check matrix, the number of logical qubits code_k(c) will be greater than code_n(c) - code_s(c), where the difference equals the redundancy.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.code_n","page":"API","title":"QuantumClifford.ECC.code_n","text":"The number of physical qubits in a code.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.code_s","page":"API","title":"QuantumClifford.ECC.code_s","text":"The number of stabilizer checks in a code. They might not be all linearly independent, thus code_s >= code_n-code_k. For the number of linearly independent checks you can use LinearAlgebra.rank.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.distance","page":"API","title":"QuantumClifford.ECC.distance","text":"The distance of a code.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.evaluate_decoder-Tuple{QuantumClifford.ECC.AbstractSyndromeDecoder, QuantumClifford.ECC.AbstractECCSetup, Int64}","page":"API","title":"QuantumClifford.ECC.evaluate_decoder","text":"Evaluate the performance of a given decoder (e.g. TableDecoder) and a given style of running an ECC code (e.g. ShorSyndromeECCSetup)\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.evaluate_decoder-Tuple{QuantumClifford.ECC.AbstractSyndromeDecoder, Vararg{Any, 5}}","page":"API","title":"QuantumClifford.ECC.evaluate_decoder","text":"Evaluate the performance of an error-correcting circuit.\n\nThis method requires you give the circuit that performs both syndrome measurements and (probably noiseless) logical state measurements. The faults matrix that translates an error vector into corresponding logical errors is necessary as well.\n\nThis is a relatively barebones method that assumes the user prepares necessary circuits, etc. It is a method that is used internally by more user-frienly methods providing automatic conversion of codes and noise models to the necessary noisy circuits.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.faults_matrix-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.ECC.faults_matrix","text":"Error-to-logical-observable map (a.k.a. fault matrix) of a code.\n\nFor a code with n physical qubits and k logical qubits this function returns a 2k × 2n binary matrix O such that O[i,j] is true if the logical observable of index i is flipped by the single physical qubit error of index j. Indexing is such that:\n\nO[1:k,:] is the error-to-logical-X-observable map (logical X observable, i.e. triggered by logical Z errors)\nO[k+1:2k,:] is the error-to-logical-Z-observable map\nO[:,1:n] is the X-physical-error-to-logical-observable map\nO[n+1:2n,:] is the Z-physical-error-to-logical-observable map\n\nE.g. for k=1, n=10, then if O[2,5] is true, then the logical Z observable is flipped by a X₅ error; and if O[1,12] is true, then the logical X observable is flipped by a Z₂ error.\n\nOf note is that there is a lot of freedom in choosing the logical operations! A logical operator multiplied by a stabilizer operator is still a logical operator. Similarly there is a different fault matrix for each choice of logical operators. But once the logical operators are picked, the fault matrix is fixed.\n\nBelow we show an example that uses the Shor code. While it is not the smallest code, it is a convenient choice to showcase the importance of the fault matrix when dealing with degenerate codes where a correction operation and an error do not need to be the same.\n\nFirst, consider a single-qubit error, potential correction operations, and their effect on the Shor code:\n\njulia> using QuantumClifford.ECC: faults_matrix, Shor9\n\njulia> state = MixedDestabilizer(Shor9())\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n+ _X_______\n+ __X______\n+ ____X____\n+ _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n+ ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n+ XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\njulia> err_Z₁ = single_z(9,1) # the error we will simulate\n+ Z________\n\njulia> cor_Z₂ = single_z(9,2) # the correction operation we will perform\n+ _Z_______\n\njulia> err_Z₁ * state # observe that one of the syndrome bits is now flipped\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n+ _X_______\n+ __X______\n+ ____X____\n+ _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n+ ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n- XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\njulia> cor_Z₂ * err_Z₁ * state # we are back to a good code state\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n- _X_______\n+ __X______\n+ ____X____\n+ _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n+ ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n+ XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\njulia> bad_Z₆Z₉ = single_z(9,6) * single_z(9,9) # a different \"correction\" operation\n+ _____Z__Z\n\njulia> bad_Z₆Z₉ * err_Z₁ * state # the syndrome is trivial, but now we have a logical error\n𝒟ℯ𝓈𝓉𝒶𝒷━━━━━\n+ Z________\n+ ___Z_____\n+ _X_______\n+ __X______\n+ ____X____\n- _____X___\n+ ______X__\n+ _______X_\n𝒳ₗ━━━━━━━━━\n- ______XXX\n𝒮𝓉𝒶𝒷━━━━━━━\n+ XXX___XXX\n+ ___XXXXXX\n+ ZZ_______\n+ Z_Z______\n+ ___ZZ____\n+ ___Z_Z___\n+ ______Z_Z\n+ _______ZZ\n𝒵ₗ━━━━━━━━━\n+ Z__Z____Z\n\nThe success of cor_Z₂ and the failure of bad_Z₆Z₉ can be immediately seen through the fault matrix, as the wrong \"correction\" does not result in the same logical flips ad the error:\n\njulia> O = faults_matrix(Shor9())\n2×18 BitMatrix:\n 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1\n 1 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0\n\njulia> O * stab_to_gf2(err_Z₁)\n2-element Vector{Int64}:\n 0\n 0\n\njulia> O * stab_to_gf2(cor_Z₂)\n2-element Vector{Int64}:\n 0\n 0\n\njulia> O * stab_to_gf2(bad_Z₆Z₉)\n2-element Vector{Int64}:\n 1\n 0\n\nWhile its use in this situation is rather contrived, the fault matrix is incredibly useful when running large scale simulations in which we want a separate fast error sampling process, (e.g. with Pauli frames) and a syndrome decoding process, without coupling between them. We just gather all our syndrome measurement and logical observables from the Pauli frame simulations, and then use them with the fault matrix in the syndrome decoding simulation.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.generalized_bicycle_codes","page":"API","title":"QuantumClifford.ECC.generalized_bicycle_codes","text":"Implemented in a package extension with Hecke.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.iscss-Union{Tuple{Type{T}}, Tuple{T}} where T<:QuantumClifford.ECC.AbstractECC","page":"API","title":"QuantumClifford.ECC.iscss","text":"Check if the code is CSS.\n\nReturn nothing if unknown from the type.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.isdegenerate","page":"API","title":"QuantumClifford.ECC.isdegenerate","text":"Check if the code is degenerate with respect to a given set of error or with respect to all \"up to d physical-qubit\" errors (defaulting to d=1).\n\njulia> using QuantumClifford.ECC\n\njulia> isdegenerate(Shor9(), [single_z(9,1), single_z(9,2)])\ntrue\n\njulia> isdegenerate(Shor9(), [single_z(9,1), single_x(9,1)])\nfalse\n\njulia> isdegenerate(Steane7(), 1)\nfalse\n\njulia> isdegenerate(Steane7(), 2)\ntrue\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.naive_encoding_circuit-Tuple{Any}","page":"API","title":"QuantumClifford.ECC.naive_encoding_circuit","text":"Encoding physical qubits into a larger logical code.\n\nThe initial physical qubits to be encoded have to be at indices n-k+1:n.\n\ninfo: Encoding circuits are not fault-tolerant\nEncoding circuits are not fault-tolerant, and thus should not be used in practice. Instead, you should measure the stabilizers of the code and the logical observables, thus projecting into the code space (which can be fault-tolerant).\n\nThe canonicalization operation performed on the code may permute the qubits (see canonicalize_gott!). That permutation is corrected for with SWAP gates by default (controlled by the undoperm keyword argument).\n\nBased on (Cleve and Gottesman, 1997) and (Gottesman, 1997), however it seems the published algorithm has some errors. Consult the erratum, as well as the more recent (Grassl, 2002) and (Grassl, 2011), and be aware that this implementation also uses H instead of Z gates.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.naive_syndrome_circuit","page":"API","title":"QuantumClifford.ECC.naive_syndrome_circuit","text":"Generate the non-fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.\n\nUse the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts.\n\nReturns the circuit, the number of ancillary qubits that were added, and a list of bit indices that will store the measurement results.\n\nSee also: shor_syndrome_circuit\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.parity_checks","page":"API","title":"QuantumClifford.ECC.parity_checks","text":"Parity check tableau of a code.\n\nSee also: parity_checks_x and parity_checks_z\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.parity_checks_x-Tuple{QuantumClifford.ECC.AbstractECC}","page":"API","title":"QuantumClifford.ECC.parity_checks_x","text":"Parity check boolean matrix of a code (only the X entries in the tableau, i.e. the checks for Z errors).\n\nOnly CSS codes have this method.\n\nSee also: parity_checks\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.parity_checks_z-Tuple{QuantumClifford.ECC.AbstractECC}","page":"API","title":"QuantumClifford.ECC.parity_checks_z","text":"Parity check boolean matrix of a code (only the Z entries in the tableau, i.e. the checks for X errors).\n\nOnly CSS codes have this method.\n\nSee also: parity_checks\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.random_all_to_all_circuit_code","page":"API","title":"QuantumClifford.ECC.random_all_to_all_circuit_code","text":"Random all-to-all Clifford circuit code (Brown and Fawzi, Jul 2013).\n\nThe code of n qubits is generated by an all-to-all random Clifford circuit of ngates gates that encodes a subset of qubits encode_qubits into logical qubits.\n\nBecause of the random picking, the size of encode_qubits is the only thing that matters for the code, referred to as k.\n\nSee also: random_all_to_all_clifford_circuit, CircuitCode\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.random_brickwork_circuit_code","page":"API","title":"QuantumClifford.ECC.random_brickwork_circuit_code","text":"Random brickwork Clifford circuit code (Brown and Fawzi, Jul 2013).\n\nThe code is generated by a brickwork random Clifford circuit of nlayers layers that encodes a subset of qubits encode_qubits into logical qubits.\n\nSee also: random_brickwork_clifford_circuit, CircuitCode\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.rate-Tuple{Any}","page":"API","title":"QuantumClifford.ECC.rate","text":"The rate of a code.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.shor_syndrome_circuit","page":"API","title":"QuantumClifford.ECC.shor_syndrome_circuit","text":"Generate the Shor fault-tolerant stabilizer measurement cicuit for a given code instance or parity check tableau.\n\nUse the ancillary_index and bit_index arguments to offset where the corresponding part the circuit starts. Ancillary qubits\n\nReturns:\n\nThe ancillary cat state preparation circuit.\nThe Shor syndrome measurement circuit.\nThe number of ancillary qubits that were added.\nThe list of bit indices that store the final measurement results.\n\nSee also: naive_syndrome_circuit\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#QuantumClifford.ECC.two_block_group_algebra_codes","page":"API","title":"QuantumClifford.ECC.two_block_group_algebra_codes","text":"Implemented in a package extension with Hecke.\n\n\n\n\n\n","category":"function"},{"location":"ECC_API/#Implemented-in-an-extension-requiring-Hecke.jl","page":"API","title":"Implemented in an extension requiring Hecke.jl","text":"","category":"section"},{"location":"ECC_API/","page":"API","title":"API","text":"Modules = [QuantumCliffordHeckeExt]\nPrivate = true","category":"page"},{"location":"ECC_API/#QuantumCliffordHeckeExt.LPCode","page":"API","title":"QuantumCliffordHeckeExt.LPCode","text":"struct LPCode <: QuantumClifford.ECC.AbstractECC\n\nLifted product codes ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nA lifted product code is defined by the hypergraph product of a base matrices A and the conjugate of another base matrix B'. Here, the hypergraph product is taken over a group algebra, of which the base matrices are consisting.\n\nThe binary parity check matrix is obtained by applying repr to each element of the matrix resulted from the hypergraph product, which is mathematically a linear map from each group algebra element to a binary matrix.\n\nConstructors\n\nMultiple constructors are available:\n\nTwo base matrices of group algebra elements.\nTwo lifted codes, whose base matrices are for quantum code construction.\nTwo base matrices of group elements, where each group element will be considered as a group algebra element by assigning a unit coefficient.\nTwo base matrices of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.\n\nExamples\n\nA [[882, 24, d ≤ 24]] code from Appendix B of (Roffe et al., 2023). We use the 1st constructor to generate the code and check its length and dimension. During the construction, we do arithmetic operations to get the group algebra elements in base matrices A and B. Here x is the generator of the group algebra, i.e., offset-1 cyclic permutation, and GA(1) is the unit element.\n\njulia> import Hecke: group_algebra, GF, abelian_group, gens; import LinearAlgebra: diagind;\n\njulia> l = 63; GA = group_algebra(GF(2), abelian_group(l)); x = gens(GA)[];\n\njulia> A = zeros(GA, 7, 7);\n\njulia> A[diagind(A)] .= x^27;\n\njulia> A[diagind(A, -1)] .= x^54;\n\njulia> A[diagind(A, 6)] .= x^54;\n\njulia> A[diagind(A, -2)] .= GA(1);\n\njulia> A[diagind(A, 5)] .= GA(1);\n\njulia> B = reshape([1 + x + x^6], (1, 1));\n\njulia> c1 = LPCode(A, B);\n\njulia> code_n(c1), code_k(c1)\n(882, 24)\n\nA [[175, 19, d ≤ 0]] code from Eq. (18) in Appendix A of (Raveendran et al., 2022), following the 4th constructor.\n\njulia> base_matrix = [0 0 0 0; 0 1 2 5; 0 6 3 1]; l = 7;\n\njulia> c2 = LPCode(base_matrix, l .- base_matrix', l);\n\njulia> code_n(c2), code_k(c2)\n(175, 19)\n\nCode subfamilies and convenience constructors for them\n\nWhen the base matrices of the LPCode are 1×1, the code is called a two-block group-algebra code two_block_group_algebra_codes.\nWhen the base matrices of the LPCode are 1×1 and their elements are sums of cyclic permutations, the code is called a generalized bicycle code generalized_bicycle_codes.\nWhen the two matrices are adjoint to each other, the code is called a bicycle code bicycle_codes.\n\nThe representation function\n\nWe use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.\n\nWe also accept a custom representation function as detailed in LiftedCode.\n\nSee also: LiftedCode, two_block_group_algebra_codes, generalized_bicycle_codes, bicycle_codes.\n\nA::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the first base matrix of the code, whose elements are in a group algebra.\nB::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the second base matrix of the code, whose elements are in the same group algebra as A.\nGA::Hecke.GroupAlgebra: the group algebra for which elements in A and B are from.\nrepr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumCliffordHeckeExt.LiftedCode","page":"API","title":"QuantumCliffordHeckeExt.LiftedCode","text":"struct LiftedCode <: QuantumClifford.ECC.ClassicalCode\n\nClassical codes lifted over a group algebra, used for lifted product code construction ((Panteleev and Kalachev, 2021), (Panteleev and Kalachev, Jun 2022))\n\nThe parity-check matrix is constructed by applying repr to each element of A, which is mathematically a linear map from a group algebra element to a binary matrix. The size of the parity check matrix will enlarged with each element of A being inflated into a matrix. The procedure is called a lift (Panteleev and Kalachev, Jun 2022).\n\nConstructors\n\nA lifted code can be constructed via the following approaches:\n\nA matrix of group algebra elements.\nA matrix of group elements, where a group element will be considered as a group algebra element by assigning a unit coefficient.\nA matrix of integers, where each integer represent the shift of a cyclic permutation. The order of the cyclic permutation should be specified.\n\nThe default GA is the group algebra of A[1, 1], the default representation repr is the permutation representation.\n\nThe representation function repr\n\nWe use the default representation function Hecke.representation_matrix to convert a GF(2)-group algebra element to a binary matrix. The default representation, provided by Hecke, is the permutation representation.\n\nWe also accept a custom representation function (the repr field of the constructor). Whatever the representation, the matrix elements need to be convertible to Integers (e.g. permit lift(ZZ, ...)). Such a customization would be useful to reduce the number of bits required by the code construction.\n\nFor example, if we use a D4 group for lifting, our default representation will be 8×8 permutation matrices, where 8 is the group's order. However, we can find a 4×4 matrix representation for the group, e.g. by using the typical 2×2 representation and converting it into binary representation by replacing \"1\" with the Pauli I, and \"-1\" with the Pauli X matrix.\n\nSee also: LPCode.\n\nA::Union{LinearAlgebra.Adjoint{<:Hecke.GroupAlgebraElem, <:Matrix{<:Hecke.GroupAlgebraElem}}, Matrix{<:Hecke.GroupAlgebraElem}}: the base matrix of the code, whose elements are in a group algebra.\nGA::Hecke.GroupAlgebra: the group algebra for which elements in A are from.\nrepr::Function: a function that converts a group algebra element to a binary matrix; default to be the permutation representation for GF(2)-algebra.\n\n\n\n\n\n","category":"type"},{"location":"ECC_API/#QuantumCliffordHeckeExt.LiftedCode-Tuple{Matrix{Hecke.GroupAlgebraElem{Nemo.FqFieldElem, <:Hecke.GroupAlgebra}}}","page":"API","title":"QuantumCliffordHeckeExt.LiftedCode","text":"LiftedCode constructor using the default GF(2) representation (coefficients converted to a permutation matrix by representation_matrix provided by Hecke).\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#Base.adjoint-Union{Tuple{Hecke.GroupAlgebraElem{T}}, Tuple{T}} where T","page":"API","title":"Base.adjoint","text":"Compute the adjoint of a group algebra element. The adjoint is defined as the conjugate of the element in the group algebra, i.e. the inverse of the element in the associated group.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.bicycle_codes-Tuple{Array{Int64}, Int64}","page":"API","title":"QuantumClifford.ECC.bicycle_codes","text":"Bicycle codes are a special case of generalized bicycle codes, where a and b are conjugate to each other. The order of the cyclic group is l, and the shifts a_shifts and b_shifts are reverse to each other.\n\nSee also: two_block_group_algebra_codes, generalized_bicycle_codes.\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.generalized_bicycle_codes-Tuple{Array{Int64}, Array{Int64}, Int64}","page":"API","title":"QuantumClifford.ECC.generalized_bicycle_codes","text":"Generalized bicycle codes, which are a special case of 2GBA codes (and therefore of lifted product codes). Here the group is chosen as the cyclic group of order l, and the base matrices a and b are the sum of the group algebra elements corresponding to the shifts a_shifts and b_shifts.\n\nSee also: two_block_group_algebra_codes, bicycle_codes.\n\nA [[254, 28, 14 ≤ d ≤ 20]] code from (A1) in Appendix B of (Panteleev and Kalachev, 2021).\n\njulia> c = generalized_bicycle_codes([0, 15, 20, 28, 66], [0, 58, 59, 100, 121], 127);\n\njulia> code_n(c), code_k(c)\n(254, 28)\n\n\n\n\n\n","category":"method"},{"location":"ECC_API/#QuantumClifford.ECC.two_block_group_algebra_codes-Tuple{Hecke.GroupAlgebraElem, Hecke.GroupAlgebraElem}","page":"API","title":"QuantumClifford.ECC.two_block_group_algebra_codes","text":"Two-block group algebra (2GBA) codes, which are a special case of lifted product codes from two group algebra elements a and b, used as 1x1 base matrices.\n\nSee also: LPCode, generalized_bicycle_codes, bicycle_codes\n\n\n\n\n\n","category":"method"},{"location":"allops/#all-operations","page":"All Gates","title":"Operations - Gates, Measurements, and More","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"DocTestSetup = quote\n using QuantumClifford\n using StableRNGs\n rng = StableRNG(42)\nend","category":"page"},{"location":"allops/#Operations","page":"All Gates","title":"Operations","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Acting on quantum states can be performed either:","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"In a \"linear algebra\" language where unitaries, measurements, and other operations have separate interfaces. This is an explicitly deterministic lower-level interface, which provides a great deal of control over how tableaux are manipulated. See the Stabilizer Tableau Algebra Manual as a primer on these approaches.\nOr in a \"circuit\" language, where the operators (and measurements and noise) are represented as circuit gates. This is a higher-level interface in which the outcome of an operation can be stochastic. The API for it is centered around the apply! function. Particularly useful for Monte Carlo simulations and Perturbative Expansion Symbolic Results.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"In the circuit language, all operations can be applied on a state with the apply! function. Whether they are deterministic and their computational complexity is listed in the table below. A list of lower-level \"linear algebra style\" functions for more control over how an operation is performed is also given.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Type Deterministic 𝒪(nˣ) Low-level functions\nAbstractOperation \n├─ AbstractCliffordOperator \n│ ├─ AbstractSymbolicOperator \n│ │ ├─ AbstractSingleQubitOperator \n│ │ │ ├─ SingleQubitOperator ✔️ n \n│ │ │ ├─ sHadamard ✔️ n \n│ │ │ ├─ sId1 ✔️ n \n│ │ │ ├─ sInvPhase ✔️ n \n│ │ │ ├─ sPhase ✔️ n \n│ │ │ ├─ sX ✔️ n \n│ │ │ ├─ sY ✔️ n \n│ │ │ └─ sZ ✔️ n \n│ │ └─ AbstractTwoQubitOperator \n│ │ ├─ sCNOT ✔️ n \n│ │ ├─ sCPHASE ✔️ n \n│ │ └─ sSWAP ✔️ n \n│ │ \n│ ├─ CliffordOperator ✔️ n³ \n│ ├─ PauliOperator ✔️ n² \n│ └─ SparseGate ✔️ kn² \n├─ AbstractMeasurement \n│ ├─ PauliMeasurement ❌ n² project!, projectrand!\n│ ├─ sMX ❌ n² projectX!\n│ ├─ sMY ❌ n² projectY!\n│ └─ sMZ ❌ n² projectZ!\n│ \n├─ BellMeasurement ❌ n² \n├─ NoiseOp ❌ ? applynoise!\n├─ NoiseOpAll ❌ ? applynoise!\n├─ NoisyGate ❌ ? applynoise!\n└─ Reset ✔️ kn² reset_qubits!","category":"page"},{"location":"allops/#Details-of-Operations-Supported-by-[apply!](@ref)","page":"All Gates","title":"Details of Operations Supported by apply!","text":"","category":"section"},{"location":"allops/#Unitary-Gates","page":"All Gates","title":"Unitary Gates","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"We distinguish between symbolic gates like sCNOT that have specialized (fast) apply! methods (usually just for single and two qubit gates) and general tableau representation of gates like CliffordOperator that can represent any multi-qubit gate.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Predefined unitary gates are available, like sCNOT, sHadamard, etc.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\n[sCNOT(2,4),sHadamard(2),sCPHASE(1,3),sSWAP(2,4)]","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Any arbitrary tableaux can be used as a gate too. ","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"They can be specified by giving a Clifford operator tableaux and the indices on which it acts (particularly useful for gates acting on a small part of a circuit):","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\nSparseGate(tCNOT, [2,4])","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"The Clifford operator tableaux can be completely arbitrary.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"SparseGate(random_clifford(3), [2,4,5])","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"If the Clifford operator acts on all qubits, we do not need to specify indices, just use the operator.","category":"page"},{"location":"allops/#Noisy-Gates","page":"All Gates","title":"Noisy Gates","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Each gate can be followed by noise applied to the qubits on which it has acted. This is done by wrapping the given gate into a NoisyGate","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"ε = 0.03 # X/Y/Z error probability\nnoise = UnbiasedUncorrelatedNoise(ε)\nnoisy_gate = NoisyGate(SparseGate(tCNOT, [2,4]), noise)","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"In circuit diagrams the noise is not depicted, but after each application of the gate defined in noisy_gate, a noise operator will also be applied. The example above is of Pauli Depolarization implemented by UnbiasedUncorrelatedNoise.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"One can also apply only the noise operator by using NoiseOp which acts only on specified qubits. Or alternatively, one can use NoiseOpAll in order to apply noise to all qubits.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"[NoiseOp(noise, [4,5]), NoiseOpAll(noise)]","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"The machinery behind noise processes and different types of noise is detailed in the section on noise","category":"page"},{"location":"allops/#Coincidence-Measurements","page":"All Gates","title":"Coincidence Measurements","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"Global parity measurements involving single-qubit projections and classical communication are implemented with BellMeasurement. One needs to specify the axes of measurement and the qubits being measured. If the parity is trivial, the circuit continues, if the parity is non-trivial, the circuit ends and reports a detected failure. This operator is frequently used in the simulation of entanglement purification.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"BellMeasurement([sMX(1), sMY(3), sMZ(4)])","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"There is also NoisyBellMeasurement that takes the bit-flip probability of a single-qubit measurement as a third argument.","category":"page"},{"location":"allops/#Stabilizer-Measurements","page":"All Gates","title":"Stabilizer Measurements","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"A measurement over one or more qubits can also be performed, e.g., a direct stabilizer measurement on multiple qubits without the use of ancillary qubits. When applied to multiple qubits, this differs from BellMeasurement as it performs a single projection, unlike BellMeasurement which performs a separate projection for every single qubit involved. This measurement is implemented in PauliMeasurement which requires a Pauli operator on which to project and the index of the classical bit in which to store the result. Alternatively, there are sMX, sMZ, sMY if you are measuring a single qubit.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"[PauliMeasurement(P\"XYZ\", 1), sMZ(2, 2)]","category":"page"},{"location":"allops/#Reset-Operations","page":"All Gates","title":"Reset Operations","text":"","category":"section"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"The Reset operations lets you trace out the specified qubits and set their state to a specific tableau.","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"new_state = random_stabilizer(3)\nqubit_indices = [1,2,3]\nReset(new_state, qubit_indices)","category":"page"},{"location":"allops/","page":"All Gates","title":"All Gates","text":"It can be done anywhere in a circuit, not just at the beginning.","category":"page"},{"location":"noisycircuits/#Simulation-of-Noisy-Clifford-Circuits","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Clifford Circuits","text":"","category":"section"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\nend","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"warning: Unstable\nThis is unfinished experimental functionality that will change significantly.","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"We have experimental support for simulation of noisy Clifford circuits which can be imported with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"Both Monte Carlo and Perturbative Expansion approaches are supported. When performing a perturbative expansion in the noise parameter, the expansion can optionally be performed symbolically, to arbitrary high orders.","category":"page"},{"location":"noisycircuits/","page":"Simulation of Noisy Circuits","title":"Simulation of Noisy Circuits","text":"Multiple notebooks with examples are also available. For instance, see this tutorial on entanglement purification for many examples.","category":"page"},{"location":"ECC_evaluating/#ecc_evaluating","page":"Evaluating codes and decoders","title":"Evaluating an ECC code and decoders","text":"","category":"section"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.ECC\nend\nCurrentModule = QuantumClifford.ECC","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"warning: The documentation is incomplete\nWhile waiting for a better documentation than the small example below, consider looking into evaluate_decoder, TableDecoder, BeliefPropDecoder, PyBeliefPropDecoder, PyMatchingDecoder, CommutationCheckECCSetup, NaiveSyndromeECCSetup, ShorSyndromeECCSetup","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"This is a quick and durty example on how to use some of the decoders.","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"A function to plot the results of ","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"using CairoMakie\n\nfunction make_decoder_figure(phys_errors, results, title=\"\")\n minlim = min(minimum(phys_errors),minimum(results[results.!=0]))\n maxlim = min(1, max(maximum(phys_errors),maximum(results[results.!=0])))\n\n fresults = copy(results)\n fresults[results.==0] .= NaN\n\n f = Figure()\n a = Axis(f[1,1],\n xscale=log10, yscale=log10,\n limits=(minlim,maxlim,minlim,maxlim),\n aspect=DataAspect(),\n xlabel=\"physical error rate\",\n ylabel=\"logical error rate\",\n title=title)\n lines!(a, [minlim,maxlim],[minlim,maxlim], color=:black)\n for (i,sresults) in enumerate(eachslice(fresults, dims=1))\n scatter!(a, phys_errors, sresults[:,1], marker=:+, color=Cycled(i))\n scatter!(a, phys_errors, sresults[:,2], marker=:x, color=Cycled(i))\n end\n f\nend","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"Testing out a lookup table decoder on a small code.","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"using QuantumClifford\nusing QuantumClifford.ECC\n\nmem_errors = 0.001:0.0005:0.01\ncodes = [Shor9()]\nresults = zeros(length(codes), length(mem_errors), 2)\n\nfor (ic, c) in pairs(codes)\n for (i,m) in pairs(mem_errors)\n setup = CommutationCheckECCSetup(m)\n decoder = TableDecoder(c)\n r = evaluate_decoder(decoder, setup, 10000)\n results[ic,i,:] .= r\n end\nend\n\nmake_decoder_figure(mem_errors, results, \"Shor's code with a lookup table decoder\")","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"Testing out the toric code with a decoder provided by the python package pymatching (provided in julia by the meta package PyQDecoders.jl).","category":"page"},{"location":"ECC_evaluating/","page":"Evaluating codes and decoders","title":"Evaluating codes and decoders","text":"import PyQDecoders\n\nmem_errors = 0.001:0.005:0.1\ncodes = [Toric(4,4), Toric(6,6)]\nresults = zeros(length(codes), length(mem_errors), 2)\n\nfor (ic, c) in pairs(codes)\n for (i,m) in pairs(mem_errors)\n setup = ShorSyndromeECCSetup(m, 0)\n decoder = PyMatchingDecoder(c)\n r = evaluate_decoder(decoder, setup, 1000)\n results[ic,i,:] .= r\n end\nend\n\nmake_decoder_figure(mem_errors, results, \"Toric code with a MWPM decoder\")","category":"page"},{"location":"canonicalization/#Canonicalization-operations","page":"Canonicalization","title":"Canonicalization operations","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Different types of canonicalization operations are implemented. All of them are types of Gaussian elimination.","category":"page"},{"location":"canonicalization/#[canonicalize!](@ref)","page":"Canonicalization","title":"canonicalize!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"First do elimination on all X components and only then perform elimination on the Z components. Based on (Garcia et al., 2012). It is used in logdot for inner products of stabilizer states.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"The final tableaux, if square should look like the following (Image: )","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"If the tableaux is shorter than a square, the diagonals might not reach all the way to the right.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize!(random_stabilizer(20,30)))\nf","category":"page"},{"location":"canonicalization/#[canonicalize_rref!](@ref)","page":"Canonicalization","title":"canonicalize_rref!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Cycle between elimination on X and Z for each qubit. Particularly useful for tracing out qubits. Based on (Audenaert and Plenio, 2005). For convenience reasons, the canonicalization starts from the bottom row, and you can specify as a second argument which columns to be canonicalized (useful for tracing out arbitrary qubits, e.g., in traceout!).","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"The tableau canonicalization is done in recursive steps, each one of which results in something akin to one of these three options (Image: )","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize_rref!(random_stabilizer(20,30),1:30)[1])\nf","category":"page"},{"location":"canonicalization/#[canonicalize_gott!](@ref)","page":"Canonicalization","title":"canonicalize_gott!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"First do elimination on all X components and only then perform elimination on the Z components, but without touching the qubits that were eliminated during the X pass. Unlike other canonicalization operations, qubit columns are reordered, providing for a straight diagonal in each block. Particularly useful as certain blocks of the new created matrix are related to logical operations of the corresponding code, e.g. computing the logical X and Z operators of a MixedDestabilizer. Based on (Gottesman, 1997).","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"A canonicalized tableau would look like the following (the right-most block does not exist for square tableaux). (Image: )","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize_gott!(random_stabilizer(30))[1])\nf","category":"page"},{"location":"canonicalization/#[canonicalize_clip!](@ref)","page":"Canonicalization","title":"canonicalize_clip!","text":"","category":"section"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Convert to the \"clipped\" gauge of a stabilizer state resulting in a \"river\" of non-identity operators around the diagonal.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1], canonicalize_clip!(random_stabilizer(30)))\nf","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"The properties of the clipped gauge are:","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Each qubit is the left/right \"endpoint\" of exactly two stabilizer rows.\nFor the same qubit the two endpoints are always different Pauli operators.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"This canonicalization is used to derive the bigram a stabilizer state, which is also related to entanglement entropy in the state.","category":"page"},{"location":"canonicalization/","page":"Canonicalization","title":"Canonicalization","text":"Introduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in Appendix A of (Li et al., 2019).","category":"page"},{"location":"noisycircuits_mc/#noisycircuits_mc","page":"Monte Carlo","title":"Monte Carlo simulations of noisy Clifford circuits","text":"","category":"section"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\n using Quantikz\nend","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"Import with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"This module enables the simulation of noisy Clifford circuits through a Monte Carlo method where the same circuit is evaluated multiple times with random errors interspersed through it as prescribed by a given error model.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"Below is an example of a purification circuit. We first prepare the circuit we desire to use, including a noise model. Quantikz.jl was is used to visualize the circuit.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\ngood_bell_state = S\"XX\n ZZ\"\ninitial_state = MixedDestabilizer(good_bell_state⊗good_bell_state)\n\ng1 = sCNOT(1,3) # CNOT between qubit 1 and qubit 3 (both with Alice)\ng2 = sCNOT(2,4) # CNOT between qubit 2 and qubit 4 (both with Bob)\nm = BellMeasurement([sMX(3),sMX(4)]) # Bell measurement on qubit 3 and 4\nv = VerifyOp(good_bell_state,[1,2]) # Verify that qubit 1 and 2 indeed form a good Bell pair\nepsilon = 0.01 # The error rate\nn = NoiseOpAll(UnbiasedUncorrelatedNoise(epsilon))\n\n# This circuit performs a depolarization at rate `epsilon` to all qubits,\n# then bilater CNOT operations\n# then a Bell measurement\n# followed by checking whether the final result indeed corresponds to the correct Bell pair.\ncircuit = [n,g1,g2,m,v]","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"And we can run a Monte Carlo simulation of that circuit with mctrajectories.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"mctrajectories(initial_state, circuit, trajectories=500)","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"For more examples, see the notebook comparing the Monte Carlo and Perturbative method or this tutorial on entanglement purification for many examples.","category":"page"},{"location":"noisycircuits_mc/#Interface-for-custom-operations","page":"Monte Carlo","title":"Interface for custom operations","text":"","category":"section"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"If you want to create a custom gate type (e.g. calling it Operation), you need to definite the following methods.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"applywstatus!(s::T, g::Operation)::Tuple{T,Symbol} where T is a tableaux type like Stabilizer or a Register. The Symbol is the status of the operation. Predefined statuses are kept in the registered_statuses list, but you can add more. Be sure to expand this list if you want the trajectory simulators using your custom statuses to output all trajectories.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"There is also applynoise! which is convenient wait to create a noise model that can then be plugged into the NoisyGate struct, letting you reuse the predefined perfect gates and measurements. However, you can also just make up your own noise operator simply by implementing applywstatus! for it.","category":"page"},{"location":"noisycircuits_mc/","page":"Monte Carlo","title":"Monte Carlo","text":"You can also consult the list of implemented operators.","category":"page"},{"location":"commonstates/#Useful-States-and-Operators","page":"Useful States","title":"Useful States and Operators","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"DocTestSetup = quote\n using QuantumClifford\n using StableRNGs\n rng = StableRNG(42)\nend","category":"page"},{"location":"commonstates/#States","page":"Useful States","title":"States","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Stabilizer states can be represented with the Stabilizer, Destabilizer, MixedStabilizer, and MixedDestabilizer tableau data structures. You probably want to use MixedDestabilizer which supports the widest set of operations.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Moreover, a MixedDestabilizer can be stored inside a Register together with a set of classical bits in which measurement results can be written.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Below are convenience constructors for common types of states and operators, already implemented in this library.","category":"page"},{"location":"commonstates/#Pauli-Operators","page":"Useful States","title":"Pauli Operators","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Single qubit PauliOperator is implemented in [single_z] and [single_x].","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> single_z(4,2)\n+ _Z__\n\njulia> single_x(4,3)\n+ __X_","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"All identity operators use zero.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> zero(PauliOperator, 3)\n+ ___\n\njulia> zero(P\"XYZXYZ\")\n+ ______","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Random Pauli operators are implemented as well (with or without a random phase).","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> using StableRNGs; rng = StableRNG(42);\n\njulia> random_pauli(rng, 4)\n+ ZYY_\n\njulia> random_pauli(rng, 4; nophase=false)\n- YZ_X","category":"page"},{"location":"commonstates/#Stabilizer-States","page":"Useful States","title":"Stabilizer States","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"An all-identity stabilizer can be created with zero.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> zero(Stabilizer, 3)\n+ ___\n+ ___\n+ ___\n\njulia> zero(Stabilizer, 2, 3)\n+ ___\n+ ___\n\njulia> zero(S\"XIZ\n YZX\")\n+ ___\n+ ___","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Diagonal stabilizers in different bases are available as well, through one.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> one(Stabilizer, 3)\n+ Z__\n+ _Z_\n+ __Z\n\njulia> one(Stabilizer, 3; basis=:Y)\n+ Y__\n+ _Y_\n+ __Y\n\njulia> one(S\"XX\n ZZ\")\n+ Z_\n+ _Z","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"A random stabilizer (or destabilizers or Clifford operators) can be created as well. We use the algorithm described in (Bravyi and Maslov, 2021).","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> random_stabilizer(rng, 2,5)\n+ YZXZZ\n- XZYYY","category":"page"},{"location":"commonstates/#Mixed-States","page":"Useful States","title":"Mixed States","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Similarly, one can create a diagonal mixed state.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> one(MixedDestabilizer, 2, 3)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ X__\n+ _X_\n𝒳ₗ━━━\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ _Z_\n𝒵ₗ━━━\n+ __Z","category":"page"},{"location":"commonstates/#Enumerating-all-Clifford-Operations","page":"Useful States","title":"Enumerating all Clifford Operations","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"The algorithm from (Koenig and Smolin, 2014) can be used to enumerate all Clifford operations on a given number of qubits through enumerate_cliffords. Or one can use random_clifford, random_stabilizer to directly sample from that set.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> length(enumerate_cliffords(1))\n6\n\njulia> length(enumerate_cliffords(2))\n720","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"To also enumerate possible phases, you can use enumerate_phases.","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> length(collect(enumerate_phases(tCNOT)))\n16\n\njulia> length(collect(enumerate_phases(enumerate_cliffords(2))))\n11520","category":"page"},{"location":"commonstates/#Common-entangled-states","page":"Useful States","title":"Common entangled states","text":"","category":"section"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"Bell states and GHZ states have convenience constructors:","category":"page"},{"location":"commonstates/","page":"Useful States","title":"Useful States","text":"julia> bell()\n+ XX\n+ ZZ\n\njulia> bell(2)\n+ XX__\n+ ZZ__\n+ __XX\n+ __ZZ\n\njulia> ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ","category":"page"},{"location":"API/#Full-API","page":"API","title":"Full API","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"","category":"page"},{"location":"API/#States","page":"API","title":"States","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"Stabilizer states can be represented with the Stabilizer, Destabilizer, MixedStabilizer, and MixedDestabilizer tableau data structures. You probably want to use MixedDestabilizer which supports the widest set of operations.","category":"page"},{"location":"API/","page":"API","title":"API","text":"Moreover, a MixedDestabilizer can be stored inside a Register together with a set of classical bits in which measurement results can be written.","category":"page"},{"location":"API/","page":"API","title":"API","text":"Lastly, for Pauli frame simulations there is the PauliFrame type, a tableau in which each row represents a different Pauli frame.","category":"page"},{"location":"API/","page":"API","title":"API","text":"There are convenience constructors for common types of states and operators.","category":"page"},{"location":"API/#Operations","page":"API","title":"Operations","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"Acting on quantum states can be performed either:","category":"page"},{"location":"API/","page":"API","title":"API","text":"In a \"linear algebra\" language where unitaries, measurements, and other operations have separate interfaces. This is an explicitly deterministic lower-level interface, which provides a great deal of control over how tableaux are manipulated. See the Stabilizer Tableau Algebra Manual as a primer on these approaches.\nOr in a \"circuit\" language, where the operators (and measurements and noise) are represented as circuit gates. This is a higher-level interface in which the outcome of an operation can be stochastic. The API for it is centered around the apply! function. Particularly useful for Monte Carlo simulations and Perturbative Expansion Symbolic Results.","category":"page"},{"location":"API/","page":"API","title":"API","text":"See the full list of operations for a list of implemented operations.","category":"page"},{"location":"API/#Autogenerated-API-list","page":"API","title":"Autogenerated API list","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"Modules = [QuantumClifford]\nPrivate = false","category":"page"},{"location":"API/#QuantumClifford.QuantumClifford","page":"API","title":"QuantumClifford.QuantumClifford","text":"A module for using the Stabilizer formalism and simulating Clifford circuits.\n\n\n\n\n\n","category":"module"},{"location":"API/#QuantumClifford.continue_stat","page":"API","title":"QuantumClifford.continue_stat","text":"Returned by applywstatus! if the circuit simulation should continue.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.failure_stat","page":"API","title":"QuantumClifford.failure_stat","text":"Returned by applywstatus! if the circuit reports a failure.\n\nSee also: VerifyOp, BellMeasurement.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.false_success_stat","page":"API","title":"QuantumClifford.false_success_stat","text":"Returned by applywstatus! if the circuit reports a success, but it is a false positive (i.e., there was an undetected error).\n\nSee also: VerifyOp, BellMeasurement.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.true_success_stat","page":"API","title":"QuantumClifford.true_success_stat","text":"Returned by applywstatus! if the circuit reports a success and there is no undetected error.\n\nSee also: VerifyOp, BellMeasurement.\n\n\n\n\n\n","category":"constant"},{"location":"API/#QuantumClifford.AbstractSingleQubitOperator","page":"API","title":"QuantumClifford.AbstractSingleQubitOperator","text":"Supertype of all single-qubit symbolic operators.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.AbstractSymbolicOperator","page":"API","title":"QuantumClifford.AbstractSymbolicOperator","text":"Supertype of all symbolic operators. Subtype of AbstractCliffordOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.AbstractTwoQubitOperator","page":"API","title":"QuantumClifford.AbstractTwoQubitOperator","text":"Supertype of all two-qubit symbolic operators.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.BellMeasurement","page":"API","title":"QuantumClifford.BellMeasurement","text":"A Bell measurement performing the correlation measurement corresponding to the given pauli projections on the qubits at the selected indices.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.CircuitStatus","page":"API","title":"QuantumClifford.CircuitStatus","text":"A convenience struct to represent the status of a circuit simulated by mctrajectories\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.ClassicalXOR","page":"API","title":"QuantumClifford.ClassicalXOR","text":"Applies an XOR gate to classical bits. Currently only implemented for functionality with pauli frames.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.CliffordOperator","page":"API","title":"QuantumClifford.CliffordOperator","text":"Clifford Operator specified by the mapping of the basis generators.\n\njulia> tCNOT\nX₁ ⟼ + XX\nX₂ ⟼ + _X\nZ₁ ⟼ + Z_\nZ₂ ⟼ + ZZ\n\njulia> phase_gate = C\"Y\n Z\"\nX₁ ⟼ + Y\nZ₁ ⟼ + Z\n\njulia> stab = S\"XI\n IZ\";\n\n\njulia> entangled = tCNOT*stab\n+ XX\n+ ZZ\n\njulia> CliffordOperator(T\"YY\")\nERROR: DimensionMismatch: Input tableau should be of size 2n×n (top half is the X mappings and the bottom half are the Z mappings).\n[...]\n\nDestabilizer can also be converted.\n\njulia> d = Destabilizer(S\"Y\")\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z\n𝒮𝓉𝒶𝒷\n+ Y\n\njulia> CliffordOperator(d)\nX₁ ⟼ + Z\nZ₁ ⟼ + Y\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Destabilizer","page":"API","title":"QuantumClifford.Destabilizer","text":"A tableau representation of a pure stabilizer state. The tableau tracks the destabilizers as well, for efficient projections. On initialization there are no checks that the provided state is indeed pure. This enables the use of this data structure for mixed stabilizer state, but a better choice would be to use MixedDestabilizer.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.MixedDestabilizer","page":"API","title":"QuantumClifford.MixedDestabilizer","text":"A tableau representation for mixed stabilizer states that keeps track of the destabilizers in order to provide efficient projection operations.\n\nThe rank r of the n-qubit tableau is tracked, either so that it can be used to represent a mixed stabilizer state, or so that it can be used to represent an n-r logical-qubit code over n physical qubits. The \"logical\" operators are tracked as well.\n\nWhen the constructor is called on an incomplete Stabilizer it automatically calculates the destabilizers and logical operators, following chapter 4 of (Gottesman, 1997). Under the hood the conversion uses the canonicalize_gott! canonicalization. That canonicalization permutes the columns of the tableau, but we automatically undo the column permutation in the preparation of a MixedDestabilizer so that qubits are not reindexed. The boolean keyword arguments undoperm and reportperm can be used to control this behavior and to report the permutations explicitly.\n\nSee also: stabilizerview, destabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.MixedStabilizer","page":"API","title":"QuantumClifford.MixedStabilizer","text":"A slight improvement of the Stabilizer data structure that enables more naturally and completely the treatment of mixed states, in particular when the project! function is used.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.NoiseOp","page":"API","title":"QuantumClifford.NoiseOp","text":"An operator that applies the given noise model to the qubits at the selected indices.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.NoiseOpAll","page":"API","title":"QuantumClifford.NoiseOpAll","text":"An operator that applies the given noise model to all qubits.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.NoisyGate","page":"API","title":"QuantumClifford.NoisyGate","text":"A gate consisting of the given noise applied after the given perfect Clifford gate.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliChannel","page":"API","title":"QuantumClifford.PauliChannel","text":"A Pauli channel datastructure, mainly for use with StabMixture\n\nSee also: UnitaryPauliChannel\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliFrame","page":"API","title":"QuantumClifford.PauliFrame","text":"struct PauliFrame{T, S} <: QuantumClifford.AbstractQCState\n\nThis is a wrapper around a tableau. This \"frame\" tableau is not to be viewed as a normal stabilizer tableau, although it does conjugate the same under Clifford operations. Each row in the tableau refers to a single frame. The row represents the Pauli operation by which the frame and the reference differ.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliFrame-Tuple{Any, Any, Any}","page":"API","title":"QuantumClifford.PauliFrame","text":"PauliFrame(\n frames,\n qubits,\n measurements\n) -> PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}}\n\n\nPrepare an empty set of Pauli frames with the given number of frames and qubits. Preallocates spaces for measurement number of measurements.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliMeasurement","page":"API","title":"QuantumClifford.PauliMeasurement","text":"A Stabilizer measurement on the entirety of the quantum register.\n\nprojectrand!(state, pauli) and apply!(state, PauliMeasurement(pauli)) give the same (possibly non-deterministic) result. Particularly useful when acting on Register.\n\nSee also: apply!, projectrand!.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliNoise","page":"API","title":"QuantumClifford.PauliNoise","text":"Pauli noise model with probabilities px, py, and pz respectively for the three types of Pauli errors.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliNoise-Tuple{Any}","page":"API","title":"QuantumClifford.PauliNoise","text":"Constructs an unbiased Pauli noise model with total probability of error p.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliOperator","page":"API","title":"QuantumClifford.PauliOperator","text":"A multi-qubit Pauli operator (1iIZXY^otimes n).\n\nA Pauli can be constructed with the P custom string macro or by building up one through products and tensor products of smaller operators.\n\njulia> pauli3 = P\"-iXYZ\"\n-iXYZ\n\njulia> pauli4 = 1im * pauli3 ⊗ X\n+ XYZX\n\njulia> Z*X\n+iY\n\nWe use a typical F(2,2) encoding internally. The X and Z bits are stored in a single concatenated padded array of UInt chunks of a bit array.\n\njulia> p = P\"-IZXY\";\n\n\njulia> p.xz\n2-element Vector{UInt64}:\n 0x000000000000000c\n 0x000000000000000a\n\nYou can access the X and Z bits through getters and setters or through the xview, zview, xbit, and zbit functions.\n\njulia> p = P\"XYZ\"; p[1]\n(true, false)\n\njulia> p[1] = (true, true); p\n+ YYZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Register","page":"API","title":"QuantumClifford.Register","text":"A register, representing the state of a computer including both a tableaux and an array of classical bits (e.g. for storing measurement results)\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Reset","page":"API","title":"QuantumClifford.Reset","text":"Reset the specified qubits to the given state.\n\nBe careful, this operation implies first tracing out the qubits, which can lead to mixed states if these qubits were entangled with the rest of the system.\n\nSee also: sMRZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.SingleQubitOperator","page":"API","title":"QuantumClifford.SingleQubitOperator","text":"A \"symbolic\" general single-qubit operator which permits faster multiplication than an operator expressed as an explicit tableau.\n\njulia> op = SingleQubitOperator(2, true, true, true, false, true, true) # Tableau components and phases\nSingleQubitOperator on qubit 2\nX₁ ⟼ - Y\nZ₁ ⟼ - X\n\njulia> typeof(op)\nSingleQubitOperator\n\njulia> t_op = CliffordOperator(op, 3) # Transforming it back into an explicit tableau representation (specifying the size)\nX₁ ⟼ + X__\nX₂ ⟼ - _Y_\nX₃ ⟼ + __X\nZ₁ ⟼ + Z__\nZ₂ ⟼ - _X_\nZ₃ ⟼ + __Z\n\njulia> typeof(t_op)\nCliffordOperator{QuantumClifford.Tableau{Vector{UInt8}, Matrix{UInt64}}}\n\njulia> CliffordOperator(op, 1, compact=true) # You can also extract just the non-trivial part of the tableau\nX₁ ⟼ - Y\nZ₁ ⟼ - X\n\nSee also: sHadamard, sPhase, sId1, sX, sY, sZ, CliffordOperator\n\nOr simply consult subtypes(QuantumClifford.AbstractSingleQubitOperator) and subtypes(QuantumClifford.AbstractTwoQubitOperator) for a full list. You can think of the s prefix as \"symbolic\" or \"sparse\".\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.SparseGate","page":"API","title":"QuantumClifford.SparseGate","text":"A Clifford gate, applying the given cliff operator to the qubits at the selected indices.\n\napply!(state, cliff, indices) and apply!(state, SparseGate(cliff, indices)) give the same result.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.StabMixture","page":"API","title":"QuantumClifford.StabMixture","text":"mutable struct StabMixture{T, F}\n\nRepresents mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is a pure stabilizer state.\n\njulia> StabMixture(S\"-X\")\nA mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z\n𝒮𝓉𝒶𝒷\n- X\nwith ϕᵢⱼ | Pᵢ | Pⱼ:\n 1.0+0.0im | + _ | + _\n\njulia> pcT\nA unitary Pauli channel P = ∑ ϕᵢ Pᵢ with the following branches:\nwith ϕᵢ | Pᵢ\n 0.853553+0.353553im | + _\n 0.146447-0.353553im | + Z\n\njulia> apply!(StabMixture(S\"-X\"), pcT)\nA mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z\n𝒮𝓉𝒶𝒷\n- X\nwith ϕᵢⱼ | Pᵢ | Pⱼ:\n 0.0+0.353553im | + _ | + Z\n 0.0-0.353553im | + Z | + _\n 0.853553+0.0im | + _ | + _\n 0.146447+0.0im | + Z | + Z\n\nSee also: PauliChannel\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Stabilizer","page":"API","title":"QuantumClifford.Stabilizer","text":"Stabilizer, i.e. a list of commuting multi-qubit Hermitian Pauli operators.\n\nInstances can be created with the S custom string macro or as direct sum of other stabilizers.\n\ntip: Stabilizers and Destabilizers\nIn many cases you probably would prefer to use the MixedDestabilizer data structure, as it caries a lot of useful additional information, like tracking rank and destabilizer operators. Stabilizer has mostly a pedagogical value, and it is also used for slightly faster simulation of a particular subset of Clifford operations.\n\njulia> s = S\"XXX\n ZZI\n IZZ\"\n+ XXX\n+ ZZ_\n+ _ZZ\n\njulia> s⊗s\n+ XXX___\n+ ZZ____\n+ _ZZ___\n+ ___XXX\n+ ___ZZ_\n+ ____ZZ\n\nIt has an indexing API, looking like a list of PauliOperators.\n\njulia> s[2]\n+ ZZ_\n\nPauli operators can act directly on the a stabilizer.\n\njulia> P\"YYY\" * s\n- XXX\n+ ZZ_\n+ _ZZ\n\nThere are a number of ways to create a Stabilizer, including:\n\ngenerate Stabilizers from a list of Pauli operators\n\njulia> Stabilizer([P\"XX\", P\"ZZ\"])\n+ XX\n+ ZZ\n\ngenerate Stabilizers from boolean matrices\n\njulia> a = [true true; false false]; b = [false true; true true];\n\njulia> Stabilizer(a, b)\n+ XY\n+ ZZ\n\njulia> Stabilizer([0x0, 0x2], a, b)\n+ XY\n- ZZ\n\ninitialize an empty Stabilizer and fill it through indexing\n\njulia> s = zero(Stabilizer, 2)\n+ __\n+ __\n\njulia> s[1,1] = (true, false); s\n+ X_\n+ __\n\nThere are no automatic checks for correctness (i.e. independence of all rows, commutativity of all rows, hermiticity of all rows). The rank (number of rows) is permitted to be less than the number of qubits (number of columns): canonilization, projection, etc. continue working in that case. To great extent this library uses the Stabilizer data structure simply as a tableau. This might be properly abstracted away in future versions.\n\nSee also: PauliOperator, canonicalize!\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Stabilizer-Tuple{Graphs.SimpleGraphs.SimpleGraph}","page":"API","title":"QuantumClifford.Stabilizer","text":"Convert a graph representing a stabilizer state to an explicit Stabilizer.\n\nSee also: graphstate\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.UnbiasedUncorrelatedNoise","page":"API","title":"QuantumClifford.UnbiasedUncorrelatedNoise","text":"Depolarization noise model with total probability of error p.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.UnitaryPauliChannel","page":"API","title":"QuantumClifford.UnitaryPauliChannel","text":"A Pauli channel datastructure, mainly for use with StabMixture.\n\nMore convenient to use than PauliChannel when you know your Pauli channel is unitary.\n\njulia> Tgate = UnitaryPauliChannel(\n (I, Z),\n ((1+exp(im*π/4))/2, (1-exp(im*π/4))/2)\n )\nA unitary Pauli channel P = ∑ ϕᵢ Pᵢ with the following branches:\nwith ϕᵢ | Pᵢ\n 0.853553+0.353553im | + _\n 0.146447-0.353553im | + Z\n\njulia> PauliChannel(Tgate)\nPauli channel ρ ↦ ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† with the following branches:\nwith ϕᵢⱼ | Pᵢ | Pⱼ:\n 0.853553+0.0im | + _ | + _\n 0.0+0.353553im | + _ | + Z\n 0.0-0.353553im | + Z | + _\n 0.146447+0.0im | + Z | + Z\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.VerifyOp","page":"API","title":"QuantumClifford.VerifyOp","text":"A \"probe\" to verify that the state of the qubits corresponds to a desired good_state, e.g. at the end of the execution of a circuit.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCNOT","page":"API","title":"QuantumClifford.sCNOT","text":"A \"symbolic\" CNOT. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCPHASE","page":"API","title":"QuantumClifford.sCPHASE","text":"A \"symbolic\" CPHASE. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCXYZ","page":"API","title":"QuantumClifford.sCXYZ","text":"A \"symbolic\" single-qubit CXYZ. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sCZYX","page":"API","title":"QuantumClifford.sCZYX","text":"A \"symbolic\" single-qubit CZYX. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sHadamard","page":"API","title":"QuantumClifford.sHadamard","text":"A \"symbolic\" single-qubit Hadamard. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sHadamardXY","page":"API","title":"QuantumClifford.sHadamardXY","text":"A \"symbolic\" single-qubit HadamardXY. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sHadamardYZ","page":"API","title":"QuantumClifford.sHadamardYZ","text":"A \"symbolic\" single-qubit HadamardYZ. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sId1","page":"API","title":"QuantumClifford.sId1","text":"A \"symbolic\" single-qubit Identity operation.\n\nSee also: SingleQubitOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvPhase","page":"API","title":"QuantumClifford.sInvPhase","text":"A \"symbolic\" single-qubit InvPhase. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvSQRTX","page":"API","title":"QuantumClifford.sInvSQRTX","text":"A \"symbolic\" single-qubit InvSQRTX. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvSQRTY","page":"API","title":"QuantumClifford.sInvSQRTY","text":"A \"symbolic\" single-qubit InvSQRTY. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sInvZCrY","page":"API","title":"QuantumClifford.sInvZCrY","text":"A \"symbolic\" InvZCrY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMRX","page":"API","title":"QuantumClifford.sMRX","text":"Measure a qubit in the X basis and reset to the |+⟩ state.\n\nSee also: sMRZ, Reset, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMRY","page":"API","title":"QuantumClifford.sMRY","text":"Measure a qubit in the Y basis and reset to the |i₊⟩ state.\n\nSee also: sMRZ, Reset, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMRZ","page":"API","title":"QuantumClifford.sMRZ","text":"Measure a qubit in the Z basis and reset to the |0⟩ state.\n\nwarning: It does not trace out the qubit!\nAs described below there is a difference between measuring the qubit (followed by setting it to a given known state) and \"tracing out\" the qubit. By reset here we mean \"measuring and setting to a known state\", not \"tracing out\".\n\njulia> s = MixedDestabilizer(S\"XXX ZZI IZZ\") # |000⟩+|111⟩\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ ZZ_\n+ Z_Z\n\njulia> traceout!(copy(s), 1) # = I⊗(|00⟩⟨00| + |11⟩⟨11|)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ _X_\n𝒳ₗ━━━\n+ _XX\n+ Z__\n𝒮𝓉𝒶𝒷━\n+ _ZZ\n𝒵ₗ━━━\n+ Z_Z\n+ XXX\n\njulia> projectZ!(traceout!(copy(s), 1), 1)[1] # = |000⟩⟨000|+|011⟩⟨011| or |100⟩⟨100|+|111⟩⟨111| (use projectZrand! to actually get a random result)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ _X_\n+ XXX\n𝒳ₗ━━━\n+ _XX\n𝒮𝓉𝒶𝒷━\n+ _ZZ\n+ Z__\n𝒵ₗ━━━\n+ Z_Z\n\njulia> projectZ!(copy(s), 1)[1] # = |000⟩ or |111⟩ (use projectZrand! to actually get a random result)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ XXX\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ ZZ_\n+ Z_Z\n\njulia> apply!(Register(copy(s)), sMRZ(1)) |> quantumstate # |000⟩ or |011⟩, depending on randomization\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ XXX\n+ _X_\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n- ZZ_\n- Z_Z\n\nSee also: Reset, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMX","page":"API","title":"QuantumClifford.sMX","text":"Symbolic single qubit X measurement. See also Register, projectXrand!, sMY, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMY","page":"API","title":"QuantumClifford.sMY","text":"Symbolic single qubit Y measurement. See also Register, projectYrand!, sMX, sMZ\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sMZ","page":"API","title":"QuantumClifford.sMZ","text":"Symbolic single qubit Z measurement. See also Register, projectZrand!, sMX, sMY\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sPhase","page":"API","title":"QuantumClifford.sPhase","text":"A \"symbolic\" single-qubit Phase. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sSQRTX","page":"API","title":"QuantumClifford.sSQRTX","text":"A \"symbolic\" single-qubit SQRTX. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sSQRTY","page":"API","title":"QuantumClifford.sSQRTY","text":"A \"symbolic\" single-qubit SQRTY. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sSWAP","page":"API","title":"QuantumClifford.sSWAP","text":"A \"symbolic\" SWAP. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sX","page":"API","title":"QuantumClifford.sX","text":"A \"symbolic\" single-qubit X. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sXCX","page":"API","title":"QuantumClifford.sXCX","text":"A \"symbolic\" XCX. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sXCY","page":"API","title":"QuantumClifford.sXCY","text":"A \"symbolic\" XCY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sXCZ","page":"API","title":"QuantumClifford.sXCZ","text":"A \"symbolic\" XCZ. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sY","page":"API","title":"QuantumClifford.sY","text":"A \"symbolic\" single-qubit Y. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sYCX","page":"API","title":"QuantumClifford.sYCX","text":"A \"symbolic\" YCX. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sYCY","page":"API","title":"QuantumClifford.sYCY","text":"A \"symbolic\" YCY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sYCZ","page":"API","title":"QuantumClifford.sYCZ","text":"A \"symbolic\" YCZ. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZ","page":"API","title":"QuantumClifford.sZ","text":"A \"symbolic\" single-qubit Z. See also: SingleQubitOperator, AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCX","page":"API","title":"QuantumClifford.sZCX","text":"A \"symbolic\" ZCX. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCY","page":"API","title":"QuantumClifford.sZCY","text":"A \"symbolic\" ZCY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCZ","page":"API","title":"QuantumClifford.sZCZ","text":"A \"symbolic\" ZCZ. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.sZCrY","page":"API","title":"QuantumClifford.sZCrY","text":"A \"symbolic\" ZCrY. See also: AbstractSymbolicOperator\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.PauliError","page":"API","title":"QuantumClifford.PauliError","text":"A convenient constructor for various types of Pauli errors, that can be used as circuit gates in simulations. Returns more specific types when necessary.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.PauliError-NTuple{4, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies a biased Pauli error on all qubits independently, each with probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliError-Tuple{Any, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies an unbiased Pauli error on all qubits, each with independent probability p.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliError-Tuple{Int64, Any, Any, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies a biased Pauli error on qubit q with independent probabilities px, py, pz. Note that the probability of any error occurring is px+py+pz. Because of this, PauliError(1, p) is equivalent to PauliError(1,p/3,p/3,p/3). Similarly, if one wanted to exclude Z errors from PauliError(1,p/3,p/3,p/3) while mainting the same rate of X errors, one could write PauliError(1, p*2/3, 0, 0) (in the sense that Y errors can be interpreted as an X and a Z happening at the same time).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.PauliError-Tuple{Int64, Any}","page":"API","title":"QuantumClifford.PauliError","text":"\"Construct a gate operation that applies an unbiased Pauli error on qubit q with probability p.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.affectedqubits","page":"API","title":"QuantumClifford.affectedqubits","text":"A method giving the qubits acted upon by a given operation. Part of the Noise interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.applybranches","page":"API","title":"QuantumClifford.applybranches","text":"Compute all possible new states after the application of the given operator. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Perturbative Expansion interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.applynoise!","page":"API","title":"QuantumClifford.applynoise!","text":"A method modifying a given state by applying the corresponding noise model. It is non-deterministic, part of the Noise interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.applywstatus!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.applywstatus!","text":"Used for mctrajectories.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.bell","page":"API","title":"QuantumClifford.bell","text":"Prepare one or more Bell pairs (with optional phases).\n\njulia> bell()\n+ XX\n+ ZZ\n\njulia> bell(2)\n+ XX__\n+ ZZ__\n+ __XX\n+ __ZZ\n\njulia> bell((true, false))\n- XX\n+ ZZ\n\njulia> bell([true, false, true, true])\n- XX__\n+ ZZ__\n- __XX\n- __ZZ\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.bigram-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.bigram","text":"bigram(\n state::QuantumClifford.AbstractStabilizer;\n clip\n) -> Matrix{Int64}\n\n\nGet the bigram of a tableau.\n\nIt is the list of endpoints of a tableau in the clipped gauge.\n\nIf clip=true (the default) the tableau is converted to the clipped gauge in-place before calculating the bigram. Otherwise, the clip gauge conversion is skipped (for cases where the input is already known to be in the correct gauge).\n\nIntroduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in (Li et al., 2019) and (Gullans et al., 2021).\n\nSee also: canonicalize_clip!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.bitview","page":"API","title":"QuantumClifford.bitview","text":"A view of the classical bits stored with the state\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.canonicalize!-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.canonicalize!","text":"canonicalize!(\n state::QuantumClifford.AbstractStabilizer;\n phases,\n ranks\n) -> Union{Tuple{QuantumClifford.AbstractStabilizer, Int64, Int64}, QuantumClifford.AbstractStabilizer}\n\n\nCanonicalize a stabilizer (in place).\n\nAssumes the input is a valid stabilizer (all operators commute and have real phases). It permits redundant generators and identity generators.\n\njulia> ghz = S\"XXXX\n ZZII\n IZZI\n IIZZ\";\n\n\njulia> canonicalize!(ghz)\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> canonicalize!(S\"XXXX\n IZZI\n IIZZ\")\n+ XXXX\n+ _Z_Z\n+ __ZZ\n\nNot all rows in the tableau in the next example are independent:\n\njulia> canonicalize!(S\"XXXX\n ZZII\n IZZI\n IZIZ\n IIZZ\")\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n+ ____\n\nIn cases of lower rank, more advanced tableau structures might be better. For instance the MixedStabilizer or MixedDestabilizer structures (you can read more about them in the Data Structures section of the documentation).\n\nIf phases=false is set, the canonicalization does not track the phases in the tableau, leading to significant (constant factor) speedup.\n\njulia> s = S\"-ZX\n XZ\"\n- ZX\n+ XZ\n\njulia> canonicalize!(copy(s), phases=false)\n- XZ\n+ ZX\n\njulia> canonicalize!(copy(s))\n+ XZ\n- ZX\n\nIf ranks=true is set, the last pivot indices for the X and Z stage of the canonicalization are returned as well.\n\njulia> s = S\"XXXX\n ZZII\n IZIZ\n ZIIZ\";\n\n\njulia> _, ix, iz = canonicalize!(s, ranks=true); ix, iz\n(1, 3)\n\njulia> s\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ ____\n\nBased on (Garcia et al., 2012).\n\nSee also: canonicalize_rref!, canonicalize_gott!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_clip!-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.canonicalize_clip!","text":"canonicalize_clip!(\n state::QuantumClifford.AbstractStabilizer;\n phases\n) -> QuantumClifford.AbstractStabilizer\n\n\nFix the clipped gauge of a stabilizer (in place).\n\nAssumes the input is a valid full-rank stabilizer (all operators commute and have real phases).\n\njulia> s = S\"- X_ZX_X\n + XXYZ__\n - YZ_Z_X\n - XZX__Y\n + _Z_Y_Y\n - ____Z_\";\n\n\njulia> canonicalize_clip!(s)\n- X_XY__\n+ YZY___\n+ _XZX__\n- _ZYX_Z\n- __YZ_X\n- ____Z_\n\nIf phases=false is set, the canonicalization does not track the phases in the tableau, leading to a significant speedup.\n\nIntroduced in (Nahum et al., 2017), with a more detailed explanation of the algorithm in Appendix A of (Li et al., 2019)\n\nSee also: canonicalize!, canonicalize_rref!, canonicalize_gott!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_gott!-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.canonicalize_gott!","text":"Inplace Gottesman canonicalization of a tableau.\n\nThis uses different canonical form from canonicalize!. It is used in the computation of the logical X and Z operators of a MixedDestabilizer.\n\nIt returns the (in place) modified state, the indices of the last pivot of both Gaussian elimination steps, and the permutations that have been used to put the X and Z tableaux in standard form.\n\nBased on (Gottesman, 1997).\n\nSee also: canonicalize!, canonicalize_rref!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_rref!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.canonicalize_rref!","text":"canonicalize_rref!(\n state::QuantumClifford.AbstractStabilizer,\n colindices;\n phases\n) -> Tuple{QuantumClifford.AbstractStabilizer, Any}\n\n\nCanonicalize a stabilizer (in place) along only some columns.\n\nThis uses different canonical form from canonicalize!. It also indexes in reverse in order to make its use in traceout! more efficient. Its use in traceout! is its main application.\n\nIt returns the (in place) modified state and the index of the last pivot.\n\nBased on (Audenaert and Plenio, 2005).\n\nSee also: canonicalize!, canonicalize_gott!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.canonicalize_rref!-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.canonicalize_rref!","text":"canonicalize_rref!(\n state::QuantumClifford.AbstractStabilizer;\n phases\n) -> Tuple{QuantumClifford.AbstractStabilizer, Any}\n\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.centralizer-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.centralizer","text":"For a given set of Paulis (in the form of a Tableau), return the subset of Paulis that commute with all Paulis in set.\n\njulia> centralizer(T\"XX ZZ _Z\")\n+ ZZ\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.clifford_cardinality-Tuple{Int64}","page":"API","title":"QuantumClifford.clifford_cardinality","text":"The size of the Clifford group 𝒞 over a given number of qubits, possibly modulo the phases.\n\nFor n qubits, not accounting for phases is 2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1). There are 4ⁿ different phase configurations.\n\njulia> clifford_cardinality(7)\n457620995529680351512370381586432000\n\nWhen not accounting for phases (phases = false) the result is the same as the size of the Symplectic group Sp(2n) ≡ 𝒞ₙ/𝒫ₙ, where 𝒫ₙ is the Pauli group over n qubits.\n\njulia> clifford_cardinality(7, phases=false)\n27930968965434591767112450048000\n\nSee also: enumerate_cliffords.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.comm","page":"API","title":"QuantumClifford.comm","text":"Check whether two operators commute.\n\n0x0 if they commute, 0x1 if they anticommute.\n\njulia> P\"XX\"*P\"ZZ\", P\"ZZ\"*P\"XX\"\n(- YY, - YY)\n\njulia> comm(P\"ZZ\", P\"XX\")\n0x00\n\njulia> comm(P\"IZ\", P\"XX\")\n0x01\n\nSee also: comm!\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.comm!","page":"API","title":"QuantumClifford.comm!","text":"An in-place version of comm, storing its output in the given buffer.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.compactify_circuit-Tuple{Any}","page":"API","title":"QuantumClifford.compactify_circuit","text":"Convert a list of gates to a more optimized \"sum type\" format which permits faster dispatch.\n\nGenerally, this should be called on a circuit before it is used in a simulation.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.contractor-Tuple{Stabilizer, Any}","page":"API","title":"QuantumClifford.contractor","text":"Return the subset of Paulis in a Stabilizer that have identity operators on all qubits corresponding to the given subset, without the entries corresponding to subset.\n\njulia> contractor(S\"_X X_\", [1])\n+ X\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.delete_columns-Tuple{Stabilizer, Any}","page":"API","title":"QuantumClifford.delete_columns","text":"Return the given stabilizer without all the qubits in the given iterable.\n\nThe resulting tableaux is not guaranteed to be valid (to retain its commutation relationships).\n\njulia> delete_columns(S\"XYZ YZX ZXY\", [1,3])\n+ Y\n+ Z\n+ X\n\nSee also: traceout!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.destabilizerview-Tuple{Destabilizer}","page":"API","title":"QuantumClifford.destabilizerview","text":"A view of the subtableau corresponding to the destabilizer. See also tab, stabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_cliffords-Tuple{Any, Any}","page":"API","title":"QuantumClifford.enumerate_cliffords","text":"Give the i-th n-qubit Clifford operation, where i∈{1..2ⁿⁿΠⱼ₌₁ⁿ(4ʲ-1)}\n\nThe algorithm is detailed in (Koenig and Smolin, 2014).\n\nSee also: symplecticGS, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_cliffords-Tuple{Any}","page":"API","title":"QuantumClifford.enumerate_cliffords","text":"Give all n-qubit Clifford operations.\n\nThe algorithm is detailed in (Koenig and Smolin, 2014).\n\nSee also: symplecticGS, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_phases-Tuple{CliffordOperator}","page":"API","title":"QuantumClifford.enumerate_phases","text":"Given an operator, return all operators that have the same tableau but different phases.\n\njulia> length(collect(enumerate_phases(tCNOT)))\n16\n\nSee also: enumerate_cliffords, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_phases-Tuple{Union{Base.Generator, AbstractVector}}","page":"API","title":"QuantumClifford.enumerate_phases","text":"Given a set of operators, return all operators that have the same tableaux but different phases.\n\njulia> length(collect(enumerate_phases(enumerate_cliffords(2))))\n11520\n\nSee also: enumerate_cliffords, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_single_qubit_gates-Tuple{Any}","page":"API","title":"QuantumClifford.enumerate_single_qubit_gates","text":"Generate a symbolic single-qubit gate given its index. Optionally, set non-trivial phases.\n\njulia> enumerate_single_qubit_gates(6)\nsPhase on qubit 1\nX₁ ⟼ + Y\nZ₁ ⟼ + Z\n\njulia> enumerate_single_qubit_gates(6, qubit=2, phases=(true, true))\nSingleQubitOperator on qubit 2\nX₁ ⟼ - Y\nZ₁ ⟼ - Z\n\nSee also: enumerate_cliffords.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.fastcolumn","page":"API","title":"QuantumClifford.fastcolumn","text":"Convert a tableau to a memory layout that is fast for column operations.\n\nIn this layout a column of the tableau is stored (mostly) contiguously in memory. Due to bitpacking, e.g., packing 64 bits into a single UInt64, the memory layout is not perfectly contiguous, but it is still optimal given that some bitwrangling is required to extract a given bit.\n\nSee also: fastrow\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.fastrow","page":"API","title":"QuantumClifford.fastrow","text":"Convert a tableau to a memory layout that is fast for row operations.\n\nIn this layout a Pauli string (a row of the tableau) is stored contiguously in memory.\n\nSee also: fastrow\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.generate!-Tuple{PauliOperator, Stabilizer}","page":"API","title":"QuantumClifford.generate!","text":"Generate a Pauli operator by using operators from a given the Stabilizer.\n\nIt assumes the stabilizer is already canonicalized. It modifies the Pauli operator in place, generating it in reverse, up to a phase. That phase is left in the modified operator, which should be the identity up to a phase. Returns the new operator and the list of indices denoting the elements of stabilizer that were used for the generation.\n\njulia> ghz = S\"XXXX\n ZZII\n IZZI\n IIZZ\";\n\n\njulia> canonicalize!(ghz)\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> generate!(P\"-ZIZI\", ghz)\n(- ____, [2, 4])\n\nWhen the Pauli operator can not be generated by the given tableau, nothing is returned.\n\njulia> generate!(P\"XII\",canonicalize!(S\"ZII\")) === nothing\ntrue\n\njulia> generate!(P\"XII\",canonicalize!(S\"XII\")) === nothing\nfalse\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_H_to_G-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_H_to_G","text":"For a given F(2,2) parity check matrix, return the generator matrix.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_gausselim!-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_gausselim!","text":"Gaussian elimination over the binary field.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_invert-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_invert","text":"Invert a binary matrix.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_isinvertible-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_isinvertible","text":"Check whether a binary matrix is invertible.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.ghz","page":"API","title":"QuantumClifford.ghz","text":"Prepare a GHZ state of n qubits.\n\njulia> ghz()\n+ XXX\n+ ZZ_\n+ _ZZ\n\njulia> ghz(2)\n+ XX\n+ ZZ\n\njulia> ghz(4)\n+ XXXX\n+ ZZ__\n+ _ZZ_\n+ __ZZ\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.graph_gate-NTuple{4, Any}","page":"API","title":"QuantumClifford.graph_gate","text":"A helper function converting the gate indices from graphstate into a Clifford operator.\n\njulia> s = S\" XXX\n YZ_\n -_ZZ\";\n\n\njulia> graph, h_idx, ip_idx, z_idx = graphstate(s);\n\n\njulia> gate = graph_gate(h_idx, ip_idx, z_idx, nqubits(s));\n\n\njulia> apply!(s, gate) # This is now a graph state (notice you need to multiply row 1 by row 2)\n+ YYZ\n+ XZ_\n+ _ZX\n\njulia> canonicalize!(s) == canonicalize!(Stabilizer(graph))\ntrue\n\nSee also: graph_gatesequence\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.graph_gatesequence-Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}}","page":"API","title":"QuantumClifford.graph_gatesequence","text":"A helper function converting the gate indices from graphstate into a sequence of gates.\n\njulia> s = S\" XXX\n YZ_\n -_ZZ\";\n\n\njulia> graph, h_idx, ip_idx, z_idx = graphstate(s);\n\n\njulia> gates = graph_gatesequence(h_idx, ip_idx, z_idx);\n\n\njulia> for gate in vcat(gates...) apply!(s, gate) end\n\n\njulia> s # This is now a graph state (notice you need to multiply row 1 by row 2)\n+ YYZ\n+ XZ_\n+ _ZX\n\njulia> canonicalize!(s) == canonicalize!(Stabilizer(graph))\ntrue\n\nSee also: graph_gatesequence\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.graphstate!-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.graphstate!","text":"An in-place version of graphstate.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.graphstate-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.graphstate","text":"Convert any stabilizer state to a graph state\n\nGraph states are a special type of entangled stabilizer states that can be represented by a graph. For a graph G=(VE) the corresponding stabilizers are S_v = X_v prod_u N(v) Z_u. Notice that such tableau rows contain only a single X operator. There is a set of single qubit gates that converts any stabilizer state to a graph state.\n\nThis function returns the graph state corresponding to a stabilizer and the gates that might be necessary to convert the stabilizer into a state representable as a graph.\n\nFor a tableau stab you can convert it with:\n\ngraph, hadamard_idx, iphase_idx, flips_idx = graphstate()\n\nwhere graph is the graph representation of stab, and the rest specifies the single-qubit gates converting stab to graph: hadamard_idx are the qubits that require a Hadamard gate (mapping X ↔ Z), iphase_idx are (different) qubits that require an inverse Phase gate (Y → X), and flips_idx are the qubits that require a phase flip (Pauli Z gate), after the previous two sets of gates.\n\njulia> using Graphs\n\njulia> s = S\" XXX\n ZZ_\n -_ZZ\";\n\n\njulia> g, h_idx, ip_idx, z_idx = graphstate(s);\n\n\njulia> collect(edges(g))\n2-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:\n Edge 1 => 2\n Edge 1 => 3\n\njulia> h_idx\n2-element Vector{Int64}:\n 2\n 3\n\njulia> ip_idx\nInt64[]\n\njulia> z_idx\n1-element Vector{Int64}:\n 3\n\nThe Graphs.jl library provides many graph-theory tools and the MakieGraphs.jl library provides plotting utilities for graphs.\n\nYou can directly call the graph constructor on a stabilizer, if you just want the graph and do not care about the Clifford operation necessary to convert an arbitrary state to a state representable as a graph:\n\njulia> collect(edges( Graph(bell()) ))\n1-element Vector{Graphs.SimpleGraphs.SimpleEdge{Int64}}:\n Edge 1 => 2\n\nFor a version that does not copy the stabilizer, but rather performs transformations in-place, use graphstate!. It would perform canonicalize_gott! on its argument as it finds a way to convert it to a graph state.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.groupify-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.groupify","text":"Return the full stabilizer group represented by the input generating set (a Stabilizer).\n\nThe returned object is exponentially long.\n\njulia> groupify(S\"XZ ZX\")\n+ __\n+ XZ\n+ ZX\n+ YY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.logdot-Tuple{QuantumClifford.AbstractStabilizer, QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumClifford.logdot","text":"Logarithm of the inner product between to Stabilizer states.\n\nIf the result is nothing, the dot inner product is zero. Otherwise the inner product is 2^(-logdot/2).\n\nThe actual inner product can be computed with LinearAlgebra.dot.\n\nBased on (Garcia et al., 2012).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.logicalxview-Tuple{MixedDestabilizer}","page":"API","title":"QuantumClifford.logicalxview","text":"A view of the subtableau corresponding to the logical X operators. See also tab, stabilizerview, destabilizerview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.logicalzview-Tuple{MixedDestabilizer}","page":"API","title":"QuantumClifford.logicalzview","text":"A view of the subtableau corresponding to the logical Z operators. See also tab, stabilizerview, destabilizerview, logicalxview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.mctrajectories-Tuple{Any, Any}","page":"API","title":"QuantumClifford.mctrajectories","text":"Run multiple Monte Carlo trajectories and report the aggregate final statuses of each.\n\nSee also: pftrajectories, petrajectories\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.mctrajectory!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.mctrajectory!","text":"Run a single Monte Carlo sample, starting with (and modifying) state by applying the given circuit. Uses apply! under the hood.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.minimal_generating_set-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.minimal_generating_set","text":"For a not-necessarily-minimal generating set, return the minimal generating set.\n\nThe input has to have only real phases.\n\njulia> minimal_generating_set(S\"__ XZ ZX YY\")\n+ XZ\n+ ZX\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.normalizer-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.normalizer","text":"Return all Pauli operators with the same number of qubits as the given Tableau t that commute with all operators in t.\n\njulia> normalizer(T\"X\")\n+ _\n+ X\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pauligroup-Tuple{Int64}","page":"API","title":"QuantumClifford.pauligroup","text":"Return the full Pauli group of a given length. Phases are ignored by default, but can be included by setting phases=true.\n\njulia> pauligroup(1)\n+ _\n+ X\n+ Z\n+ Y\n\njulia> pauligroup(1, phases=true)\n+ _\n+ X\n+ Z\n+ Y\n- _\n- X\n- Z\n- Y\n+i_\n+iX\n+iZ\n+iY\n-i_\n-iX\n-iZ\n-iY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.petrajectories-Tuple{Any, Any}","page":"API","title":"QuantumClifford.petrajectories","text":"Run a perturbative expansion to a given order. This is the main public function for the perturbative expansion approach.\n\nSee also: pftrajectories, mctrajectories\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurements-Tuple{PauliFrame}","page":"API","title":"QuantumClifford.pfmeasurements","text":"pfmeasurements(frame::PauliFrame) -> Any\n\n\nReturns the measurement results for each frame in the PauliFrame instance.\n\nwarning: Relative measurements\nThe return measurements are relative to the reference measurements, i.e. they only say whether the reference measurements have been flipped in the given frame.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurements-Tuple{Register, PauliFrame}","page":"API","title":"QuantumClifford.pfmeasurements","text":"pfmeasurements(register::Register, frame::PauliFrame) -> Any\n\n\nTakes the references measurements from the given Register and applies the flips as prescribed by the PauliFrame relative measurements. The result is the actual (non-relative) measurement results for each frame.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurements-Tuple{Register}","page":"API","title":"QuantumClifford.pfmeasurements","text":"pfmeasurements(register::Register) -> Vector{Bool}\n\n\nReturns the measurements stored in the bits of the given Register.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pftrajectories","page":"API","title":"QuantumClifford.pftrajectories","text":"Perform a \"Pauli frame\" style simulation of a quantum circuit.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.pftrajectories-Tuple{Any}","page":"API","title":"QuantumClifford.pftrajectories","text":"pftrajectories(\n circuit;\n trajectories,\n threads\n) -> PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}, Matrix{Bool}}\n\n\nThe main method for running Pauli frame simulations of circuits. See the other methods for lower level access.\n\nMultithreading is enabled by default, but can be disabled by setting threads=false. Do not forget to launch Julia with multiple threads enabled, e.g. julia -t4, if you want to use multithreading.\n\nSee also: mctrajectories, petrajectories\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pftrajectories-Tuple{PauliFrame, Any}","page":"API","title":"QuantumClifford.pftrajectories","text":"pftrajectories(state::PauliFrame, circuit) -> PauliFrame\n\n\nEvolve each frame stored in PauliFrame by the given circuit.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pftrajectories-Tuple{Register, Any}","page":"API","title":"QuantumClifford.pftrajectories","text":"pftrajectories(\n register::Register,\n circuit;\n trajectories\n) -> Tuple{Register, PauliFrame{Stabilizer{QuantumClifford.Tableau{Vector{UInt8}, LinearAlgebra.Adjoint{UInt64, Matrix{UInt64}}}}, Matrix{Bool}}}\n\n\nFor a given Register and circuit, simulates the reference circuit acting on the register and then also simulate numerous PauliFrame trajectories. Returns the register and the PauliFrame instance.\n\nUse pfmeasurements to get the measurement results.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.phases-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.phases","text":"The phases of a given tableau. It is a view, i.e. if you modify this array, the original tableau caries these changes.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.prodphase-Union{Tuple{T}, Tuple{AbstractVector{T}, AbstractVector{T}}} where T<:Unsigned","page":"API","title":"QuantumClifford.prodphase","text":"Get the phase of the product of two Pauli operators.\n\nPhase is encoded as F(4) in the low qubits of an UInt8.\n\njulia> P\"ZZZ\"*P\"XXX\"\n-iYYY\n\njulia> prodphase(P\"ZZZ\", P\"XXX\")\n0x03\n\njulia> prodphase(P\"XXX\", P\"ZZZ\")\n0x01\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectXrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectXrand!","text":"projectXrand!(state, qubit) -> Tuple{Register, UInt8}\n\n\nProject qubit of state along the X axis and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectX!, projectZrand!, projectYrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectYrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectYrand!","text":"projectYrand!(state, qubit) -> Tuple{Register, UInt8}\n\n\nProject qubit of state along the Y axis and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectY!, projectXrand!, projectZrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectZrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectZrand!","text":"projectZrand!(state, qubit) -> Tuple{Register, UInt8}\n\n\nProject qubit of state along the Z axis and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectZ!, projectXrand!, projectYrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectrand!-Tuple{Any, Any}","page":"API","title":"QuantumClifford.projectrand!","text":"projectrand!(state, pauli) -> Tuple{Register, Any}\n\n\nMeasure pauli operator on state and randomize the phase if necessary.\n\nLower boilerplate version of project!.\n\nSee also: project!, projectXrand!, projectZrand!, projectYrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.puttableau!-Union{Tuple{M2}, Tuple{M1}, Tuple{T}, Tuple{V2}, Tuple{V1}, Tuple{B}, Tuple{QuantumClifford.Tableau{V1, M1}, QuantumClifford.Tableau{V2, M2}, Int64, Int64}} where {B, V1, V2, T<:Unsigned, M1<:AbstractMatrix{T}, M2<:AbstractMatrix{T}}","page":"API","title":"QuantumClifford.puttableau!","text":"Put source tableau in target tableau at given row and column. Assumes target location is zeroed out.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.quantumstate","page":"API","title":"QuantumClifford.quantumstate","text":"Only the quantum part of the state (excluding classical bits)\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.random_all_to_all_clifford_circuit-Tuple{Random.AbstractRNG, Int64, Int64}","page":"API","title":"QuantumClifford.random_all_to_all_clifford_circuit","text":"Random all-to-all Clifford circuit.\n\nThe circuit contains nqubits qubits and ngates gates. The connectivity is all to all. Each gate in the circuit is a random 2-qubit Clifford gate on randomly picked two qubits.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_brickwork_clifford_circuit-Tuple{Random.AbstractRNG, NTuple{N, Int64} where N, Int64}","page":"API","title":"QuantumClifford.random_brickwork_clifford_circuit","text":"Random brickwork Clifford circuit.\n\nThe connectivity of the random circuit is brickwork in some dimensions. Each gate in the circuit is a random 2-qubit Clifford gate.\n\nThe brickwork is defined as follows: The qubits are arranged as a lattice, and lattice_size contains side length in each dimension. For example, a chain of length five will have lattice_size = (5,), and a 5×5 lattice will have lattice_size = (5, 5).\n\nIn multi-dimensional cases, gate layers act alternatively along each direction. The nearest two layers along the same direction are offset by one qubit, forming a so-called brickwork. The boundary condition is chosen as open.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_clifford-Tuple{Random.AbstractRNG, Int64}","page":"API","title":"QuantumClifford.random_clifford","text":"A random Clifford operator generated by the Bravyi-Maslov Algorithm 2 from (Bravyi and Maslov, 2021).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_clifford1-Tuple{Random.AbstractRNG, Any}","page":"API","title":"QuantumClifford.random_clifford1","text":"Random symbolic single-qubit Clifford applied to qubit at index qubit.\n\nSee also: SingleQubitOperator, random_clifford\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_destabilizer-Tuple{Random.AbstractRNG, Int64}","page":"API","title":"QuantumClifford.random_destabilizer","text":"A random Stabilizer/Destabilizer tableau generated by the Bravyi-Maslov Algorithm 2 from (Bravyi and Maslov, 2021).\n\nrandom_destabilizer(n) gives a n-qubit tableau of rank n. random_destabilizer(r,n) gives a n-qubit tableau of rank r.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.random_pauli","page":"API","title":"QuantumClifford.random_pauli","text":"A random Pauli operator on n qubits.\n\nUse nophase=false to randomize the phase. Use realphase=false to get operators with phases including ±i.\n\nOptionally, a \"flip\" probability p can be provided specified, in which case each bit is set to I with probability 1-p and to X or Y or Z with probability p. Useful for simulating unbiased Pauli noise.\n\nSee also random_pauli!\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.random_pauli!","page":"API","title":"QuantumClifford.random_pauli!","text":"An in-place version of random_pauli\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.random_stabilizer-Tuple{Random.AbstractRNG, Int64}","page":"API","title":"QuantumClifford.random_stabilizer","text":"A random Stabilizer tableau generated by the Bravyi-Maslov Algorithm 2 from (Bravyi and Maslov, 2021).\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.single_x-Tuple{Any, Any}","page":"API","title":"QuantumClifford.single_x","text":"A multiqubit operator corresponding to all identities except for Pauli X at i. See also: sX, sMX\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.single_y-Tuple{Any, Any}","page":"API","title":"QuantumClifford.single_y","text":"A multiqubit operator corresponding to all identities except for Pauli Y at i. See also: sY, sMY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.single_z-Tuple{Any, Any}","page":"API","title":"QuantumClifford.single_z","text":"A multiqubit operator corresponding to all identities except for Pauli Z at i. See also: sY, sMY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.stab_to_gf2-Tuple{QuantumClifford.Tableau}","page":"API","title":"QuantumClifford.stab_to_gf2","text":"The F(2,2) matrix of a given tableau, represented as the concatenation of two binary matrices, one for X and one for Z.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.stabilizerplot","page":"API","title":"QuantumClifford.stabilizerplot","text":"A Makie.jl recipe for pictorial representation of a tableau.\n\nRequires a Makie.jl backend to be loaded, e.g. using CairoMakie.\n\nAlternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S\"XXX ZZZ\").\n\nConsult the documentation for more details on visualization options.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.stabilizerplot_axis","page":"API","title":"QuantumClifford.stabilizerplot_axis","text":"A Makie.jl recipe for pictorial representation of a tableau.\n\nRequires a Makie.jl backend to be loaded, e.g. using CairoMakie.\n\nAlternatively, you can use the Plots.jl plotting ecosystem, e.g. using Plots; plot(S\"XXX ZZZ\").\n\nConsult the documentation for more details on visualization options.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.stabilizerview-Tuple{Stabilizer}","page":"API","title":"QuantumClifford.stabilizerview","text":"A view of the subtableau corresponding to the stabilizer. See also tab, destabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.symplecticGS-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.symplecticGS","text":"Perform the Symplectic Gram-Schmidt procedure that gives a Clifford operator canonically related to a given Pauli operator.\n\nThe algorithm is detailed in (Koenig and Smolin, 2014).\n\njulia> symplecticGS(P\"X\", padded_n=3)\nX₁ ⟼ + X__\nX₂ ⟼ + _X_\nX₃ ⟼ + __X\nZ₁ ⟼ + Z__\nZ₂ ⟼ + _Z_\nZ₃ ⟼ + __Z\n\njulia> symplecticGS(P\"Z\")\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\nSee also: enumerate_cliffords, clifford_cardinality.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.tab-Union{Tuple{Stabilizer{T}}, Tuple{T}} where T","page":"API","title":"QuantumClifford.tab","text":"Extract the underlying tableau structure.\n\njulia> s = S\"X\"\n+ X\n\njulia> tab(s)\n+ X\n\njulia> tab(Destabilizer(s))\n+ Z\n+ X\n\njulia> tab(MixedDestabilizer(s))\n+ Z\n+ X\n\njulia> tab(tHadamard)\n+ Z\n+ X\n\njulia> typeof(tab(tHadamard))\nQuantumClifford.Tableau{Vector{UInt8}, Matrix{UInt64}}\n\nSee also: stabilizerview, destabilizerview, logicalxview, logicalzview\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.xbit-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.xbit","text":"Extract as a new bit array the X part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.xview-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.xview","text":"Get a view of the X part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.zbit-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.zbit","text":"Extract as a new bit array the Z part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.zview-Tuple{PauliOperator}","page":"API","title":"QuantumClifford.zview","text":"Get a view of the Y part of the UInt array of packed qubits of a given Pauli operator.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.apply!","page":"API","title":"QuantumInterface.apply!","text":"In QuantumClifford the apply! function is used to apply any quantum operation to a stabilizer state, including unitary Clifford operations, Pauli measurements, and noise. Thus, this function may result in a random/stochastic result (e.g. with measurements or noise).\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumInterface.embed-Tuple{Int64, Int64, PauliOperator}","page":"API","title":"QuantumInterface.embed","text":"Embed a Pauli operator in a larger Pauli operator.\n\njulia> embed(5, 3, P\"-Y\")\n- __Y__\n\njulia> embed(5, (3,5), P\"-YX\")\n- __Y_X\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.entanglement_entropy","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy of a subsystem\n\nDefined as entropy of the reduced density matrix.\n\nIt can be calculated with multiple different algorithms, the most performant one depending on the particular case.\n\nCurrently implemented are the :clip (clipped gauge), :graph (graph state), and :rref (Gaussian elimination) algorithms. Benchmark your particular case to choose the best one.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumInterface.entanglement_entropy-Tuple{QuantumClifford.AbstractStabilizer, AbstractVector, Val{:graph}}","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy by first converting the state to a graph and computing the rank of the adjacency matrix.\n\nBased on \"Entanglement in graph states and its applications\".\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.entanglement_entropy-Tuple{QuantumClifford.AbstractStabilizer, AbstractVector, Val{:rref}}","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy by converting to RREF form (i.e., partial trace form).\n\nThe state will be partially canonicalized in an RREF form.\n\nSee also: canonicalize_rref!, traceout!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.entanglement_entropy-Tuple{QuantumClifford.AbstractStabilizer, UnitRange, Val{:clip}}","page":"API","title":"QuantumInterface.entanglement_entropy","text":"Get bipartite entanglement entropy of a contiguous subsystem by passing through the clipped gauge.\n\nIf clip=false is set the canonicalization step is skipped, useful if the input state is already in the clipped gauge.\n\nSee also: bigram, canonicalize_clip!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.expect-Tuple{PauliOperator, QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumInterface.expect","text":"expect(p::PauliOperator, st::AbstractStabilizer)\n\nCompute the expectation value of a Pauli operator p on a stabilizer state st. This function will allocate a temporary copy of the stabilizer state st.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.nqubits-Tuple{QuantumClifford.AbstractStabilizer}","page":"API","title":"QuantumInterface.nqubits","text":"The number of qubits of a given state.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.project!-Tuple{Any, PauliOperator}","page":"API","title":"QuantumInterface.project!","text":"project!(\n state,\n pauli::PauliOperator;\n keep_result,\n phases\n) -> Tuple{MixedStabilizer, Any, Any}\n\n\nProject the state of a Stabilizer on the two eigenspaces of a Pauli operator.\n\nAssumes the input is a valid stabilizer. The projection is done inplace on that stabilizer and it does not modify the projection operator.\n\nIt returns\n\na stabilizer that might not be in canonical form\nthe index of the row where the non-commuting operator was (that row is now equal to pauli; its phase is not updated and for a faithful measurement simulation it needs to be randomized by the user)\nand the result of the projection if there was no non-commuting operator (nothing otherwise)\n\nIf keep_result==false that result of the projection in case of anticommutation is not computed, sparing a canonicalization operation. This canonicalization operation is the only one potentially of cubic complexity. The rest of the calculations are of quadratic complexity.\n\nIf you need to measure a single qubit instead of a multiqubit Pauli operator, the faster projectX!, projectY!, and projectZ! are available.\n\nFor less boilerplate and automatic randomization of the phase use projectrand!.\n\nHere is an example of a projection destroying entanglement:\n\njulia> ghz = S\"XXXX\n ZZII\n IZZI\n IIZZ\";\n\n\njulia> canonicalize!(ghz)\n+ XXXX\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> state, anticom_index, result = project!(ghz, P\"ZIII\");\n\n\njulia> state\n+ Z___\n+ Z__Z\n+ _Z_Z\n+ __ZZ\n\njulia> canonicalize!(state)\n+ Z___\n+ _Z__\n+ __Z_\n+ ___Z\n\njulia> anticom_index, result\n(1, nothing)\n\nAnd an example of projection consistent with the stabilizer state.\n\njulia> s = S\"ZII\n IXI\n IIY\";\n\n\njulia> canonicalize!(s)\n+ _X_\n+ __Y\n+ Z__\n\njulia> state, anticom_index, result = project!(s, P\"-ZII\");\n\n\njulia> state\n+ _X_\n+ __Y\n+ Z__\n\njulia> anticom_index, result\n(0, 0x02)\n\nWhile not the best choice, Stabilizer can be used for mixed states, simply by providing an incomplete tableau. In that case it is possible to attempt to project on an operator that can not be generated by the provided stabilizer operators. In that case we have anticom_index==rank and result===nothing, where rank is the the new rank of the tableau, one more than the number of rows in the initial tableau. However, if keep_result was set to false, then anticom_index would stay at zero.\n\njulia> s = S\"XZI\n IZI\";\n\n\njulia> project!(s, P\"IIX\")[1]\n+ X__\n+ _Z_\n\nIf we had used MixedStabilizer we would have added the projector to the list of stabilizers.\n\njulia> s = one(MixedStabilizer, 2, 3)\n+ Z__\n+ _Z_\n\njulia> project!(s, P\"IIX\")[1]\n+ Z__\n+ _Z_\n+ __X\n\nHowever, MixedDestabilizer would be an even better choice as it has mathcalO(n^2) complexity instead of the mathcalO(n^3) complexity of *Stabilizer.\n\njulia> s = one(MixedDestabilizer, 2, 3)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ X__\n+ _X_\n𝒳ₗ━━━\n+ __X\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ _Z_\n𝒵ₗ━━━\n+ __Z\n\njulia> project!(s, P\"IIX\")[1]\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ X__\n+ _X_\n+ __Z\n𝒮𝓉𝒶𝒷━\n+ Z__\n+ _Z_\n+ __X\n\nSee the \"Datastructure Choice\" section in the documentation for more details.\n\nSee also: projectX!, projectY!, projectZ!, projectrand!\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.project!-Tuple{MixedStabilizer, PauliOperator}","page":"API","title":"QuantumInterface.project!","text":"project!(\n state::MixedStabilizer,\n pauli::PauliOperator;\n phases\n) -> Tuple{MixedStabilizer, Any, Any}\n\n\nWhen using project! on MixedStabilizer it automates some of the extra steps we encounter when implicitly using the Stabilizer datastructure to represent mixed states. Namely, it helps when the projector is not among the list of stabilizers:\n\njulia> s = S\"XZI\n IZI\";\n\n\njulia> ms = MixedStabilizer(s)\n+ X__\n+ _Z_\n\njulia> project!(ms, P\"IIY\")[1]\n+ X__\n+ _Z_\n+ __Y\n\nSimilarly to project! on Stabilizer, this function has cubic complexity when the Pauli operator commutes with all rows of the tableau. Most of the time it is better to simply use MixedDestabilizer representation.\n\nUnlike other project! methods, this one does not allow for keep_result=false, as the correct rank or anticommutation index can not be calculated without the expensive (cubic) canonicalization operation required by keep_result=true.\n\nSee the \"Datastructure Choice\" section in the documentation for more details.\n\nSee also: projectX!, projectY!, projectZ!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.projectX!-Tuple{MixedDestabilizer, Int64}","page":"API","title":"QuantumInterface.projectX!","text":"Measure a given qubit in the X basis. A faster special-case version of project!.\n\nSee also: project!, projectXrand!, projectY!, projectZ!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.projectY!-Tuple{MixedDestabilizer, Int64}","page":"API","title":"QuantumInterface.projectY!","text":"Measure a given qubit in the Y basis. A faster special-case version of project!.\n\nSee also: project!, projectYrand!, projectX!, projectZ!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.projectZ!-Tuple{MixedDestabilizer, Int64}","page":"API","title":"QuantumInterface.projectZ!","text":"Measure a given qubit in the Z basis. A faster special-case version of project!.\n\nSee also: project!, projectZrand!, projectY!, projectX!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.reset_qubits!-Tuple{MixedDestabilizer, QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumInterface.reset_qubits!","text":"reset_qubits!(\n s::MixedDestabilizer,\n newstate::QuantumClifford.AbstractStabilizer,\n qubits;\n phases\n) -> MixedDestabilizer\n\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.reset_qubits!-Tuple{MixedStabilizer, Any, Any}","page":"API","title":"QuantumInterface.reset_qubits!","text":"reset_qubits!(\n s::MixedStabilizer,\n newstate,\n qubits;\n phases\n) -> MixedStabilizer\n\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.reset_qubits!-Tuple{Stabilizer, Any, Any}","page":"API","title":"QuantumInterface.reset_qubits!","text":"reset_qubits!(\n s::Stabilizer,\n newstate,\n qubits;\n phases\n) -> Union{PauliOperator, Stabilizer}\n\n\nReset a given set of qubits to be in the state newstate. These qubits are traced out first, which could lead to \"nonlocal\" changes in the tableau.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.tensor","page":"API","title":"QuantumInterface.tensor","text":"Tensor product between operators or tableaux. \n\nTensor product between CiffordOperators:\n\njulia> tensor(CliffordOperator(sCNOT), CliffordOperator(sCNOT))\nX₁ ⟼ + XX__\nX₂ ⟼ + _X__\nX₃ ⟼ + __XX\nX₄ ⟼ + ___X\nZ₁ ⟼ + Z___\nZ₂ ⟼ + ZZ__\nZ₃ ⟼ + __Z_\nZ₄ ⟼ + __ZZ\n\nTensor product between PauliOperators:\n\njulia> tensor(P\"-IXYZ\", P\"iIXYZ\")\n-i_XYZ_XYZ\n\nTensor product between Tableaux:\n\njulia> s = S\"-XX\n +ZZ\";\n\njulia> tensor(s, s, s)\n- XX____\n+ ZZ____\n- __XX__\n+ __ZZ__\n- ____XX\n+ ____ZZ\n\njulia> s = S\"+XZI\n -IZI\";\n\njulia> tensor(s, s)\n+ XZ____\n- _Z____\n+ ___XZ_\n- ____Z_\n\nSee also tensor_pow.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumInterface.tensor_pow-Tuple{Union{QuantumClifford.AbstractCliffordOperator, QuantumClifford.AbstractStabilizer}, Any}","page":"API","title":"QuantumInterface.tensor_pow","text":"Repeated tensor product of an operators or a tableau.\n\nFor CliffordOperator:\n\njulia> tensor_pow(CliffordOperator(sHadamard), 3)\nX₁ ⟼ + Z__\nX₂ ⟼ + _Z_\nX₃ ⟼ + __Z\nZ₁ ⟼ + X__\nZ₂ ⟼ + _X_\nZ₃ ⟼ + __X\n\nFor PauliOperator:\n\njulia> tensor_pow(P\"IXYZ\", 2)\n+ _XYZ_XYZ\n\nFor Tableaux:\n\njulia> tensor_pow(S\"Z\", 4)\n+ Z___\n+ _Z__\n+ __Z_\n+ ___Z\n\njulia> s = S\"+XZI\n +IZI\";\n\njulia> tensor_pow(s, 3)\n+ XZ_______\n+ _Z_______\n+ ___XZ____\n+ ____Z____\n+ ______XZ_\n+ _______Z_\n\nSee also tensor.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.traceout!-Tuple{Stabilizer, Any}","page":"API","title":"QuantumInterface.traceout!","text":"traceout!(\n s::Stabilizer,\n qubits;\n phases,\n rank\n) -> Union{Tuple{Stabilizer, Any}, Stabilizer}\n\n\nTrace out a qubit.\n\nSee also: delete_columns\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumInterface.traceout!-Tuple{Union{MixedDestabilizer, MixedStabilizer}, Any}","page":"API","title":"QuantumInterface.traceout!","text":"traceout!(\n s::Union{MixedDestabilizer, MixedStabilizer},\n qubits;\n phases,\n rank\n) -> Union{Tuple{Union{MixedDestabilizer, MixedStabilizer}, Any}, MixedDestabilizer, MixedStabilizer}\n\n\n\n\n\n\n","category":"method"},{"location":"API/#Private-API","page":"API","title":"Private API","text":"","category":"section"},{"location":"API/","page":"API","title":"API","text":"danger: Private Implementation Details\nThese functions are used internally by the library and might be drastically modified or deleted without warning or deprecation.","category":"page"},{"location":"API/","page":"API","title":"API","text":"Modules = [QuantumClifford]\nPrivate = true\nPublic = false","category":"page"},{"location":"API/#QuantumClifford.AbstractMeasurement","page":"API","title":"QuantumClifford.AbstractMeasurement","text":"Supertype of all symbolic single-qubit measurements.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.SymbolicDataType","page":"API","title":"QuantumClifford.SymbolicDataType","text":"An intermediary when we want to create a new concrete type in a macro.\n\n\n\n\n\n","category":"type"},{"location":"API/#QuantumClifford.Tableau","page":"API","title":"QuantumClifford.Tableau","text":"Internal Tableau type for storing a list of Pauli operators in a compact form. No special semantic meaning is attached to this type, it is just a convenient way to store a list of Pauli operators. E.g. it is not used to represent a stabilizer state, or a stabilizer group, or a Clifford circuit.\n\n\n\n\n\n","category":"type"},{"location":"API/#Base.hcat-Tuple{Vararg{QuantumClifford.Tableau}}","page":"API","title":"Base.hcat","text":"Horizontally concatenates tableaux.\n\njulia> hcat(ghz(2), ghz(2))\n+ XXXX\n+ ZZZZ\n\nSee also: vcat\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.inv-Tuple{CliffordOperator}","page":"API","title":"Base.inv","text":"inv(\n c::CliffordOperator;\n phases\n) -> CliffordOperator{QuantumClifford.Tableau{Vector{UInt8}, Matrix{UInt64}}}\n\n\nInverse of a CliffordOperator\n\njulia> inv(CliffordOperator(sCNOT))\nX₁ ⟼ + XX\nX₂ ⟼ + _X\nZ₁ ⟼ + Z_\nZ₂ ⟼ + ZZ\n\njulia> inv(CliffordOperator(sCNOT(2, 1), 2))\nX₁ ⟼ + X_\nX₂ ⟼ + XX\nZ₁ ⟼ + ZZ\nZ₂ ⟼ + _Z\n\njulia> inv(CliffordOperator(tHadamard))\nX₁ ⟼ + Z\nZ₁ ⟼ + X\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.permute!-Tuple{QuantumClifford.AbstractStabilizer, AbstractVector}","page":"API","title":"Base.permute!","text":"Permute the qubits (i.e., columns) of the state in place.\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.permute!-Tuple{QuantumClifford.Tableau, AbstractVector}","page":"API","title":"Base.permute!","text":"Permute the qubits (i.e., columns) of the tableau in place.\n\n\n\n\n\n","category":"method"},{"location":"API/#Base.vcat-Tuple{Vararg{QuantumClifford.Tableau}}","page":"API","title":"Base.vcat","text":"Vertically concatenates tableaux.\n\njulia> vcat(ghz(2), ghz(2))\n+ XX\n+ ZZ\n+ XX\n+ ZZ\n\nSee also: hcat\n\n\n\n\n\n","category":"method"},{"location":"API/#LinearAlgebra.dot-Tuple{QuantumClifford.AbstractStabilizer, QuantumClifford.AbstractStabilizer}","page":"API","title":"LinearAlgebra.dot","text":"The inner product of two Stabilizers.\n\nBased on (Garcia et al., 2012).\n\njulia> using LinearAlgebra\n\njulia> dot(S\"Z\", S\"Z\")\n1.0\n\njulia> dot(S\"Z\", S\"Y\")\n0.7071067811865476\n\nSee also: logdot\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._apply_nonthread!-Tuple{QuantumClifford.AbstractStabilizer, CliffordOperator, AbstractVector{Int64}}","page":"API","title":"QuantumClifford._apply_nonthread!","text":"Nonvectorized version of apply! used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._apply_nonthread!-Tuple{QuantumClifford.AbstractStabilizer, CliffordOperator}","page":"API","title":"QuantumClifford._apply_nonthread!","text":"Nonvectorized version of apply! used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._mul_left_nonvec!-Union{Tuple{T}, Tuple{AbstractVector{T}, AbstractVector{T}}} where T<:Unsigned","page":"API","title":"QuantumClifford._mul_left_nonvec!","text":"Nonvectorized version of mul_left! used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._remove_rowcol!-Tuple{MixedDestabilizer, Any, Any}","page":"API","title":"QuantumClifford._remove_rowcol!","text":"Unexported low-level function that removes a row (by shifting all rows up as necessary)\n\nBecause MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.\n\nUsed on its own, this function will break invariants. Meant to be used with projectremove!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._rowmove!-Union{Tuple{B}, Tuple{QuantumClifford.Tableau, Any, Any}} where B","page":"API","title":"QuantumClifford._rowmove!","text":"Unexported low-level function that moves row i to row j.\n\nUsed on its own, this function will break invariants. Meant to be used in _remove_rowcol!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford._stim_prodphase-Union{Tuple{T}, Tuple{AbstractVector{T}, AbstractVector{T}}} where T<:Unsigned","page":"API","title":"QuantumClifford._stim_prodphase","text":"The quantumlib/Stim implementation, which performs the prodphase and mul_left! together. Used for unit tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.apply_single_x!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.apply_single_x!","text":"Apply a Pauli X to the i-th qubit of state s. You should use apply!(stab,sX(i)) instead of this.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.apply_single_y!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.apply_single_y!","text":"Apply a Pauli Y to the i-th qubit of state s. You should use apply!(stab,sY(i)) instead of this.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.apply_single_z!-Tuple{QuantumClifford.AbstractStabilizer, Any}","page":"API","title":"QuantumClifford.apply_single_z!","text":"Apply a Pauli Z to the i-th qubit of state s. You should use apply!(stab,sZ(i)) instead of this.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.applynoise_branches","page":"API","title":"QuantumClifford.applynoise_branches","text":"Compute all possible new states after the application of the given noise model. Reports the probability of each one of them. Deterministic (as it reports all branches of potentially random processes), part of the Noise interface.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.colswap!-Tuple{QuantumClifford.Tableau, Any, Any}","page":"API","title":"QuantumClifford.colswap!","text":"Swap two columns of a stabilizer in place.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.destab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.destab_looks_good","text":"Check basic consistency requirements of a destabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.enumerate_cliffords_slow-Tuple{Any, Any}","page":"API","title":"QuantumClifford.enumerate_cliffords_slow","text":"The O(n^4) implementation from (Koenig and Smolin, 2014) – their algorithm seems wrong as ⟨w'₁|wₗ⟩=bₗ which is not always zero.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.fill_tril-Tuple{Any, Any, Any}","page":"API","title":"QuantumClifford.fill_tril","text":"Assign (symmetric) random ints to off diagonals of matrix.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.get_all_subtypes-Tuple{Any}","page":"API","title":"QuantumClifford.get_all_subtypes","text":"Returns a tuple of all concrete subtypes and all UnionAll non-abstract subtypes of a given type.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.gf2_H_standard_form_indices-Tuple{Any}","page":"API","title":"QuantumClifford.gf2_H_standard_form_indices","text":"The permutation of columns which turns a binary matrix into standard form. It is assumed the matrix has already undergone Gaussian elimination.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.initZ!-Tuple{PauliFrame}","page":"API","title":"QuantumClifford.initZ!","text":"initZ!(frame::PauliFrame) -> PauliFrame\n\n\nInject random Z errors over all frames and qubits for the supplied PauliFrame with probability 0.5.\n\nCalling this after initialization is essential for simulating any non-deterministic circuit. It is done automatically by most PauliFrame constructors.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_sumtype-Tuple{Any}","page":"API","title":"QuantumClifford.make_sumtype","text":"julia> make_sumtype([sCNOT])\nquote\n @sum_type CompactifiedGate :hidden begin\n sCNOT(::Int64, ::Int64)\n end\nend\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_sumtype_method","page":"API","title":"QuantumClifford.make_sumtype_method","text":"``` julia> makesumtypemethod([sCNOT], :apply!, (:s,)) quote function QuantumClifford.apply!(s, g::CompactifiedGate) @cases g begin sCNOT(q1, q2) => apply!(s, sCNOT(q1, q2)) end end end\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.make_sumtype_variant_constructor-Tuple{Any}","page":"API","title":"QuantumClifford.make_sumtype_variant_constructor","text":"julia> make_sumtype_variant_constructor(sCNOT)\n:(CompactifiedGate(g::sCNOT) = begin\n (CompactifiedGate').sCNOT(g.q1, g.q2)\nend)\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_variant-Tuple{Union{DataType, QuantumClifford.SymbolicDataType}}","page":"API","title":"QuantumClifford.make_variant","text":"julia> make_variant(sCNOT)\n:(sCNOT(::Int64, ::Int64))\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.make_variant_deconstruct","page":"API","title":"QuantumClifford.make_variant_deconstruct","text":"julia> make_variant_deconstruct(sCNOT, :apply!, (:s,))\n:(sCNOT(q1, q2) => apply!(s, sCNOT(q1, q2)))\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.mixed_destab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.mixed_destab_looks_good","text":"Check basic consistency requirements of a mixed destabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.mixed_stab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.mixed_stab_looks_good","text":"Check basic consistency requirements of a mixed stabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.pfmeasurement","page":"API","title":"QuantumClifford.pfmeasurement","text":"For a given simulated state, e.g. a PauliFrame instance, returns the measurement results.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.precise_inv-Tuple{Any}","page":"API","title":"QuantumClifford.precise_inv","text":"Inverting a binary matrix: uses floating point for small matrices and Nemo for large matrices.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.project_cond!-Union{Tuple{PHASES}, Tuple{RESET}, Tuple{IS}, Tuple{MixedDestabilizer, Int64, Val{IS}, Val{RESET}}} where {IS, RESET, PHASES}","page":"API","title":"QuantumClifford.project_cond!","text":"Internal method used to implement projectX!, projectZ!, and projectY!.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.projectremoverand!-Union{Tuple{F}, Tuple{MixedDestabilizer, F, Any}} where F<:Union{typeof(projectX!), typeof(projectY!), typeof(projectZ!)}","page":"API","title":"QuantumClifford.projectremoverand!","text":"Unexported low-level function that projects a qubit and returns the result while making the tableau smaller by a qubit.\n\nBecause MixedDestabilizer is not mutable we return a new MixedDestabilizer with the same (modified) xzs array.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.quantum_mallows-Tuple{Any, Any}","page":"API","title":"QuantumClifford.quantum_mallows","text":"Sample (h, S) from the distribution P_n(h, S) from Bravyi and Maslov Algorithm 1.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.remove_column!-Union{Tuple{M}, Tuple{T}, Tuple{V}, Tuple{QuantumClifford.Tableau{V, M}, Int64}} where {V, T<:Unsigned, M<:AbstractMatrix{T}}","page":"API","title":"QuantumClifford.remove_column!","text":"Unexported low-level function that removes a column (by shifting all columns to the right of the target by one step to the left)\n\nBecause Tableau is not mutable we return a new Tableau with the same (modified) xzs array.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.rowdecompose-Tuple{Any, Union{Destabilizer, MixedDestabilizer}}","page":"API","title":"QuantumClifford.rowdecompose","text":"Decompose a Pauli P in terms of stabilizer and destabilizer rows from a given tableaux.\n\nFor given tableaux of rows destabilizer rows d_i and stabilizer rows s_i, there are boolean vectors b and c such that P = i^p prod_i d_i^b_i prod_i s_i^c_i.\n\nThis function returns p, b, c.\n\njulia> s = MixedDestabilizer(ghz(2))\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z_\n+ _X\n𝒮𝓉𝒶𝒷\n+ XX\n+ ZZ\n\njulia> phase, destab_rows, stab_rows = QuantumClifford.rowdecompose(P\"XY\", s)\n(3, Bool[1, 0], Bool[1, 1])\n\njulia> im^3 * P\"Z_\" * P\"XX\" * P\"ZZ\"\n+ XY\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.sample_geometric_2-Tuple{Any, Integer}","page":"API","title":"QuantumClifford.sample_geometric_2","text":"This function samples a number from 1 to n where n >= 1 probability of outputting i is proportional to 2^i\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.stab_looks_good-Tuple{Any}","page":"API","title":"QuantumClifford.stab_looks_good","text":"Check basic consistency requirements of a stabilizer. Used in tests.\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.to_cpu","page":"API","title":"QuantumClifford.to_cpu","text":"copies the memory content of the object to CPU\n\nYou can only use this function if CUDA.jl is imported\n\nFor more advanced users to_cpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your CPU architecture, if working with matrices of UInt32 is faster than UInt64, you can use to_cpu(data, UInt32)\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> stab = S\"- X_Z\\n+ _ZZ\\n+ __Z\"\n- X_Z\n+ _ZZ\n+ __Z\n\njulia> stab_gpu = to_gpu(stab);\n\njulia> apply!(stab_gpu, sHadamard(1));\n\njulia> stab_result_cpu = to_cpu(stab_gpu)\n- Z_Z\n+ _ZZ\n+ __Z\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> pf_gpu = to_gpu(PauliFrame(1000, 2, 2));\njulia> circuit = [sMZ(1, 1), sHadamard(2), sMZ(2, 2)];\njulia> pftrajectories(pf_gpu, circuit);\njulia> measurements = to_cpu(pf_gpu.measurements);\n\nSee also: to_gpu\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.to_gpu","page":"API","title":"QuantumClifford.to_gpu","text":"copies the memory content of the object to GPU\n\nYou can only use this function if CUDA.jl is imported\n\nFor more advanced users to_gpu(data, element_type) will reinterpret elements of data and converts them to element_type. For example based on your GPU architecture, if working with matrices of UInt64 is faster than UInt32, you can use to_gpu(data, UInt64)\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> stab = S\"- X_Z\\n+ _ZZ\\n+ __Z\"\n- X_Z\n+ _ZZ\n+ __Z\n\njulia> stab_gpu = to_gpu(stab);\n\njulia> apply!(stab_gpu, sHadamard(1));\n\njulia> stab_result_cpu = to_cpu(stab_gpu)\n- Z_Z\n+ _ZZ\n+ __Z\n\njulia> using QuantumClifford: to_cpu, to_gpu\n\njulia> using CUDA # without this import, to_cpu, to_gpu are just function\n\njulia> pf_gpu = to_gpu(PauliFrame(1000, 2, 2));\njulia> circuit = [sMZ(1, 1), sHadamard(2), sMZ(2, 2)];\njulia> pftrajectories(pf_gpu, circuit);\njulia> measurements = to_cpu(pf_gpu.measurements);\n\nSee also: to_cpu\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.trusted_rank","page":"API","title":"QuantumClifford.trusted_rank","text":"A \"trusted\" rank which returns rank(state) for Mixed[De]Stabilizer and length(state) for [De]Stabilizer.\n\n\n\n\n\n","category":"function"},{"location":"API/#QuantumClifford.zero!-Tuple{QuantumClifford.Tableau, Any}","page":"API","title":"QuantumClifford.zero!","text":"Zero-out a given row of a Tableau\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.zero!-Union{Tuple{PauliOperator{Tₚ, Tᵥ}}, Tuple{Tᵥ}, Tuple{Tᵥₑ}, Tuple{Tₚ}} where {Tₚ, Tᵥₑ<:Unsigned, Tᵥ<:AbstractVector{Tᵥₑ}}","page":"API","title":"QuantumClifford.zero!","text":"Zero-out the phases and single-qubit operators in a PauliOperator\n\n\n\n\n\n","category":"method"},{"location":"API/#QuantumClifford.@qubitop1-Tuple{Any, Any}","page":"API","title":"QuantumClifford.@qubitop1","text":"Macro used to define single qubit symbolic gates and their qubit_kernel methods.\n\n\n\n\n\n","category":"macro"},{"location":"API/#QuantumClifford.@qubitop2-Tuple{Any, Any}","page":"API","title":"QuantumClifford.@qubitop2","text":"Macro used to define 2-qubit symbolic gates and their qubit_kernel methods.\n\n\n\n\n\n","category":"macro"},{"location":"API/#QuantumClifford.@valbooldispatch-Tuple{Any, Vararg{Any}}","page":"API","title":"QuantumClifford.@valbooldispatch","text":"Turns f(Val(x)) into x ? f(Val(true)) : f(Val(false)) in order to avoid dynamic dispatch\n\nSee discourse discussion\n\n\n\n\n\n","category":"macro"},{"location":"mixed/#Mixed-Stabilizer-States","page":"Mixed States","title":"Mixed Stabilizer States","text":"","category":"section"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"DocTestSetup = quote\n using QuantumClifford\nend","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"The Stabilizer and Destabilizer have some support for mixed states (by being initialized with an incomplete list of stabilizer generators), but for most purposes one would use the Mixed* data structures.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"Mixed stabilizer states are implemented with MixedStabilizer and MixedDestabilizer, the latter of which is the preferred data structure for most tasks as it is much faster by virtue of tracking the destabilizer generators.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"julia> s = S\"XXX\n IZZ\";\n\njulia> Destabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ _ZZ","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"Unlike Destabilizer, MixedDestabilizer also tracks the logical operation generators.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"julia> m = MixedDestabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n𝒳ₗ━━━\n+ _XX\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ _ZZ\n𝒵ₗ━━━\n+ Z_Z\n\njulia> stabilizerview(m)\n+ XXX\n+ _ZZ\n\njulia> destabilizerview(m)\n+ Z__\n+ _X_\n\njulia> logicalxview(m)\n+ _XX\n\njulia> logicalzview(m)\n+ Z_Z","category":"page"},{"location":"mixed/#Gottesman-Canonicalization","page":"Mixed States","title":"Gottesman Canonicalization","text":"","category":"section"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"To obtain the logical operators we perform a different type of canonicalization, described in Gottesman's thesis and implemented in canonicalize_gott!. Unlike canonicalize! which uses only row operations, canonicalize_gott! performs column swaps as well. MixedDestabilizer undoes those swaps by default when instantiated, but that behavior can be turned off, if you prefer to work with the canonicalized tableau.","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"julia> s = S\"XXX\n ZIZ\";\n\njulia> MixedDestabilizer(s)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ __X\n𝒳ₗ━━━\n+ _X_\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ Z_Z\n𝒵ₗ━━━\n+ ZZ_\n\njulia> MixedDestabilizer(s; undoperm=false)\n𝒟ℯ𝓈𝓉𝒶𝒷\n+ Z__\n+ _X_\n𝒳ₗ━━━\n+ __X\n𝒮𝓉𝒶𝒷━\n+ XXX\n+ ZZ_\n𝒵ₗ━━━\n+ Z_Z","category":"page"},{"location":"mixed/","page":"Mixed States","title":"Mixed States","text":"Destabilizer and MixedStabilizer do not use any column swaps on instantiation as they do not track the logical operators.","category":"page"},{"location":"datastructures/#Data-Structures-Options","page":"Datastructure Choice","title":"Data Structures Options","text":"","category":"section"},{"location":"datastructures/#Choosing-Appropriate-Data-Structure","page":"Datastructure Choice","title":"Choosing Appropriate Tableau Data Structure","text":"","category":"section"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"There are four different data structures used to represent stabilizer states. If you will never need projective measurements you probably would want to use Stabilizer. If you require projective measurements, but only on pure states, Destabilizer should be the appropriate data structure. If mixed stabilizer states are involved, MixedStabilizer would be necessary.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Stabilizer is simply a list of Pauli operators in a tableau form. As a data structure it does not enforce the requirements for a pure stabilizer state (the rows of the tableau do not necessarily commute, nor are they forced to be Hermitian; the tableau might be underdetermined, redundant, or contradictory). It is up to the user to ensure that the initial values in the tableau are meaningful and consistent.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"canonicalize!, project!, and generate! can accept an under determined (mixed state) Stabilizer instance and operate correctly. canonicalize! can also accept a redundant Stabilizer (i.e. not all rows are independent), leaving as many identity rows at the bottom of the canonicalized tableau as the number of redundant stabilizers in the initial tableau.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"canonicalize! takes mathcalO(n^3) steps. generate! expects a canonicalized input and then takes mathcalO(n^2) steps. project! takes mathcalO(n^3) for projecting on commuting operators due to the need to call canonicalize! and generate!. If the projections is on an anticommuting operator (or if keep_result=false) then it takes mathcalO(n^2) steps.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"MixedStabilizer provides explicit tracking of the rank of the mixed state and works properly when the projection is on a commuting operator not in the stabilizer (see table below for details). Otherwise it has the same performance as Stabilizer.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"The canonicalization can be made unnecessary if we track the destabilizer generators. There are two data structures capable of that.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Destabilizer stores both the destabilizer and stabilizer states. project! called on it never requires a stabilizer canonicalization, hence it runs in mathcalO(n^2). However, project! will raise an exception if you try to project on a commuting state that is not in the stabilizer as that would be an expensive mathcalO(n^3) operation.","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"MixedDestabilizer tracks both the destabilizer operators and the logical operators in addition to the stabilizer generators. It does not require canonicalization for measurements and its project! operations always takes mathcalO(n^2).","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"For the operation _, anticom_index, result = project!(...) we have the following behavior:","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"projection Stabilizer MixedStabilizer Destabilizer MixedDestabilizer\non anticommuting operator anticom_index>0 result===nothing correct result in mathcalO(n^2) steps same as Stabilizer same as Stabilizer same as Stabilizer\non commuting operator in the stabilizer anticom_index==0 result!==nothing mathcalO(n^3); or mathcalO(n^2) if keep_result=false mathcalO(n^3) mathcalO(n^2) if the state is pure, throws exception otherwise mathcalO(n^2)\non commuting operator out of the stabilizer[1] anticom_index==rank result===nothing mathcalO(n^3), but the user needs to manually include the new operator to the stabilizer; or mathcalO(n^2) if keep_result=false but then result indistinguishable from cell above and anticom_index==0 mathcalO(n^3) and rank goes up by one not applicable if the state is pure, throws exception otherwise mathcalO(n^2) and rank goes up by one","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Notice the results when the projection operator commutes with the state but is not generated by the stabilizers of the state (the last row of the table). In that case we have _, anticom_index, result = project!(...) where both anticom_index==rank and result===nothing, with rank being the new rank after projection, one more than the number of rows in the tableau before the measurement. ","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"[1]: This can occur only if the state being projected is mixed. Both Stabilizer and Destabilizer can be used for mixed states by simply providing fewer stabilizer generators than qubits at initialization. This can be useful for low-level code that tries to avoid the extra memory cost of using MixedStabilizer and MixedDestabilizer but should be avoided otherwise. project! works correctly or raises an explicit warning on all 4 data structures.","category":"page"},{"location":"datastructures/#Bit-Packing-in-Integers-and-Array-Order","page":"Datastructure Choice","title":"Bit Packing in Integers and Array Order","text":"","category":"section"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"We do not use boolean arrays to store information about the qubits as this would be wasteful (7 out of 8 bits in the boolean would be unused). Instead, we use all 8 qubits in a byte and perform bitwise logical operations as necessary. Implementation details of the object in RAM can matter for performance. The library permits any of the standard UInt types to be used for packing the bits, and larger UInt types (like UInt64) are usually faster as they permit working on 64 qubits at a time (instead of 1 if we used a boolean, or 8 if we used a byte).","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Moreover, how a tableau is stored in memory can affect performance, as a row-major storage usually permits more efficient use of the CPU cache (for the particular algorithms we use).","category":"page"},{"location":"datastructures/","page":"Datastructure Choice","title":"Datastructure Choice","text":"Both of these parameters are benchmarked (testing the application of a Pauli operator, which is an mathcalO(n^2) operation; and testing the canonicalization of a Stabilizer, which is an mathcalO(n^3) operation). Row-major UInt64 is the best performing and it is used by default in this library.","category":"page"},{"location":"noisycircuits_ops/#noisycircuits_ops","page":"Circuit Operations","title":"Operators in Circuit Simulations","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"DocTestSetup = quote\n using QuantumClifford\n using QuantumClifford.Experimental.NoisyCircuits\n using Quantikz\nend","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"warning: Unstable\nThis is experimental functionality with an unstable API.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Import with using QuantumClifford.Experimental.NoisyCircuits.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Too see a condensed list of all operations check out the API docs.","category":"page"},{"location":"noisycircuits_ops/#Unitary-Gates","page":"Circuit Operations","title":"Unitary Gates","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"We distinguish between symbolic gates like sCNOT that have specialized (fast) apply! methods (usually just for single and two qubit gates) and general tableau representation of gates like CliffordOperator that can represent any multi-qubit gate.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Predefined unitary gates are available, like sCNOT, sHadamard, etc.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\n[sCNOT(2,4),sHadamard(2),sCPHASE(1,3),sSWAP(2,4)]","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Any arbitrary tableaux can be used as a gate too. ","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"They can be specified by giving a Clifford operator tableaux and the indices on which it acts (particularly useful for gates acting on a small part of a circuit):","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"using QuantumClifford # hide\nusing QuantumClifford.Experimental.NoisyCircuits # hide\nusing Quantikz # hide\nSparseGate(tCNOT, [2,4])","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"The Clifford operator tableaux can be completely arbitrary.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"SparseGate(random_clifford(3), [2,4,5])","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"If the Clifford operator acts on all qubits, we do not need to specify indices, just use the operator.","category":"page"},{"location":"noisycircuits_ops/#Noisy-Gates","page":"Circuit Operations","title":"Noisy Gates","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Each gate can be followed by noise applied to the qubits on which it has acted. This is done by wrapping the given gate into a NoisyGate","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"ε = 0.03 # X/Y/Z error probability\nnoise = UnbiasedUncorrelatedNoise(ε)\nnoisy_gate = NoisyGate(SparseGate(tCNOT, [2,4]), noise)","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"In circuit diagrams the noise is not depicted, but after each application of the gate defined in noisy_gate, a noise operator will also be applied. The example above is of Pauli Depolarization implemented by UnbiasedUncorrelatedNoise.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"One can also apply only the noise operator by using NoiseOp which acts only on specified qubits. Or alternatively, one can use NoiseOpAll in order to apply noise to all qubits.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"[NoiseOp(noise, [4,5]), NoiseOpAll(noise)]","category":"page"},{"location":"noisycircuits_ops/#Coincidence-Measurements","page":"Circuit Operations","title":"Coincidence Measurements","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"Global parity measurements involving single-qubit projections and classical communication are implemented with BellMeasurement. One needs to specify the axes of measurement and the qubits being measured. If the parity is trivial, the circuit continues, if the parity is non-trivial, the circuit ends and reports a detected failure. This operator is frequently used in the simulation of entanglement purification.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"BellMeasurement([sMX(1), sMY(3), sMZ(4)])","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"There is also NoisyBellMeasurement that takes the bit-flip probability of a single-qubit measurement as a third argument.","category":"page"},{"location":"noisycircuits_ops/#Stabilizer-Measurements","page":"Circuit Operations","title":"Stabilizer Measurements","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"A measurement over one or more qubits can also be performed, e.g., a direct stabilizer measurement on multiple qubits without the use of ancillary qubits. When applied to multiple qubits, this differs from BellMeasurement as it performs a single projection, unlike BellMeasurement which performs a separate projection for every single qubit involved. This measurement is implemented in PauliMeasurement which requires a Pauli operator on which to project and the index of the classical bit in which to store the result. Alternatively, there are sMX, sMZ, sMY if you are measuring a single qubit.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"[PauliMeasurement(P\"XYZ\", 1), sMZ(2, 2)]","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"TODO: SparseMeasurement, NoisyMeasurement","category":"page"},{"location":"noisycircuits_ops/#Verification-Operations","page":"Circuit Operations","title":"Verification Operations","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"At the end of many circuits one might want to check whether they performed correctly. The VerifyOp operation corresponds to an unphysical perfect tomographic operation, checking whether the state of the qubits at the given indices is indeed what is expected. If it is, the operation reports a success, otherwise it reports an undetected error.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"desired_state = random_stabilizer(5)\nqubit_indices = [1,2,3,4,7]\nVerifyOp(desired_state, qubit_indices)","category":"page"},{"location":"noisycircuits_ops/#Reset-Operations","page":"Circuit Operations","title":"Reset Operations","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"The Reset operations lets you trace out the specified qubits and set their state to a specific tableau.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"new_state = random_stabilizer(3)\nqubit_indices = [1,2,3]\nReset(new_state, qubit_indices)","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"It can be done anywhere in a circuit, not just at the beginning.","category":"page"},{"location":"noisycircuits_ops/#Gates-Conditioned-on-Classical-Bits","page":"Circuit Operations","title":"Gates Conditioned on Classical Bits","text":"","category":"section"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"ConditionalGate is a conditional gate that performs one of two provided gates, depending on the value of a given classical bit.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"DecisionGate is a conditional gate that performs one of the supplied gates, depending on the output of decisionfunction applied to the entire classical bit register.","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"gate1 = SparseGate(tCNOT, [1,2])\ngate2 = sCPHASE(1,2)\ngate3 = SparseGate(tSWAP, [1,3])\ncg = ConditionalGate(gate1, gate2, 2)\ndg = DecisionGate([gate1,gate2,gate3], bit_register->1) # it will always perform gate1\n[sMX(4,1), sMZ(5,2), cg, dg]","category":"page"},{"location":"noisycircuits_ops/","page":"Circuit Operations","title":"Circuit Operations","text":"TODO: Split ConditionalGate into quantum conditional and classical conditional","category":"page"},{"location":"plotting/#Visualizations","page":"Visualizations","title":"Visualizations","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Stabilizers have a plot recipe that can be used with Plots.jl or Makie.jl. It simply displays the corresponding parity check matrix (extracted with stab_to_gf2) as a bitmap image. Circuits can be visualized with Quantikz.jl.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Importing the aforementioned packages together with QuantumClifford is necessary to enable the plotting functionality (implemented as package extensions).","category":"page"},{"location":"plotting/#Plots.jl","page":"Visualizations","title":"Plots.jl","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"In Plots.jl we have a simple recipe plot(s::Stabilizer; xzcomponents=...) where xzcomponents=:split plots the tableau heatmap in a wide form, X bits on the left, Z bits on the right; or xzcomponents=:together plots them overlapping, with different colors for I, X, Z, and Y.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(random_stabilizer(20,30), xzcomponents=:split)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize!(random_stabilizer(20,30)))","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize_gott!(random_stabilizer(30))[1], xzcomponents=:split)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize_gott!(random_stabilizer(30))[1]; xzcomponents=:together)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Plots\nplot(canonicalize_rref!(random_stabilizer(20,30),1:30)[1]; xzcomponents=:together)","category":"page"},{"location":"plotting/#Makie.jl","page":"Visualizations","title":"Makie.jl","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Makie's heatmap can be directly called on Stabilizer.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\ns = S\"IIXZ\n ZZIZ\n YYIZ\n IIIZ\n ZZXZ\"\nf, ax, p = CairoMakie.heatmap(s)\nhidedecorations!(ax); hidespines!(ax); # remove ticks and spines\nax.aspect = DataAspect(); # set a one-to-one aspect ratio\nf","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"A full Makie recipe is available as well (supporting xzcomponents)","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\ns = S\"IIXZ\n ZZIZ\n YYIZ\n IIIZ\n ZZXZ\"\nf, ax, p = stabilizerplot(s, xzcomponents=:together)\nhidedecorations!(ax); hidespines!(ax)\nax.aspect = DataAspect()\nf","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"You can easily add colorbars (and change the colormap) as well:","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\nfig = Figure()\nax, p = stabilizerplot(fig[1, 1], s, colormap=cgrad(:heat, 4, categorical = true))\nhidedecorations!(ax)\nhidespines!(ax)\nxlims!(ax, 0.5, size(s,2)+0.5) # otherwise there is padding\nylims!(ax, 0.5, size(s,1)+0.5) # otherwise there is padding\n# set the aspect ratio of the plot\nax.aspect = DataAspect()\n# set the aspect ratio of the layout\ncolsize!(fig.layout, 1, Aspect(1, size(s,2)/size(s,1))) \nColorbar(fig[1, 2], p, ticks = (0:3, [\"I\", \"X\", \"Z\", \"Y\"]))\nfig","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"Or set a completely custom set of colors:","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"fig = Figure()\nax, p = stabilizerplot(fig[1, 1], s, colormap=cgrad([:lightgray,RGBf(1,0.4,0.4),RGBf(0.3,1,0.5),RGBf(0.4,0.4,1)], 4, categorical = true))\nhidedecorations!(ax)\nhidespines!(ax)\nxlims!(ax, 0.5, size(s,2)+0.5)\nylims!(ax, 0.5, size(s,1)+0.5)\nax.aspect = DataAspect()\ncolsize!(fig.layout, 1, Aspect(1, size(s,2)/size(s,1))) \nColorbar(fig[2, 1], p, ticks = (0:3, [\"I\", \"X\", \"Z\", \"Y\"]), vertical = false, flipaxis = false)\nfig","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"You might have noticed, Makie recipes do not let you edit the axes or figure, rather they only permit you to set the plot content. Which is why we use hidedecorations!, hidesplines!, and DataAspect to further modify the plot. However, these defaults are also available in stabilizerplot_axis.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, CairoMakie\nf=Figure()\nstabilizerplot_axis(f[1,1],random_stabilizer(100))\nf","category":"page"},{"location":"plotting/#Quantikz.jl","page":"Visualizations","title":"Quantikz.jl","text":"","category":"section"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"With the Quantikz library you can visualize gates or sequences of gates.","category":"page"},{"location":"plotting/","page":"Visualizations","title":"Visualizations","text":"using QuantumClifford, Quantikz\ncircuit = [sCNOT(1,2), SparseGate(random_clifford(4), [1,4,5,6]), sMZ(4)]","category":"page"},{"location":"#QuantumClifford.jl","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"DocTestSetup = quote\n using QuantumClifford\nend","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"QuantumClifford.jl is a Julia library for simulation of Clifford circuits, which are a subclass of quantum circuits that can be efficiently simulated on a classical computer.","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"This library uses the tableaux formalism[1] with the destabilizer improvements[2]. Pauli frames are supported for faster repeated simulation of noisy circuits. Various symbolic and algebraic tools for manipulating, converting, and visualizing states and circuits are also implemented. ","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"[1]: (Gottesman, 1998)","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"[2]: (Aaronson and Gottesman, 2004)","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The library consists of two main parts: Tools for working with the algebra of Stabilizer Tableaux and tools specifically for efficient Circuit Simulation.","category":"page"},{"location":"#Stabilizer-Tableau-Algebra","page":"QuantumClifford.jl","title":"Stabilizer Tableau Algebra","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The Stabilizer Tableau Algebra component of QuantumClifford.jl efficiently handles pure and mixed stabilizer states of thousands of qubits, along with support for sparse or dense Clifford operations acting upon them. It provides operations such as canonicalization, projection, generation , and partial traces. The code is vectorized and multithreaded, offering fast, in-place, and allocation-free implementations. Tools for conversion to graph states and for visualization of tableaux are available.","category":"page"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"See the Stabilizer Tableau Algebra manual or the curated list of useful functions.","category":"page"},{"location":"#Example-Usage","page":"QuantumClifford.jl","title":"Example Usage","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"julia> using QuantumClifford\n\njulia> P\"X\" * P\"Z\"\n-iY\n\njulia> P\"X\" ⊗ P\"Z\"\n+ XZ\n\njulia> S\"-XX\n +ZZ\"\n- XX\n+ ZZ\n\njulia> tCNOT * S\"-XX\n +ZZ\"\n- X_\n+ _Z","category":"page"},{"location":"#Circuit-Simulation","page":"QuantumClifford.jl","title":"Circuit Simulation","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The circuit simulation component of QuantumClifford.jl enables Monte Carlo (or symbolic) simulations of noisy Clifford circuits. It provides three main simulation methods: mctrajectories, pftrajectories, and petrajectories. These methods offer varying levels of efficiency, accuracy, and insight.","category":"page"},{"location":"#Monte-Carlo-Simulations-with-Stabilizer-Tableaux-(mctrajectories)","page":"QuantumClifford.jl","title":"Monte Carlo Simulations with Stabilizer Tableaux (mctrajectories)","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The mctrajectories method runs Monte Carlo simulations using a Stabilizer tableau representation for the quantum states.","category":"page"},{"location":"#Monte-Carlo-Simulations-with-Pauli-Frames-(pftrajectories)","page":"QuantumClifford.jl","title":"Monte Carlo Simulations with Pauli Frames (pftrajectories)","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The pftrajectories method runs Monte Carlo simulations of Pauli frames over a single reference Stabilizer tableau simulation. This approach is much more efficient but supports a smaller class of circuits.","category":"page"},{"location":"#Symbolic-Depth-First-Traversal-of-Quantum-Trajectories-(petrajectories)","page":"QuantumClifford.jl","title":"Symbolic Depth-First Traversal of Quantum Trajectories (petrajectories)","text":"","category":"section"},{"location":"","page":"QuantumClifford.jl","title":"QuantumClifford.jl","text":"The petrajectories method performs a depth-first traversal of the most probable quantum trajectories, providing a fixed-order approximation of the circuit's behavior. This approach gives symbolic expressions for various figures of merit instead of just a numeric value.","category":"page"}] } diff --git a/dev/stab-algebra-manual/index.html b/dev/stab-algebra-manual/index.html index 38a470a8d..2fa47c042 100644 --- a/dev/stab-algebra-manual/index.html +++ b/dev/stab-algebra-manual/index.html @@ -302,4 +302,4 @@ 𝒮𝓉𝒶𝒷━ + _ZX - _Z_ -- Z_X

Mixed States

Both the Stabilizer and Destabilizer structures have more general forms that enable work with mixed stabilizer states. They are the MixedStabilizer and MixedDestabilizer structures, described in Mixed States. More information that can be seen in the data structures page, which expands upon the algorithms available for each structure.

Random States and Circuits

random_clifford, random_stabilizer, and enumerate_cliffords can be used for the generation of random states.

+- Z_X

Mixed States

Both the Stabilizer and Destabilizer structures have more general forms that enable work with mixed stabilizer states. They are the MixedStabilizer and MixedDestabilizer structures, described in Mixed States. More information that can be seen in the data structures page, which expands upon the algorithms available for each structure.

Random States and Circuits

random_clifford, random_stabilizer, and enumerate_cliffords can be used for the generation of random states.

diff --git a/dev/tutandpub/index.html b/dev/tutandpub/index.html index cee624186..1b493dea7 100644 --- a/dev/tutandpub/index.html +++ b/dev/tutandpub/index.html @@ -1,2 +1,2 @@ -Tutorials and Publications · QuantumClifford.jl
+Tutorials and Publications · QuantumClifford.jl