Open Bennybenassius opened 3 months ago
Hmm I find this surprising that the error only manifests when the two CircBox
(es) are next to one another. As you pointed out if we put gates in between then the KAKDecomposition
pass can be applied without issue.
The subcircuits here are pure quantum so the subcircuit unitary is well defined.
We can do
circbox_subcirc_0.get_unitary()
and
circbox_subcirc_1.get_unitary()
without issue.
In the default_compilation_pass
for the different backends we always call DecomposeBoxes
prior to doing local rewrites like KAKDecomposition
or FullPeepholeOptimise
. However its understandable that the beahviour exhibited above is confusing. If indeed DecomposeBoxes
is needed then this should ideally be clear from the error message.
Any ideas @cqc-alec ?
I would expect KAKDecomposition
to leave all CircBoxes alone and optimize around them; this is clearly a bug.
Ilan and I have found this issue during random testing:
When running:
Throws a runtime error:
This error seems to only occur when the Circboxes are right next to each other. Upon uncommenting the line
# main_circ.CX(0, 2).X(0)
, the code runs without an issue and simply leaves the Circboxes untouched. This bug also disappears whenDecomposeBoxes
is used on the Circuit first.