Clifford#

class qiskit.quantum_info.Clifford(data, validate=True, copy=True)[ソース]#

ベースクラス: BaseOperator, AdjointMixin, Operation

An N-qubit unitary operator from the Clifford group.

Representation

An N-qubit Clifford operator is stored as a length 2N × (2N+1) boolean tableau using the convention from reference [1].

  • Rows 0 to N-1 are the destabilizer group generators

  • Rows N to 2N-1 are the stabilizer group generators.

The internal boolean tableau for the Clifford can be accessed using the tableau attribute. The destabilizer or stabilizer rows can each be accessed as a length-N Stabilizer table using destab and stab attributes.

A more easily human readable representation of the Clifford operator can be obtained by calling the to_dict() method. This representation is also used if a Clifford object is printed as in the following example

from qiskit import QuantumCircuit
from qiskit.quantum_info import Clifford

# Bell state generation circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
cliff = Clifford(qc)

# Print the Clifford
print(cliff)

# Print the Clifford destabilizer rows
print(cliff.to_labels(mode="D"))

# Print the Clifford stabilizer rows
print(cliff.to_labels(mode="S"))
Clifford: Stabilizer = ['+XX', '+ZZ'], Destabilizer = ['+IZ', '+XI']
['+IZ', '+XI']
['+XX', '+ZZ']

Circuit Conversion

Clifford operators can be initialized from circuits containing only the following Clifford gates: IGate, XGate, YGate, ZGate, HGate, SGate, SdgGate, SXGate, SXdgGate, CXGate, CZGate, CYGate, DXGate, SwapGate, iSwapGate, ECRGate. They can be converted back into a QuantumCircuit, or Gate object using the to_circuit() or to_instruction() methods respectively. Note that this decomposition is not necessarily optimal in terms of number of gates.

注釈

A minimally generating set of gates for Clifford circuits is the HGate and SGate gate and either the CXGate or CZGate two-qubit gate.

Clifford operators can also be converted to Operator objects using the to_operator() method. This is done via decomposing to a circuit, and then simulating the circuit as a unitary operator.

参照

  1. S. Aaronson, D. Gottesman, Improved Simulation of Stabilizer Circuits, Phys. Rev. A 70, 052328 (2004). arXiv:quant-ph/0406196

Initialize an operator object.

Attributes

destab#

The destabilizer array for the symplectic representation.

destab_phase#

Return phase of destabilizer with boolean representation.

destab_x#

The destabilizer x array for the symplectic representation.

destab_z#

The destabilizer z array for the symplectic representation.

destabilizer#

Return the destabilizer block of the StabilizerTable.

バージョン 0.24.0 で非推奨: The property qiskit.quantum_info.operators.symplectic.clifford.Clifford.destabilizer is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. Use Clifford.destab properties instead.

dim#

Return tuple (input_shape, output_shape).

name#

Unique string identifier for operation type.

num_clbits#

Number of classical bits.

num_qubits#

Return the number of qubits if a N-qubit operator or None otherwise.

phase#

Return phase with boolean representation.

qargs#

Return the qargs for the operator.

stab#

The stabilizer array for the symplectic representation.

stab_phase#

Return phase of stabilizer with boolean representation.

stab_x#

The stabilizer x array for the symplectic representation.

stab_z#

The stabilizer array for the symplectic representation.

stabilizer#

Return the stabilizer block of the StabilizerTable.

バージョン 0.24.0 で非推奨: The property qiskit.quantum_info.operators.symplectic.clifford.Clifford.stabilizer is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. Use Clifford.stab properties instead.

symplectic_matrix#

Return boolean symplectic matrix.

table#

Return StabilizerTable

バージョン 0.24.0 で非推奨: The property qiskit.quantum_info.operators.symplectic.clifford.Clifford.table is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. Use Clifford.stab and Clifford.destab properties instead.

x#

The x array for the symplectic representation.

z#

The z array for the symplectic representation.

Methods

