Transpilation#

QCut.transpile_subcircuits(cut_circuit: CutCircuit, backend, optimization_level: int = 3, transpile_options: dict | None = None, use_iqm_transpiler: bool = True) → CutCircuit[source]#

Transpile subcircuits for a given backend. More efficient than transpiling experiment circuits as it only transpiles each subcircuit once instead of each experiment circuit. However, may lead to suboptimal transpilation results as the transpiler cannot use the backend object directly due to need to retain some placeholder gates for cuts and observables. transpile_options can be used to pass additional options to the transpiler. For more control over transpilation of experiment circuits, use transpile_experiments or manually transpile them.

On an IQM backend this gives up IQM’s single-qubit optimisation, which would otherwise commute Z rotations across the cut placeholders and put them on the wrong side of a cut. Nothing can be told to leave the placeholders alone – a barrier is a scheduling directive there, not an algebraic wall – so circuits come out perhaps a fifth deeper than they need to be. transpile_experiments() has no placeholders left to protect and keeps the optimisation, so it is the one to use when the depth matters more than the transpilation time.

Parameters:
  • cut_circuit (CutCircuit) – The split circuit whose subcircuits are transpiled.

  • backend – Backend to transpile to.

  • optimization_level (int) – Optimization level for transpilation (0-3).

  • transpile_options (dict) – Arguments passed to the transpiler.

  • use_iqm_transpiler (bool) – Whether an IQM backend may use IQM’s transpiler. Pass False for the ordinary qiskit path.

Returns:

Transpiled subcircuits wrapped in CutCircuit class.

Return type:

CutCircuit

QCut.transpile_experiments(cut_experiment: CutExperiment, backend, optimization_level: int = 3, transpile_options: dict | None = None, use_iqm_transpiler: bool = True) → CutExperiment[source]#

Transpile experiment circuits. Transpiles all generated experiment circuits for a given backend. Most often one should use transpile_subcircuits instead, as that only transpiles subcircuits before experiment generation which is a lot more efficient. This function is mainly provided for special cases where one needs/wants extra control over the transpilation of experiment circuits.

As with transpile_subcircuits(), an IQM backend is handed to IQM’s own transpiler when the adapter is installed, with the same defaults inverted and for the same reasons. No placeholders are left at this point, so nothing has to be hidden from it as barriers – and nothing has to give up IQM’s single-qubit optimisation either, which is why this route produces the shallower circuits of the two, at the cost of transpiling every experiment circuit rather than each subcircuit once. The layout still has to be recorded afterwards.

Parameters:
  • cut_experiment – (CutExperiment): Experiment circuits to be transpiled.

  • backend (str) – Backend to transpile to.

  • optimization_level (int) – Optimization level for transpilation (0-3).

  • transpile_options (dict) – Arguments passed to the transpiler.

  • use_iqm_transpiler (bool) – Whether an IQM backend may use IQM’s transpiler. Pass False for the ordinary qiskit path.

Returns:

Transpiled experiment circuits wrapped in CutExperiment class.

Return type:

CutExperiment

QCut.transpile_circuits(circuits: CutCircuit | CutExperiment | list[QuantumCircuit], backend, optimization_level: int = 3, transpile_options: dict | None = None, use_iqm_transpiler: bool = True)[source]#

Transpile for a backend, whatever stage the circuits have reached.

A CutCircuit goes to transpile_subcircuits(), which has placeholders to protect, and a CutExperiment to transpile_experiments(), which does not. Plain circuits are transpiled as they are, which is what a backend given circuits rather than an experiment needs – see ParallelBackend.

Parameters:
  • circuits – a cut circuit, an experiment, or circuits with nothing left to hide.

  • backend – backend to transpile to.

  • optimization_level (int) – optimization level for transpilation (0-3).

  • transpile_options (dict) – arguments passed to the transpiler.

  • use_iqm_transpiler (bool) – whether an IQM backend may use IQM’s transpiler.

Returns:

The same kind of thing it was given, transpiled.