Quantum State¶
Definition of the quantum state classes.
This module defines the classes used to track quantum states in SeQUeNCe. These include 2 classes used by a quantum manager, and one used for individual photons:
The KetState class represents the ket vector formalism and is used by a quantum manager.
The DensityState class represents the density matrix formalism and is also used by a quantum manager.
The FreeQuantumState class uses the ket vector formalism, and is used by individual photons (not the quantum manager).
- class src.kernel.quantum_state.DensityState(state: List[List[complex]], keys: List[int], truncation: int = 1)¶
Class to represent an individual quantum state as a density matrix.
- 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 src.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 src.kernel.quantum_state.KetState(amplitudes: List[complex], keys: List[int], truncation: int = 1)¶
Class to represent an individual quantum state as a ket vector.
- 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 src.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]
- src.kernel.quantum_state.swap_bits(num, pos1, pos2)¶
Swaps bits in num at positions 1 and 2.
Used by quantum_state.measure_multiple method.