mimiqcircuits.operations.noisechannel.standards.pauli¶
Classes
|
N-qubit Pauli noise channel given by probabilities and Pauli strings. |
|
One-qubit Pauli X noise channel (bit flip error). |
|
One-qubit Pauli Y noise channel (bit-phase flip error). |
|
One-qubit Pauli Z noise channel (phase flip error). |
- class PauliNoise(p, paulistr)[source]¶
Bases:
krauschannelN-qubit Pauli noise channel given by probabilities and Pauli strings.
A Pauli channel is defined by
\[\mathcal{E}(\rho) = \sum_k p_k P_k \rho P_k,\]where \(0 \leq p_k \leq 1\) and \(P_k\) are Pauli string operators, defined as tensor products of one-qubit Pauli operators. The probabilities must fulfill \(\sum_k p_k = 1\).
This channel is a mixed unitary channel (see
ismixedunitary()).Depolarizing,PauliX,PauliYandPauliZare special cases of it.- Parameters:
p (List[float | int]) – Probabilities, one per Pauli string. Numeric values must lie in \([0, 1]\) and add up to 1; the checks are skipped when any value is symbolic.
paulistr (List[str]) – Pauli strings, all of the same length \(N\), made of the characters
"I","X","Y"and"Z". \(N\) is the number of qubits of the channel.
- Raises:
ValueError – If
paulistris empty, the two lists have different lengths, the strings have different lengths or are not valid Pauli strings, or the numeric probabilities are out of range or do not add up to 1.
Examples
>>> from mimiqcircuits import * >>> # one qubit: identity with probability 0.8, X or Y with 0.1 each >>> c = Circuit() >>> c.push(PauliNoise([0.8, 0.1, 0.1], ["I", "X", "Y"]), 1) 2-qubit circuit with 1 instruction: └── PauliNoise((0.8, pauli"I"), (0.1, pauli"X"), (0.1, pauli"Y")) @ q[1]
>>> # two qubits: XY with probability 0.9, nothing with 0.1 >>> c.push(PauliNoise([0.9, 0.1], ["XY", "II"]), 1, 2) 3-qubit circuit with 2 instructions: ├── PauliNoise((0.8, pauli"I"), (0.1, pauli"X"), (0.1, pauli"Y")) @ q[1] └── PauliNoise((0.9, pauli"XY"), (0.1, pauli"II")) @ q[1]
>>> # any number of qubits and of Pauli strings >>> c.push(PauliNoise([0.5, 0.2, 0.2, 0.1], ["IXIX", "XYXY", "ZZZZ", "IXYZ"]), 1, 2, 3, 4) 5-qubit circuit with 3 instructions: ├── PauliNoise((0.8, pauli"I"), (0.1, pauli"X"), (0.1, pauli"Y")) @ q[1] ├── PauliNoise((0.9, pauli"XY"), (0.1, pauli"II")) @ q[1] └── PauliNoise((0.5, pauli"IXIX"), (0.2, pauli"XYXY"), (0.2, pauli"ZZZZ"), (0.1, pauli"IXYZ")) @ q[1]
- property num_qubits¶
Number of qubits the operation acts on.
Read-only: assigning to it raises
ValueError.
- property parnames¶
Names of the operation’s parameters, as a tuple of strings.
Read-only: assigning to it raises
ValueError.
- evaluate(d={})[source]¶
Return a copy with symbols in the probabilities substituted by values.
- Parameters:
d (dict) – Map from symbols to the values to substitute.
- Returns:
A new channel with the same Pauli strings.
- Return type:
- Raises:
ValueError – If a substituted probability is outside \([0, 1]\) or the probabilities are all numeric and do not add up to 1.
- krausmatrices()[source]¶
Return the matrices of the Kraus operators \(E_k\) of the channel.
These are the matrices of
krausoperators(), in the same order. For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per Kraus operator.
- Return type:
Examples
>>> from mimiqcircuits import * >>> AmplitudeDamping(0.36).krausmatrices() [[1.0, 0] [0, 0.8] , [0, 0.6] [0, 0] ]
- krausoperators()[source]¶
Return the Kraus operators \(E_k\) of the channel as operator objects.
Every concrete channel implements this method; the base class raises.
- Returns:
One operator (for example
Operator,DiagonalOporRescaledGate) per Kraus operator.- Return type:
- Raises:
NotImplementedError – When called on a class that does not define it.
Examples
>>> from mimiqcircuits import * >>> # projective noise in Z: project on |0> or on |1> >>> ProjectiveNoise("Z").krausoperators() [P₀(1), P₁(1)]
- probabilities()[source]¶
Return the probabilities \(p_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) this is the list of \(p_k\), in the same order as
unitarygates().- Returns:
One probability per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> # identity with probability 0.9, X with probability 0.1 >>> PauliX(0.1).probabilities() [0.9, 0.1]
- unitarymatrices()[source]¶
Return the matrices of the unitaries \(U_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the matrices of
unitarygates(), in the same order asprobabilities(). For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
See also
Examples
>>> from mimiqcircuits import * >>> # identity and Pauli X >>> PauliX(0.2).unitarymatrices() [[1.0, 0] [0, 1.0] , [0, 1.0] [1.0, 0] ]
- unitarygates()[source]¶
Return the unitaries \(U_k\) of a mixed unitary channel as gates.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the \(U_k\), in the same order as
probabilities().- Returns:
One gate per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> PauliX(0.1).unitarygates() [ID, X]
- classmethod ismixedunitary()[source]¶
Whether the channel is a mixed unitary channel.
A channel is mixed unitary when every Kraus operator \(E_k\) is proportional to a unitary matrix \(U_k\), so that
\[\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger,\]with probabilities \(0 \leq p_k \leq 1\) that add up to 1. The answer depends only on the channel type, not on its parameters, so this is a class method. Only mixed unitary channels support
probabilities(),cumprobabilities(),unitarygates()andunitarymatrices().- Returns:
Truefor mixed unitary channel types,Falseotherwise.- Return type:
Examples
>>> from mimiqcircuits import * >>> # PauliX applies X with probability p: mixed unitary >>> PauliX(0.1).ismixedunitary() True
>>> # amplitude damping has a non-unitary Kraus operator >>> AmplitudeDamping(0.1).ismixedunitary() False
- iswrapper()[source]¶
Whether the operation wraps another operation.
Truefor composite operations such asControl,Power,Inverse,ParallelorIfStatement,Falseotherwise.- Returns:
bool
- unwrappedkrausmatrices()[source]¶
Return the Kraus matrices of a channel whose parameters all have values.
Returns the same matrices as
krausmatrices(), after checking that every parameter evaluates to a constant.- Returns:
One symengine matrix per Kraus operator.
- Return type:
- Raises:
ValueError – If a parameter is still a free symbol.
See also
Examples
>>> from mimiqcircuits import * >>> # PauliX(p) has Kraus operators sqrt(1-p) I and sqrt(p) X >>> op = PauliX(0.2) >>> op.unwrappedkrausmatrices() [[0.894427190999916, 0] [0, 0.894427190999916] , [0, 0.447213595499958] [0.447213595499958, 0] ]
- class PauliX(p)[source]¶
Bases:
krauschannelOne-qubit Pauli X noise channel (bit flip error).
This channel is defined by the Kraus operators:
\[E_1 = \sqrt{1-p}\,I, \quad E_2 = \sqrt{p}\,X,\]where \(0 \leq p \leq 1\).
This channel is a mixed unitary channel (see
ismixedunitary()), and is a special case ofPauliNoise:PauliX(p)acts likePauliNoise([1-p, p], ["I", "X"]).- Parameters:
p (float | int) – Probability of a bit flip error, in \([0, 1]\); may be symbolic.
- Raises:
ValueError – If a numeric
pis outside \([0, 1]\).
Examples
>>> from mimiqcircuits import * >>> # apply X to qubit 1 with probability 0.1 >>> c = Circuit() >>> c.push(PauliX(0.1), 1) 2-qubit circuit with 1 instruction: └── PauliX(0.1) @ q[1]
- krausmatrices()[source]¶
Return the matrices of the Kraus operators \(E_k\) of the channel.
These are the matrices of
krausoperators(), in the same order. For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per Kraus operator.
- Return type:
Examples
>>> from mimiqcircuits import * >>> AmplitudeDamping(0.36).krausmatrices() [[1.0, 0] [0, 0.8] , [0, 0.6] [0, 0] ]
- evaluate(d={})[source]¶
Return a copy with symbols in
psubstituted by values.- Parameters:
d (dict) – Map from symbols to the values to substitute.
- Returns:
A new channel of the same type.
- Raises:
ValueError – If the substituted
pis outside \([0, 1]\).
- krausoperators()[source]¶
Return the Kraus operators \(E_k\) of the channel as operator objects.
Every concrete channel implements this method; the base class raises.
- Returns:
One operator (for example
Operator,DiagonalOporRescaledGate) per Kraus operator.- Return type:
- Raises:
NotImplementedError – When called on a class that does not define it.
Examples
>>> from mimiqcircuits import * >>> # projective noise in Z: project on |0> or on |1> >>> ProjectiveNoise("Z").krausoperators() [P₀(1), P₁(1)]
- probabilities()[source]¶
Return the probabilities \(p_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) this is the list of \(p_k\), in the same order as
unitarygates().- Returns:
One probability per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> # identity with probability 0.9, X with probability 0.1 >>> PauliX(0.1).probabilities() [0.9, 0.1]
- unitarymatrices()[source]¶
Return the matrices of the unitaries \(U_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the matrices of
unitarygates(), in the same order asprobabilities(). For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
See also
Examples
>>> from mimiqcircuits import * >>> # identity and Pauli X >>> PauliX(0.2).unitarymatrices() [[1.0, 0] [0, 1.0] , [0, 1.0] [1.0, 0] ]
- unitarygates()[source]¶
Return the unitaries \(U_k\) of a mixed unitary channel as gates.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the \(U_k\), in the same order as
probabilities().- Returns:
One gate per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> PauliX(0.1).unitarygates() [ID, X]
- static ismixedunitary()[source]¶
Whether the channel is a mixed unitary channel.
A channel is mixed unitary when every Kraus operator \(E_k\) is proportional to a unitary matrix \(U_k\), so that
\[\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger,\]with probabilities \(0 \leq p_k \leq 1\) that add up to 1. The answer depends only on the channel type, not on its parameters, so this is a class method. Only mixed unitary channels support
probabilities(),cumprobabilities(),unitarygates()andunitarymatrices().- Returns:
Truefor mixed unitary channel types,Falseotherwise.- Return type:
Examples
>>> from mimiqcircuits import * >>> # PauliX applies X with probability p: mixed unitary >>> PauliX(0.1).ismixedunitary() True
>>> # amplitude damping has a non-unitary Kraus operator >>> AmplitudeDamping(0.1).ismixedunitary() False
- class PauliY(p)[source]¶
Bases:
krauschannelOne-qubit Pauli Y noise channel (bit-phase flip error).
This channel is determined by the Kraus operators:
\[E_1 = \sqrt{1-p}\,I, \quad E_2 = \sqrt{p}\,Y,\]where \(0 \leq p \leq 1\).
This channel is a mixed unitary channel (see
ismixedunitary()), and is a special case ofPauliNoise:PauliY(p)acts likePauliNoise([1-p, p], ["I", "Y"]).- Parameters:
p (float | int) – Probability of a bit-phase flip error, in \([0, 1]\); may be symbolic.
- Raises:
ValueError – If a numeric
pis outside \([0, 1]\).
Examples
>>> from mimiqcircuits import * >>> # apply Y to qubit 1 with probability 0.1 >>> c = Circuit() >>> c.push(PauliY(0.1), 1) 2-qubit circuit with 1 instruction: └── PauliY(0.1) @ q[1]
- evaluate(d={})[source]¶
Return a copy with symbols in
psubstituted by values.- Parameters:
d (dict) – Map from symbols to the values to substitute.
- Returns:
A new channel of the same type.
- Raises:
ValueError – If the substituted
pis outside \([0, 1]\).
- krausmatrices()[source]¶
Return the matrices of the Kraus operators \(E_k\) of the channel.
These are the matrices of
krausoperators(), in the same order. For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per Kraus operator.
- Return type:
Examples
>>> from mimiqcircuits import * >>> AmplitudeDamping(0.36).krausmatrices() [[1.0, 0] [0, 0.8] , [0, 0.6] [0, 0] ]
- krausoperators()[source]¶
Return the Kraus operators \(E_k\) of the channel as operator objects.
Every concrete channel implements this method; the base class raises.
- Returns:
One operator (for example
Operator,DiagonalOporRescaledGate) per Kraus operator.- Return type:
- Raises:
NotImplementedError – When called on a class that does not define it.
Examples
>>> from mimiqcircuits import * >>> # projective noise in Z: project on |0> or on |1> >>> ProjectiveNoise("Z").krausoperators() [P₀(1), P₁(1)]
- probabilities()[source]¶
Return the probabilities \(p_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) this is the list of \(p_k\), in the same order as
unitarygates().- Returns:
One probability per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> # identity with probability 0.9, X with probability 0.1 >>> PauliX(0.1).probabilities() [0.9, 0.1]
- unitarymatrices()[source]¶
Return the matrices of the unitaries \(U_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the matrices of
unitarygates(), in the same order asprobabilities(). For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
See also
Examples
>>> from mimiqcircuits import * >>> # identity and Pauli X >>> PauliX(0.2).unitarymatrices() [[1.0, 0] [0, 1.0] , [0, 1.0] [1.0, 0] ]
- unitarygates()[source]¶
Return the unitaries \(U_k\) of a mixed unitary channel as gates.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the \(U_k\), in the same order as
probabilities().- Returns:
One gate per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> PauliX(0.1).unitarygates() [ID, X]
- static ismixedunitary()[source]¶
Whether the channel is a mixed unitary channel.
A channel is mixed unitary when every Kraus operator \(E_k\) is proportional to a unitary matrix \(U_k\), so that
\[\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger,\]with probabilities \(0 \leq p_k \leq 1\) that add up to 1. The answer depends only on the channel type, not on its parameters, so this is a class method. Only mixed unitary channels support
probabilities(),cumprobabilities(),unitarygates()andunitarymatrices().- Returns:
Truefor mixed unitary channel types,Falseotherwise.- Return type:
Examples
>>> from mimiqcircuits import * >>> # PauliX applies X with probability p: mixed unitary >>> PauliX(0.1).ismixedunitary() True
>>> # amplitude damping has a non-unitary Kraus operator >>> AmplitudeDamping(0.1).ismixedunitary() False
- class PauliZ(p)[source]¶
Bases:
krauschannelOne-qubit Pauli Z noise channel (phase flip error).
This channel is determined by the Kraus operators:
\[E_1 = \sqrt{1-p}\,I, \quad E_2 = \sqrt{p}\,Z,\]where \(0 \leq p \leq 1\).
This channel is a mixed unitary channel (see
ismixedunitary()), and is a special case ofPauliNoise:PauliZ(p)acts likePauliNoise([1-p, p], ["I", "Z"]).- Parameters:
p (float | int) – Probability of a phase flip error, in \([0, 1]\); may be symbolic.
- Raises:
ValueError – If a numeric
pis outside \([0, 1]\).
Examples
>>> from mimiqcircuits import * >>> # apply Z to qubit 1 with probability 0.1 >>> c = Circuit() >>> c.push(PauliZ(0.1), 1) 2-qubit circuit with 1 instruction: └── PauliZ(0.1) @ q[1]
- evaluate(d={})[source]¶
Return a copy with symbols in
psubstituted by values.- Parameters:
d (dict) – Map from symbols to the values to substitute.
- Returns:
A new channel of the same type.
- Raises:
ValueError – If the substituted
pis outside \([0, 1]\).
- krausmatrices()[source]¶
Return the matrices of the Kraus operators \(E_k\) of the channel.
These are the matrices of
krausoperators(), in the same order. For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per Kraus operator.
- Return type:
Examples
>>> from mimiqcircuits import * >>> AmplitudeDamping(0.36).krausmatrices() [[1.0, 0] [0, 0.8] , [0, 0.6] [0, 0] ]
- krausoperators()[source]¶
Return the Kraus operators \(E_k\) of the channel as operator objects.
Every concrete channel implements this method; the base class raises.
- Returns:
One operator (for example
Operator,DiagonalOporRescaledGate) per Kraus operator.- Return type:
- Raises:
NotImplementedError – When called on a class that does not define it.
Examples
>>> from mimiqcircuits import * >>> # projective noise in Z: project on |0> or on |1> >>> ProjectiveNoise("Z").krausoperators() [P₀(1), P₁(1)]
- probabilities()[source]¶
Return the probabilities \(p_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) this is the list of \(p_k\), in the same order as
unitarygates().- Returns:
One probability per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> # identity with probability 0.9, X with probability 0.1 >>> PauliX(0.1).probabilities() [0.9, 0.1]
- unitarymatrices()[source]¶
Return the matrices of the unitaries \(U_k\) of a mixed unitary channel.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the matrices of
unitarygates(), in the same order asprobabilities(). For a parametric channel the entries are symbolic expressions.- Returns:
One symengine matrix per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
See also
Examples
>>> from mimiqcircuits import * >>> # identity and Pauli X >>> PauliX(0.2).unitarymatrices() [[1.0, 0] [0, 1.0] , [0, 1.0] [1.0, 0] ]
- unitarygates()[source]¶
Return the unitaries \(U_k\) of a mixed unitary channel as gates.
For \(\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger\) these are the \(U_k\), in the same order as
probabilities().- Returns:
One gate per unitary.
- Return type:
- Raises:
ValueError – If the channel is not mixed unitary.
Examples
>>> from mimiqcircuits import * >>> PauliX(0.1).unitarygates() [ID, X]
- static ismixedunitary()[source]¶
Whether the channel is a mixed unitary channel.
A channel is mixed unitary when every Kraus operator \(E_k\) is proportional to a unitary matrix \(U_k\), so that
\[\mathcal{E}(\rho) = \sum_k p_k U_k \rho U_k^\dagger,\]with probabilities \(0 \leq p_k \leq 1\) that add up to 1. The answer depends only on the channel type, not on its parameters, so this is a class method. Only mixed unitary channels support
probabilities(),cumprobabilities(),unitarygates()andunitarymatrices().- Returns:
Truefor mixed unitary channel types,Falseotherwise.- Return type:
Examples
>>> from mimiqcircuits import * >>> # PauliX applies X with probability p: mixed unitary >>> PauliX(0.1).ismixedunitary() True
>>> # amplitude damping has a non-unitary Kraus operator >>> AmplitudeDamping(0.1).ismixedunitary() False