iqm.iqm_client.transpile.ResonatorStateTracker#

class iqm.iqm_client.transpile.ResonatorStateTracker(available_moves)#

Bases: object

Class for tracking the location of the |0> state of the resonators on the quantum computer as they are moved with the MOVE gates because the MOVE gate is not defined when acting on a |11> state. This is equivalent to tracking the which qubit state has been MOVEd into which resonator.

Parameters:
  • available_moves (dict[str, list[str]]) – A dictionary describing between which qubits a move gate is

  • available

  • resonator (for each) –

  • [qubit] (i.e. available_moves[resonator] =) –

Attributes

move_gate

resonators

Getter for the resonator registers that are being tracked.

supports_move

Bool whether any move gate is allowed.

Methods

_score_choice_heuristic(args)

A simple look ahead heuristic for choosing which qubit to move where.

apply_move(qubit, resonator)

Apply the logical changes of the resonator state location when a move gate between qubit and resonator is applied.

available_resonators_to_move(qubits)

Generates a dictionary with which resonators a qubit can be moved to, for each qubit.

choose_move_pair(qubits, remaining_instructions)

Chooses which qubit of the given qubits to move into which resonator, given a sequence of instructions to be executed later for looking ahead.

create_move_instructions(qubit, resonator[, ...])

Create the move instructions needed to move the given resonator state into the resonator if needed and then move resonator state to the given qubit.

from_circuit(circuit)

Constructor to make the ResonatorStateTracker from a circuit.

from_instructions(instructions)

Constructor to make the ResonatorStateTracker from a sequence of instructions.

from_quantum_architecture_specification(arch)

Constructor to make the ResonatorStateTracker from a QuantumArchitectureSpecification.

reset_as_move_instructions([resonators, ...])

Creates the move instructions needed to move all resonator states to their original state.

resonators_holding_qubits(qubits)

Returns the resonators that are currently holding one of the given qubit states.

update_qubits_in_resonator(qubits)

Applies the resonator to qubit map in the state of the resonator state tracker to the given qubits.

static from_quantum_architecture_specification(arch)#

Constructor to make the ResonatorStateTracker from a QuantumArchitectureSpecification.

Parameters:

arch (QuantumArchitectureSpecification) – The architecture to track the resonator state on.

Return type:

ResonatorStateTracker

static from_circuit(circuit)#

Constructor to make the ResonatorStateTracker from a circuit. It infers the resonator connectivity from the move gates in the circuit.

Parameters:

circuit (Circuit) – The circuit to track the resonator state on.

Return type:

ResonatorStateTracker

static from_instructions(instructions)#

Constructor to make the ResonatorStateTracker from a sequence of instructions. It infers the resonator connectivity from the move instructions.

Parameters:

instructions (Iterable[Instruction]) – The instructions to track the resonator state on.

Return type:

ResonatorStateTracker

property resonators: Iterable[str]#

Getter for the resonator registers that are being tracked.

property supports_move: bool#

Bool whether any move gate is allowed.

apply_move(qubit, resonator)#

Apply the logical changes of the resonator state location when a move gate between qubit and resonator is applied.

Parameters:
  • qubit (str) – The moved qubit.

  • resonator (str) – The moved resonator.

Raises:
  • CircuitExecutionError – When the move is not allowed, either because the resonator does not exist, the move

  • gate is not valid between this qubit-resonator pair, or the resonator state is currently in a different

  • qubit register.

Return type:

None

create_move_instructions(qubit, resonator, apply_move=True, alt_qubit_names=None)#

Create the move instructions needed to move the given resonator state into the resonator if needed and then move resonator state to the given qubit.

Parameters:
  • qubit (str) – The qubit

  • resonator (str) – The resonator

  • apply_move (bool | None) – Whether the moves should be applied to the resonator tracking state.

  • True. (Defaults to) –

  • alt_qubit_names (dict[str, str] | None) – Mapping of logical qubit names to physical qubit names.

Yields:

The one or two move instructions needed.

Return type:

Iterable[Instruction]

reset_as_move_instructions(resonators=None, apply_move=True, alt_qubit_names=None)#

Creates the move instructions needed to move all resonator states to their original state.

Parameters:
  • resonators (Iterable[str] | None) – The set of resonators to reset, if None, all resonators will

  • None. (be reset. Defaults to) –

  • apply_move (bool | None) – Whether the moves should be applied to the resonator tracking state.

  • True. (Defaults to) –

  • alt_qubit_names (dict[str, str] | None) –

Returns:

The instructions needed to move all qubit states out of the resonators.

Return type:

list[Instruction]

available_resonators_to_move(qubits)#

Generates a dictionary with which resonators a qubit can be moved to, for each qubit.

Parameters:

qubits (Iterable[str]) – The qubits to check which move gates are available.

Returns:

The dict that maps each qubit to a list of resonators.

Return type:

dict[str, list[str]]

resonators_holding_qubits(qubits)#

Returns the resonators that are currently holding one of the given qubit states.

Parameters:

qubits (Iterable[str]) – The qubits

Returns:

The resonators

Return type:

list[str]

choose_move_pair(qubits, remaining_instructions)#

Chooses which qubit of the given qubits to move into which resonator, given a sequence of instructions to be executed later for looking ahead.

Parameters:
  • qubits (list[str]) – The qubits to choose from

  • remaining_instructions (list[list[str]]) – The instructions to use for the look-ahead.

Raises:

CircuitExecutionError – When no move pair is available, most likely because the circuit was not routed.

Returns:

A sorted preference list of resonator and qubit chosen to apply the move on.

Return type:

list[tuple[str, str, list[list[str]]]]

update_qubits_in_resonator(qubits)#

Applies the resonator to qubit map in the state of the resonator state tracker to the given qubits.

Parameters:

qubits (Iterable[str]) – The qubits or resonators to apply the state to

Returns:

The remapped qubits

Return type:

list[str]