Liam

Liam

Joined October 5, 2024

Karma 3

Liam

4

Posted by lgh

The issue with your code is that it's trying to use non-unitary operations in a unitary-only framework. To address this, you can use unitary reconstruction, which introduces new qubits and applies the principle of deferred measurement. I wrote a library that does exactly this.
The problem with your code is that the resets have no effect, since you're not applying any operations to the reset qubits. Here's an equivalent reset-free code that you can use:
OPENQASM 2.0;
include "qelib1.inc";
qreg q[18];
creg c[14];
h q[0];
h q[1];
h q[2];
h q[3];
h q[4];
h q[5];
CX q[0], q[6];
CX q[1], q[8];
CX q[2], q[10];
CX q[3], q[6];
CX q[3], q[7];
CX q[4], q[8];
CX q[4], q[9];
CX q[5], q[10];
CX q[5], q[11];
x q[6];
x q[8];
x q[9];
x q[10];
x q[11];
measure q[12] -> c[12];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
measure q[4] -> c[4];
measure q[5] -> c[5];
measure q[6] -> c[6];
measure q[7] -> c[7];
measure q[8] -> c[8];
measure q[9] -> c[9];
measure q[10] -> c[10];
measure q[11] -> c[11];
For more information on unitary reconstruction and how to integrate it into your software, you can check out the tutorial on Dynamic Quantum Circuits: https://juliaeda.github.io/DynamicQuantumCircuits.jl/dev/tutorial/#tutorial
If you have any questions or suggestion please open an issue. I am currently working on a OpenQASM 3 parser, as there are some bugs in the OpenQASM 2 parser (such as CX needing to be capitalized)
For you to integrate the unitary reconstruction into your software, you can follow Example 2 from the juliacall package. https://pypi.org/project/juliacall/