transpile

transpile(self, backend=None, **kwargs)[source]

Transpile the circuit.

If the circuit has a target_backend assigned and backend=None then the target backend is used for transpilation. All other transpile functionality remains unchanged.

Parameters
  • backend (BaseBackend) – Backend to transpile for.

  • kwargs – any other transpiler kwargs.

Returns

Transpiled quantum circuit.

Return type

QuantumCircuit

Example

from qiskit import QuantumCircuit
import kaleidoscope.qiskit
from kaleidoscope.qiskit.services import Simulators

qc = QuantumCircuit(5) >> Simulators.aer_vigo_simulator
qc.h(0)
qc.cx(0, range(1,5))

new_qc = qc.transpile()
new_qc.draw('mpl')
Traceback (most recent call last):
  File "<ipython-input-1-02b2282ac9a8>", line 5, in <module>
    qc = QuantumCircuit(5) >> Simulators.aer_vigo_simulator
  File "/opt/miniconda3/envs/qiskit/lib/python3.9/site-packages/kaleidoscope/qiskit/services/_simulators.py", line 190, in __getattr__
    raise AttributeError("Couldn't load {}.".format(attr))
AttributeError: Couldn't load aer_vigo_simulator.

Use %tb to get the full traceback.