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.
| Circuit | Qubits | Gates | Two-qubit or larger | Depth |
|---|---|---|---|---|
| Superposition with one Hadamard gate | 1 | 1 | 0 | 1 |
| Interference: why H, Z, H flips a bit | 1 | 3 | 0 | 3 |
| Bell state: your first entangled pair | 2 | 2 | 1 | 2 |
| GHZ state: three-qubit entanglement | 3 | 3 | 2 | 3 |
| SWAP built from three CNOT gates | 2 | 3 | 3 | 3 |
| Toffoli gate as a reversible AND | 3 | 1 | 1 | 1 |
| Superdense coding: two bits in one qubit | 2 | 6 | 2 | 6 |
| Quantum teleportation (deferred measurement) | 3 | 7 | 4 | 6 |
| Deutsch–Jozsa: constant or balanced in one query | 3 | 7 | 1 | 4 |
| Bernstein–Vazirani: finding a hidden string | 4 | 10 | 2 | 5 |
| Grover search on two qubits | 2 | 12 | 2 | 7 |
| Quantum Fourier transform on three qubits | 3 | 7 | 4 | 7 |
| A quantum random bit generator | 3 | 3 | 0 | 1 |
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
- A. W. Cross, L. S. Bishop, J. A. Smolin and J. M. Gambetta, “Open quantum assembly language” (2017)
- A. Cross et al., “OpenQASM 3: A broader and deeper quantum assembly language” (2022)
- Qiskit, Cirq and PennyLane documentation
- Frameworks overview on this site
- Circuit Builder gate reference
Check the original sources for exact citations.