qiskit.quantum_info.StabilizerState¶

class StabilizerState(data, validate=True)[código fonte]

StabilizerState class. Stabilizer simulator using the convention from reference [1]. Based on the internal class Clifford.

from qiskit import QuantumCircuit
from qiskit.quantum_info import StabilizerState, Pauli

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

# Print the StabilizerState
print(stab)

# Calculate the StabilizerState measurement probabilities dictionary
print (stab.probabilities_dict())

# Calculate expectation value of the StabilizerState
print (stab.expectation_value(Pauli('ZZ')))

StabilizerState(StabilizerTable: ['+XX', '+ZZ'])
{'00': 0.5, '11': 0.5}
1


Referências

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

Initialize a StabilizerState object.

Parâmetros
• (StabilizerState or Clifford or Pauli or QuantumCircuit or (data) – qiskit.circuit.Instruction): Data from which the stabilizer state can be constructed.

• validate (boolean) – validate that the stabilizer state data is a valid Clifford.

__init__(data, validate=True)[código fonte]

Initialize a StabilizerState object.

Parâmetros
• (StabilizerState or Clifford or Pauli or QuantumCircuit or (data) – qiskit.circuit.Instruction): Data from which the stabilizer state can be constructed.

• validate (boolean) – validate that the stabilizer state data is a valid Clifford.

Methods

 __init__(data[, validate]) Initialize a StabilizerState object. Return the conjugate of the operator. Make a copy of current operator. dims([qargs]) Return tuple of input dimension for specified subsystems. evolve(other[, qargs]) Evolve a stabilizer state by a Clifford operator. expand(other) Return the tensor product stabilzier state other ⊗ self. expectation_value(oper[, qargs]) Compute the expectation value of an operator. is_valid([atol, rtol]) Return True if a valid StabilizerState. measure([qargs]) Measure subsystems and return outcome and post-measure state. probabilities([qargs, decimals]) Return the subsystem measurement probability vector. probabilities_dict([qargs, decimals]) Return the subsystem measurement probability dictionary. Return the purity of the quantum state, which equals to 1, since it is always a pure state. reset([qargs]) Reset state or subsystems to the 0-state. sample_counts(shots[, qargs]) Sample a dict of qubit measurement outcomes in the computational basis. sample_memory(shots[, qargs]) Sample a list of qubit measurement outcomes in the computational basis. seed([value]) Set the seed for the quantum state RNG. tensor(other) Return the tensor product stabilzier state self ⊗ other. Convert state to matrix operator class Return the trace of the stabilizer state as a density matrix, which equals to 1, since it is always a pure state.

Attributes

 clifford Return StabilizerState Clifford data dim Return total state dimension. num_qubits Return the number of qubits if a N-qubit state or None otherwise.
property clifford

Return StabilizerState Clifford data

conjugate()[código fonte]

Return the conjugate of the operator.

copy()

Make a copy of current operator.

property dim

dims(qargs=None)

Return tuple of input dimension for specified subsystems.

evolve(other, qargs=None)[código fonte]

Evolve a stabilizer state by a Clifford operator.

Parâmetros
Retorna

the output stabilizer state.

Tipo de retorno

StabilizerState

Levanta
• QiskitError – if other is not a StabilizerState.

• QiskitError – if the operator dimension does not match the specified StabilizerState subsystem dimensions.

expand(other)[código fonte]

Return the tensor product stabilzier state other ⊗ self.

Parâmetros

other (StabilizerState) – a stabilizer state object.

Retorna

the tensor product operator other ⊗ self.

Tipo de retorno

StabilizerState

Levanta

QiskitError – if other is not a StabilizerState.

expectation_value(oper, qargs=None)[código fonte]

Compute the expectation value of an operator.

Parâmetros
• oper (BaseOperator) – an operator to evaluate expval.

• qargs (None or list) – subsystems to apply the operator on.

Retorna

the expectation value (only 0 or 1 or -1).

Tipo de retorno

complex

is_valid(atol=None, rtol=None)[código fonte]

Return True if a valid StabilizerState.

measure(qargs=None)[código fonte]

