Inliner does not inline conditioned gates
p51lee opened this issue · comments
Hello, I'm working with the inliner and it does not inline gates with if
conditions.
To reproduce this issue, inline the following bug.qasm
:
❯ cat bug.qasm
OPENQASM 2.0;
include "qelib1.inc";
gate cx_o q0,q1 { x q0; cx q0,q1; x q0; }
qreg q[2];
creg c[2];
if (c==1) cx_o q[0], q[1];
cx_o
gate is not inlined:
❯ staq --version
staq version 3.5
(c) 2019 - 2024 softwareQ Inc. All rights reserved.
❯ staq_inliner < bug.qasm
OPENQASM 2.0;
include "qelib1.inc";
gate cx_o q0,q1 {
x q0;
cx q0,q1;
x q0;
}
qreg q[2];
creg c[2];
if (c==1) cx_o q[0],q[1];
@meamy Any idea?
Hi there!
This is the output I get with the latest commit
OPENQASM 2.0;
include "qelib1.inc";
gate cx_o q0,q1 {
x q0;
cx q0,q1;
x q0;
}
qreg q[2];
creg c[2];
if (c==1) x q[0];
if (c==1) cx q[0],q[1];
if (c==1) x q[0];
which looks like the intended behaviour for this file. Note that we're constrained by the syntax of openQASM 2.0 to have an explicit if
statement for each gate in cx_o
.
Can you try pulling the latest source from the main branch and try? A little while back we fixed a missing feature which involved some code transformations inside if
blocks, due to the issue above where an if
block can only contain one command. I imagine what's happening is you have an older version of the inliner from before this was fixed.
I'll check out the latest commit. Thanks for the support!