3
$\begingroup$

When I run a certain circuit (using several qubits, it is not a very simple one) in IBM quantum experience, I find that sometimes it is transpiled in one way and sometimes in another. And the final results are (quite) different. Specifically, I notice this fact in IBM q-computers with more than 5 qubits.

Is it possible to avoid this apparently random behaviour? Is it possible to control the way the circuit is transpiled?

$\endgroup$
1
  • $\begingroup$ Hi and welcome to Quantum Computing SE. Different quantum processor have different physical implementation, or in other words they differ in connections among qubits (see for example physical implementation of Yorktown and Ourense). As a result, a circuit can be transpilled differently, mainly in terms of additional swap gates. $\endgroup$ Apr 1, 2020 at 21:54

1 Answer 1

5
$\begingroup$

The default Qiskit transpiler uses a stochastic swap (StochasticSwap) method to insert the swap gates needed to map the circuit to a given device topology. As the name suggests, this routine uses random numbers in the swap computation, leading to an output that varies. This is an heuristic that is used to get around the fact that computing the optimal answer is NP-hard.

$\endgroup$
2
  • 1
    $\begingroup$ If you use Qiskit you can make the behavior deterministic by passing a seed: transpiled_circuit = transpile(circuit, backend, seed_transpiler=2) $\endgroup$
    – Ali Javadi
    Apr 1, 2020 at 22:28
  • $\begingroup$ Thanks for the explanation! $\endgroup$ Apr 2, 2020 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.