iqm.iqm_client.transpile.ResonatorStateTracker#

class iqm.iqm_client.transpile.ResonatorStateTracker(available_moves: dict[str, list[str]])#

Bases: object

Class for tracking the location of the \(|0\rangle\) 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\rangle\) state. This is equivalent to tracking 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, for each resonator, i.e. available_moves[resonator] = [qubit]

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_dynamic_architecture(arch)

Constructor to make the ResonatorStateTracker from a DynamicQuantumArchitecture.

from_instructions(instructions)

Constructor to make the ResonatorStateTracker from a sequence of instructions.

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_dynamic_architecture(arch: DynamicQuantumArchitecture) ResonatorStateTracker#

Constructor to make the ResonatorStateTracker from a DynamicQuantumArchitecture.

Parameters:

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

Return type:

ResonatorStateTracker

static from_circuit(circuit: Circuit) ResonatorStateTracker#

Constructor to make the ResonatorStateTracker from a circuit.

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: Iterable[Instruction]) ResonatorStateTracker#

Constructor to make the ResonatorStateTracker from a sequence of instructions.

Infers the resonator connectivity from the MOVE gates.

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: str, resonator: str) None#

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:

CircuitTranspilationError – MOVE is not allowed, either because the resonator does not exist, the MOVE gate is not available between this qubit-resonator pair, or the resonator state is currently in a different qubit register.

Return type:

None

create_move_instructions(qubit: str, resonator: str, apply_move: bool | None = True, alt_qubit_names: dict[str, str] | None = None) Iterable[Instruction]#

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.

  • 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: Iterable[str] | None = None, apply_move: bool | None = True, alt_qubit_names: dict[str, str] | None = None) list[Instruction]#

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 be reset.

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

  • 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: Iterable[str]) dict[str, list[str]]#

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: Iterable[str]) list[str]#

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: list[str], remaining_instructions: list[list[str]]) list[tuple[str, str, list[list[str]]]]#

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:

CircuitTranspilationError – 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: Iterable[str]) list[str]#

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]