adjoint()[ソース]#

Return the adjoint of the Operator.

compose(other, qargs=None, front=False)[ソース]#

Return the operator composition with another Clifford.

パラメータ:
  • other (Clifford) – a Clifford object.

  • qargs (list or None) – Optional, a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).

  • front (bool) – If True compose using right operator multiplication, instead of left multiplication [default: False].

戻り値:

The composed Clifford.

戻り値の型:

Clifford

例外:

QiskitError – if other cannot be converted to an operator, or has incompatible dimensions for specified subsystems.

注釈

Composition (&) by default is defined as left matrix multiplication for matrix operators, while @ (equivalent to dot()) is defined as right matrix multiplication. That is that A & B == A.compose(B) is equivalent to B @ A == B.dot(A) when A and B are of the same type.

Setting the front=True kwarg changes this to right matrix multiplication and is equivalent to the dot() method A.dot(B) == A.compose(B, front=True).

conjugate()[ソース]#

Return the conjugate of the Clifford.

copy()[ソース]#

Make a deep copy of current operator.

dot(other, qargs=None)#

Return the right multiplied operator self * other.

パラメータ:
  • other (Operator) – an operator object.

  • qargs (list or None) – Optional, a list of subsystem positions to apply other on. If None apply on all subsystems (default: None).

戻り値:

The right matrix multiplied Operator.

戻り値の型:

Operator

注釈

The dot product can be obtained using the @ binary operator. Hence a.dot(b) is equivalent to a @ b.

expand(other)[ソース]#

Return the reverse-order tensor product with another Clifford.

パラメータ:

other (Clifford) – a Clifford object.

戻り値:

the tensor product \(b \otimes a\), where \(a\)

is the current Clifford, and \(b\) is the other Clifford.

戻り値の型:

Clifford

static from_circuit(circuit)[ソース]#

Initialize from a QuantumCircuit or Instruction.

パラメータ:

circuit (QuantumCircuit or Instruction) – instruction to initialize.

戻り値:

the Clifford object for the instruction.

戻り値の型:

Clifford

例外:

QiskitError – if the input instruction is non-Clifford or contains classical register instruction.

classmethod from_dict(obj)[ソース]#

Load a Clifford from a dictionary

static from_label(label)[ソース]#

Return a tensor product of single-qubit Clifford gates.

パラメータ:

label (string) – single-qubit operator string.

戻り値:

The N-qubit Clifford operator.

戻り値の型:

Clifford

例外:

QiskitError – if the label contains invalid characters.

Additional Information:

The labels correspond to the single-qubit Cliffords are

    • Label

    • Stabilizer

    • Destabilizer

    • "I"

    • +Z

    • +X

    • "X"

    • -Z

    • +X

    • "Y"

    • -Z

    • -X

    • "Z"

    • +Z

    • -X

    • "H"

    • +X

    • +Z

    • "S"

    • +Z

    • +Y

classmethod from_matrix(matrix)[ソース]#

Create a Clifford from a unitary matrix.

Note that this function takes exponentially long time w.r.t. the number of qubits.

パラメータ:

matrix (np.array) – A unitary matrix representing a Clifford to be converted.

戻り値:

the Clifford object for the unitary matrix.

戻り値の型:

Clifford

例外:

QiskitError – if the input is not a Clifford matrix.

classmethod from_operator(operator)[ソース]#

Create a Clifford from a operator.

Note that this function takes exponentially long time w.r.t. the number of qubits.

パラメータ:

operator (Operator) – An operator representing a Clifford to be converted.

戻り値:

the Clifford object for the operator.

戻り値の型:

Clifford

例外:

QiskitError – if the input is not a Clifford operator.

input_dims(qargs=None)#

Return tuple of input dimension for specified subsystems.

is_unitary()[ソース]#

Return True if the Clifford table is valid.

output_dims(qargs=None)#

Return tuple of output dimension for specified subsystems.

power(n)#

Return the compose of a operator with itself n times.

