Quantum State

Definition of the quantum state classes.

This package defines classes used to track quantum states in SeQUeNCe. The formalism-specific state classes are used by quantum managers, while FreeQuantumState is used by individual photons that do not use a quantum manager.

class sequence.kernel.quantum_state.BellDiagonalState(diag_elems: list[float], keys: list[int])

Class for representing a 2-qubit EPR pair in the Bell diagonal formalism.

Has 4 diagonal elements of density matrix in Bell basis.

state

diagonal elements of 2-qubit density matrix in Bell bases. Should be of length 4.

Type:

np.array

keys

list of keys (subsystems) associated with this state. Should be length 2.

Type:

list[int]

class sequence.kernel.quantum_state.DensityState(state: list[complex] | tuple[complex, ...] | list[list[complex]] | tuple[tuple[complex, ...], ...], keys: list[int], truncation: int = 1)

Class for representing a quantum state in the density matrix formalism.

state

density matrix values. NxN matrix with N = d ** len(keys), where d is dimension of elementary Hilbert space. Default is d = 2 for qubits.

Type:

np.array

keys

list of keys (subsystems) associated with this state.

Type:

list[int]

truncation

maximally allowed number of excited states for elementary subsystems. Default is 1 for qubit. dim = truncation + 1

Type:

int

class sequence.kernel.quantum_state.FreeQuantumState

Class used by photons to track internal quantum states.

This is an alternative to tracking states in a dedicated quantum manager, which adds simulation overhead. It defines several operations, including entanglement and measurement. For memories with an internal quantum state and certain photons, such as those stored in a memory or in parallel simulation, this class should not be used. Quantum states stored in a quantum manager class should be used instead. This module uses the ket vector formalism for storing and manipulating states.

state

list of complex coefficients in Z-basis.

Type:

tuple[complex]

entangled_states

list of entangled states (including self).

Type:

list[QuantumState]

combine_state(another_state: FreeQuantumState)

Method to tensor multiply two quantum states.

Parameters:

another_state (QuantumState) – state to entangle current state with.

Side Effects:

Modifies the entangled_states field for current state and another_state. Modifies the state field for current state and another_state.

measure(basis: tuple[tuple[complex]], rng: Generator) int

Method to measure a single quantum state.

Parameters:
  • basis (tuple[tuple[complex]]) – measurement basis, given as list of states (that are themselves lists of complex coefficients).

  • rng (Generator) – random number generator for measurement

Returns:

0/1 measurement result, corresponding to one basis vector.

Return type:

int

Side Effects:

Modifies the state field for current and any entangled states.

static measure_multiple(basis, states, rng: Generator)

Method to measure multiple qubits in a more complex basis.

May be used for bell state measurement.

Parameters:
  • basis (list[list[complex]]) – list of basis vectors.

  • states (list[QuantumState]) – list of quantum state objects to measure.

  • rng (Generator) – random number generator for measurement

Returns:

measurement result in given basis.

Return type:

int

Side Effects:

Will modify the state field of all entangled states.

random_noise(rng: Generator)

Method to add random noise to a single state.

Chooses a random angle to set the quantum state to (with no phase difference).

Side Effects:

Modifies the state field.

set_state(state: tuple[complex])

Method to change entangled state of multiple quantum states.

Parameters:

state (tuple[complex]) – new coefficients for state. Should be 2^n in length, where n is the length of entangled_states.

Side Effects:

Modifies the state field for current and entangled states.

set_state_single(state: tuple[complex])

Method to unentangle and set the state of a single quantum state object.

Parameters:

state (tuple[complex]) – 2-element list of new complex coefficients.

Side Effects:

Will remove current state from any entangled states (if present). Modifies the state field of current state.

class sequence.kernel.quantum_state.KetState(amplitudes: list[complex] | tuple[complex, ...], keys: list[int], truncation: int = 1)

Class for representing a quantum state in the ket vector formalism.

state

state vector. Should be of length d ** len(keys), where d is dimension of elementary Hilbert space. Default is 2 for qubits.

Type:

np.array

keys

list of keys (subsystems) associated with this state.

Type:

list[int]

truncation

maximally allowed number of excited states for elementary subsystems. Default is 1 for qubit. dim = truncation + 1

Type:

int

class sequence.kernel.quantum_state.StabilizerState(state: TableauSimulator | None, keys: list[int], seed: int | None = None)

Stim-backed stabilizer quantum state used by a quantum manager.

The state is stored internally by a stim.TableauSimulator. Tableau accessors are provided for inspection and interoperability with Stim.

state

the internal stabilizer state simulator.

Type:

TableauSimulator

keys

list of keys (subsystems) associated with this state.

Type:

list[int]

seed

random seed used by the simulator

Type:

int | None

canonical_stabilizers() list[PauliString]

Return the simulator’s canonical stabilizer generators, which describes the quantum state in a normalized stabilizer-generator form.

Distinction against forward tableau: many different Clifford circuits can produce the same stabilizer state.

Their forward tableaus may differ, but their canonical stabilizers can be the same because the final state is the same.

Returns:

canonical stabilizer generators.

Return type:

list[PauliString]

copy() StabilizerState

Create a copy of this stabilizer state.

Returns:

Copied state with copied keys and simulator.

Return type:

StabilizerState

current_forward_tableau() Tableau

Return the forward tableau for user-facing state inspection, which describes the Clifford transformation

Returns:

current forward tableau.

Return type:

Tableau

current_inverse_tableau() Tableau

Return current inverse tableau from simulator state.

Returns:

current inverse tableau.

Return type:

Tableau

get_seed() int | None

Get the current random seed for this state.

Returns:

Current random seed.

Return type:

int | None

set_seed(seed: int)

Set the random seed for this state, affecting future simulator operations.

Parameters:

seed (int) – new random seed to set.

classmethod zero_state(key: int, seed: int | None = None) StabilizerState

Create a single-qubit stabilizer state initialized to |0>.

Parameters:
  • key (int) – Quantum-manager key for the qubit.

  • seed (int | None) – Seed used by stim.TableauSimulator.

Returns:

New state bound to [key].

Return type:

StabilizerState

class sequence.kernel.quantum_state.State(**kwargs)

Base class for storing quantum states (abstract).

state

internal representation of the state, may vary by state type.

Type:

any

keys

list of keys pointing to the state, for use with a quantum manager.

Type:

list[int]