Skip to content
Pasqal Documentation

QutipState

class pulser_simulation.QutipState(state, *, eigenstates)

Bases: State[SupportsComplex, float]

A quantum state stored as a qutip.Qobj.

Parameters:
  • state (Qobj) – The state as a qutip.Qobj. Can be a statevector or a density matrix.

  • eigenstates (Sequence[Literal['u', 'd', 'r', 'g', 'h', 'x'] | Literal['0', '1']]) – The eigenstates that form a qudit’s eigenbasis, each given as an individual character. The order of the eigenstates matters, as for eigenstates (“a”, “b”, …), “a” will be associated to eigenvector (1, 0, …), “b” to (0, 1, …) and so on.

Attributes

eigenstates

The eigenstates that form a qudit's eigenbasis.

n_qudits

The number of qudits in the state.

qudit_dim

The dimensions (ie number of eigenstates) of a qudit.

Methods

bitstring_probabilities

Extracts the probabilties of measuring each bitstring.

from_state_amplitudes

Construct the state from its basis states' amplitudes.

get_basis_state_from_index

Generates a basis state combination from its index in the state.

infer_one_state

Infers the state measured as 1 from the eigenstates.

overlap

Compute the overlap between this state and another of the same type.

probabilities

Extracts the probabilties of measuring each basis state combination.

sample

Sample bitstrings from the state, taking into account error rates.

to_qobj

Returns a copy of the state's Qobj representation.

Signatures

bitstring_probabilities(*, one_state=None, cutoff=1e-12)

Extracts the probabilties of measuring each bitstring.

Parameters:
  • one_state (Literal['u', 'd', 'r', 'g', 'h', 'x'] | Literal['0', '1'] | None, default: None) – The eigenstate that measures to 1. Can be left undefined if the state’s eigenstates form a known eigenbasis with a defined “one state”.

  • cutoff (float, default: 1e-12) – The value below which a probability is considered to be zero.

Return type:

Mapping[str, float]

Returns:

A mapping between bitstrings and their respective probabilities.

classmethod from_state_amplitudes(*, eigenstates, amplitudes)

Construct the state from its basis states’ amplitudes.

Only states constructed with this method are allowed in remote backend.

Parameters:
  • eigenstates (Sequence[Literal['u', 'd', 'r', 'g', 'h', 'x'] | Literal['0', '1']]) – The basis states (e.g., (‘r’, ‘g’)).

  • amplitudes (Mapping[str, TypeVar(ArgScalarType)]) – A mapping between basis state combinations and complex amplitudes (e.g., {“rgr”: 0.5, “grg”: 0.5}).

Return type:

TypeVar(StateType, bound= State)

Returns:

The state constructed from the amplitudes.

get_basis_state_from_index(index)

Generates a basis state combination from its index in the state.

Assumes a state vector representation regardless of the actual support of the state.

Parameters:

index (int) – The position of the state in a state vector.

Return type:

str

Returns:

The basis state combination for the desired index.

infer_one_state()

Infers the state measured as 1 from the eigenstates.

Only works when the eigenstates form a known eigenbasis with a well-defined “one state”.

Return type:

Literal['u', 'd', 'r', 'g', 'h', 'x'] | Literal['0', '1']

overlap(other)

Compute the overlap between this state and another of the same type.

Generally computes Tr[AB] for mixed states A and B, which corresponds to |<a|b>|^2 for pure states A=|a><a| and B=|b><b|.

Parameters:

other (QutipState) – The other state.

Return type:

float

Returns:

The overlap between the two states.

probabilities(*, cutoff=1e-12)

Extracts the probabilties of measuring each basis state combination.

The probabilities are normalized to sum to 1.

Parameters:

cutoff (float, default: 1e-12) – The value below which a probability is considered to be zero.

Return type:

dict[str, float]

Returns:

A mapping between basis state combinations and their respective probabilities.

sample(*, num_shots, one_state=None, p_false_pos=0.0, p_false_neg=0.0)

Sample bitstrings from the state, taking into account error rates.

Parameters:
  • num_shots (int) – How many bitstrings to sample.

  • one_state (Literal['u', 'd', 'r', 'g', 'h', 'x'] | Literal['0', '1'] | None, default: None) – The eigenstate that measures to 1. Can be left undefined if the state’s eigenstates form a known eigenbasis with a defined “one state”.

  • p_false_pos (float, default: 0.0) – The rate at which a 0 is read as a 1.

  • p_false_neg (float, default: 0.0) – The rate at which a 1 is read as a 0.

Return type:

Counter[str]

Returns:

The measured bitstrings, by count.

to_qobj()

Returns a copy of the state’s Qobj representation.

Return type:

Qobj

property eigenstates: tuple[Literal['u', 'd', 'r', 'g', 'h', 'x', '0', '1'], ...]

The eigenstates that form a qudit’s eigenbasis.

The order of the states should match the order in a numerical (ie state vector or density matrix) representation. For example, with eigenstates (“a”, “b”, …), “a” will be associated to eigenvector (1, 0, …), “b” to (0, 1, …) and so on.

property n_qudits: int

The number of qudits in the state.

property qudit_dim: int

The dimensions (ie number of eigenstates) of a qudit.