Open TheGupta2012 opened 1 year ago
There's a couple of things going on here. First, the repr
method of Instruction
misleading always writes Instruction(...)
and ignores the type. As things happen, the OQ2 importer returns a library.UGate
and the OQ3 importer returns an ad-hoc Gate
instance. This happens because both importers treat gates in their corresponding standard library specially, and define a custom gate object whenever they're dealing with a gate
declaration. The new OQ2 importer (qiskit.qasm2.loads
) is more configurable, and can be told to use certain objects to represent certain symbols in the program. We're planning to rewrite the OQ3 importer completely (obsoleting this package) with similar configurability in the future.
The second main point is that the ==
method for circuits is a tricky beast. Quantum circuits represent executable programs, and there's an infinite number of ways of representing the exact same program in general. There's no reasonable normalisation/canonicalisation that we could do that would make ==
always detect equal programs, so the result is that there'll be a lot of false negatives.
I was trying to check the equality of circuits when converting from qasm2 and qasm3 strings. I was using the following qasm strings for the conversion -
and the following script to check circuit equivalence -
This should produce a
True
output but I am gettingFalse
, even though on printing thedata
of circuits I get identical instructions -