Checking that a conversion is correct

How to verify that the same circuit gives the same answer in two tools, and what the lab has and has not tested.

8 min read · reviewed December 2026

What was tested here

  • All 13 example circuits were exported to OpenQASM 2.0 and to Qiskit code, read back by the importer, and simulated. The outcome probabilities matched the originals to nine decimal places.
  • The angle reader was tested on expressions like 3*pi/4, −pi/2, (pi+pi)/4 and plain decimals.
  • The Cirq, PennyLane and OpenQASM 3.0 outputs were written from the gate names in each tool’s documentation, as recalled when the lab was built, and were not run.

The generated Python was not run against installed copies of Qiskit, Cirq or PennyLane in the lab’s tests, since they were not available. Gate names and signatures change across releases, so try the code and check the version you use.

A method for you

  • Compute the exact outcome chances in the lab.
  • Run the converted code in your tool with a state-vector or exact-probability option if it has one.
  • Convert the tool’s bit strings to this site’s order using the Bit order tab.
  • Compare. Differences below shot noise are expected, and larger ones point to a conversion problem.

The sizes of the examples

These are the circuits the conversion was tested on.

The 13 example circuits in the Circuit Builder, with their size. Any of them can be loaded in the Convert tab.
CircuitQubitsGatesTwo-qubit or largerDepth
Superposition with one Hadamard gate1101
Interference: why H, Z, H flips a bit1303
Bell state: your first entangled pair2212
GHZ state: three-qubit entanglement3323
SWAP built from three CNOT gates2333
Toffoli gate as a reversible AND3111
Superdense coding: two bits in one qubit2626
Quantum teleportation (deferred measurement)3746
Deutsch–Jozsa: constant or balanced in one query3714
Bernstein–Vazirani: finding a hidden string41025
Grover search on two qubits21227
Quantum Fourier transform on three qubits3747
A quantum random bit generator3301

Common causes of a mismatch

  • Reversed bit order.
  • A rotation angle in degrees where radians are expected.
  • A CZ-power exponent entered as θ instead of θ/π in Cirq.
  • Measuring into classical bits in a different order.

Try it

Questions

Is a matching probability table proof of equal circuits?

No. Different circuits can have the same output chances. It is a good sanity check, not a proof.

Should I compare state vectors?

If your tool offers them, yes, but remember global phase and bit order may differ.

What if the code fails to run?

Check the installed version and the documentation. Names such as the Aer import have changed between releases.

Read next

Sources and further reading

Check the original sources for exact citations.