Measure subsystems and return outcome and post-measure state.

Note that this function uses the QuantumStates internal random number generator for sampling the measurement outcome. The RNG seed can be set using the seed() method.

Parâmetros

qargs (list or None) – subsystems to sample measurements for, if None sample measurement of all subsystems (Default: None).

Retorna

the pair (outcome, state) where outcome is the

measurement outcome string label, and state is the collapsed post-measurement stabilizer state for the corresponding outcome.

Tipo de retorno

tuple

property num_qubits

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

probabilities(qargs=None, decimals=None)[código fonte]

Return the subsystem measurement probability vector.

Measurement probabilities are with respect to measurement in the computation (diagonal) basis.

Parâmetros
• qargs (None or list) – subsystems to return probabilities for, if None return for all subsystems (Default: None).

• decimals (None or int) – the number of decimal places to round values. If None no rounding is done (Default: None).

Retorna

The Numpy vector array of probabilities.

Tipo de retorno

np.array

probabilities_dict(qargs=None, decimals=None)[código fonte]

Return the subsystem measurement probability dictionary.

Measurement probabilities are with respect to measurement in the computation (diagonal) basis.

This dictionary representation uses a Ket-like notation where the dictionary keys are qudit strings for the subsystem basis vectors. If any subsystem has a dimension greater than 10 comma delimiters are inserted between integers so that subsystems can be distinguished.

Parâmetros
• qargs (None or list) – subsystems to return probabilities for, if None return for all subsystems (Default: None).

• decimals (None or int) – the number of decimal places to round values. If None no rounding is done (Default: None).

Retorna

The measurement probabilities in dict (ket) form.

Tipo de retorno

dict

purity()[código fonte]

Return the purity of the quantum state, which equals to 1, since it is always a pure state.

Retorna

the purity (should equal 1).

Tipo de retorno

double

Levanta

QiskitError – if input is not a StabilizerState.

reset(qargs=None)[código fonte]

Reset state or subsystems to the 0-state.

Parâmetros

qargs (list or None) – subsystems to reset, if None all subsystems will be reset to their 0-state (Default: None).

Retorna

the reset state.

Tipo de retorno

StabilizerState

If all subsystems are reset this will return the ground state on all subsystems. If only some subsystems are reset this function will perform a measurement on those subsystems and evolve the subsystems so that the collapsed post-measurement states are rotated to the 0-state. The RNG seed for this sampling can be set using the seed() method.

sample_counts(shots, qargs=None)

Sample a dict of qubit measurement outcomes in the computational basis.

Parâmetros
• shots (int) – number of samples to generate.

• qargs (None or list) – subsystems to sample measurements for, if None sample measurement of all subsystems (Default: None).

Retorna

sampled counts dictionary.

Tipo de retorno

Counts

This function samples measurement outcomes using the measure probabilities() for the current state and qargs. It does not actually implement the measurement so the current state is not modified.

The seed for random number generator used for sampling can be set to a fixed value by using the stats seed() method.

sample_memory(shots, qargs=None)[código fonte]

Sample a list of qubit measurement outcomes in the computational basis.

Parâmetros
• shots (int) – number of samples to generate.

• qargs (None or list) – subsystems to sample measurements for, if None sample measurement of all subsystems (Default: None).

Retorna

list of sampled counts if the order sampled.

Tipo de retorno

np.array

This function implements the measurement measure() method.

The seed for random number generator used for sampling can be set to a fixed value by using the stats seed() method.

seed(value=None)

Set the seed for the quantum state RNG.

tensor(other)[código fonte]

Return the tensor product stabilzier state self ⊗ other.

Parâmetros

other (StabilizerState) – a stabilizer state object.

Retorna

the tensor product operator self ⊗ other.

Tipo de retorno

StabilizerState

Levanta

QiskitError – if other is not a StabilizerState.

to_operator()[código fonte]

Convert state to matrix operator class

trace()[código fonte]

Return the trace of the stabilizer state as a density matrix, which equals to 1, since it is always a pure state.

Retorna

the trace (should equal 1).

Tipo de retorno

double

Levanta

QiskitError – if input is not a StabilizerState.