パラメータ:

n (int) – the number of times to compose with self (n>0).

戻り値:

the n-times composed operator.

戻り値の型:

Pauli

例外:

QiskitError – if the input and output dimensions of the operator are not equal, or the power is not a positive integer.

reshape(input_dims=None, output_dims=None, num_qubits=None)#

Return a shallow copy with reshaped input and output subsystem dimensions.

パラメータ:
  • input_dims (None or tuple) – new subsystem input dimensions. If None the original input dims will be preserved [Default: None].

  • output_dims (None or tuple) – new subsystem output dimensions. If None the original output dims will be preserved [Default: None].

  • num_qubits (None or int) – reshape to an N-qubit operator [Default: None].

戻り値:

returns self with reshaped input and output dimensions.

戻り値の型:

BaseOperator

例外:

QiskitError – if combined size of all subsystem input dimension or subsystem output dimensions is not constant.

tensor(other)[ソース]#

Return the tensor product with another Clifford.

パラメータ:

other (Clifford) – a Clifford object.

戻り値:

the tensor product \(a \otimes b\), where \(a\)

is the current Clifford, and \(b\) is the other Clifford.

戻り値の型:

Clifford

注釈

The tensor product can be obtained using the ^ binary operator. Hence a.tensor(b) is equivalent to a ^ b.

to_circuit()[ソース]#

Return a QuantumCircuit implementing the Clifford.

For N <= 3 qubits this is based on optimal CX cost decomposition from reference [1]. For N > 3 qubits this is done using the general non-optimal compilation routine from reference [2].

戻り値:

a circuit implementation of the Clifford.

戻り値の型:

QuantumCircuit

参照

  1. S. Bravyi, D. Maslov, Hadamard-free circuits expose the structure of the Clifford group, arXiv:2003.09412 [quant-ph]

  2. S. Aaronson, D. Gottesman, Improved Simulation of Stabilizer Circuits, Phys. Rev. A 70, 052328 (2004). arXiv:quant-ph/0406196

to_dict()[ソース]#

Return dictionary representation of Clifford object.

to_instruction()[ソース]#

Return a Gate instruction implementing the Clifford.

to_labels(array=False, mode='B')[ソース]#

Convert a Clifford to a list Pauli (de)stabilizer string labels.

For large Clifford converting using the array=True kwarg will be more efficient since it allocates memory for the full Numpy array of labels in advance.

Table 2 Stabilizer Representations#

Label

Phase

Symplectic

Matrix

Pauli

"+I"

0

\([0, 0]\)

\(\begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\)

\(I\)

"-I"

1

\([0, 0]\)

\(\begin{bmatrix} -1 & 0 \\ 0 & -1 \end{bmatrix}\)

\(-I\)

"X"

0

\([1, 0]\)

\(\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\)

\(X\)

"-X"

1

\([1, 0]\)

\(\begin{bmatrix} 0 & -1 \\ -1 & 0 \end{bmatrix}\)

\(-X\)

"Y"

0

\([1, 1]\)

\(\begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix}\)

\(iY\)

"-Y"

1

\([1, 1]\)

\(\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}\)

\(-iY\)

"Z"

0

\([0, 1]\)

\(\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\)

\(Z\)

"-Z"

1

\([0, 1]\)

\(\begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix}\)

\(-Z\)

パラメータ:
  • array (bool) – return a Numpy array if True, otherwise return a list (Default: False).

  • mode (Literal["S", "D", "B"]) – return both stabilizer and destabilizer if 「B」, return only stabilizer if 「S」 and return only destabilizer if 「D」.

戻り値:

The rows of the StabilizerTable in label form.

戻り値の型:

list or array

例外:

QiskitError – if stabilizer and destabilizer are both False.

to_matrix()[ソース]#

Convert operator to Numpy matrix.

to_operator()[ソース]#

Convert to an Operator object.

戻り値の型:

Operator

transpose()[ソース]#

Return the transpose of the Clifford.