Skip to main content

Why and how to transpile your circuits

Most quantum computers do not support arbitrary operations, but implement quantum computation using specific gates from a universal gateset. It is therefore necessary to convert a quantum circuit, consisting of various quantum operations, to one compatible with a specific physical quantum hardware device before executing the circuit on the device. This process is called transpilation. While Haiqu SDK takes care of transpilation automatically when you submit your circuits using the haiqu.run function, it may be useful to transpile your circuits and inspect the relations between the circuit characteristics and transpilation parameters. Haiqu SDK uses the open-source Rivet Transpiler for transpilation of your circuits. Transpiling a circuit is straightforward:
device = haiqu.get_device("fake_torino")

transpiled_circuit = haiqu.transpile(circuit, device) 
Every circuit stores the information about its transpiled versions, which can be viewed using:
haiqu.list_transpiled_circuits(circuit)
Light mode interface

Comparing transpilations

As haiqu.transpile offers a large number of parameters that allow you to customize the transpilation, such as optimization_level, initial_layout, basis_gates (for more details see the documentation of Rivet), it may sometimes be useful to compare the circuits resulting from transpilation with different parameters. For instance, one can change the optimization level during transpilation:
transpiled_circuit_opt0 = haiqu.transpile(circuit, device, optimization_level=0)
transpiled_circuit_opt3 = haiqu.transpile(circuit, device, optimization_level=3)
It is then convenient to compare the resulting circuits using haiqu.compare_metrics function:
haiqu.compare_metrics(transpiled_circuit_opt0, transpiled_circuit_opt3)
Light mode interface