Quantum Manager

This module defines the quantum manager class, to track quantum states.

The states may currently be defined in two possible ways:
  • KetState (with the QuantumManagerKet class)

  • DensityMatrix (with the QuantumManagerDensity class)

The manager defines an API for interacting with quantum states.

class src.kernel.quantum_manager.QuantumManager(formalism: str, truncation: int = 1)

Class to track and manage quantum states (abstract).

All states stored are of a single formalism (by default as a ket vector).

states

mapping of state keys to quantum state objects.

Type:

Dict[int, State]

truncation

maximally allowed number of excited states for elementary subsystems. Default is 1 for qubit.

Type:

int

dim

subsystem Hilbert space dimension. dim = truncation + 1

Type:

int

get(key: int) State

Method to get quantum state stored at an index.

Parameters:

key (int) – key for quantum state.

Returns:

quantum state at supplied key.

Return type:

State

abstract new(state: any) int

Method to create a new quantum state.

Parameters:

state (any) – complex amplitudes of new state. Type depends on type of subclass.

Returns:

key for new state generated.

Return type:

int

remove(key: int) None

Method to remove state stored at key.

abstract run_circuit(circuit: Circuit, keys: List[int], meas_samp=None) Dict[int, int]

Method to run a circuit on a given set of quantum states.

Parameters:
  • circuit (Circuit) – quantum circuit to apply.

  • keys (List[int]) – list of keys for quantum states to apply circuit to.

  • meas_samp (float) – random sample used for measurement.

Returns:

dictionary mapping qstate keys to measurement results.

Return type:

Dict[int, int]

abstract set(keys: List[int], amplitudes: any) None

Method to set quantum state at a given key(s).

Parameters:
  • keys (List[int]) – key(s) of state(s) to change.

  • amplitudes (any) – Amplitudes to set state to, type determined by type of subclass.

class src.kernel.quantum_manager.QuantumManagerDensity

Class to track and manage states with the density matrix formalism.

new(state=([1 + 0j, 0j], [0j, 0j])) int

Method to create a new quantum state.

Parameters:

state (any) – complex amplitudes of new state. Type depends on type of subclass.

Returns:

key for new state generated.

Return type:

int

run_circuit(circuit: Circuit, keys: List[int], meas_samp=None) Dict[int, int]

Method to run a circuit on a given set of quantum states.

Parameters:
  • circuit (Circuit) – quantum circuit to apply.

  • keys (List[int]) – list of keys for quantum states to apply circuit to.

  • meas_samp (float) – random sample used for measurement.

Returns:

dictionary mapping qstate keys to measurement results.

Return type:

Dict[int, int]

set(keys: List[int], state: List[List[complex]]) None

Method to set the quantum state at the given keys.

The state argument should be passed as List[List[complex]], where each internal list is a row. However, the state may also be given as a one-dimensional pure state. If the list is one-dimensional, will be converted to matrix with the outer product operation.

Parameters:
  • keys (List[int]) – list of quantum manager keys to modify.

  • state – quantum state to set input keys to.

class src.kernel.quantum_manager.QuantumManagerDensityFock(truncation: int = 1)

Class to track and manage Fock states with the density matrix formalism.

add_loss(key, loss_rate)

Method to apply generalized amplitude damping channel on a single subspace corresponding to key.

Parameters:
  • key (int) – key for the subspace experiencing loss.

  • loss_rate (float) – loss rate for the quantum channel.

build_ladder()

Generate matrix of creation and annihilation (ladder) operators on truncated Hilbert space.

measure(keys: List[int], povms: List[array], meas_samp: float) int

Method to measure subsystems at given keys in POVM formalism.

Serves as wrapper for private _measure method, performing quantum manager specific operations.

Parameters:
  • keys (List[int]) – list of keys to measure.

  • povms – (List[array]): list of POVM operators to use for measurement.

  • meas_samp (float) – random measurement sample to use for computing resultant state.

Returns:

measurement as index of matching POVM in supplied tuple.

Return type:

int

new(state=None) int

Method to create a new state with key

Parameters:

state (Union[str, List[complex], List[List[complex]]]) – amplitudes of new state. Default value is ‘gnd’: create zero-excitation state with current truncation. Other inputs are passed to the constructor of DensityState.

run_circuit(circuit: Circuit, keys: List[int], meas_samp=None) Dict[int, int]

Currently the Fock states do not support quantum circuits. This method is only to implement abstract method of parent class and SHOULD NOT be called after instantiation.

set(keys: List[int], state: List[List[complex]]) None

Method to set the quantum state at the given keys.

The state argument should be passed as List[List[complex]], where each internal list is a row. However, the state may also be given as a one-dimensional pure state. If the list is one-dimensional, will be converted to matrix with the outer product operation.

Parameters:
  • keys (List[int]) – list of quantum manager keys to modify.

  • state – quantum state to set input keys to.

set_to_zero(key: int)

set the state to ground (zero) state.

class src.kernel.quantum_manager.QuantumManagerKet

Class to track and manage quantum states with the ket vector formalism.

new(state=(1 + 0j, 0j)) int

Method to create a new quantum state.

Parameters:

state (any) – complex amplitudes of new state. Type depends on type of subclass.

Returns:

key for new state generated.

Return type:

int

run_circuit(circuit: Circuit, keys: List[int], meas_samp=None) Dict[int, int]

Method to run a circuit on a given set of quantum states.

Parameters:
  • circuit (Circuit) – quantum circuit to apply.

  • keys (List[int]) – list of keys for quantum states to apply circuit to.

  • meas_samp (float) – random sample used for measurement.

Returns:

dictionary mapping qstate keys to measurement results.

Return type:

Dict[int, int]

set(keys: List[int], amplitudes: List[complex]) None

Method to set quantum state at a given key(s).

Parameters:
  • keys (List[int]) – key(s) of state(s) to change.

  • amplitudes (any) – Amplitudes to set state to, type determined by type of subclass.